diffengine.datasets.transforms.wrappers

Module Contents

Classes

RandomChoice

Process data with a randomly chosen transform from given candidates.

Attributes

Transform

diffengine.datasets.transforms.wrappers.Transform[source]
class diffengine.datasets.transforms.wrappers.RandomChoice(transforms, prob=None)[source]

Bases: diffengine.datasets.transforms.base.BaseTransform

Process data with a randomly chosen transform from given candidates.

Copied from mmcv/transforms/wrappers.py.

Args:

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
>>>         ]
>>>     )
>>> ]
__iter__()[source]

Iterate over transforms.

Return type:

collections.abc.Iterator

random_pipeline_index()[source]

Return a random transform index.

Return type:

int

transform(results)[source]

Randomly choose a transform to apply.

Parameters:

results (dict) –

Return type:

dict | None

Parameters:
  • transforms (list[Transform | list[Transform]]) –

  • prob (list[float] | None) –