mindspore.dataset.vision.ToPIL
- class mindspore.dataset.vision.ToPIL[源代码]
将 numpy.ndarray 格式的解码图像转换为 PIL.Image.Image 格式的图像。
- 异常:
TypeError - 当输入图像的类型不为
numpy.ndarray
或 PIL.Image.Image 。
- 支持平台:
CPU
样例:
>>> 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")
- 教程样例: