Augmentation Parameters
Image augmentation is a technique that applies various types of transformations to an image in order to produce different versions of it. This can be useful when training deep learning models because it allows the model to be exposed to a greater variety of images than what is available in the original dataset.
Tracebloc allows you to generate batches of tensor image data with real-time data augmentation. We offer a number of different augmentation parameters that can be used to customize the image transformations:
- brightness_range: This parameter is used to specify the range for shifting the brightness in images. You can pass a list or tuple of two floats to this parameter. The default value is None.
trainingObject.brightness_range((0.1,0.4))
This parameter is supported for both TensorFlow and PyTorch.
- channel_shift_range: This parameter is used to specify the range for random channel shifts. The default value is 0.
trainingObject.channel_shift_range(0.4)
This parameter is supported for both TensorFlow and PyTorch.
For PyTorch this parameter can only be used if the image type is rgb.
- cval: This parameter is used to set the value for points outside the image boundaries when fill_mode = "constant". The default value is 0.0.
trainingObject.cval(0.3)
This parameter is supported for both TensorFlow and PyTorch.
- fill_mode: This parameter is used to fill points outside the image boundaries according to a given mode. Supported fill modes for TensorFlow are "constant", "nearest", "reflect", "wrap" and for PyTorch are "constant", "edge", "symmetric", "reflect", "wrap". The default value is 'nearest'.
trainingObject.fill_mode("nearest")
This parameter is supported for both TensorFlow and PyTorch.
- height_shift_range: This parameter is used to shift the image along its height. This can be specified as a float, which is a fraction of the total height, or as an integer number of pixels. The default value is 0.0.
trainingObject.height_shift_range(0.1)
This parameter is supported for both TensorFlow and PyTorch.
- horizontal_flip: This parameter is used to randomly flip the image horizontally in order to generate new images. The default value is False.
trainingObject.horizontal_flip(True)
This parameter is supported for TensorFlow but not for PyTorch.
- rescale: This parameter is used to specify a rescaling factor. This can be a float. The default value is None.
trainingObject.rescale(1.0/255.0)
This parameter is supported for both TensorFlow and PyTorch.
- rotation_range: This parameter is used to specify the degree range for random rotations. By applying random rotations between the given ranges, new images are generated. For example, if the rotation_range is set to 2, images will be rotated by a random degree between -2 and 2. The acceptable value is an integer and the default value is 0.
trainingObject.rotation_range(2)
This parameter is supported for both TensorFlow and PyTorch.
- samplewise_center: This parameter is used to calculate the mean pixel value for each image and center it. This is done by subtracting the mean pixel value from all pixels in the image. This operation doesn't require any statistics to be calculated on the training dataset. The acceptable value is a Boolean, with a default value of False.
trainingObject.samplewise_center(True)
This parameter is supported for TensorFlow but not for PyTorch.
- samplewise_std_normalization: This parameter is used to standardize the image. Standardization is achieved by subtracting the mean pixel value and dividing the result by the standard deviation of the pixel values. The statistics are calculated for each image separately in case of samplewise_std_normalization. The acceptable value is Boolean, with a default value of False.
trainingObject.samplewise_std_normalization(True)
This parameter is supported for TensorFlow but not for PyTorch.
- shear_range: This parameter is used to specify the shear intensity (Shear angle in counter-clockwise direction in degrees) to generate new images. Shearing means that the image will be distorted along an axis, mostly to create or rectify the perception angles. This operation is usually used to augment images so that computers can see how humans see things from different angles. The acceptable value is a float, with a default value of 0.0.
trainingObject.shear_range(0.2)
This parameter is supported for both TensorFlow and PyTorch.
- shuffle: This parameter is used to specify whether to shuffle the data. The acceptable value is a Boolean, with a default value of True.
trainingObject.shuffle(False)
This parameter is supported for both TensorFlow and PyTorch.
- vertical_flip: This parameter is used to randomly flip the inputs vertically to generate new images. The acceptable value is Boolean, with a default value of False.
trainingObject.vertical_flip(True)
This parameter is supported for TensorFlow but not for PyTorch.
- width_shift_range: This parameter is used to specify a range for shifting the images along the width of the image. The acceptable values are a Float or an int. If the value is a float, it represents a fraction of the total width. If the value is less than 1, it represents a fraction of the total width, otherwise, it represents the number of pixels. If the value is an int, it represents the integer number of pixels from the interval (-width_shift_range, +width_shift_range). The default value is 0.0.
trainingObject.width_shift_range(0.1)
This parameter is supported for both TensorFlow and PyTorch.
- zoom_range: This parameter is used to specify a range for zooming on the image. The acceptable values are a Float or list. If the value is a float, then zoom range is defined as [1-zoom_range, 1+zoom_range]. If the value is list, it represents range of zoom. The default value is 0.0.
trainingObject.zoom_range(0.1)
or
trainingObject.zoom_range([0.2, 0.8])
This parameter is supported for both TensorFlow and PyTorch.
You can refer to the TensorFlow Documentation for more information on TensorFlow augmentation parameters and the PyTorch Documentation for more information on PyTorch augmentation parameters.