快捷方式

RandAugment

class torchvision.transforms.RandAugment(num_ops: int = 2, magnitude: int = 9, num_magnitude_bins: int = 31, interpolation: InterpolationMode = InterpolationMode.NEAREST, fill: Optional[List[float]] = None)[source]

基于 “RandAugment: Practical automated data augmentation with a reduced search space” 论文的 RandAugment 数据增强方法。如果图像是 torch Tensor,则应为 torch.uint8 类型,并且应具有 […, 1 或 3, H, W] 形状,其中 … 表示任意数量的前导维度。如果 img 是 PIL Image,则应处于 “L” 或 “RGB” 模式。

参数:
  • num_ops (int) – 顺序应用的增强变换的数量。

  • magnitude (int) – 所有变换的幅度。

  • num_magnitude_bins (int) – 不同幅度值的数量。

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

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

使用 RandAugment 的示例

变换的图示

变换的图示
forward(img: Tensor) Tensor[source]

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

返回值:

变换后的图像。

返回类型:

PIL Image 或 Tensor

文档

访问 PyTorch 的全面开发者文档

查看文档

教程

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

查看教程

资源

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

查看资源