1

我正在使用Keras data augmentationx_train和我y_train的图像进行图像分割任务。

为此,我使用以下代码:

data_gen_args = dict(width_shift_range = 0.05)
aug = kp.image.ImageDataGenerator(**data_gen_args)

history = model.fit_generator(aug.flow(x_train, y_train, save_to_dir = augment_save_dir),
steps_per_epoch = len(x_train) / 32, validation_data=(x_val, y_val), epochs=epochs, verbose=1)

但这只会节省我的增强版x images而不是他们的labels. 如何保存图像及其标签以可视化它们?

我已经尝试过将图像和蒙版一起转换但没有成功的示例Keras Image preprocessing页面上的示例。

我得到错误AttributeError: 'zip' object has no attribute 'shape'

编码:

image_datagen = kp.image.ImageDataGenerator(**data_gen_args)
mask_datagen = kp.image.ImageDataGenerator(**data_gen_args)

image_generator = image_datagen.flow(x_train, save_to_dir = augment_save_dir)
mask_generator = mask_datagen.flow(y_train, save_to_dir = augment_save_dir)

train_generator = zip(image_generator, mask_generator)

history = model.fit_generator(train_generator, steps_per_epoch=len(x_train) / 32, validation_data=(x_val, y_val), epochs=epochs,verbose=1)

另外,有没有办法data_augmentation在训练期间增加参数?

4

0 回答 0