composer.algorithms.utils.augmentation_primitives#
Helper functions to perform augmentations on a PIL.Image.Image
.
Augmentation that take an intensity value are normalized on a scale of 1-10, where 10 is the strongest and maximum value an augmentation function will accept.
Adapted from AugMix: A Simple Data Processing Method to Improve Robustness and Uncertainty.
- composer.algorithms.utils.augmentation_primitives.AugmentationFn#
The type annotation for describing an augmentation function.
Each augmentation takes a
Image
and an intensity level on the range[0; 10]
, and returns an augmented image.
- composer.algorithms.utils.augmentation_primitives.augmentation_sets#
The collection of all augmentations. This dictionary has the following entries:
augmentation_sets["safe"]
contains augmentations that do not overlap with ImageNet-C/CIFAR10-C test sets.augmentation_sets["original"]
contains augmentations that use the original implementations of enhancing color, contrast, brightness, and sharpness.augmentation_sets["all"]
contains all augmentations.
- Type
Dict[str, List[AugmentationFn]]
Functions
Autocontrast an image. |
|
Enhance brightness on an image. |
|
Enhance brightness on an image, following the corruptions in the ImageNet-C/CIFAR10-C test sets. |
|
Enhance color on an image. |
|
Enhance color on an image, following the corruptions in the ImageNet-C/CIFAR10-C test sets. |
|
Enhance contrast on an image. |
|
Enhance contrast on an image, following the corruptions in the ImageNet-C/CIFAR10-C test sets. |
|
Equalize an image. |
|
Posterize an image. |
|
Rotate an image. |
|
Enhance sharpness on an image. |
|
Enhance sharpness on an image, following the corruptions in the ImageNet-C/CIFAR10-C test sets. |
|
Shear an image horizontally. |
|
Shear an image vertically. |
|
Solarize an image. |
|
Shear an image horizontally. |
|
Shear an image vertically. |
Attributes
- composer.algorithms.utils.augmentation_primitives.autocontrast(pil_img, level=0.0)[source]#
Autocontrast an image.
See also
- Parameters
pil_img (Image.Image) โ The image
- composer.algorithms.utils.augmentation_primitives.brightness(pil_img, level)[source]#
Enhance brightness on an image.
See also
- Parameters
pil_img (Image.Image) โ The image.
level (float) โ The intensity, which should be on
[0, 10]
.
- composer.algorithms.utils.augmentation_primitives.brightness_original(pil_img, level)[source]#
Enhance brightness on an image, following the corruptions in the ImageNet-C/CIFAR10-C test sets.
See also
- Parameters
pil_img (Image.Image) โ The image.
level (float) โ The intensity, which should be on
[0, 10]
.
- composer.algorithms.utils.augmentation_primitives.color(pil_img, level)[source]#
Enhance color on an image.
See also
- Parameters
pil_img (Image.Image) โ The image.
level (float) โ The intensity, which should be on
[0, 10]
.
- composer.algorithms.utils.augmentation_primitives.color_original(pil_img, level)[source]#
Enhance color on an image, following the corruptions in the ImageNet-C/CIFAR10-C test sets.
- Parameters
pil_img (Image.Image) โ The image.
level (float) โ The intensity, which should be on
[0, 10]
.
- composer.algorithms.utils.augmentation_primitives.contrast(pil_img, level)[source]#
Enhance contrast on an image.
See also
- Parameters
pil_img (Image.Image) โ The image.
level (float) โ The intensity, which should be on
[0, 10]
.
- composer.algorithms.utils.augmentation_primitives.contrast_original(pil_img, level)[source]#
Enhance contrast on an image, following the corruptions in the ImageNet-C/CIFAR10-C test sets.
See also
- Parameters
pil_img (Image.Image) โ The image.
level (float) โ The intensity, which should be on
[0, 10]
.
- composer.algorithms.utils.augmentation_primitives.equalize(pil_img, level)[source]#
Equalize an image.
See also
- Parameters
pil_img (Image.Image) โ The image
- composer.algorithms.utils.augmentation_primitives.posterize(pil_img, level)[source]#
Posterize an image.
See also
- Parameters
pil_img (Image.Image) โ The image
level (float) โ The intensity, which should be on
[0, 10]
- composer.algorithms.utils.augmentation_primitives.rotate(pil_img, level)[source]#
Rotate an image.
- Parameters
pil_img (Image.Image) โ The image.
level (float) โ The intensity, which should be on
[0, 10]
.
- composer.algorithms.utils.augmentation_primitives.sharpness(pil_img, level)[source]#
Enhance sharpness on an image.
See also
- Parameters
pil_img (Image.Image) โ The image.
level (float) โ The intensity, which should be on
[0, 10]
.
- composer.algorithms.utils.augmentation_primitives.sharpness_original(pil_img, level)[source]#
Enhance sharpness on an image, following the corruptions in the ImageNet-C/CIFAR10-C test sets.
See also
- Parameters
pil_img (Image.Image) โ The image.
level (float) โ The intensity, which should be on
[0, 10]
.
- composer.algorithms.utils.augmentation_primitives.shear_x(pil_img, level)[source]#
Shear an image horizontally.
- Parameters
pil_img (Image.Image) โ The image.
level (float) โ The intensity, which should be on
[0, 10]
.
- composer.algorithms.utils.augmentation_primitives.shear_y(pil_img, level)[source]#
Shear an image vertically.
- Parameters
pil_img (Image.Image) โ The image.
level (float) โ The intensity, which should be on
[0, 10]
.
- composer.algorithms.utils.augmentation_primitives.solarize(pil_img, level)[source]#
Solarize an image.
See also
- Parameters
pil_img (Image.Image) โ The image.
level (float) โ The intensity, which should be on
[0, 10]
.