RandomPerspective

class torchaug.transforms.RandomPerspective(distortion_scale=0.5, p=0.5, interpolation=InterpolationMode.BILINEAR, fill=0, batch_inplace=False, num_chunks=1, permute_chunks=False, batch_transform=False)[source]

Perform a random perspective transformation of the input with a given probability.

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:
  • distortion_scale (float, optional) – argument to control the degree of distortion and ranges from 0 to 1. Default: 0.5

  • p (float, optional) – probability of the input being transformed. Default: 0.5

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

  • 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