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], Optional[Union[int, float, Sequence[int], Sequence[float]]]]] = None)[source]¶
RandAugment 数据增强方法基于 “RandAugment: Practical automated data augmentation with a reduced search space”.
此转换仅适用于图像和视频。
如果输入是
torch.Tensor,它应该是torch.uint8类型,并且期望具有[…, 1或3, H, W]形状,其中…表示任意数量的前导维度。如果img是PIL图像,则期望其模式为“L”或“RGB”。- Parameters:
num_ops (int, optional) – 要顺序应用的增强变换的数量。
magnitude (int, optional) – 所有变换的幅度。
num_magnitude_bins (int, 可选) – 不同幅度值的数量。
插值 (InterpolationMode, 可选) – 由
torchvision.transforms.InterpolationMode定义的所需插值枚举。默认值为InterpolationMode.NEAREST。如果输入是张量,则仅支持InterpolationMode.NEAREST和InterpolationMode.BILINEAR。fill (sequence 或 number, 可选) – 用于变换图像外部区域的像素填充值。如果给定一个数字,则该值将分别用于所有波段。
使用
RandAugment的示例: