RandomSaturation 类keras.layers.RandomSaturation(
factor, value_range=(0, 255), data_format=None, seed=None, **kwargs
)
随机调整给定图像的饱和度。
此层将随机增加/减少输入 RGB 图像的饱和度。
注意:该层可以在 tf.data 或 grain 管道中使用(无论您使用的是哪个后端),且是安全的。
参数
factor 控制图像饱和度受影响的程度。factor=0.5 使此层执行无操作。factor=0.0 使图像完全变为灰度。factor=1.0 使图像饱和度达到最大。值应介于 0.0 和 1.0 之间。如果使用元组,则为每张增强的图像在两个值之间采样一个 factor。如果使用单个浮点数,则在 0.0 和传入的浮点数之间采样一个值。为了确保值始终相同,请传递一个包含两个相同浮点数的元组:(0.5, 0.5)。[low, high]。这通常是 [0, 1] 或 [0, 255],具体取决于你的预处理管道的设置方式。示例
(images, labels), _ = keras.datasets.cifar10.load_data()
images = images.astype("float32")
random_saturation = keras.layers.RandomSaturation(factor=0.2)
augmented_images = random_saturation(images)