draw_segmentation_masks¶
-
torchvision.utils.
draw_segmentation_masks
(image: torch.Tensor, masks: torch.Tensor, alpha: float = 0.8, colors: Optional[Union[List[Union[str, Tuple[int, int, int]]], str, Tuple[int, int, int]]] = None) → torch.Tensor[source]¶ Draws segmentation masks on given RGB image. The values of the input image should be uint8 between 0 and 255.
- Parameters
image (Tensor) – Tensor of shape (3, H, W) and dtype uint8.
masks (Tensor) – Tensor of shape (num_masks, H, W) or (H, W) and dtype bool.
alpha (float) – Float number between 0 and 1 denoting the transparency of the masks. 0 means full transparency, 1 means no transparency.
colors (color or list of colors, optional) – List containing the colors of the masks or single color for all masks. The color can be represented as PIL strings e.g. “red” or “#FF00FF”, or as RGB tuples e.g.
(240, 10, 157)
. By default, random colors are generated for each mask.
- Returns
Image Tensor, with segmentation masks drawn on top.
- Return type
img (Tensor[C, H, W])
Examples using
draw_segmentation_masks
: