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 convert_bounding_box_format when passing strings #8265

Merged
merged 2 commits into from
Feb 9, 2024

Conversation

NicolasHug
Copy link
Member

Fixes #8258

convert_bounding_box_format() is supposed to accept strings, but it was silently wrong

@NicolasHug NicolasHug requested a review from pmeier February 8, 2024 13:38
Copy link

pytorch-bot bot commented Feb 8, 2024

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/vision/8265

Note: Links to docs will display an error until the docs builds have been completed.

❌ 1 New Failure, 2 Unrelated Failures

As of commit a7a0d52 with merge base 81e2831 (image):

NEW FAILURE - The following job has failed:

FLAKY - The following job failed but was likely due to flakiness present on trunk:

BROKEN TRUNK - The following job failed but was present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@@ -3398,6 +3398,23 @@ def test_transform(self, old_format, new_format, format_type):
make_bounding_boxes(format=old_format),
)

@pytest.mark.parametrize(("old_format", "new_format"), old_new_formats)
def test_strings(self, old_format, new_format):
Copy link
Member Author

Choose a reason for hiding this comment

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

I opted to add a whole new test instead of re-purposing some of the existing ones, because in order for it to be a proper non-regression test, we need to validate the output values here. In main, we can pass strings, there's no failure: but the results are wrong, and the current existing tests cannot assert that properly.

@@ -214,6 +214,11 @@ def convert_bounding_box_format(
if not torch.jit.is_scripting():
_log_api_usage_once(convert_bounding_box_format)

if isinstance(old_format, str):
Copy link
Member Author

@NicolasHug NicolasHug Feb 8, 2024

Choose a reason for hiding this comment

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

I didn't update the type annotations of convert_bounding_box_format because it would make torchscript unhappy. If mypy fails, I'll silence it. I think it means that torchscript won't support passing strings as the format, but who cares

Copy link
Collaborator

@pmeier pmeier left a comment

Choose a reason for hiding this comment

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

LGTM

@NicolasHug NicolasHug merged commit a52607e into pytorch:main Feb 9, 2024
78 of 81 checks passed
@NicolasHug NicolasHug deleted the aefualefjnlaenf branch February 9, 2024 11:08
NicolasHug added a commit to NicolasHug/vision that referenced this pull request Feb 9, 2024
facebook-github-bot pushed a commit that referenced this pull request Mar 20, 2024
Reviewed By: vmoens

Differential Revision: D55062797

fbshipit-source-id: 776e1cd156ad5e4a857e7ea1ecbf0b7933a35f87
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.

torchvision.transforms.v2.functional.convert_bounding_box_format is wrong
3 participants