Module : Augmentations

As a preprocessing step, we perform various kinds of augmentations to our images to see which of them can logically enhance our dataset, thereby increasing the ability to generalize on unseen images. You can learn more about the effects of augmentation in Improving Model Performance. This is done during the workflow after your dataset and annotations are completed, as these augmentations don't have to be performed on the images all at once.

While augmentations are good for dataset robustness, keep in mind that augmentations make it harder for the model to learn as well, so randomly selecting augmentations will not necessarily improve model inference and can hinder model training.

Here is an example image of how the augmentation menu will look like in Advanced Mode, where you can choose your own custom options.

Augmentations Module Advanced Mode Options (Click image to enlarge)

Augmentations Module Advanced Mode Options (Click image to enlarge)

Only one Augmentations module is required for each workflow, regardless of the number of augmentation types enabled.

Augmentation Types

There are three types of augmentations: composite image augmentations, random position augmentations, and color space augmentations.

Composite Augmentations

These augmentations consist of putting multiple images together to increase diversity within a single image by combining multiple images in various ways.

Composite AugmentationsOptionsDescription
CutMixProbabilityCutMix takes a random crop from another image in the dataset and pastes it on top of the base image.
MosaicProbabilityMosaic takes multiple images, typically 4 images, and places it in a tiled image. Subsequently, a random crop is taken of on the canvas of 4 tiled images.

Positional Augmentations

These are what we call the geometric transforms. Common positional augmentations include HorizontalFlip, VerticalFlip and ShiftScaleRotate and our library has them all. Positional augmentations are ways to keep the size of the data input more similar but also augmenting the dataset by shifting or removing certain details in the visual data such that the model isn't reliant on specific features. The full list is below. The image here displays an example of positional augmentations like HorizontalFlip, VerticalFlip, ShiftScaleRotate, RandomRotate, and RandomSizedCrop using our Preview Augmentations feature at the bottom right corner of the Workflow canvas next to the green Run Training button.

📘

To see how to preview these augmentations, look at Previewing Augmentations!

2022

Positional Augmentation Example (Click image to enlarge)

Spatial AugmentationsOptionsDescription
Center CropProbability, Height, WidthCenter crop takes a crop of set height and width from the middle of the image with set probability.
Probability should be a value from 0 to 1, height and width should be less than or equal to the image height and width.
Flip HorizontalProbabilityFlips the image horizontally with set probability.
Probability should be a value from 0 to 1.
Flip VerticalProbabilityFlips the image vertically with set probability.
Probability should be a value from 0 to 1.
Random CropProbability, Height, WidthRandom crop takes a crop of set height and width from anywhere in the image with set probability.
Probability should be a value from 0 to 1, height and width should be less than or equal to the image height and width.
Random RotateProbability, Minimum Rotation, Maximum RotationRandomly rotates the image by some angle between the minimum and maximum rotation with set probability.
Minimum rotation is -360 degrees, maximum rotation is 360 degrees.
Random Resized CropProbability, Height, Width, Minimum Scale, Maximum Scale, Minimum Aspect Ratio, Maximum Aspect RatioRandom crop with set height and width taken from anywhere in the image and then resized with random scale between minimum and maximum scale, and transformed to a random aspect ratio between the minimum and maximum aspect ratio. Randomly apply affine transforms: translate, scale and rotate the input with set probability.
Random Sized CropProbability, Minimum Crop Height, Maximum Crop Height, Height, Width, Width to Height RatioRandom crop with set width to height ratio and random crop height with set probability.
The set crop height bounds should be within the image dimensions.
Shift Scale RotateProbability, Minimum Shift, Maximum Shift, Minimum Scale, Maximum Scale, Minimum Rotation, Maximum RotationRandomly apply affine transforms: translate, scale and rotate the input by randomly selected shift, scale, and rotate with set probability.

Color Augmentations

The other popular type of augmentation is color space augmentaiton. Basically, this type of augmentation does not shift the location of the pixels, but instead, will alter pixel values such that the color representation changes. For example, the RandomPixelValueScale randomly scales a pixel value between the min_scale and the max_scale. The random selection is based on a uniform distribution, so all values are equally likely to be picked.

The reason to use color augmentations is so that the model is not dependent on the color space for making predictions. Often times, data collecting instruments will not be identical and the lighting in which the visual data is collected may not be the same, so colors can be drastically different in test or inference environments even if the main features in the data remain the same. Thus, to artificially create color diversity in our train set, we use color augmentations to bolster the model's ability to detect features in different color spaces.

Below is an example of only color space augmentations such as color jitter, random brightness, random contrast, and solarize.

2022

Color Space Augmentation Example (Click image to enlarge)

Other color augmentations are very extensive with the following being included:

Color AugmentationsOptionsDescription
Channel DropoutProbability, Min Channel Dropout Limit, Max Channel Dropout Limit, Fill ValueDrop a random number of RGB channels between the minimum and maximum values, and replaced with a set fill value with set probability.
Channel ShuffleProbabilityRandomly rearrange RGB channel value order with set probability.
CLAHEProbability, Min Clip Limit, Max Clip Limit, Min Grid Limit, Max Grid LimitApply Contrast Limited Adaptive Histogram Equalization to the input image used for improving the visibility level of foggy image or video. Minimum and maximum clip limits act as upper threshold values for contrast limiting, and the grid limits define where CLAHE is applied.
Color JitterProbability, Min Brightness, Max Brightness, Min Contrast, Max Contrast, Min Saturation, Max Saturation, Min Hue, Max HueColorJitter randomly changes the brightness, contrast, saturation, and hue of an image. For brightness, contrast, and saturation, you supply the maximum and minimum bound values, which change with set probability.
CutoutProbability, Number of Holes, Max Hole Height, Max Hole Width, Fill ValueRandomly select a number of areas with random sized height and width with defined maximums to fill with some set value.
EqualizeProbabilityImprove contrast in images by effectively spreading out the most frequent intensity values, i.e. stretching out the intensity range of the image.
Fancy PCAProbability, AlphaAugments the color of the image by adding the most significant eigenvectors (defined through Principle Component Analysis or PCA) multiplied by some set alpha to the RGB values of each pixel. This creates the effect of sharpening the most vivid colors but in a more natural way than random augmentation. According to the original paper, alpha should be selected from a normal distribution with mean 0 and standard deviation 0.1.
Gaussian BlurProbability, Min Sigma Minimum, Max Sigma MinimumBlur the input image using a Gaussian filter with a random kernel size, using Gaussian function with sigma between the minimum and maximum value.
Gaussian NoiseProbability, Min Variance Range, Max Variance Range, MeanGaussian noise adds noise values selected from a Gaussian distribution with variance between the minimum and maximum variance range and with the set mean.
Glass BlurProbability, Sigma, Max Delta, IterationsApplies glass noise based on the inputted sigma for the Gaussian function, and the maximum delta for the maximum distance between swapped pixels and iterations being the number of times this occurs.
GrayscaleProbabilityGrayscale converts all color pixels into a black and white scale, making the image entirely grayscale.
Hue Saturation ValueProbability, Min Hue Shift, Max Hue Shift, Min Saturation Shift, Max Saturation Shift, Min Value Shift, Max Value ShiftRandomly change hue, saturation and value of the input image bounded by the set minimum and maximum values.
Image CompressionProbability, Lower Quality Limit, Upper Quality LimitCompresses the image on a scale of 0 to 100 within the lower and upper quality limit set.
ISO NoiseProbability, Min Color Shift, Max Color Shift, Min Intensity, Max IntensityISO noise applies camera sensor noise, which can be useful if your image data is collected from camera instruments in the real world.
Median BlurProbability, Max BlurThe Median blur operation is similar to the other averaging methods. Here, the central element of the image is replaced by the median of all the pixels in the kernel area. This operation processes the edges while removing the noise.
Motion BlurProbability, Max BlurUsing convolution filters and a randomly generated line, motion blur is constructed with the blur depending on the maximum blur set.
Multiplicative NoiseProbability, Min Multiplication Limit, Max Multiplication LimitMultiply image to random number selected between the minimum and maximum multiplication limit.
PosterizeProbability, R Channel Number of Bits, G Channel Number of Bits, B Channel Number of BitsReduces the number of bits for each color channel.
Random BlurProbability, Min Blur Limit, Max Blur LimitRandom blur applied with blur limited in between minimum and maximum.
Random BrightnessProbability, Min Brightness Limit, Max Brightness LimitRandomly change brightness of the image within the minimum and maximum brightness.
Random Brightness ContrastProbability, Min Brightness Limit, Max Brightness Limit, Min Contrast Limit, Max Contrast LimitRandomly change brightness and contrast of the image within the minimum and maximum brightness and contrast.
Random ContrastProbability, Min Contrast Limit, Max Contrast LimitRandomly change contrast of the image within the minimum and maximum contrast.
Random FogProbability, Lower Coefficient Limit, Upper Coefficient Limit, Alpha Coefficient LimitApplies fog artificially to an image. You can control the fog intensity levels with the coefficient limit, and alpha is the transparency of the fog circle.
Random GammaProbability, Min Gamma Limit, Max Gamma LimitGamma changes the brightness of the image restricted to minimum and maximum gamma limits.
Random RainProbability, Lower Slant, Upper Slant, Drop Length, Drop Width, Drop Color Red, Drop Color Green, Drop Color Blue, Blur Value, Brightness CoefficientAdds rain like effects where you can control the drop color with the red, green, and blue as well as the drop size with length and width, and the lower and upper slant for shape.
Random ShadowProbability, X Min, Y Min, X Max, Y Max, Number of Shadows Lower Limit, Number of Shadows Upper Limit, Number of EdgesRandom shadow applies a number of shadows between the lower and upper limit within a certain area space.
Random SnowProbability, Lower Snow Limit, Upper Snow Limit, Brightness CoefficientRandom snow effects are applied, bounded by the limit values.
Random Sun FlareProbability, X Min, Y Min, X Max, Y Max, Angle Lower Limit, Angle Upper Limit, Number of Flares Lower Limit, Number of Flares Upper LimitApplies random number of sun flares within a certain area from a random angle.
RGB ShiftProbability, R Channel Shift Lower Limit, R Channel Shift Upper Limit, G Channel Shift Lower Limit, G Channel Shift Upper Limit, B Channel Shift Lower Limit, B Channel Shift Upper LimitRandom RGB shift for each individual channel by a random amount for each.
SepiaProbabilityAdds the common image effect of sepia to the image.
SolarizeProbability, ThresholdInverts all pixels above the preset threshold.