distortion_scale (float) – argument to control the degree of distortion and ranges from 0 to 1.
Default is 0.5.
p (float) – probability of the image being transformed. Default is 0.5.
interpolation (InterpolationMode) – Desired interpolation enum defined by
torchvision.transforms.InterpolationMode. Default is InterpolationMode.BILINEAR.
If input is Tensor, only InterpolationMode.NEAREST, InterpolationMode.BILINEAR are supported.
The corresponding Pillow integer constants, e.g. PIL.Image.BILINEAR are accepted as well.
fill (sequence or number) – Pixel fill value for the area outside the transformed
image. Default is 0. If given a number, the value is used for all bands respectively.
Examples using RandomPerspective:
-
forward(img)[source]
- Parameters:
img (PIL Image or Tensor) – Image to be Perspectively transformed.
- Returns:
Randomly transformed image.
- Return type:
PIL Image or Tensor
-
static get_params(width: int, height: int, distortion_scale: float) → tuple[list[list[int]], list[list[int]]][source]
Get parameters for perspective for a random perspective transform.
- Parameters:
width (int) – width of the image.
height (int) – height of the image.
distortion_scale (float) – argument to control the degree of distortion and ranges from 0 to 1.
- Returns:
List containing [top-left, top-right, bottom-right, bottom-left] of the original image,
List containing [top-left, top-right, bottom-right, bottom-left] of the transformed image.