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