title: flow_from_dataframe doesn't work when I save dataframe then read it back
body: <p>When I read a CSV file then split data to train and test data from that dataframe. After that, I'm using flow_from_dataframe to create data generator, that works. But when I try to save train and test data to CSV file because I don't want to change train and test data every time and read it back then using flow_from_dataframe, it doesn't work anymore. Here is my code:</p>
  <pre><code>df = parser.labels_df
  df.head()
  
  &quot;&quot;&quot;Dividing dataset into train, val and test for validation later&quot;&quot;&quot;
  train_data, test_data = train_test_split(df, test_size=0.1)
  train_data = train_data.reset_index(drop=True)
  test_data = test_data.reset_index(drop=True)
  
  train_data.to_csv('/content/drive/MyDrive/train_data.csv', index=False)
  tmp_train_data = pd.read_csv('/content/drive/MyDrive/train_data.csv')
  
  train, val = train_test_split(tmp_train_data, test_size=0.2, random_state=42, shuffle=True)
  
  train = train.reset_index(drop=True)
  val = val.reset_index(drop=True)
  
  def data_generator(train, val, test):
      train_datagen = ImageDataGenerator(rescale=1./255,
                                          horizontal_flip = True,  
                                          height_shift_range= 0.1, 
                                          width_shift_range=0.1, 
                                          rotation_range=5, 
                                          zoom_range=0.15)
  
      val_datagen = ImageDataGenerator(rescale=1./255)
      
      test_datagen = ImageDataGenerator(rescale=1./255)
  
      train_generator = train_datagen.flow_from_dataframe(
          dataframe=train,
          directory='/content/vinbigdata/train/',
          x_col=&quot;image_id&quot;,
          y_col=&quot;class_name&quot;,
          batch_size=16,
          target_size=(512,512),
          classes = parser.labels,
          class_mode='categorical')
  
      validation_generator = val_datagen.flow_from_dataframe(
          dataframe=val,
          directory='/content/vinbigdata/train/',
          x_col=&quot;image_id&quot;,
          y_col=&quot;class_name&quot;,
          batch_size=16,
          target_size=(512,512),
          classes = parser.labels,
          class_mode='categorical')
  
      test_generator = test_datagen.flow_from_dataframe(
          dataframe=test,
          directory='/content/vinbigdata/train/',
          x_col=&quot;image_id&quot;,
          y_col=&quot;class_name&quot;,
          batch_size=16,
          target_size=(512,512),
          classes = parser.labels,
          class_mode='categorical')
      
      return train_generator, validation_generator, test_generator
  
  train_generator, validation_generator, test_generator = data_generator(train, val, test_data)
  </code></pre>
  <p>Results:</p>
  <pre><code>Found 0 validated image filenames belonging to 6 classes.
  Found 0 validated image filenames belonging to 6 classes.
  Found 790 validated image filenames belonging to 6 classes.
  </code></pre>
  <p>The test_data I didn't save to CSV so it works.
  The train, val, test have data:</p>
  <pre><code>print(&quot;Found {} samples for training&quot;.format(len(train)))
  print(&quot;Found {} samples for validation&quot;.format(len(val)))
  print(&quot;Found {} samples for test&quot;.format(len(test_data)))
  </code></pre>
  <p>Result:</p>
  <pre><code>Found 5687 samples for training
  Found 1422 samples for validation
  Found 790 samples for test
  </code></pre>