Image Augmentation#
(hivenas.utils.image_aug)
Image Augmentation methods.
- class ImgAug[source]#
Bases:
objectElement-wise image augmentation methods, used to preprocess a given dataset.
(most affine transformations used are implemented in
tensorflow.keras.preprocessing.image.ImageDataGenerator)- static augment(np_tensor)[source]#
Used by ImageDataGenerator’s preprocess_function
- Parameters
np_tensor (
numpy.array) – rank 3 numpy tensor-respresentation of the data sample- Returns
augmented numpy tensor with all applicable transformations/augmentations
- Return type
(
numpy.array)
- static random_contrast(np_tensor)[source]#
Apply random contrast augmentation
- Parameters
np_tensor (
numpy.array) – rank 3 numpy tensor-respresentation of the data sample- Returns
transformed numpy tensor with random contrast
- Return type
(
numpy.array)
- static random_cutout(np_tensor, cutout_color=127)[source]#
Randomly applies cutout augmentation to a given rank 3 tensor as defined in [1]. Defaults to grey cutout
[1] DeVries, T., & Taylor, G. W. (2017). Improved regularization of convolutional neural networks with cutout.
- Parameters
np_tensor (
numpy.array) – rank 3 numpy tensor-respresentation of the data samplecutout_color (int, optional) – RGB-uniform value of the cutout color (defaults to grey (
127). white (255) and black (0) are also valid)
- Returns
augmented numpy tensor (with a random cutout)
- Return type
numpy.array
- static random_saturation(np_tensor)[source]#
Apply random saturation augmentation (only works on RGB images, skipped on grayscale datasets)
- Parameters
np_tensor (
numpy.array) – rank 3 numpy tensor-respresentation of the data sample- Returns
transformed numpy tensor with random saturation
- Return type
(
numpy.array)