RandomRotation

class torchaug.transforms.RandomRotation(degrees, interpolation=InterpolationMode.NEAREST, expand=False, center=None, fill=0, batch_inplace=False, num_chunks=1, permute_chunks=False, batch_transform=False)[source]

Rotate the input by angle.

If the input is a torch.Tensor or a TATensor (e.g. Image, Video, BoundingBoxes etc.) it can have arbitrary number of leading batch dimensions. For example, the image can have [..., C, H, W] shape. A bounding box can have [..., 4] shape.

Parameters:
  • degrees (Union[Number, Sequence]) – Range of degrees to select from. If degrees is a number instead of sequence like (min, max), the range of degrees will be (-degrees, +degrees).

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

  • expand (bool, optional) – Optional expansion flag. If true, expands the output to make it large enough to hold the entire rotated image. If false or omitted, make the output image the same size as the input image. Note that the expand flag assumes rotation around the center (see note below) and no translation. Default: False

  • center (Optional[List[float]], optional) –

    Optional center of rotation, (x, y). Origin is the upper left corner. Default is the center of the image. Default: None

    Note

    In theory, setting center has no effect if expand=True, since the image center will become the center of rotation. In practice however, due to numerical precision, this can lead to off-by-one differences of the resulting image size compared to using the image center in the first place. Thus, when setting expand=True, it’s best to leave center=None (default).

  • 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 used when the padding_mode is constant. If a tuple of length 3, it is used to fill R, G, B channels respectively. Fill value can be also a dictionary mapping data type to the fill value, e.g. fill={ta_tensors.Image: 127, ta_tensors.Mask: 0} where Image will be filled with 127 and Mask will be filled with 0. Default: 0

  • batch_inplace (bool, optional) – whether to apply the batch transform in-place. Does not prevent functionals to make copy but can reduce time and memory consumption. Default: False

  • num_chunks (int, optional) – number of chunks to split the batched input into. Default: 1

  • permute_chunks (bool, optional) – whether to permute the chunks. Default: False

  • batch_transform (bool, optional) – whether to apply the transform in batch mode. Default: False