我想增加我的数据集中的数据,以创建一个CNN深度学习分类模型。
使用ImageDataGenerator的数据增强还是使用openCV来增加数据,哪一种更适合于模型?
顺便说一下,我正在使用Keras和floydhub。
发布于 2019-06-11 14:08:00
库imgaug、Keras、ImageDataGenerator和flow_from_dataframe的示例:
import imgaug as ia
import imgaug.augmenters as iaa
seq = iaa.Sequential([
iaa.Crop(px=(0, 16)),
# crop images from each side by 0 to 16px (randomly chosen)
iaa.Fliplr(0.5),
# horizontally flip 50% of the images
iaa.GaussianBlur(sigma=(0, 3.0))
# blur images with a sigma of 0 to 3.0
])
def augment(img):
seq_det = seq.to_deterministic()
aug_image = seq_det.augment_image(img)
return applications.inception_resnet_v2.preprocess_input(aug_image)
train_generator = image.ImageDataGenerator(preprocessing_function=augment)
train_flow = train_generator.flow_from_dataframe(
dataframe=train_df,
directory=train_data_dir,
x_col="path",
y_col=columns,
batch_size=batch_size,
class_mode="other",
target_size=(img_height ,img_width),
shuffle=True
)发布于 2018-09-16 17:45:00
Keras的ImageDataGenerator本身并不为数据增强提供太多支持。但是,它有一个名为preprocessing_function的参数,它允许您使用自定义增强器。
我个人使用英格格,它提供了几乎所有您可以想到的增强功能,并且可以很好地使用ImageDataGenerator,就像我说的。
https://datascience.stackexchange.com/questions/38302
复制相似问题