如何将图像数据集分为训练集和测试集? [英] How to split an image dataset into train and test sets?

查看:1940
本文介绍了如何将图像数据集分为训练集和测试集?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用加州理工学院的256_ObjectCategories数据集.他们将所有图像分类为256个类别,位于不同的文件夹中.我正在使用Keras的ImageDataGenerator加载数据集,但无法使用该数据集将其拆分为训练和测试.如何在不移动图像或更改目录的情况下在终端中执行此操作?任何帮助表示赞赏.谢谢你. :)

I'm working on 256_ObjectCategories dataset from Caltech. They have organised all the images in 256 categories in different folders. I'm using ImageDataGenerator from Keras to load the dataset but I'm not able to split it into training and testing using the same. How can I do this in a terminal without moving images or changing directories? Any help is appreciated. Thank you. :)

推荐答案

现在似乎无法通过ImageDataGenerator开箱即用.看到这个线程: https://github.com/fchollet/keras/issues/5862

This doesn´t seem to be possible out of the box with ImageDataGenerator right now. See this thread: https://github.com/fchollet/keras/issues/5862

作为解决方法,用户AloshkaD建议使用glob:rasterList = glob.glob(os.path.join(path_of_your_image_directory, '*.jpg'))创建索引列表,以编程方式将其拆分,然后将该列表的验证部分输入到fit_generator()的validation_data参数中.

User AloshkaD suggests as a workaround that you create an index list with glob: rasterList = glob.glob(os.path.join(path_of_your_image_directory, '*.jpg')), split that programmatically and feed the validation part of that list into the validation_data parameter of fit_generator().

这篇关于如何将图像数据集分为训练集和测试集?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆