mindspore.dataset.vision.ToPIL
- class mindspore.dataset.vision.ToPIL[源代码]
将已解码的numpy.ndarray图像转换为PIL图像。
说明
转换模式将根据
PIL.Image.fromarray
由图像的数据类型决定。- 异常:
TypeError - 当输入图像的类型不为
numpy.ndarray
或PIL.Image.Image
。
- 支持平台:
CPU
样例:
>>> 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 = image_folder_dataset.map(operations=transforms_list, ... input_columns="image")