Skip to content

Augmentation

The Augmentation classes of AUCMEDI allow creating interfaces to powerful augmentation frameworks and easily integrate them into the AUCMEDI pipeline.

An Augmentation class is a preprocessing method, which is randomly applied on each sample if provided to a DataGenerator.

Warning

Augmentation should only be applied to a training DataGenerator!

For test-time augmentation, aucmedi.ensemble.augmenting should be used.

Data augmentation is a technique that can be used to artificially expand the size of a training dataset by creating modified versions of images in the dataset.

The point of data augmentation is, that the model will learn meaningful patterns instead of meaningless characteristics due to a small data set size.

Data Augmentation Interfaces
Interface Description
ImageAugmentation Interface to package: Albumentations. Handles only images (2D data).
VolumeAugmentation Interface to package: Volumentations. Handles only volumes (3D data).
BatchgeneratorsAugmentation Interface to package: batchgenerators (DKFZ). Handles images and volumes (2D+3D data).

Recommendation:
- For images (2D data): ImageAugmentation()
- For volumes (3D data): BatchgeneratorsAugmentation()

Example

For 2D data:

from aucmedi import *

aug = ImageAugmentation(flip=True, rotate=True, brightness=True, contrast=True,
             saturation=True, hue=True, scale=True, crop=False,
             grid_distortion=False, compression=False, gaussian_noise=False,
             gaussian_blur=False, downscaling=False, gamma=False,
             elastic_transform=False)

datagen = DataGenerator(samples=index_list,
                        path_imagedir="dataset/images/",
                        labels=class_ohe,
                        data_aug=aug,
                        resize=model.meta_input,
                        image_format=image_format)

For 3D data:

from aucmedi import *

aug = BatchgeneratorsAugmentation(model.meta_input, mirror=False, rotate=True,
             scale=True, elastic_transform=False, gaussian_noise=True,
             brightness=True, contrast=True, gamma=True)

datagen = DataGenerator(samples=index_list,
                        path_imagedir="dataset/volumes/",
                        labels=class_ohe,
                        data_aug=aug,
                        resize=model.meta_input,
                        image_format=image_format)