我试图使用 ImageDataGenerator 并应用一个 prepossing 函数来应用一些随机色调。当我通过 ImageDataGenerator 对单张图片运行转换时,我没有看到它的应用。
def hue_change(image):
new_img = tf.image.random_hue(np.array(image), 0.2)
return new_img
IMG_gen = ImageDataGenerator(rotation_range=30,height_shift_range=0.05, width_shift_range=0.05,fill_mode='nearest',
zoom_range=0.03, rescale=1./255,preprocessing_function=hue_change)
当我直接将此功能直接应用到图片中时,它可以工作。
plt.imshow(hue_change(imread('Train//Apple Granny Smith//179_100.jpg')))
但是当我通过 random_transform 生成它时
plt.imshow(IMG_gen.random_transform(imread(('Train//Apple Granny Smith//179_100.jpg'))))
我没有看到任何变化。
你能告诉我为什么它会这样工作吗?