Shortcuts

自动增强

class torchvision.transforms.AutoAugment(policy: AutoAugmentPolicy = AutoAugmentPolicy.IMAGENET, interpolation: InterpolationMode = InterpolationMode.NEAREST, fill: Optional[List[float]] = None)[source]

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

Parameters:
  • policy (AutoAugmentPolicy) – 由torchvision.transforms.autoaugment.AutoAugmentPolicy定义的期望策略枚举。默认值为AutoAugmentPolicy.IMAGENET

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

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

使用AutoAugment的示例:

变换的图示

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

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

Returns:

自动增强的图像。

Return type:

PIL 图像或张量

static get_params(transform_num: int) Tuple[int, Tensor, Tensor][source]

获取自动增强变换的参数

Returns:

autoaugment 转换所需的参数