-
Notifications
You must be signed in to change notification settings - Fork 7k
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
[proto] Added functional crop_bounding_box
op
#5781
Conversation
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.
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.
One comment inline. Testing looks ok.
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.
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 Victor!
Hey @pmeier! You merged this PR, but no labels were added. The list of valid labels is available at https://github.com/pytorch/vision/blob/main/.github/process_commit.py |
).view(-1, 4) | ||
|
||
# Crop or implicit pad if left and/or top have negative values: | ||
bounding_box[:, 0::2] -= left |
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.
For batch support it may be better to instead use bounding_box[..., 0::2]
. Then view(-1, 4)
and view(shape)
would not be needed?
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.
Good catch. I was under the impression ...
was not supported by torch.jit.script
in general, but this seems fine:
@torch.jit.script
def foo(x: torch.Tensor) -> torch.Tensor:
y = x.clone()
y[..., 0::2] += 1
return y
It seems, only the explicit indices are not supported:
@torch.jit.script
def bar(x: torch.Tensor) -> torch.Tensor:
y = x.clone()
y[..., [0, 2]] += 1
return y
RuntimeError:
Ellipses followed by tensor indexing is currently not supported:
[...]
def bar(x: torch.Tensor) -> torch.Tensor:
y = x.clone()
y[..., [0, 2]] += 1
~~~~~~~~~~~~~ <--- HERE
return y
Summary: * [proto] Added crop_bounding_box op * Removed "pass" * Updated comment * Removed unused args from signature (Note: this ignores all push blocking failures!) Reviewed By: jdsgomes, NicolasHug Differential Revision: D36095685 fbshipit-source-id: a4222d23aa60ea0cb0713a389646adbed55f289d
Related to #5514
Description:
crop_bounding_box
opResults match albumentations' crop_bbox_by_coords
Results on synthetic images/bboxes:
Code