RandomInvert¶ class torchvision.transforms.RandomInvert(p=0.5)[source]¶ 以给定的概率随机反转给定图像的颜色。如果 img 是 Tensor,期望其格式为 […, 1 或 3, H, W],其中 … 表示可以有任意数量的前导维度。如果 img 是 PIL Image,期望其模式为 “L” 或 “RGB”。 参数: p (float) – 图像颜色被反转的概率。默认值为 0.5 使用 RandomInvert 的示例 变换示例 变换示例 forward(img)[source]¶ 参数: img (PIL Image 或 Tensor) – 待反转的图像。 返回: 随机颜色反转后的图像。 返回类型: PIL Image 或 Tensor