Shortcuts

AugMix

class torchvision.transforms.AugMix(severity: int = 3, mixture_width: int = 3, chain_depth: int = - 1, alpha: float = 1.0, all_ops: bool = True, interpolation: InterpolationMode = InterpolationMode.BILINEAR, fill: Optional[List[float]] = None)[source]

基于“AugMix: A Simple Data Processing Method to Improve Robustness and Uncertainty”的AugMix数据增强方法。 如果图像是torch张量,它应该是torch.uint8类型,并且期望具有[…, 1或3, H, W]形状,其中…表示任意数量的前导维度。 如果img是PIL图像,则期望其模式为“L”或“RGB”。

Parameters:
  • severity (int) – 基础增强操作的严重程度。默认值为 3

  • mixture_width (int) – 增强链的数量。默认值为 3

  • chain_depth (int) – 增强链的深度。负值表示从区间 [1, 3] 中随机采样的深度。 默认值为 -1

  • alpha (float) – 概率分布的超参数。默认值为 1.0

  • all_ops (bool) – 使用所有操作(包括亮度、对比度、颜色和锐度)。默认值为 True

  • 插值 (InterpolationMode) – 由torchvision.transforms.InterpolationMode定义的期望插值枚举。默认是InterpolationMode.NEAREST。如果输入是张量,仅支持InterpolationMode.NEARESTInterpolationMode.BILINEAR

  • fill (sequencenumber, 可选) – 用于变换图像外部区域的像素填充值。如果给定一个数字,则该值将分别用于所有波段。

使用 AugMix 的示例:

变换的图示

Illustration of transforms
forward(orig_img: Tensor) Tensor[source]

img (PIL Image 或 Tensor): 要转换的图像。

Returns:

转换后的图像。

Return type:

PIL 图像或张量