keras:ImageDataGenerator的flow_from_directory方法

结合上文,flow的ImageDataGenerator的分析,该部分伪代码如下:

xm,y=getDataIndex()#获取所有文件夹中所有图片索引,以及文件夹名也即标签
if shuffle==True:
    shuffle(xm,y)#打乱图片索引及其标签
while(True):
    for i in range(0,len(x),batch_size):
        xm_batch=xm[i:i+batch_size]#文件索引
        y_batch=y[i:i+batch_size]
        x_batch=getImg(xm_batch)#根据文件索引,获取图像数据
        ImagePro(x_batch)#数据增强
        #保存提升后的图片
        #saveToFile()
        yield (x_batch,y_batch)

源码参考:/Lib/site-packages/keras/preprocessing/image.py

猜你喜欢

转载自blog.csdn.net/nima1994/article/details/80626239