快捷方式

draw_segmentation_masks

torchvision.utils.draw_segmentation_masks(image: Tensor, masks: Tensor, alpha: float = 0.8, colors: Optional[Union[List[Union[str, Tuple[int, int, int]]], str, Tuple[int, int, int]]] = None) Tensor[source]

在給定的 RGB 圖像上繪製分割遮罩。圖像值應為 [0, 255] 中的 uint8 或 [0, 1] 中的 float。

參數:
  • image (Tensor) – 形狀為 (3, H, W) 且 dtype 為 uint8 或 float 的 Tensor。

  • masks (Tensor) – 形狀為 (num_masks, H, W) 或 (H, W) 且 dtype 為 bool 的 Tensor。

  • alpha (float) – 介於 0 和 1 之間的浮點數,表示遮罩的透明度。 0 表示完全透明,1 表示不透明。

  • colors (colorcolors 列表, optional) – 包含遮罩顏色的列表,或所有遮罩的單一顏色。顏色可以表示為 PIL 字串,例如 “red” 或 “#FF00FF”,或表示為 RGB 元組,例如 (240, 10, 157)。 預設情況下,會為每個遮罩生成隨機顏色。

返回:

圖像 Tensor,其頂部繪製了分割遮罩。

返回類型:

img (Tensor[C, H, W])

使用 draw_segmentation_masks 的範例

將遮罩重新用於邊界框

將遮罩重新用於邊界框

可視化工具

可視化工具

文件

訪問 PyTorch 的完整開發者文件

查看文件

教程

獲取適用於初學者和高級開發人員的深入教程

查看教程

資源

尋找開發資源並獲得您的問題解答

查看資源