keras进行图像预处理 并 生成一个generator

keras中有很多封装好的API可以帮助我们实现对图片数据的读取和处理。

比如 : keras.preprocessing.image.ImageDataGenerator.flow_from_directory( ) 这个函数

这个函数的参数包括:

flow_from_directory(self, directory,
                            target_size=(256, 256), color_mode='rgb',
                            classes=None, class_mode='categorical',
                            batch_size=32, shuffle=True, seed=None,
                            save_to_dir=None,
                            save_prefix='',
                            save_format='jpeg',
                            follow_links=False)

使用flow_from_directory最值得注意的是directory这个参数:

directory: path to the target directory. It should contain one subdirectory per class. Any PNG, JPG, BMP, PPM or TIF images inside each of the subdirectories directory tree will be included in the generator. 

这是官方文档的定义,它的目录格式一定要注意是包含一个子目录下的所有图片这种格式,driectoty路径只要写到标签路径上面的那个路径即可。

targe

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值