我正在使用Stanford Dog数据集http://vision.stanford.edu/aditya86/ImageNetDogs/,其中所有图像都存储在一个文件夹中。对属于训练和测试集中的那些图像的引用存储在列表中;例如
# Load pre-constructed train/test arrays from Stanford Dataset
train_list = loadmat('./lists/train_list.mat')
test_list = loadmat('./lists/test_list.mat')
最终,我阅读了这些图像并将其值存储在数组中(X_train和y_train)。我现在想进行类似于本教程的数据扩充:
https://www.learnopencv.com/keras-tutorial-fine-tuning-using-pre-trained-models/
train_datagen = ImageDataGenerator(
rescale=1./255,
rotation_range=20,
width_shift_range=0.2,
height_shift_range=0.2,
horizontal_flip=True,
fill_mode='nearest')
validation_datagen = ImageDataGenerator(rescale=1./255)
# Change the batchsize according to your system RAM
train_batchsize = 100
val_batchsize = 10
train_generator = train_datagen.flow_from_directory(
train_dir,
target_size=(image_size, image_size),
batch_size=train_batchsize,
class_mode='categorical')
validation_generator = validation_datagen.flow_from_directory(
validation_dir,
target_size=(image_size, image_size),
batch_size=val_batchsize,
class_mode='categorical',
shuffle=False)
但是,因为我的数据存储在数组中(例如X_train和X_val),所以我想不出一种在不将数据分成文件夹的情况下进行数据增强的方法。有什么想法吗?