RandomSaturation layer

[source]

RandomSaturation class

keras.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.

Arguments

  • factor: A tuple of two floats or a single float. 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).
  • value_range: the range of values the incoming images will have. Represented as a two-number tuple written [low, high]. This is typically either [0, 1] or [0, 255] depending on how your preprocessing pipeline is set up.
  • seed: Integer. Used to create a random seed.

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)