Load data on demand using flow_from_directory for AutoEncoderResizing images in Keras ImageDataGenerator flow methodsHow to manually specify class labels in keras flow_from_directory?Keras: model with one input and two outputs, trained jointly on different data (semi-supervised learning)keras ImageDataGenerator flow_from_directory generated dataKeras - Variational Autoencoder NaN lossKeras ImageDataGenerator and flow_from_directory class_mode='input'Keras dimension mismatch in last layer of autoencoderValue error with dimensions in designing a simple autoencoderHow to load images for classification problem using KerasNot able to load a custom dataset
How can a function with a hole (removable discontinuity) equal a function with no hole?
How do scammers retract money, while you can’t?
Why escape if the_content isnt?
Do all network devices need to make routing decisions, regardless of communication across networks or within a network?
Unreliable Magic - Is it worth it?
How to draw lines on a tikz-cd diagram
How can we prove that any integral in the set of non-elementary integrals cannot be expressed in the form of elementary functions?
Balance Issues for a Custom Sorcerer Variant
Type int? vs type int
How to be diplomatic in refusing to write code that breaches the privacy of our users
Customer Requests (Sometimes) Drive Me Bonkers!
Is there a good way to store credentials outside of a password manager?
How can I kill an app using Terminal?
Class Action - which options I have?
Increase performance creating Mandelbrot set in python
Detecting if an element is found inside a container
Is expanding the research of a group into machine learning as a PhD student risky?
How to run a prison with the smallest amount of guards?
Was Spock the First Vulcan in Starfleet?
Proof of work - lottery approach
What is the best translation for "slot" in the context of multiplayer video games?
What can we do to stop prior company from asking us questions?
You cannot touch me, but I can touch you, who am I?
How does the UK government determine the size of a mandate?
Load data on demand using flow_from_directory for AutoEncoder
Resizing images in Keras ImageDataGenerator flow methodsHow to manually specify class labels in keras flow_from_directory?Keras: model with one input and two outputs, trained jointly on different data (semi-supervised learning)keras ImageDataGenerator flow_from_directory generated dataKeras - Variational Autoencoder NaN lossKeras ImageDataGenerator and flow_from_directory class_mode='input'Keras dimension mismatch in last layer of autoencoderValue error with dimensions in designing a simple autoencoderHow to load images for classification problem using KerasNot able to load a custom dataset
I am trying to train an AutoEncoder on some image data. The dataset is so huge so that it won't fit in memory. So obviously I want to load the data from the directory on demand with the help of flow_from_directory in Keras.
My dataset is in the following structure
./Dataset/
./Train/
../1.jpg
../2.jpg
and so on.
I tried to use flow_from_directory like this
train_generator = datagen.flow_from_directory(
TRAIN_FOLDER,
target_size = (256, 256),
color_mode = 'rgb',
batch_size = batch_size,
class_mode = 'input')
This gives me an output Found 0 images belonging to 0 classes. I will get a ZeroDivisionError if I try to fit the model with this generator.
I have used the flow_from_directory, flow and flow_from_dataframe in various occasions but in those cases, I was going for a classification problem and had n folders in the directory for n classes.
How can I load images from the directory on demand for training auto encoder.? From the Keras docs over here I saw
class_mode : "input" will be images identical to input images (mainly used to work with autoencoders)
But this is not fixing the problem either.
One workaround I found was making another folder inside the train and moving all the files into that. Is there any direct method other than this.?
keras deep-learning
add a comment |
I am trying to train an AutoEncoder on some image data. The dataset is so huge so that it won't fit in memory. So obviously I want to load the data from the directory on demand with the help of flow_from_directory in Keras.
My dataset is in the following structure
./Dataset/
./Train/
../1.jpg
../2.jpg
and so on.
I tried to use flow_from_directory like this
train_generator = datagen.flow_from_directory(
TRAIN_FOLDER,
target_size = (256, 256),
color_mode = 'rgb',
batch_size = batch_size,
class_mode = 'input')
This gives me an output Found 0 images belonging to 0 classes. I will get a ZeroDivisionError if I try to fit the model with this generator.
I have used the flow_from_directory, flow and flow_from_dataframe in various occasions but in those cases, I was going for a classification problem and had n folders in the directory for n classes.
How can I load images from the directory on demand for training auto encoder.? From the Keras docs over here I saw
class_mode : "input" will be images identical to input images (mainly used to work with autoencoders)
But this is not fixing the problem either.
One workaround I found was making another folder inside the train and moving all the files into that. Is there any direct method other than this.?
keras deep-learning
add a comment |
I am trying to train an AutoEncoder on some image data. The dataset is so huge so that it won't fit in memory. So obviously I want to load the data from the directory on demand with the help of flow_from_directory in Keras.
My dataset is in the following structure
./Dataset/
./Train/
../1.jpg
../2.jpg
and so on.
I tried to use flow_from_directory like this
train_generator = datagen.flow_from_directory(
TRAIN_FOLDER,
target_size = (256, 256),
color_mode = 'rgb',
batch_size = batch_size,
class_mode = 'input')
This gives me an output Found 0 images belonging to 0 classes. I will get a ZeroDivisionError if I try to fit the model with this generator.
I have used the flow_from_directory, flow and flow_from_dataframe in various occasions but in those cases, I was going for a classification problem and had n folders in the directory for n classes.
How can I load images from the directory on demand for training auto encoder.? From the Keras docs over here I saw
class_mode : "input" will be images identical to input images (mainly used to work with autoencoders)
But this is not fixing the problem either.
One workaround I found was making another folder inside the train and moving all the files into that. Is there any direct method other than this.?
keras deep-learning
I am trying to train an AutoEncoder on some image data. The dataset is so huge so that it won't fit in memory. So obviously I want to load the data from the directory on demand with the help of flow_from_directory in Keras.
My dataset is in the following structure
./Dataset/
./Train/
../1.jpg
../2.jpg
and so on.
I tried to use flow_from_directory like this
train_generator = datagen.flow_from_directory(
TRAIN_FOLDER,
target_size = (256, 256),
color_mode = 'rgb',
batch_size = batch_size,
class_mode = 'input')
This gives me an output Found 0 images belonging to 0 classes. I will get a ZeroDivisionError if I try to fit the model with this generator.
I have used the flow_from_directory, flow and flow_from_dataframe in various occasions but in those cases, I was going for a classification problem and had n folders in the directory for n classes.
How can I load images from the directory on demand for training auto encoder.? From the Keras docs over here I saw
class_mode : "input" will be images identical to input images (mainly used to work with autoencoders)
But this is not fixing the problem either.
One workaround I found was making another folder inside the train and moving all the files into that. Is there any direct method other than this.?
keras deep-learning
keras deep-learning
edited Mar 8 at 13:45
Ioannis Nasios
3,75831036
3,75831036
asked Mar 8 at 11:03
Sreeram TPSreeram TP
3,10431440
3,10431440
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
The Keras docs are indeed not very precise here and the way it actually works is not intuitive (at least to me) ...
Here, even though you are using class_mode='input' which means that there are no classes (or each picture is its own class, however you like to phrase it), your images still have to be inside of subfolders.
So, inside of your Train folder just create another subfolder and move all images inside. Then the output will be Found xxx images belonging to 1 classes.
You can even have multiple subfolders, the generated X and Y data will be the same, just the console output will be different (and misleading): Found xxx images belonging to yy classes.
This may be useful if there actually are classes and you have another model using them (using class_mode='categorical' or class_mode='binary'). Then this model can load its data from the same folder.
I did the same. Made folder calledTRAINinsideTrainieTrain//TRAINand moved my image files inTrain//toTrain//TRAIN. Then it seems to work. I was thinking there is some other way to tellflow_from_directorythere is no need to look for sub folders
– Sreeram TP
Mar 8 at 12:17
1
@SreeramTP Oh damn, I completely missed your last paragraph. Sorry. So, no, I was facing this quite often now and I'm not aware of any "direct" way of doing it.
– sebrockm
Mar 8 at 12:24
1
Your answer will be helpful for others who face this issue and are looking for a quick solution / workaround
– Sreeram TP
Mar 8 at 12:28
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55061877%2fload-data-on-demand-using-flow-from-directory-for-autoencoder%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The Keras docs are indeed not very precise here and the way it actually works is not intuitive (at least to me) ...
Here, even though you are using class_mode='input' which means that there are no classes (or each picture is its own class, however you like to phrase it), your images still have to be inside of subfolders.
So, inside of your Train folder just create another subfolder and move all images inside. Then the output will be Found xxx images belonging to 1 classes.
You can even have multiple subfolders, the generated X and Y data will be the same, just the console output will be different (and misleading): Found xxx images belonging to yy classes.
This may be useful if there actually are classes and you have another model using them (using class_mode='categorical' or class_mode='binary'). Then this model can load its data from the same folder.
I did the same. Made folder calledTRAINinsideTrainieTrain//TRAINand moved my image files inTrain//toTrain//TRAIN. Then it seems to work. I was thinking there is some other way to tellflow_from_directorythere is no need to look for sub folders
– Sreeram TP
Mar 8 at 12:17
1
@SreeramTP Oh damn, I completely missed your last paragraph. Sorry. So, no, I was facing this quite often now and I'm not aware of any "direct" way of doing it.
– sebrockm
Mar 8 at 12:24
1
Your answer will be helpful for others who face this issue and are looking for a quick solution / workaround
– Sreeram TP
Mar 8 at 12:28
add a comment |
The Keras docs are indeed not very precise here and the way it actually works is not intuitive (at least to me) ...
Here, even though you are using class_mode='input' which means that there are no classes (or each picture is its own class, however you like to phrase it), your images still have to be inside of subfolders.
So, inside of your Train folder just create another subfolder and move all images inside. Then the output will be Found xxx images belonging to 1 classes.
You can even have multiple subfolders, the generated X and Y data will be the same, just the console output will be different (and misleading): Found xxx images belonging to yy classes.
This may be useful if there actually are classes and you have another model using them (using class_mode='categorical' or class_mode='binary'). Then this model can load its data from the same folder.
I did the same. Made folder calledTRAINinsideTrainieTrain//TRAINand moved my image files inTrain//toTrain//TRAIN. Then it seems to work. I was thinking there is some other way to tellflow_from_directorythere is no need to look for sub folders
– Sreeram TP
Mar 8 at 12:17
1
@SreeramTP Oh damn, I completely missed your last paragraph. Sorry. So, no, I was facing this quite often now and I'm not aware of any "direct" way of doing it.
– sebrockm
Mar 8 at 12:24
1
Your answer will be helpful for others who face this issue and are looking for a quick solution / workaround
– Sreeram TP
Mar 8 at 12:28
add a comment |
The Keras docs are indeed not very precise here and the way it actually works is not intuitive (at least to me) ...
Here, even though you are using class_mode='input' which means that there are no classes (or each picture is its own class, however you like to phrase it), your images still have to be inside of subfolders.
So, inside of your Train folder just create another subfolder and move all images inside. Then the output will be Found xxx images belonging to 1 classes.
You can even have multiple subfolders, the generated X and Y data will be the same, just the console output will be different (and misleading): Found xxx images belonging to yy classes.
This may be useful if there actually are classes and you have another model using them (using class_mode='categorical' or class_mode='binary'). Then this model can load its data from the same folder.
The Keras docs are indeed not very precise here and the way it actually works is not intuitive (at least to me) ...
Here, even though you are using class_mode='input' which means that there are no classes (or each picture is its own class, however you like to phrase it), your images still have to be inside of subfolders.
So, inside of your Train folder just create another subfolder and move all images inside. Then the output will be Found xxx images belonging to 1 classes.
You can even have multiple subfolders, the generated X and Y data will be the same, just the console output will be different (and misleading): Found xxx images belonging to yy classes.
This may be useful if there actually are classes and you have another model using them (using class_mode='categorical' or class_mode='binary'). Then this model can load its data from the same folder.
answered Mar 8 at 12:10
sebrockmsebrockm
1,735320
1,735320
I did the same. Made folder calledTRAINinsideTrainieTrain//TRAINand moved my image files inTrain//toTrain//TRAIN. Then it seems to work. I was thinking there is some other way to tellflow_from_directorythere is no need to look for sub folders
– Sreeram TP
Mar 8 at 12:17
1
@SreeramTP Oh damn, I completely missed your last paragraph. Sorry. So, no, I was facing this quite often now and I'm not aware of any "direct" way of doing it.
– sebrockm
Mar 8 at 12:24
1
Your answer will be helpful for others who face this issue and are looking for a quick solution / workaround
– Sreeram TP
Mar 8 at 12:28
add a comment |
I did the same. Made folder calledTRAINinsideTrainieTrain//TRAINand moved my image files inTrain//toTrain//TRAIN. Then it seems to work. I was thinking there is some other way to tellflow_from_directorythere is no need to look for sub folders
– Sreeram TP
Mar 8 at 12:17
1
@SreeramTP Oh damn, I completely missed your last paragraph. Sorry. So, no, I was facing this quite often now and I'm not aware of any "direct" way of doing it.
– sebrockm
Mar 8 at 12:24
1
Your answer will be helpful for others who face this issue and are looking for a quick solution / workaround
– Sreeram TP
Mar 8 at 12:28
I did the same. Made folder called
TRAIN inside Train ie Train//TRAIN and moved my image files in Train// to Train//TRAIN. Then it seems to work. I was thinking there is some other way to tell flow_from_directory there is no need to look for sub folders– Sreeram TP
Mar 8 at 12:17
I did the same. Made folder called
TRAIN inside Train ie Train//TRAIN and moved my image files in Train// to Train//TRAIN. Then it seems to work. I was thinking there is some other way to tell flow_from_directory there is no need to look for sub folders– Sreeram TP
Mar 8 at 12:17
1
1
@SreeramTP Oh damn, I completely missed your last paragraph. Sorry. So, no, I was facing this quite often now and I'm not aware of any "direct" way of doing it.
– sebrockm
Mar 8 at 12:24
@SreeramTP Oh damn, I completely missed your last paragraph. Sorry. So, no, I was facing this quite often now and I'm not aware of any "direct" way of doing it.
– sebrockm
Mar 8 at 12:24
1
1
Your answer will be helpful for others who face this issue and are looking for a quick solution / workaround
– Sreeram TP
Mar 8 at 12:28
Your answer will be helpful for others who face this issue and are looking for a quick solution / workaround
– Sreeram TP
Mar 8 at 12:28
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55061877%2fload-data-on-demand-using-flow-from-directory-for-autoencoder%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown