mindspore.dataset.vision.HWC2CHW

View Source On Gitee
class mindspore.dataset.vision.HWC2CHW[source]

Transpose the input image from shape <H, W, C> to <C, H, W>. If the input image is of shape <H, W>, it will remain unchanged.

Note

This operation is executed on the CPU by default, but it is also supported to be executed on the GPU or Ascend via heterogeneous acceleration.

Raises

RuntimeError – If shape of the input image is not <H, W> or <H, W, C>.

Supported Platforms:

CPU GPU Ascend

Examples

>>> import mindspore.dataset as ds
>>> import mindspore.dataset.vision as vision
>>>
>>> image_folder_dataset = ds.ImageFolderDataset("/path/to/image_folder_dataset_directory")
>>> transforms_list = [vision.Decode(),
...                    vision.RandomHorizontalFlip(0.75),
...                    vision.RandomCrop(512),
...                    vision.HWC2CHW()]
>>> image_folder_dataset = image_folder_dataset.map(operations=transforms_list,
...                                                 input_columns=["image"])
Tutorial Examples: