mindspore.dataset.vision.Decode

class mindspore.dataset.vision.Decode(to_pil=False)[source]

Decode the input image in RGB mode. Supported image formats: JPEG, BMP, PNG, TIFF, GIF(need to_pil=True ), WEBP(need to_pil=True ).

Parameters

to_pil (bool, optional) – Whether to decode the image to the PIL data type. If True, the image will be decoded to the PIL data type, otherwise it will be decoded to the NumPy data type. Default: False.

Raises
Supported Platforms:

CPU

Examples

>>> # Eager usage
>>> import numpy as np
>>> raw_image = np.fromfile("/path/to/image/file", np.uint8)
>>> decoded_image = vision.Decode()(raw_image)
>>>
>>> # Pipeline usage
>>> transforms_list = [vision.Decode(), vision.RandomHorizontalFlip()]
>>> image_folder_dataset = image_folder_dataset.map(operations=transforms_list,
...                                                 input_columns=["image"])