Shortcuts

RandomApply

class mmcv.transforms.RandomApply(transforms: Dict | Callable[[Dict], Dict] | List[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) Dict | None[source]

Randomly apply the transform.