Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keras images with no subfolders

I am new to Deep Learning. I have this question: I am trying to train a network with this data. Everything is in one folder and labels are in a different mat file.

I understand that I can read the data with scipy.io. But how can I get train X in one folder? If I use the built in flow_from_directory it shows no images, because every class should have it's own folder.

How can I create X with only one folder? Now it shows Found 0 images belonging to 0 classes

There is just a folder with images. All images are in 1 folder. I mean there is no classes folder. With flow_from_directory you should have something like cars/mercedes, cars/bmw, cars/audi, but my data doesn't have subfolders.

So my question is there any other way to create X data?

like image 970
Yakov Kemer Avatar asked Oct 04 '17 18:10

Yakov Kemer


2 Answers

Set classes to None and put all images into one subfolder of your image folder.

For example:

  • flow_from_directory(directory = "/path/to/your/images/", class_mode="None", …)
  • put your images into /path/to/your/images/data
like image 161
petezurich Avatar answered Nov 16 '22 22:11

petezurich


The link you posted also shows a download link to "A devkit, including class labels for training images and bounding boxes for all images".

You'll find the information there that you need in order to transform your data set into the desired folder structure required for flow_from_directory().

From the README.md

-cars_meta.mat:
  Contains a cell array of class names, one for each class.

-cars_train_annos.mat:
  Contains the variable 'annotations', which is a struct array of length
  num_images and where each element has the fields:
    bbox_x1: Min x-value of the bounding box, in pixels
    bbox_x2: Max x-value of the bounding box, in pixels
    bbox_y1: Min y-value of the bounding box, in pixels
    bbox_y2: Max y-value of the bounding box, in pixels
    class: Integral id of the class the image belongs to.
    fname: Filename of the image within the folder of images.
like image 1
Stefan Falk Avatar answered Nov 16 '22 20:11

Stefan Falk