title: Loading images in Keras for CNN from directory but label in CSV file
body: <p>I have a set of image files in a directory <code>train_images = './data/images'</code>   and <code>train_labels = './data/labels.csv'</code></p>
  
  <p>For example - There are 1000 images in <code>train_images</code> as <code>377.jpg,17814.jpg ....</code> and so on. And the class they correspond to are saved in a different CSV file.</p>
  
  <p><strong>EDIT</strong>- Here are a few rows from the CSV file -</p>
  
  <pre><code>&gt;&gt;
      ID          Class
  
  0   377.jpg     MIDDLE
  1   17814.jpg   YOUNG
  2   21283.jpg   MIDDLE
  3   16496.jpg   YOUNG
  4   4487.jpg    MIDDLE
  
  </code></pre>
  
  <p>Here I.D is the image file name and the class is the class it is associated to.</p>
  
  <p>I could have used the very usual </p>
  
  <pre><code>ImageDataGenerator().flow_from_directory(train_images, class_mode='binary', batch_size=64)
  
  </code></pre>
  
  <p>but the problem is that labels are in a CSV file. What I could do is to rename all the files using <code>os</code> and put different files in different directories and then load it but it looks so immature and foolish.</p>
  
  <p>How can I load data in Keras for CNN where each image is of dimension <code>(h,w,c)</code>?</p>