Shortcuts

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'})[源代码]

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 in scales. If flip 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 and data_samples are both 4.

Required Keys:

  • Depending on the requirements of the transforms parameter.

Modified Keys:

  • All output keys of each transform.

参数
  • 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').

transform(results: dict)Dict[源代码]

Apply test time augment transforms on results.

参数

results (dict) – Result dict contains the data to transform.

返回

The augmented data, where each value is wrapped into a list.

返回类型

dict

Read the Docs v: stable
Versions
latest
stable
2.x
v2.0.1
v2.0.0
1.x
v1.7.1
v1.7.0
v1.6.2
v1.6.1
v1.6.0
v1.5.3
v1.5.2_a
v1.5.1
v1.5.0
v1.4.8
v1.4.7
v1.4.6
v1.4.5
v1.4.4
v1.4.3
v1.4.2
v1.4.1
v1.4.0
v1.3.18
v1.3.17
v1.3.16
v1.3.15
v1.3.14
v1.3.13
Downloads
pdf
html
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.