Keras:可视化ImageDataGenerator输出 [英] Keras: Visualize ImageDataGenerator Output

查看:369
本文介绍了Keras:可视化ImageDataGenerator输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想看看ImageDataGenerator对我的网络产生了什么.

I would like to see what my ImageDataGenerator yields to my network.

修改:
删除了channel_shift_range,不小心将其留在了代码中


removed the channel_shift_range, accidently left it in the code

genNorm = ImageDataGenerator(rotation_range=10, width_shift_range=0.1, 
       height_shift_range=0.1, zoom_range=0.1, horizontal_flip=True)

获取批次

batches = genNorm.flow_from_directory(path+'train', target_size=(224,224),
      class_mode='categorical', batch_size=64)

x_batch, y_batch = next(batches)

绘制图像

for i in range (0,32):
    image = x_batch[i]
    plt.imshow(image.transpose(2,1,0))
    plt.show()

结果

发电机输出

这是正常现象吗,还是我在这里做错了什么?

Is this normal or am I doing something wrong here?

推荐答案

尝试一下;更改生成器,如下所示:

Try this; change the generator as follow:

import numpy as np

def my_preprocessing_func(img):
    image = np.array(img)
    return image / 255

genNorm = ImageDataGenerator(rotation_range=10, width_shift_range=0.1, 
       height_shift_range=0.1, zoom_range=0.1, horizontal_flip=True, 
       preprocessing_function=my_preprocessing_func)

对我有用,

布鲁诺

这篇关于Keras:可视化ImageDataGenerator输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆