mindspore.dataset.vision.RandomPerspective

View Source On Gitee
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.0, 1.0]. Default: 0.5.

  • prob (float, optional) – Probability of performing perspective transformation, which must be in range of [0.0, 1.0]. Default: 0.5.

  • interpolation (Inter, optional) – Image interpolation method defined by Inter . Default: Inter.BICUBIC.

Raises
  • TypeError – If distortion_scale is not of type float.

  • TypeError – If prob is not of type float.

  • TypeError – If interpolation is not of type Inter .

  • ValueError – If distortion_scale is not in range of [0.0, 1.0].

  • ValueError – If prob is not in range of [0.0, 1.0].

Supported Platforms:

CPU

Examples

>>> import mindspore.dataset as ds
>>> import mindspore.dataset.vision as vision
>>> 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 = ds.ImageFolderDataset("/path/to/image_folder_dataset_directory")
>>> image_folder_dataset = image_folder_dataset.map(operations=transforms_list,
...                                                 input_columns="image")
Tutorial Examples: