pytorch / vision

Datasets, Transforms and Models specific to Computer Vision
https://pytorch.org/vision
BSD 3-Clause "New" or "Revised" License
16.15k stars 6.94k forks source link

draw_segmentation_instances #6125

Open mjack3 opened 2 years ago

mjack3 commented 2 years ago

🚀 The feature

Development a function torchvision.utils.draw_segmentation_instances to draw just the external contour of a mask.

Motivation, pitch

For torchvision.utils we have draw_bounding_boxes, draw, draw_segmentation_masks, draw_keypoints but still need to do some extra preprocess for getting the instance segmentation. Would be great to have a function draw_segmentation_instances to get just the external area of the ROI.

Alternatives

Similar to draw_bounding boxes, a optional argument fill could be added into draw_segmentation_instances to achieve this behavior.

Additional context

As far as I know. We need to use other libraries to achieve this.

oke-aditya commented 2 years ago

Hi @mjack3 Thanks for the issue and feature request Can you post an example of what the output is expected? And how only contours will help?

mjack3 commented 2 years ago

Hello!

This is what we have with the current util function

Screenshot from 2022-06-02 15-02-54

With this request we would have as result just the width orange border of the mask.

This can help in order to have better visualization of what we are selecting because alpha attribute is not enough. Similar as to have filled bounding boxes or just the contour, latest shows a better visualization.

datumbox commented 2 years ago

I agree that this might be useful for people who want more advanced viz options, but is TorchVision's util the right solution for them? Historically the focus of TorchVision was to offer basic utilities for people to check the results of the models. For more complex use-cases, there are better options out there. My worry is that offering such a functionality will lead to rather complex signature methods as one will need to provide not only colours for masks but also the contours.

mjack3 commented 2 years ago

I think is straightforward as adding a fill attribute that by default is filled.

In this way you are avoiding to require other libraries.

In my case, I found this needed several times. I need to show to my clients a clear visualization of the results.

oke-aditya commented 2 years ago

Hi @mjack3 can you share the code that enabled you to do the same? Maybe someone looking for similar solution might open this issue and it may help them.

mjack3 commented 2 years ago

I haven't the code. I need to develop it

oke-aditya commented 2 years ago

Yeah that's my doubt. How feasible and easy would it be to support this by adding fill param to draw_segmentation_masks.

Each feature comes with a cost. The cost is maintainability and ease of use.