在Keras中将多个目录用于flow_from_directory [英] Use multiple directories for flow_from_directory in Keras

查看:543
本文介绍了在Keras中将多个目录用于flow_from_directory的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的情况是,我们有多个具有各自数据的同级项,它们位于不同的目录中,并且具有相同的子目录结构.我想使用这些数据来训练模型,但是如果我将所有数据都复制到一个文件夹中,则无法跟踪来自哪个数据的数据(新数据偶尔也会创建,因此不适合保留复制文件每次) 我的数据现在存储如下:

My scenario is that we have multiple peers with their own data, located in different directories, with the same sub-directory structure. I want to train the model using those data, but if I copy all of them to one folder, I can't keep track of which data is from whose (the new data is also created occasionally so it's not suitable to keep copy the files every time) My data is now stored like this:

-user01
-user02
-user03
...

(它们都有相似的子目录结构)

(all of them have similar sub-directory structure)

我一直在寻找解决方案,但是我只在这里,他们将多个输入连接成1个并行输入,这不是我的情况.

I have searched for solution, but I only found the multi-input case in here and here, which they concatenate multiple input into 1 single parallel input, which is not my case.

我知道flow_from_directory()一次只能由一个目录提供,那么如何构建一个可以一次由多个目录提供的自定义目录呢?

I know that the flow_from_directory() can only be fed by 1 directory at a time, so how can I build a custom one that can be fed by multiple directory at a time?

如果我的问题是低质量的,请提出改进​​建议,我也在keras的github上进行了搜索,但没有找到我可以适应的东西.

If my question is low-quality, please give advice on how to improve it, I have searched also on the github of keras but didn't find anything that I can adapt.

谢谢.

推荐答案

Keras ImageDataGenerator flow_from_directory方法具有一个follow_links参数.

The Keras ImageDataGenerator flow_from_directory method has a follow_links parameter.

也许您可以创建一个目录,该目录中包含指向其他所有目录中文件的符号链接.

Maybe you can create one directory which is populated with symlinks to files in all the other directories.

此堆栈问题讨论了如何在Keras ImageDataGenerator中使用符号链接:了解"follow_links"参数在Keras的ImageDataGenerator中?

This stack question discusses using symlinks with Keras ImageDataGenerator: Understanding 'follow_links' argument in Keras's ImageDataGenerator?

这篇关于在Keras中将多个目录用于flow_from_directory的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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