Shortcuts

TestTimeAug

class mmcv.transforms.TestTimeAug(transforms: list)[source]

Test-time augmentation transform.

An example configuration is as followed:

dict(type='TestTimeAug',
     transforms=[
        [dict(type='Resize', scale=(1333, 400), keep_ratio=True),
         dict(type='Resize', scale=(1333, 800), keep_ratio=True)],
        [dict(type='RandomFlip', prob=1.),
         dict(type='RandomFlip', prob=0.)],
        [dict(type='PackDetInputs',
              meta_keys=('img_id', 'img_path', 'ori_shape',
                         'img_shape', 'scale_factor', 'flip',
                         'flip_direction'))]])

results will be transformed using all transforms defined in transforms arguments.

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

After that, results are wrapped into lists of the same length as below:

dict(
    inputs=[...],
    data_samples=[...]
)

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.

Parameters

transforms (list[list[dict]]) – Transforms to be applied to data sampled from dataset. transforms is a list of list, and each list element usually represents a series of transforms with the same type and different arguments. Data will be processed by each list elements sequentially. See more information in transform().

transform(results: dict)dict[source]

Apply all transforms defined in transforms to the results.

As the example given in TestTimeAug, transforms consists of 2 Resize, 2 RandomFlip and 1 PackDetInputs. The data sampled from dataset will be processed as follows:

  1. Data will be processed by 2 Resize and return a list of 2 results.

  2. Each result in list will be further passed to 2 RandomFlip, and aggregates into a list of 4 results.

  3. Each result will be processed by PackDetInputs, and return a list of dict.

  4. Aggregates the same fields of results, and finally returns a dict. Each value of the dict represents 4 transformed results.

Parameters

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

Returns

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

Return type

dict