mindspore.dataset.vision.ToPIL

View Source On Gitee
class mindspore.dataset.vision.ToPIL[source]

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

Raises

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

Supported Platforms:

CPU

Examples

>>> import mindspore.dataset as ds
>>> import mindspore.dataset.vision as vision
>>> from mindspore.dataset.transforms import Compose
>>>
>>> # data is already decoded, but not in PIL Image format
>>> transforms_list = Compose([vision.ToPIL(),
...                            vision.RandomHorizontalFlip(0.5),
...                            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: