Keras flow_from_directory() read only from selected sub-directoriesHow to manually specify class labels in keras flow_from_directory?Keras ImageDataGenerator method flow_from_directoryKeras flow_from_directory class indexkeras ImageDataGenerator flow_from_directory generated dataSplit data directory into training and test directory with sub directory structure preservedDoes Keras flow_from_directory iterate through every sample in a directory?How to access images directly from Google Cloud Storage (GCS) when using Keras?Low validation accuracy with good training accuracy - keras imagedatagenerator flow_from_directory categorical classificationHow to load images for classification problem using KerasFolder structure Keras ImageDataGenerator
What STL algorithm can determine if exactly one item in a container satisfies a predicate?
Proving that a Russian cryptographic standard is too structured
60s or 70s novel about Empire of Man making 1st contact with 1st discovered alien race
Why we don’t make use of the t-distribution for constructing a confidence interval for a proportion?
How can I remove material from this wood beam?
Smart-expansion of a range to a list of numbers
Do you have to have figures when playing D&D?
Was Self-modifying-code possible just using BASIC?
UTC timestamp format for launch vehicles
Can we completely replace inheritance using strategy pattern and dependency injection?
Is Lambda Calculus purely syntactic?
Who voices the small round football sized demon In Good Omens
What is the logic behind charging tax _in the form of money_ for owning property when the property does not produce money?
Why am I getting a strange double quote (“) in Open Office instead of the ordinary one (")?
2019 gold coins to share
How can I make 12 tone and atonal melodies sound interesting?
Can the removal of a duty-free sales trolley result in a measurable reduction in emissions?
Does the Nuka-Cola bottler actually generate nuka cola?
What would be the way to say "just saying" in German? (Not the literal translation)
Java Servlet & JSP simple login
How do we say "within a kilometer radius spherically"?
Increase speed altering column on large table to NON NULL
Are polynomials with the same roots identical?
Analogy between an unknown in an argument, and a contradiction in the principle of explosion
Keras flow_from_directory() read only from selected sub-directories
How to manually specify class labels in keras flow_from_directory?Keras ImageDataGenerator method flow_from_directoryKeras flow_from_directory class indexkeras ImageDataGenerator flow_from_directory generated dataSplit data directory into training and test directory with sub directory structure preservedDoes Keras flow_from_directory iterate through every sample in a directory?How to access images directly from Google Cloud Storage (GCS) when using Keras?Low validation accuracy with good training accuracy - keras imagedatagenerator flow_from_directory categorical classificationHow to load images for classification problem using KerasFolder structure Keras ImageDataGenerator
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I have a directory structure as follows.
train
|- dog --> contains image files of dogs
|- cat --> contains image files of cats
|- elephant --> contains image files of elephants
I want to train a CNN to identify animals, but only for cats and dogs and not elephants.
I want to use keras ImageDataGenerator
class to augment data and flow_from_directory()
method to read the image files.
train_datagen = ImageDataGenerator(rescale=1./255)
train_generator = train_datagen.flow_from_directory(directory='train', class_mode='categorical', target_size=(64,64), batch_size=16, shuffle=True)
The above code will read data from all sub-directories of 'train', which I don't want. One option is to create a new directory and copy of 'dog' and 'cat' sub-directories along with the files inside it. But is there a way to control it from flow_from_directory()
method itself?
tensorflow keras deep-learning conv-neural-network
add a comment |
I have a directory structure as follows.
train
|- dog --> contains image files of dogs
|- cat --> contains image files of cats
|- elephant --> contains image files of elephants
I want to train a CNN to identify animals, but only for cats and dogs and not elephants.
I want to use keras ImageDataGenerator
class to augment data and flow_from_directory()
method to read the image files.
train_datagen = ImageDataGenerator(rescale=1./255)
train_generator = train_datagen.flow_from_directory(directory='train', class_mode='categorical', target_size=(64,64), batch_size=16, shuffle=True)
The above code will read data from all sub-directories of 'train', which I don't want. One option is to create a new directory and copy of 'dog' and 'cat' sub-directories along with the files inside it. But is there a way to control it from flow_from_directory()
method itself?
tensorflow keras deep-learning conv-neural-network
add a comment |
I have a directory structure as follows.
train
|- dog --> contains image files of dogs
|- cat --> contains image files of cats
|- elephant --> contains image files of elephants
I want to train a CNN to identify animals, but only for cats and dogs and not elephants.
I want to use keras ImageDataGenerator
class to augment data and flow_from_directory()
method to read the image files.
train_datagen = ImageDataGenerator(rescale=1./255)
train_generator = train_datagen.flow_from_directory(directory='train', class_mode='categorical', target_size=(64,64), batch_size=16, shuffle=True)
The above code will read data from all sub-directories of 'train', which I don't want. One option is to create a new directory and copy of 'dog' and 'cat' sub-directories along with the files inside it. But is there a way to control it from flow_from_directory()
method itself?
tensorflow keras deep-learning conv-neural-network
I have a directory structure as follows.
train
|- dog --> contains image files of dogs
|- cat --> contains image files of cats
|- elephant --> contains image files of elephants
I want to train a CNN to identify animals, but only for cats and dogs and not elephants.
I want to use keras ImageDataGenerator
class to augment data and flow_from_directory()
method to read the image files.
train_datagen = ImageDataGenerator(rescale=1./255)
train_generator = train_datagen.flow_from_directory(directory='train', class_mode='categorical', target_size=(64,64), batch_size=16, shuffle=True)
The above code will read data from all sub-directories of 'train', which I don't want. One option is to create a new directory and copy of 'dog' and 'cat' sub-directories along with the files inside it. But is there a way to control it from flow_from_directory()
method itself?
tensorflow keras deep-learning conv-neural-network
tensorflow keras deep-learning conv-neural-network
asked Mar 24 at 20:40
Supratim HaldarSupratim Haldar
1,255518
1,255518
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Assuming that I understood your question in the right way, this should help you:
train_generator = train_datagen.flow_from_directory(directory='train', class_mode='categorical', target_size=(64,64), batch_size=16, shuffle=True, classes=["dog", "cat"])
This will read only the images from the directories dog
and cat
, leave out the elephant
directory and provide distinct categorical labels for them.
Perfect. Thanks for your help!
– Supratim Haldar
Mar 25 at 5:29
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%2f55328355%2fkeras-flow-from-directory-read-only-from-selected-sub-directories%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
Assuming that I understood your question in the right way, this should help you:
train_generator = train_datagen.flow_from_directory(directory='train', class_mode='categorical', target_size=(64,64), batch_size=16, shuffle=True, classes=["dog", "cat"])
This will read only the images from the directories dog
and cat
, leave out the elephant
directory and provide distinct categorical labels for them.
Perfect. Thanks for your help!
– Supratim Haldar
Mar 25 at 5:29
add a comment |
Assuming that I understood your question in the right way, this should help you:
train_generator = train_datagen.flow_from_directory(directory='train', class_mode='categorical', target_size=(64,64), batch_size=16, shuffle=True, classes=["dog", "cat"])
This will read only the images from the directories dog
and cat
, leave out the elephant
directory and provide distinct categorical labels for them.
Perfect. Thanks for your help!
– Supratim Haldar
Mar 25 at 5:29
add a comment |
Assuming that I understood your question in the right way, this should help you:
train_generator = train_datagen.flow_from_directory(directory='train', class_mode='categorical', target_size=(64,64), batch_size=16, shuffle=True, classes=["dog", "cat"])
This will read only the images from the directories dog
and cat
, leave out the elephant
directory and provide distinct categorical labels for them.
Assuming that I understood your question in the right way, this should help you:
train_generator = train_datagen.flow_from_directory(directory='train', class_mode='categorical', target_size=(64,64), batch_size=16, shuffle=True, classes=["dog", "cat"])
This will read only the images from the directories dog
and cat
, leave out the elephant
directory and provide distinct categorical labels for them.
answered Mar 24 at 21:09
gorjangorjan
1,652617
1,652617
Perfect. Thanks for your help!
– Supratim Haldar
Mar 25 at 5:29
add a comment |
Perfect. Thanks for your help!
– Supratim Haldar
Mar 25 at 5:29
Perfect. Thanks for your help!
– Supratim Haldar
Mar 25 at 5:29
Perfect. Thanks for your help!
– Supratim Haldar
Mar 25 at 5:29
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%2f55328355%2fkeras-flow-from-directory-read-only-from-selected-sub-directories%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