-
Notifications
You must be signed in to change notification settings - Fork 7.2k
[proto] Added functional crop_bounding_box op
#5781
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
datumbox
left a comment
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.
pmeier
left a comment
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.
datumbox
left a comment
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.
pmeier
left a comment
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 yIt 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 yRuntimeError:
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_boxopResults match albumentations' crop_bbox_by_coords
Results on synthetic images/bboxes:
Code