Skip to content

Adjust clamping for rotated bboxes #9112

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

AntoineSimoulin
Copy link
Member

Adjust clamping for Rotated Boxes

This PR is a follow-up for #9104 and slightly adjust some inconsistency in the clamping function. This PR implements in particular the following modifications :

  • Modify the conditions from the clamping function to ensure the resulting box completely encapsulate the input box. The output from the clamping operation is the box of smallest area completely overlapping the intersection polygon between the input box and the canvas (and preserving the input box rotation angle).
  • With this adjustments, clamped rotated boxes can have vertices outside of the canvas. However, the center of the bounding box is guaranteed to be within the canvas.
  • This PR should address Allow bounding boxes transforms to *not* clamp #8254 as we now SHOULD clamp rotated bounding boxes (similar to what is done for un-rotated boxes). The operation should not impact the information captured by the box.

Details on the clamping function

We illustrate the adjustments on the clamping function using this image example. The clamping should be more intuitive and should prevent from loosing information.

Before:
image

After:
image

Test plan

Please run the following tests:

pytest test/test_transforms_v2.py -k box -v
...
2372 passed, 1432 skipped, 5025 deselected in 46.08s

Test Plan:
```bash
pytest test/test_transforms_v2.py -k box -v
```
Copy link

pytorch-bot bot commented Jun 20, 2025

🔗 Helpful Links

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

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

❌ 1 New Failure

As of commit 4261ed3 with merge base d5df0d6 (image):

NEW FAILURE - The following job has failed:

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

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.

2 participants