mindspore.dataset.vision.py_transforms.ToType
- class mindspore.dataset.vision.py_transforms.ToType(output_type)[source]
Convert the input numpy.ndarray image to the desired dtype.
- Parameters
output_type (numpy.dtype) – The dtype of the numpy.ndarray output, e.g. numpy.float32.
- Raises
TypeError – If the input is not numpy.ndarray.
- Supported Platforms:
CPU
Examples
>>> from mindspore.dataset.transforms.py_transforms import Compose >>> import numpy as np >>> transforms_list =Compose([py_vision.Decode(), ... py_vision.RandomHorizontalFlip(0.5), ... py_vision.ToTensor(), ... py_vision.ToType(np.float32)]) >>> # apply the transform to dataset through map function >>> image_folder_dataset = image_folder_dataset.map(operations=transforms_list, ... input_columns="image")