RandAugment
classkeras_cv.layers.RandAugment(
value_range,
augmentations_per_image=3,
magnitude=0.5,
magnitude_stddev=0.15,
rate=0.9090909090909091,
geometric=True,
seed=None,
**kwargs
)
RandAugment performs the Rand Augment operation on input images.
This layer can be thought of as an all-in-one image augmentation layer. The policy implemented by this layer has been benchmarked extensively and is effective on a wide variety of datasets.
The policy operates as follows:
For each augmentation in the range [0, augmentations_per_image]
,
the policy selects a random operation from a list of operations.
It then samples a random number and if that number is less than
rate
applies it to the given image.
References
Arguments
[0, 1]
or [0, 255]
depending
on how your preprocessing pipeline is set up.3
.[0, 1]
. A magnitude of 0
indicates that the augmentations are as weak as possible (not
recommended), while a value of 1.0
implies use of the strongest
possible augmentation. All magnitudes are clipped to the range
[0, 1]
after sampling. Defaults to 0.5
.[0, 1]
after samples are drawn from the normal
distribution. Defaults to 0.15
.[0, 1]
. To reproduce the original RandAugment paper results, set
this to 10/11
. The original RandAugment
paper includes an
Identity transform. By setting the rate to 10/11 in our
implementation, the behavior is identical to sampling an Identity
augmentation 10/11th of the time. Defaults to 1.0
.Example
(x_test, y_test), _ = keras.datasets.cifar10.load_data()
rand_augment = keras_cv.layers.RandAugment(
value_range=(0, 255), augmentations_per_image=3, magnitude=0.5
)
x_test = rand_augment(x_test)