Description
🚀 Feature
We recently added utility to draw bounding boxes, which works really well with detection models. #2785 #2556
It might be nice to draw segmentation masks which we obtain from instance segmentation models.
Motivation
Same as bounding box utils. It is very useful to have these. It reduces the dependence of users over other plotting libraries.
Pitch
Our API should be compatible with segmentation models, so we should probably use Tensors.
I think most params remain as same as the previous util. This keeps consistency too.
@torch.no_grad()
def draw_segmentation_masks(image: torch.Tensor,
masks: torch.Tensor,
labels: Optional[List[str]] = None,
colors: Optional[List[Union[str, Tuple[int, int, int]]]] = None,
width: int = 1,
font: Optional[str] = None,
font_size: int = 10)
We might need to see a method using which we can draw with PIL.
We used draw.rectangle()
to draw a box in utils, maybe there is some functionality in PIL that can help us draw shapes.
Alternatives
Let's discuss further, how this API would work with our models.
Also, it would be nice if this works directly for instance segmentation model Mask RCNN.