RandomPerspective — Torchvision 0.22 documentation (original) (raw)

class torchvision.transforms.RandomPerspective(distortion_scale=0.5, p=0.5, interpolation=InterpolationMode.BILINEAR, fill=0)[source]

Performs a random perspective transformation of the given image with a given probability. If the image is torch Tensor, it is expected to have […, H, W] shape, where … means an arbitrary number of leading dimensions.

Parameters:

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:

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.