python-3.x - ImageDataGenerator 中 channel_shift_range 的影响(Keras 图像增强)

标签 python-3.x tensorflow keras computer-vision tf.keras

也许我误解了。如果我在 ImageDataGenerator 中实现 channel_shift_range,输出应该有“乱码”的颜色值,对吗?我想用它来使我的模型对颜色变化更加稳健。

但是,当我测试它时,我没有看到任何效果。我用错了吗?这是我的代码:

from keras.preprocessing.image import ImageDataGenerator

import cv2
import matplotlib.pyplot as plt
%matplotlib inline

path = '/mnt/Project/Imaging/samples'

datagen = ImageDataGenerator(channel_shift_range=0.9)

genObject = datagen.flow_from_directory(path,
                                        batch_size=1)

augs = []
i = 0

for batch in genObject:
    augs.append(batch)
    i += 1
    if i > 10:
        break

for item in augs:
    plt.imshow(item[0][0].astype('uint8'))
    plt.show()

环境:
Jupyter 实验室
python 3.6.6
Keras==2.2.4
Keras-应用程序==1.0.7
Keras-预处理==1.0.9
张量板==1.9.0
tensorflow -GPU == 1.9.0

在此先感谢您的帮助!

最佳答案

图像数据的值在 [0..255] 范围内,因此几乎看不到 0..0.9 的偏移。尝试一个更大的转变,看看有什么效果。

请注意,使用 rescale=1./255。没有帮助,因为在转换后应用了重新缩放。

关于python-3.x - ImageDataGenerator 中 channel_shift_range 的影响(Keras 图像增强),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56840526/

相关文章:

tensorflow - 尝试使用 Keras 上的回调保存我的模型时,Sequential' 对象没有属性 '_ckpt_saved_epoch' 错误

python - 即使在使用正则化器之后 LSTM 中的过度拟合

python - 如何解释 keras "predict_generator "输出?

python - 训练 uNet 模型预测只有黑色

python - 如何在python中循环多个文件并逐一处理

Python,为每个方法安排一个线程的并行线程

python - 计数向量化器中是否可以有无序二元组

python - 属性错误: module 'tensorflow.python.summary.summary' has no attribute 'FileWriter'

python - 选择 Tensorflow 1 层中的特定功能

tensorflow - 为什么验证准确度在每个时期都会波动?