快捷方式

RandomPosterize

class torchvision.transforms.RandomPosterize(bits, p=0.5)[源代码]

通过减少每个颜色通道的位数,以给定的概率随机进行海报化处理图像。如果图像是 torch Tensor,则其类型应为 torch.uint8,并且预期具有 […, 1 or 3, H, W] 形状,其中 … 表示任意数量的前导维度。如果 img 是 PIL Image,则预期为 “L” 或 “RGB” 模式。

参数:
  • bits (int) – 每个通道要保留的位数 (0-8)

  • p (float) – 图像被海报化处理的概率。默认值为 0.5

使用 RandomPosterize 的示例

转换的图示

转换的图示
forward(img)[源代码]
参数:

img (PIL ImageTensor) – 要进行海报化处理的图像。

返回:

随机海报化处理的图像。

返回类型:

PIL Image 或 Tensor

文档

访问 PyTorch 的全面开发者文档

查看文档

教程

获取面向初学者和高级开发者的深度教程

查看教程

资源

查找开发资源并获得您的问题解答

查看资源