-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Fix IndexError on draw_segmentation_masks
and draw_bounding_boxes
#5857
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 IndexError on draw_segmentation_masks
and draw_bounding_boxes
#5857
Conversation
Hi @oxabz! Thank you for your pull request and welcome to our community. Action RequiredIn 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. ProcessIn 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 If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
draw_segmentation_masks
and ``draw_segmentation_masks
and draw_bounding_boxes
draw_segmentation_masks
and draw_bounding_boxes
draw_segmentation_masks
and draw_bounding_boxes
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small comment. Also can you add tests in test_utils.py ?
torchvision/utils.py
Outdated
@@ -206,6 +206,10 @@ def draw_bounding_boxes( | |||
|
|||
num_boxes = boxes.shape[0] | |||
|
|||
if num_boxes == 0: | |||
warnings.warn("boxes doesn't contain any box. No box was drawn") | |||
return image.to(torch.uint8) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you don't ned to do this as the image dtype is unit8 in the input.
torchvision/utils.py
Outdated
@@ -306,6 +310,12 @@ def draw_segmentation_masks( | |||
if colors is not None and num_masks > len(colors): | |||
raise ValueError(f"There are more masks ({num_masks}) than colors ({len(colors)})") | |||
|
|||
out_dtype = torch.uint8 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same. No need of this, only uint8 images are allowed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great. cc @NicolasHug for a look :)
test/test_utils.py
Outdated
@@ -4,6 +4,8 @@ | |||
import tempfile | |||
from io import BytesIO | |||
|
|||
import warnings |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import warnings |
Hi @oxabz , thanks for the PR. Is it still WIP or is it ready for reviews? |
draw_segmentation_masks
and draw_bounding_boxes
draw_segmentation_masks
and draw_bounding_boxes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks a lot both of you @oxabz @oke-aditya
I'll merge when green
linux unittest are passing , merging. (MacOS and ONNX notoriously toasted ATM). |
Hey @NicolasHug! 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 |
…ation_masks and draw_bounding_boxes (#5857) Summary: * Fixing the IndexError in draw_segmentation_masks * fixing the bug on draw_bounding_boxes * Changing fstring to normal string * Removing unecessary conversion * Adding test for the change * Adding a test for draw seqmentation mask * Fixing small mistake * Fixing an error in the tests * removing useless imports * ufmt Reviewed By: NicolasHug Differential Revision: D36760928 fbshipit-source-id: c9acb7854f9f6068d79155aa6975b6224c926cef Co-authored-by: LEGRAND Matthieu <[email protected]> Co-authored-by: Nicolas Hug <[email protected]>
Closes #5818