RandomSaturation
类keras.layers.RandomSaturation(
factor, value_range=(0, 255), data_format=None, seed=None, **kwargs
)
随机调整给定图像的饱和度。
此层将随机增加/减少输入 RGB 图像的饱和度。
参数
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)