from keras.preprocessing import image
in_path = './dataset'
out_path = 'output'
datagen = image.ImageDataGenerator()
#指定target_size后所有图像都变为相同大小
gen_data = datagen.flow_from_directory(in_path, batch_size=1, shuffle=False,
                                       save_to_dir=out_path+'resize',
                                       save_prefix='gen', target_size=(224, 224))

for i in range(20):
    gen_data.next()