-
Notifications
You must be signed in to change notification settings - Fork 7k
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
position, colour, and background colour of text labels in draw_bounding_boxes #8317
Comments
Thanks for opening this issue @carandraug. I think the proposal is reasonable, the current position of the label does make them difficult to read. In terms of API / functionality, what exactly would you have in mind? |
Hi, I'd have the same request!
|
For the colours, I think something like For label positioning, there is a lot of things going on. There is the position to the box, and then whether the label goes outside or inside the box. I think we could just copy matplotlib syntax for placement of the legend box. Effectively, a string defines location ( |
That SGTM, thanks for the details. |
Can you confirm that both (text colour/font/etc and label positioning) look good? Just want to make sure that you're not only referring to the label positioning? I If so, I will prepare a PR for text colour/etc first and then another for the label positioning.
I'll take a look at matplotlib license and logic but we probably can't use it as is. At the very least, we need to handle the case where placing the label outside the resion places the label outside the image. With matplotlib, the plot has marging but we do not. I'll experiment and see what I think is the most reasonable behaviour when I start coding but I think it will be try to place the closest to the desired position while ensuring that the text stays inside the image. |
Yes, that sounds good. Happy to consider better default for these. Thank you! |
🚀 The feature
Text labels from
torchvision.utils.draw_bounding_boxes
are currently always inside the box with origin at the top left corner of the box, without a background colour, and the same colour as the bounding box itself. These are three things that would be nice to control.Motivation, pitch
The problem with the current implementation is that it makes it hard to read the label, particularly when the bounding box is filled (because the text has the same colour as the filling colour and is placed inside the box.
For example, this is the results from the current implementation:
Moving the label to outside the box already makes things better:
But by controlling those three things (placement of label, background colour behind the label, and text colour) one could fit to whatever they have. For what is worth, in the original issue for this feature, the only example image had labels outside the box, text coloured different from the box (black), and background of the same colour as the box. See #2556 (comment)
I'm happy to contribute this but want to know if this will be accepted and with what interface.
The text was updated successfully, but these errors were encountered: