MultiScaleFlipAug¶
- class mmcv.transforms.MultiScaleFlipAug(transforms: List[dict], scales: Optional[Union[Tuple, List[Tuple]]] = None, scale_factor: Optional[Union[float, List[float]]] = None, allow_flip: bool = False, flip_direction: Union[str, List[str]] = 'horizontal', resize_cfg: dict = {'keep_ratio': True, 'type': 'Resize'}, flip_cfg: dict = {'type': 'RandomFlip'})[source]¶
Test-time augmentation with multiple scales and flipping.
An example configuration is as followed:
dict( type='MultiScaleFlipAug', scales=[(1333, 400), (1333, 800)], flip=True, transforms=[ dict(type='Normalize', **img_norm_cfg), dict(type='Pad', size_divisor=1), dict(type='ImageToTensor', keys=['img']), dict(type='Collect', keys=['img']) ])
results
will be resized using all the sizes inscales
. Ifflip
is True, then flipped results will also be added into output list.For the above configuration, there are four combinations of resize and flip:
Resize to (1333, 400) + no flip
Resize to (1333, 400) + flip
Resize to (1333, 800) + no flip
resize to (1333, 800) + flip
The four results are then transformed with
transforms
argument. After that, results are wrapped into lists of the same length as below:dict( inputs=[...], data_samples=[...] )
Where the length of
inputs
anddata_samples
are both 4.Required Keys:
Depending on the requirements of the
transforms
parameter.
Modified Keys:
All output keys of each transform.
- Parameters
transforms (list[dict]) – Transforms to be applied to each resized and flipped data.
scales (tuple | list[tuple] | None) – Images scales for resizing.
scale_factor (float or tuple[float]) – Scale factors for resizing. Defaults to None.
allow_flip (bool) – Whether apply flip augmentation. Defaults to False.
flip_direction (str | list[str]) – Flip augmentation directions, options are “horizontal”, “vertical” and “diagonal”. If flip_direction is a list, multiple flip augmentations will be applied. It has no effect when flip == False. Defaults to “horizontal”.
resize_cfg (dict) – Base config for resizing. Defaults to
dict(type='Resize', keep_ratio=True)
.flip_cfg (dict) – Base config for flipping. Defaults to
dict(type='RandomFlip')
.