-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Cleanup conversion transforms #6801
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
bounding_box = (
bounding_box.clone()
if format == features.BoundingBoxFormat.XYXY
else convert_format_bounding_box(bounding_box, old_format=format, new_format=features.BoundingBoxFormat.XYXY)
) IMO, this is too bulky. I do not mind to have |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @pmeier, looks good overall. Just a couple of minor comments.
Same here with the focus on consistency. If one Vasilis argument was that besides for I'm ok with or without the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, only one comment below.
@datumbox @pmeier can we do the following:
bounding_box = convert_format_bounding_box(
bounding_box.clone(), old_format=format, new_format=features.BoundingBoxFormat.XYXY
) ? |
@vfdev-5 that would make our only operator that does in-place ops (outside of the optimizations that have no effect). If we were to go down that route, purely for speed reasons, I would recommend adopting the |
Conflicts: torchvision/prototype/features/_image.py torchvision/prototype/features/_video.py
Summary: * remove copy from convert_color_space * remove copy from convert_format_bounding_box * remove .to_* methods from features * remove unnecessary clones * add perf todos * refactor convert_color_space * lint * remove another clone * and another clone * remove a missed copy Reviewed By: YosuaMichael Differential Revision: D40722906 fbshipit-source-id: 3b757af1b69fcd85b085a5df9ff88cdaeafca130
This PR stems from the discussion in #6783 (comment). @datumbox and I agreed to the following things:
Let's not have a
copy
flag on ourconvert_*
kernels. It is currently unused forconvert_color_space
. It is used extensively forconvert_bounding_box
in our kernels due the idiom of converting to a specific format, performing the computation, and converting back. In the future, we wanted to have a look at these kernels anyway for possible performance gains by implementing the computation for every format. After this PR the current implementation likechanges to
Let's not have any
.to_*()
methods on the features. While useful for debugging, they go against the other idioms we are using. We can always re-add them later if there is user demand for it. Note thatLabel.to_categories()
is an exception since it has no transformation associated with it.cc @vfdev-5 @datumbox @bjuncek