-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Add sanitize_bounding_boxes
kernel/functional
#8308
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
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/vision/8308
Note: Links to docs will display an error until the docs builds have been completed. ❌ 16 New Failures, 20 Unrelated FailuresAs of commit e5a5892 with merge base d1f3a7b ( NEW FAILURES - The following jobs have failed:
FLAKY - The following jobs failed but were likely due to flakiness present on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
Returns: | ||
out (tuple of Tensors): The subset of valid bounding boxes, and the corresponding indexing mask. | ||
The mask can then be used to subset other tensors (e.g. labels) that are associated with the bounding boxes. | ||
""" |
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.
@pytest.mark.parametrize("min_size", (1, 10)) | ||
@pytest.mark.parametrize("labels_getter", ("default", lambda inputs: inputs["labels"], None, lambda inputs: None)) | ||
@pytest.mark.parametrize("sample_type", (tuple, dict)) | ||
def test_transform(self, min_size, labels_getter, sample_type): |
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.
That test did not change, I just moved the input generation above in a function so that it can be reused in the newly added tests below
valid = _get_sanitize_bounding_boxes_mask( | ||
bounding_boxes, format=format, canvas_size=canvas_size, min_size=min_size | ||
) | ||
bounding_boxes = bounding_boxes[valid] |
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.
A bit sad that these 2 lines are somewhat duplicated below in the else:
block. I couldn't find a decent way to make all that work without upsetting torchscript.
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.
Yeah, let's not bother.
return bounding_boxes, valid | ||
|
||
|
||
def _get_sanitize_bounding_boxes_mask( |
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.
The logic of this function is completely unchanged from the existing logic in the class.
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.
Some minor comments but otherwise LGTM. Thanks Nicolas!
valid = _get_sanitize_bounding_boxes_mask( | ||
bounding_boxes, format=format, canvas_size=canvas_size, min_size=min_size | ||
) | ||
bounding_boxes = bounding_boxes[valid] |
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.
Yeah, let's not bother.
@@ -123,7 +123,7 @@ def _extract_image_targets( | |||
if not (len(images) == len(bboxes) == len(masks) == len(labels)): | |||
raise TypeError( | |||
f"{type(self).__name__}() requires input sample to contain equal sized list of Images, " | |||
"BoundingBoxeses, Masks and Labels or OneHotLabels." | |||
"BoundingBoxes, Masks and Labels or OneHotLabels." |
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.
Driveby
Reviewed By: vmoens Differential Revision: D55062772 fbshipit-source-id: 677840081e6516e2d1d603853f16314d209dbf5b
Addresses part of #8294
Some design discussion started on #8294 (comment). After chatting a bit offline we decided to go with Option 3 (#8294 (comment)) because:
*args
)tv_tensors.wrap()
cc @vfdev-5