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) – decode to PIL Image (default=False).
- Raises
RuntimeError – If given tensor is not a 1D sequence.
RuntimeError – If the input is not raw image bytes.
RuntimeError – If the input image is already decoded.
- 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"])