title: Keras Image data generator throwing no files found error?
body: <p>I unable to run simple data generator code from keras </p>
  
  <pre><code>import os
  import keras as K
  from keras.preprocessing.image import ImageDataGenerator
  
  def save_images_from_generator(maximal_nb_of_images, generator):
      nb_of_images_processed = 0
      for x, _ in generator:
          nb_of_images += x.shape[0]
          if nb_of_images &lt;= maximal_nb_of_images:
              for image_nb in range(x.shape[0]):
                  your_custom_save(x[image_nb]) # your custom function for saving images
          else:
              break
  
  Gen=ImageDataGenerator(featurewise_center=True,
      samplewise_center=False,
      featurewise_std_normalization=False,
      samplewise_std_normalization=False,
      zca_whitening=True,
      rotation_range=90,
      width_shift_range=0.2,
      height_shift_range=0.1,
      shear_range=0.5,
      zoom_range=0.2,
      channel_shift_range=0.1,
      fill_mode='nearest',
      cval=0.,
      horizontal_flip=True,
      vertical_flip=True,
      rescale=None,
      preprocessing_function=None)
  
  
  if __name__ == '__main__':
      save_images_from_generator(40,Gen.flow_from_directory('C:\\Users\\aanilil\\PycharmProjects\\untitled\\images_input', target_size=(150, 150),class_mode=None,save_prefix='augm',save_to_dir='C:\\Users\\aanilil\\PycharmProjects\\untitled\\im_output\\'))
  </code></pre>
  
  <h1>Output</h1>
  
  <pre><code>Using TensorFlow backend.
  Found 0 images belonging to 0 classes.
  Found 0 images belonging to 0 classes.
  Found 0 images belonging to 0 classes.
  Found 0 images belonging to 0 classes.
  Found 0 images belonging to 0 classes.
  Traceback (most recent call last):
    File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.3.2\helpers\pydev\pydevd.py", line 1578, in &lt;module&gt;
      globals = debugger.run(setup['file'], None, None, is_module)
    File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.3.2\helpers\pydev\pydevd.py", line 1015, in run
      pydev_imports.execfile(file, globals, locals)  # execute the script
    File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.3.2\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
      exec(compile(contents+"\n", file, 'exec'), glob, loc)
    File "C:/Users/aanilil/PycharmProjects/untitled/generate_data_from_folder.py", line 35, in &lt;module&gt;
      save_images_from_generator(40,Gen.flow_from_directory('C:\\Users\\aanilil\\PycharmProjects\\untitled\\images_input', target_size=(150, 150),class_mode=None,save_prefix='augm',save_to_dir='C:\\Users\\aanilil\\PycharmProjects\\untitled\\im_output\\'))
    File "C:/Users/aanilil/PycharmProjects/untitled/generate_data_from_folder.py", line 7, in save_images_from_generator
      for x, _ in generator:
    File "C:\ProgramData\Anaconda3\envs\tensorflow\lib\site-packages\keras\preprocessing\image.py", line 727, in __next__
      return self.next(*args, **kwargs)
    File "C:\ProgramData\Anaconda3\envs\tensorflow\lib\site-packages\keras\preprocessing\image.py", line 950, in next
      index_array, current_index, current_batch_size = next(self.index_generator)
    File "C:\ProgramData\Anaconda3\envs\tensorflow\lib\site-packages\keras\preprocessing\image.py", line 710, in _flow_index
      current_index = (self.batch_index * batch_size) % n
  ZeroDivisionError: integer division or modulo by zero
  </code></pre>
  
  <p>When I do a os. listdir I get an output like so </p>
  
  <pre><code>os.listdir('C:\\Users\\aanilil\\PycharmProjects\\untitled\\images_input') 
  ['download (1).png', 'download.jpg', 'download.png', 'images.jpg']
  </code></pre>
  
  <p>So there are images in the input folder and It still throws an error assoiciated to no files found</p>