RandomCutout
classkeras_cv.layers.RandomCutout(
height_factor, width_factor, fill_mode="constant", fill_value=0.0, seed=None, **kwargs
)
Randomly cut out rectangles from images and fill them.
Arguments
keras_cv.FactorSampler
. height_factor
controls the size of the
cutouts. height_factor=0.0
means the rectangle will be of size 0%
of the image height, height_factor=0.1
means the rectangle will
have a size of 10% of the image height, and so forth. Values should
be between 0.0
and 1.0
. If a tuple is used, a height_factor
is sampled between the two values for every image augmented. If a
single float is used, a value between 0.0
and the passed float is
sampled. In order to ensure the value is always the same, please
pass a tuple with two identical floats: (0.5, 0.5)
.keras_cv.FactorSampler
. width_factor
controls the size of the
cutouts. width_factor=0.0
means the rectangle will be of size 0%
of the image height, width_factor=0.1
means the rectangle will
have a size of 10% of the image width, and so forth.
Values should be between 0.0
and 1.0
. If a tuple is used, a
width_factor
is sampled between the two values for every image
augmented. If a single float is used, a value between 0.0
and the
passed float is sampled. In order to ensure the value is always the
same, please pass a tuple with two identical floats: (0.5, 0.5)
.{"constant", "gaussian_noise"}
).fill_mode="constant"
.Example
(images, labels), _ = keras.datasets.cifar10.load_data()
random_cutout = keras_cv.layers.preprocessing.RandomCutout(0.5, 0.5)
augmented_images = random_cutout(images)