RandomSaturation classkeras.layers.RandomSaturation(
factor, value_range=(0, 255), data_format=None, seed=None, **kwargs
)
Randomly adjusts the saturation on given images.
This layer will randomly increase/reduce the saturation for the input RGB images.
Note: This layer is safe to use inside a tf.data or grain pipeline
(independently of which backend you're using).
Arguments
factor controls the extent to which the image saturation
is impacted. factor=0.5 makes this layer perform a no-op
operation. factor=0.0 makes the image fully grayscale.
factor=1.0 makes the image fully saturated. Values should
be between 0.0 and 1.0. If a tuple is used, a 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. To ensure the value is always the same,
pass a tuple with two identical floats: (0.5, 0.5).[low, high]. This is
typically either [0, 1] or [0, 255] depending on how your
preprocessing pipeline is set up.Example
(images, labels), _ = keras.datasets.cifar10.load_data()
images = images.astype("float32")
random_saturation = keras.layers.RandomSaturation(factor=0.2)
augmented_images = random_saturation(images)