question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Keras needs a flow_from_csv function

See original GitHub issue

Keras has this awesome flow_from_directory function to read images that are stored in different directories named with their class names for image classification tasks, but it doesn’t provide anything for regression tasks and also many datasets available on the internet simply has all the images stored in a single directory, with a csv file which maps the filename to the class names. So my suggestion is If someone can implement a flow_from_csv function that takes a CSV file as input. Something that looks like the below code will look great! datagen.flow_from_csv(csv="train.csv",filename_col="filenames", output_cols=["value1","value2"], sep=",", target_size=(224, 224), batch_size=32) The filename_col specifies the column that contains the filenames, The output_cols (is a list) specifies the columns that will be treated as Y values (specifying a column that contains filenames here should also read the images and return them as Y). The sep tells what seperator is used to seperate different columns(default “,”) target_size and batch_size has the same functions as in flow_from_directory.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Vijayabhaskar96commented, May 10, 2018

Have a look at this PR. This works exactly like flow_from_directory but with a dataframe, if shuffling is the problem,then it already exist in both flow_from_directory and flow

1reaction
minimaxircommented, Apr 30, 2018

The real problem with this approach is that the batch input would be non-random, which will introduce a bias into the model.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tutorial on Keras flow_from_dataframe | by Vijayabhaskar J
csv file which maps the filenames of the training images to their respective classes. Let's dive into the code! Import all the stuff...
Read more >
Introduction to Keras for Engineers
CSV data needs to be parsed, with numerical features converted to floating point tensors and categorical features indexed and converted to ...
Read more >
Save and load Keras models | TensorFlow Core
At loading time, Keras will need access to the Python classes/functions of these objects in order to reconstruct the model.
Read more >
Keras Loss Functions: Everything You Need to Know
Which loss functions are available in Keras? Binary Classification. Binary classification loss function comes into play when solving a problem ...
Read more >
How to correctly install Keras and Tensorflow - ActiveState
It's not necessary to import all of the Keras and Tensorflow library functions. Instead, import just the function(s) you need for your project....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found