mindspore.dataset.vision.py_transforms.ToPIL

class mindspore.dataset.vision.py_transforms.ToPIL[source]

Convert the input decoded numpy.ndarray image to PIL Image.

Note

The conversion mode will be determined by the data type using PIL.Image.fromarray.

Raises

TypeError – If the input image is not of type numpy.ndarray or PIL.Image.Image.

Supported Platforms:

CPU

Examples

>>> from mindspore.dataset.transforms.py_transforms import Compose
>>>
>>> # data is already decoded, but not in PIL Image format
>>> transforms_list = Compose([py_vision.ToPIL(),
...                            py_vision.RandomHorizontalFlip(0.5),
...                            py_vision.ToTensor()])
>>> # apply the transform to dataset through map function
>>> image_folder_dataset = image_folder_dataset.map(operations=transforms_list,
...                                                 input_columns="image")