title: How to add data augmentation to regression problem?
body: <p>I am trying to build a CNN model for regression problem with limited number of input data with 400 sample size. The inputs are images and labels are extracted from a column of csv file. To increase the input data, I need to augment the input images and match them with existing labels. I am using rotation and flipping augmentation methods. I am not sure how existing labels should be linked to the augmented images and how the final tensorflow dataset should be created to fit the model. Can anyone help me to solve this data augmentation?</p>
  <pre><code>#load csv file
  labelPath =  &quot;/content/drive/MyDrive/Notebook/tepm.csv&quot;
  cols = [&quot;temperature&quot;]
  df = pd.read_csv(labelPath, sep=&quot; &quot;, header=None, names=cols)
  
  inputPath='/content/drive/MyDrive/Notebook/test_png_64'
  images = []
  
  # Load in the images
  for filepath in os.listdir(inputPath):
  images.append(cv2.imread(inputPath+'/{0}'.format(filepath),flags=(cv2.IMREAD_ANYCOLOR | cv2.IMREAD_ANYDEPTH)))
  
  images_scaled = np.array(images, dtype=&quot;float&quot;) / 255.0
  
  (trainY, testY, trainX, testX) = train_test_split(df, images_scaled, test_size=0.20, random_state=42)
  
  (trainY, valY, trainX, valX) = train_test_split(trainY, trainX, test_size=0.20, random_state=42)
  
  
  def rotate(trainX: tf.Tensor) -&gt; tf.Tensor:
  
      # Rotate 90 degrees
      return tf.image.rot90(trainX, tf.random_uniform(shape=[], minval=0, maxval=4, dtype=tf.float32))
  
  def flip(trainX: tf.Tensor) -&gt; tf.Tensor:
      trainX = tf.image.random_flip_left_right(trainX)
      trainX = tf.image.random_flip_up_down(trainX)
  
      return trainX
  </code></pre>
  <p>update with ImageDataGenerator</p>
  <pre><code>datagen = ImageDataGenerator(
          vertical_flip=True,
          horizontal_flip=True,
          fill_mode=&quot;nearest&quot;)
  
  datagen.fit(trainX)
  
  model.compile(optimizer=tf.keras.optimizers.Adam(lr=0.0001), loss='mean_squared_error', metrics='mse')
  </code></pre>