Keras needs a flow_from_csv function
See original GitHub issueKeras 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:
- Created 5 years ago
- Reactions:2
- Comments:6 (2 by maintainers)
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
andflow
The real problem with this approach is that the batch input would be non-random, which will introduce a bias into the model.