Shortcuts

mmagic.datasets.transforms.albumentations

Module Contents

Classes

Albumentations

Albumentation augmentation.

Attributes

albumentations

mmagic.datasets.transforms.albumentations.albumentations[source]
class mmagic.datasets.transforms.albumentations.Albumentations(keys: List[str], transforms: List[dict])[source]

Bases: mmcv.transforms.BaseTransform

Albumentation augmentation.

Adds custom transformations from Albumentations library. Please, visit https://github.com/albumentations-team/albumentations and https://albumentations.ai/docs/getting_started/transforms_and_targets to get more information.

An example of transforms is as followed:

albu_transforms = [
    dict(
        type='Resize',
        height=100,
        width=100,
    ),
    dict(
        type='RandomFog',
        p=0.5,
    ),
    dict(
        type='RandomRain',
        p=0.5
    ),
    dict(
        type='RandomSnow',
        p=0.5,
    ),
]
pipeline = [
    dict(
        type='LoadImageFromFile',
        key='img',
        color_type='color',
        channel_order='rgb',
        imdecode_backend='cv2'),
    dict(
        type='Albumentations',
        keys=['img'],
        transforms=albu_transforms),
    dict(type='PackInputs')
]
Parameters
  • keys (list[str]) – A list specifying the keys whose values are modified.

  • transforms (list[dict]) – A list of albu transformations.

albu_builder(cfg: dict) albumentations[source]

Import a module from albumentations.

It inherits some of build_from_cfg() logic.

Parameters

cfg (dict) – Config dict. It should at least contain the key “type”.

Returns

The constructed object.

Return type

obj

_apply_albu(imgs)[source]
transform(results)[source]

Transform function of Albumentations.

__repr__()[source]

Return repr(self).

Read the Docs v: latest
Versions
latest
stable
0.x
Downloads
pdf
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.