RandAugment

class torchaug.transforms.RandAugment(num_ops=2, magnitude=9, num_magnitude_bins=31, interpolation=InterpolationMode.NEAREST, fill=None)[source]

RandAugment data augmentation method based on “RandAugment: Practical automated data augmentation with a reduced search space”.

This transformation works on images and videos only.

If the input is torch.Tensor, it should be of type torch.uint8, and it is expected to have […, 1 or 3, H, W] shape, where … means an arbitrary number of leading dimensions. If img is PIL Image, it is expected to be in mode “L” or “RGB”.

Parameters:
  • num_ops (int, optional) – Number of augmentation transformations to apply sequentially. Default: 2

  • magnitude (int, optional) – Magnitude for all the transformations. Default: 9

  • num_magnitude_bins (int, optional) – The number of different magnitude values. Default: 31

  • interpolation (Union[InterpolationMode, int], optional) – Desired interpolation enum defined by torchvision.transforms.InterpolationMode. Only InterpolationMode.NEAREST, InterpolationMode.BILINEAR are supported. Default: InterpolationMode.NEAREST

  • fill (Union[int, float, Sequence[int], Sequence[float], None, Dict[Union[Type, str], Union[int, float, Sequence[int], Sequence[float], None]]], optional) – Pixel fill value for the area outside the transformed image. If given a number, the value is used for all bands respectively. Default: None

forward(*inputs)[source]

Performs forward pass of the transform.

Parameters:

inputs (Any) – Inputs to the transform.

Return type:

Any

Returns:

Transformed inputs.