Skip to content

Conversation

@pmeier
Copy link
Contributor

@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
Contributor 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.

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
Contributor 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
Contributor 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
Contributor 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