RandAugment¶
- class torchvision.transforms.v2.RandAugment(num_ops: int = 2, magnitude: int = 9, num_magnitude_bins: int = 31, interpolation: Union[InterpolationMode, int] = InterpolationMode.NEAREST, fill: Union[int, float, Sequence[int], Sequence[float], None, dict[Union[type, str], Union[int, float, collections.abc.Sequence[int], collections.abc.Sequence[float], NoneType]] = None)[源代码]¶
基于 “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, optional) – 连续应用的增强变换的数量,必须是非负整数。默认值:2。
magnitude (int, optional) – 所有变换的幅度。
num_magnitude_bins (int, optional) – 不同幅度值的数量。
interpolation (InterpolationMode, optional) – 由
torchvision.transforms.InterpolationMode
定义的期望的插值枚举。默认为InterpolationMode.NEAREST
。如果输入是 Tensor,则只支持InterpolationMode.NEAREST
和InterpolationMode.BILINEAR
。fill (sequence 或 number, 可选) – 转换后图像外部区域的像素填充值。如果给定一个数字,则该值分别用于所有通道。
使用
RandAugment
的示例