Shortcuts

RandomApply

class mmcv.transforms.RandomApply(transforms: Union[Dict, Callable[[Dict], Dict], List[Union[Dict, Callable[[Dict], Dict]]]], prob: float = 0.5)[source]

Apply transforms randomly with a given probability.

Parameters
  • transforms (list[dict | callable]) – The transform or transform list to randomly apply.

  • prob (float) – The probability to apply transforms. Default: 0.5

Examples

>>> # config
>>> pipeline = [
>>>     dict(type='RandomApply',
>>>         transforms=[dict(type='HorizontalFlip')],
>>>         prob=0.3)
>>> ]
transform(results: Dict)Optional[Dict][source]

Randomly apply the transform.