Skip to content

Fix _ImageDrawTV #9137

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

Merged
merged 2 commits into from
Jul 1, 2025
Merged

Conversation

AntoineSimoulin
Copy link
Member

@AntoineSimoulin AntoineSimoulin commented Jul 1, 2025

The code to draw rotated bounding boxes were wrong for the case where we want to fill the bounding boxes. Indeed we need to plot a polygon since the box maybe be rotated. The following code should now work without error.

from test.common_utils import make_bounding_boxes
from torchvision import tv_tensors
from gallery.transforms.helpers import plot

canvas_size = (360, 360)
num_boxes = 2
bounding_boxes = make_bounding_boxes(
    canvas_size=canvas_size,
    format=tv_tensors.BoundingBoxFormat.XYXYXYXY,
    num_boxes=num_boxes,
    clamping_mode="hard",
)

img = torch.ones(3, canvas_size[0], canvas_size[1])
drawn_boxes = draw_bounding_boxes(
    img,
    v2.ConvertBoundingBoxFormat("xyxyxyxy")(bounding_boxes),
    colors="black",
    fill=True,
)

plot([drawn_boxes])

image

Tests

Please run tests with

pytest test/test_utils.py -v -k "test_draw_rotated_boxes_fill"
1 passed, 94 deselected in 0.65s

Copy link

pytorch-bot bot commented Jul 1, 2025

🔗 Helpful Links

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

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

✅ No Failures

As of commit f410b84 with merge base 646341d (image):
💚 Looks good so far! There are no failures yet. 💚

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

Copy link
Member

@NicolasHug NicolasHug left a comment

Choose a reason for hiding this comment

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

stamping

@AntoineSimoulin AntoineSimoulin merged commit d31c3e9 into pytorch:main Jul 1, 2025
58 checks passed
Copy link

github-actions bot commented Jul 1, 2025

Hey @AntoineSimoulin!

You merged this PR, but no labels were added.
The list of valid labels is available at https://github.com/pytorch/vision/blob/main/.github/process_commit.py

AntoineSimoulin added a commit to AntoineSimoulin/vision that referenced this pull request Jul 1, 2025
facebook-github-bot pushed a commit that referenced this pull request Jul 31, 2025
Reviewed By: AntoineSimoulin

Differential Revision: D79175032

fbshipit-source-id: 1ba8ad53cf5cac6327043dd06a2de9d7e696ee4c
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