RandAugment¶
-
class
torchvision.transforms.
RandAugment
(num_ops: int = 2, magnitude: int = 9, num_magnitude_bins: int = 31, interpolation: torchvision.transforms.functional.InterpolationMode = <InterpolationMode.NEAREST: 'nearest'>, fill: Optional[List[float]] = None)[source]¶ RandAugment data augmentation method based on “RandAugment: Practical automated data augmentation with a reduced search space”. If the image 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) – Number of augmentation transformations to apply sequentially.
magnitude (int) – Magnitude for all the transformations.
num_magnitude_bins (int) – The number of different magnitude values.
interpolation (InterpolationMode) – Desired interpolation enum defined by
torchvision.transforms.InterpolationMode
. Default isInterpolationMode.NEAREST
. If input is Tensor, onlyInterpolationMode.NEAREST
,InterpolationMode.BILINEAR
are supported.fill (sequence or number, optional) – Pixel fill value for the area outside the transformed image. If given a number, the value is used for all bands respectively.
Examples using
RandAugment
:-
forward
(img: torch.Tensor) → torch.Tensor[source]¶ img (PIL Image or Tensor): Image to be transformed.
- Returns
Transformed image.
- Return type
PIL Image or Tensor