title: Python, store the number of training and validation images obtained from ImageDataGenerator in variables for use later on
body: <p>I have the following python code which I run in Google Colab Notebooks which uses ImageDataGenerator to split out a development set into training and validation. </p>
  
  <pre><code>datagen = tf.keras.preprocessing.image.ImageDataGenerator(
      rescale=1./255, 
      validation_split=0.35)
  
  train_data_gen = datagen.flow_from_directory(
      base_dir,
      shuffle=True,
      target_size=(IMG_HEIGHT, IMG_WIDTH),
      batch_size=batch_size,
      subset='training' 
      )
  
  val_data_gen = datagen.flow_from_directory(
      base_dir,
      target_size=(IMG_HEIGHT, IMG_WIDTH),
      batch_size=batch_size, 
      subset='validation')
  </code></pre>
  
  <p>The output of the code is below:</p>
  
  <pre><code>Found 4708 images belonging to 40 classes.
  Found 2512 images belonging to 40 classes.
  </code></pre>
  
  <p>I want to store the values (4708 and 2512) in variables (eg train_size and val_size) for use later on. Please can someone explain how I would do this? </p>