mindspore.dataset.vision.ToNumpy

查看源文件
class mindspore.dataset.vision.ToNumpy[源代码]

将输入PIL图像转换为numpy.ndarray图像。

支持平台:

CPU

样例:

>>> import mindspore.dataset as ds
>>> import mindspore.dataset.vision as vision
>>> from mindspore.dataset.transforms import Compose
>>>
>>> # Use ToNumpy to explicitly select C++ implementation of subsequent op
>>> transforms_list = Compose([vision.Decode(True),
...                            vision.RandomHorizontalFlip(0.5),
...                            vision.ToNumpy(),
...                            vision.Resize((100, 120))])
>>> # 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")
教程样例: