本文介绍了ImageDataGenerator是否将更多图像添加到我的数据集中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Inception V3模型进行图像分类. Keras的ImageDataGenerator是否创建新图像并添加到我的数据集中?如果我有1000张图像,是否可以使用此功能将其翻倍到用于训练的2000张图像?有没有办法知道已经创建了多少张图像,现在将它们输入到模型中?

I'm trying to do image classification with the Inception V3 model. Does ImageDataGenerator from Keras create new images which are added onto my dataset? If I have 1000 images, will using this function double it to 2000 images which are used for training? Is there a way to know how many images were created and now fed into the model?

推荐答案

简短答案::1)所有原始图像都已转换(即旋转,缩放等).每个时期,然后用于训练,以及2)[因此,每个纪元中的图片数量等于您拥有的原始图片数量.

Short answer: 1) All the original images are just transformed (i.e. rotation, zooming, etc.) every epoch and then used for training, and 2) [Therefore] the number of images in each epoch is equal to the number of original images you have.

长答案::在每个时期, ImageDataGenerator 对您拥有的图像进行转换,并将转换后的图像用于训练.转换集包括旋转,缩放等.通过这种方式,您以某种方式创建了新的数据(即也称为数据增强),但是显然生成的图像与原始图像并没有完全不同.这样,当学习模型在相同图像的不同变化上进行训练时,它可能会更加健壮和准确.

Long answer: In each epoch, the ImageDataGenerator applies a transformation on the images you have and use the transformed images for training. The set of transformations includes rotation, zooming, etc. By doing this you're somehow creating new data (i.e. also called data augmentation), but obviously the generated images are not totally different from the original ones. This way the learned model may be more robust and accurate as it is trained on different variations of the same image.

您需要将fit方法的steps_per_epoch参数设置为n_samples / batch_size,其中n_samples是您拥有的训练数据的总数(即您的情况下为1000).这样,在每个时期中,每个训练样本仅增加一次,因此在每个时期中将生成1000个变换图像.

You need to set the steps_per_epoch argument of fit method to n_samples / batch_size, where n_samples is the total number of training data you have (i.e. 1000 in your case). This way in each epoch, each training sample is augmented only one time and therefore 1000 transformed images will be generated in each epoch.

这篇关于ImageDataGenerator是否将更多图像添加到我的数据集中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-22 21:34