Skip to content
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

fix reference tests for convert_format_bounding_box #6860

Merged
merged 2 commits into from
Oct 28, 2022

Conversation

pmeier
Copy link
Collaborator

@pmeier pmeier commented Oct 28, 2022

Without this, the reference tests for convert_format_bounding_box were not run at all.

cc @vfdev-5 @datumbox @bjuncek



def reference_inputs_convert_format_bounding_box():
for args_kwargs in sample_inputs_convert_color_space_image_tensor():
for args_kwargs in sample_inputs_convert_format_bounding_box():
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the root cause. We are iterating over images and below checking for only two dimensions. Since no such images exist in the sample function, we never yielded and therefore never saw an error.

@@ -536,12 +536,12 @@ def sample_inputs_convert_format_bounding_box():

def reference_convert_format_bounding_box(bounding_box, old_format, new_format):
return torchvision.ops.box_convert(
bounding_box, in_fmt=old_format.kernel_name.lower(), out_fmt=new_format.kernel_name.lower()
)
bounding_box, in_fmt=old_format.name.lower(), out_fmt=new_format.name.lower()
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These crept in during some auto-renaming, but were never caught since the test hasn't been run in the first place.

bounding_box, in_fmt=old_format.kernel_name.lower(), out_fmt=new_format.kernel_name.lower()
)
bounding_box, in_fmt=old_format.name.lower(), out_fmt=new_format.name.lower()
).to(bounding_box.dtype)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need this because the reference does not convert back to the original dtype. Thus, if we put in integer boxes, we might get floating point boxes out, which might have a value of .5.

Copy link
Contributor

@datumbox datumbox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Comment on lines +41 to +44
if not args_kwargs:
raise pytest.UsageError(
f"Couldn't collect a single `ArgsKwargs` for `{info.id}`{f' in {test_id}' if test_id else ''}"
)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sure this doesn't happen again in the future.

@datumbox datumbox merged commit e47843c into pytorch:main Oct 28, 2022
@pmeier pmeier deleted the fix-reference-test branch October 28, 2022 15:42
facebook-github-bot pushed a commit that referenced this pull request Oct 31, 2022
Summary:
* fix reference tests for convert_format_bounding_box

* add check to prevent empty args_kwargs_fns in the future

Reviewed By: datumbox

Differential Revision: D40851025

fbshipit-source-id: 5b95c2e3c2bf858edd79916b74fc529ec8ed7424
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants