RandomGrayscale¶
- class torchvision.transforms.RandomGrayscale(p=0.1)[原始碼]¶
以機率 p (預設為 0.1) 隨機將影像轉換為灰度圖。如果影像是 torch Tensor,則期望其形狀為 […, 3, H, W],其中 … 表示任意數量的前導維度
- 引數:
p (float) – 影像轉換為灰度的機率。
- 返回:
以機率 p 返回輸入影像的灰度版本,以機率 (1-p) 返回原影像。 - 如果輸入影像是 1 通道:灰度版本是 1 通道 - 如果輸入影像是 3 通道:灰度版本是 3 通道,且 r == g == b
- 返回型別:
PIL Image 或 Tensor