使用keras.preprocessing.image.ImageDataGenerator进行图像数据论证的技巧? [英] Image data agumentation tequniques using keras.preprocessing.image.ImageDataGenerator?
问题描述
我想通过随机旋转,平移,剪切和翻转来生成图像的增强数据.
I would like to generate augmented data for images by Random rotation, shifts, shear and flips.
我发现了此 keras
函数.
函数keras.preprocessing.image.ImageDataGenerator
但是我已经看到它被用于直接训练网络.
The function keras.preprocessing.image.ImageDataGenerator
But I've seen this being used to directly train networks.
是否可以输入图像,然后将转换后的图像保存在HDD上,而不是当前
Is there a way to input images and then save the transformed images on HDD instead of how if currently works in examples in this link
还是有另一个简单的即插即用python包,我可以使用它代替使用numpy
或opencv
来实现所有功能?
Or is there another simple plug and use python package I can use instead of implementing everything with numpy
or opencv
?
推荐答案
基本上-这是generator
,它会无限返回一批图像.一个人可以做以下事情:
Basically - this is generator
which is infinitely returning a batches of images. One could do the following:
def save_images_from_generator(maximal_nb_of_images, generator):
nb_of_images_processed = 0
for x, _ in generator:
nb_of_images += x.shape[0]
if nb_of_images <= maximal_nb_of_images:
for image_nb in range(x.shape[0]):
your_custom_save(x[image_nb]) # your custom function for saving images
else:
break
从keras
图像生成器保存图像.
to save images from keras
image generator.
这篇关于使用keras.preprocessing.image.ImageDataGenerator进行图像数据论证的技巧?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!