我正在使用Keras flow_from_directory执行数据扩充:
from keras.applications.inception_v3 import preprocess_input
from keras.preprocessing.image import ImageDataGenerator
batch_size = 32
# Create train generator
train_datagen = ImageDataGenerator(preprocessing_function=preprocess_input,
rotation_range = 15,
width_shift_range = 0.2,
height_shift_range = 0.2,
shear_range = 10,
brightness_range = (0.8,0.9))
train_generator = train_datagen.flow_from_directory(directory = '../input/train/',
target_size=(299,299),
color_mode='rgb',
batch_size=batch_size,
class_mode='binary', # if not binary, set to categorical
shuffle = True, seed = 0)
如何绘制示例图像及其数据增强示例?
例如,我的目录是../input/train/cats/
和../input/train/dogs/
答案 0 :(得分:0)
生成器只会在增强后为您提供img,并非没有
如果您想查看图像之间的差异,我会:
因此,生成器将按给定顺序生成img。然后,生成器将为您提供的第一个img是00001.jpg的提示,第二个是00002.jpg的提示,依此类推。