mindspore.dataset.transforms.RandomOrder

class mindspore.dataset.transforms.RandomOrder(transforms)[source]

Perform a series of transforms to the input image in a random order.

Parameters

transforms (list) – List of the transformations to apply.

Raises
  • TypeError – If transforms is not of type list.

  • TypeError – If elements of transforms are neither Python callable objects nor data processing operations in mindspore.dataset.transforms.transforms.

  • ValueError – If transforms is empty.

Supported Platforms:

CPU

Examples

>>> import mindspore.dataset as ds
>>> import mindspore.dataset.vision as vision
>>> import mindspore.dataset.transforms as transforms
>>> from mindspore.dataset.transforms import Compose
>>>
>>> transforms_list = [vision.RandomHorizontalFlip(0.5),
...                    vision.Normalize((0.491, 0.482, 0.447), (0.247, 0.243, 0.262)),
...                    vision.RandomErasing()]
>>> composed_transform = Compose([vision.Decode(to_pil=False),
...                               transforms.RandomOrder(transforms_list),
...                               vision.ToTensor()])
>>>
>>> image_folder_dataset = ds.ImageFolderDataset("/path/to/image_folder_dataset_directory")
>>> image_folder_dataset = image_folder_dataset.map(operations=composed_transform, input_columns=["image"])