mindspore.dataset.vision.RandomSelectSubpolicy

View Source On Gitee
class mindspore.dataset.vision.RandomSelectSubpolicy(policy)[source]

Choose a random sub-policy from a policy list to be applied on the input image.

Parameters

policy (list[list[tuple[TensorOperation, float]]]) – List of sub-policies to choose from. A sub-policy is a list of tuple[operation, prob], where operation is a data processing operation and prob is the probability that this operation will be applied, and the prob values must be in range [0.0, 1.0]. Once a sub-policy is selected, each operation within the sub-policy with be applied in sequence according to its probability.

Raises

TypeError – If policy contains invalid data processing operations.

Supported Platforms:

CPU

Examples

>>> import mindspore.dataset as ds
>>> import mindspore.dataset.vision as vision
>>>
>>> image_folder_dataset = ds.ImageFolderDataset("/path/to/image_folder_dataset_directory")
>>> policy = [[(vision.RandomRotation((45, 45)), 0.5),
...            (vision.RandomVerticalFlip(), 1),
...            (vision.RandomColorAdjust(), 0.8)],
...           [(vision.RandomRotation((90, 90)), 1),
...            (vision.RandomColorAdjust(), 0.2)]]
>>> image_folder_dataset = image_folder_dataset.map(operations=vision.RandomSelectSubpolicy(policy),
...                                                 input_columns=["image"])
Tutorial Examples: