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