Skip to content

Conversation

AndreiMoraru123
Copy link
Contributor

Context

PR for: #9199 (comment)

How to use

import torch
from PIL import Image
from torchvision.utils import draw_bounding_boxes

boxes = torch.tensor(
    [[100, 100, 150, 150], [50, 50, 100, 100], [300, 100, 400, 300]],
    dtype=torch.float32,
)

image = torch.ones((3, 500, 500), dtype=torch.uint8) * 255

colors = ["blue", "yellow", "red"]
label_bg_colors = ["green", "magenta", "orange"]
image = draw_bounding_boxes(
    image,
    boxes,
    colors=colors,
    width=1,
    fill=False,
    labels=colors,
    label_background_colors=label_bg_colors,  # new param
    fill_labels=True,  # only does something when fill_labels is set to True
)
img = Image.fromarray(image.permute(1, 2, 0).numpy())
img.show()
image

Copy link

pytorch-bot bot commented Sep 3, 2025

🔗 Helpful Links

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

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

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

Copy link

meta-cla bot commented Sep 3, 2025

Hi @AndreiMoraru123!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

Copy link

meta-cla bot commented Sep 4, 2025

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@AntoineSimoulin AntoineSimoulin self-requested a review September 4, 2025 15:41
@AntoineSimoulin
Copy link
Member

Also, is it possible to apply linting with pre-commit run --all-files as detailed in the contributing guidelines?

@AndreiMoraru123
Copy link
Contributor Author

Also, is it possible to apply linting with pre-commit run --all-files as detailed in the contributing guidelines?

Must've missed the memo. I noticed now the repo has flake8 and ufmt. Hopefully, running the pre-commit on the modified files should be enough in this case.

@AndreiMoraru123 AndreiMoraru123 force-pushed the feature/different-label-background branch from 6a7b38c to 3503a63 Compare September 5, 2025 08:52
@AntoineSimoulin AntoineSimoulin merged commit bddc4d8 into pytorch:main Sep 12, 2025
3 checks passed
Copy link

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 Sep 15, 2025
Co-authored-by: Antoine Simoulin <antoinesimoulin@fb.com>
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