title: How to extract all tf.data.Dataset object into features and labels and pass into ImageDataGenerator's flow() method?
body: <p>I am acutally working on a mini-project based on <code>cifar10</code> dataset. I have loaded the data from <code>tfds.load(...)</code> and practicing image augmentation techniques. </p>
  
  <p>As I am using <code>tf.data.Dataset</code> object, which is my dataset, real-time data augmentation is quite unachievable, hence I want to pass all the features into <code>tf.keras.preprocessing.image.ImageDataGenerator.flow(...)</code> to gain the functionality of real-time augmentation.</p>
  
  <p>But this <code>flow(...)</code> method accepts NumPy arrays which in no way related to <code>tf.data.Dataset</code> object.</p>
  
  <p>Can somebody guide me in this regard (or any alternative) and how do I proceed further?</p>
  
  <p>Are <code>tf.image</code> transformations real-time? If not, what can be the best aproach other than <code>ImageDataGenerator.flow(...)</code>?</p>
  
  <p>My code:</p>
  
  <pre class="lang-py prettyprint-override"><code>import tensorflow as tf
  import tensorflow_datasets as tfds
  from tensorflow.keras.preprocessing.image import ImageDataGenerator
  
  splitting = tfds.Split.ALL.subsplit(weighted=(70, 20, 10))
  dataset_cifar10, dataset_info = tfds.load(name='cifar10', 
                                            split=splitting, 
                                            as_supervised=True, 
                                            with_info=True)
  
  train_dataset, valid_dataset, test_dataset = dataset_cifar10
  
  BATCH_SIZE = 32
  
  train_dataset = train_dataset.batch(batch_size=BATCH_SIZE)
  train_dataset = train_dataset.prefetch(buffer_size=1)
  
  image_generator = ImageDataGenerator(rotation_range=45, 
                                       width_shift_range=0.15, 
                                       height_shift_range=0.15, 
                                       zoom_range=0.2, 
                                       horizontal_flip=True, 
                                       vertical_flip=True, 
                                       rescale=1./255)
  
  train_dataset_generator = image_generator.flow(...)
  
  ...
  </code></pre>