mindspore.dataset.vision.RandomPerspective

class mindspore.dataset.vision.RandomPerspective(distortion_scale=0.5, prob=0.5, interpolation=Inter.BICUBIC)[source]

Randomly apply perspective transformation to the input PIL Image with a given probability.

Parameters
  • distortion_scale (float, optional) – Scale of distortion, in range of [0, 1]. Default: 0.5.

  • prob (float, optional) – Probability of performing perspective transformation. Default: 0.5.

  • interpolation (Inter, optional) –

    Method of interpolation. It can be Inter.BILINEAR, Inter.NEAREST or Inter.BICUBIC. Default: Inter.BICUBIC.

    • Inter.BILINEAR, bilinear interpolation.

    • Inter.NEAREST, nearest-neighbor interpolation.

    • Inter.BICUBIC, bicubic interpolation.

Raises
Supported Platforms:

CPU

Examples

>>> from mindspore.dataset.transforms import Compose
>>>
>>> transforms_list = Compose([vision.Decode(to_pil=True)),
...                            vision.RandomPerspective(prob=0.1),
...                            vision.ToTensor()])
>>> # apply the transform to dataset through map function
>>> image_folder_dataset = image_folder_dataset.map(operations=transforms_list,
...                                                 input_columns="image")
execute_py(img)[source]

Execute method.

Parameters

img (PIL Image) – Image to be applied randomly perspective transformation.

Returns

PIL Image, image applied randomly perspective transformation.