Shortcuts

RandomChoice

class mmcv.transforms.RandomChoice(transforms: List[Union[Dict, Callable[[Dict], Dict], List[Union[Dict, Callable[[Dict], Dict]]]]], prob: Optional[List[float]] = None)[source]

Process data with a randomly chosen transform from given candidates.

Parameters
  • transforms (list[list]) – A list of transform candidates, each is a sequence of transforms.

  • prob (list[float], optional) – The probabilities associated with each pipeline. The length should be equal to the pipeline number and the sum should be 1. If not given, a uniform distribution will be assumed.

Examples

>>> # config
>>> pipeline = [
>>>     dict(type='RandomChoice',
>>>         transforms=[
>>>             [dict(type='RandomHorizontalFlip')],  # subpipeline 1
>>>             [dict(type='RandomRotate')],  # subpipeline 2
>>>         ]
>>>     )
>>> ]
transform(results: Dict)Optional[Dict][source]

Randomly choose a transform to apply.