title: Tensorflow random numbers in Data Augmentation map function
body: <p>I want to use the <code>crop_central</code> function with a random float between 0.50-1.00 for data augmentation. However, when using <code>numpy.random.uniform(0.50, 1.00)</code> and plotting the images the crop is constant. I debugged this by using 4 images and plotting 8 rows, the images are identical.</p>
  
  <p>In general the question might be formulated as follows: How to use random numbers in the Dataset map functions?</p>
  
  <pre><code>def data_augment(image, label=None, seed=2020):
      # I want a random number here for every individual image
      image = tf.image.central_crop(image, np.random.uniform(0.50, 1.00)) # random crop central
      image = tf.image.resize(image, INPUT_SHAPE) # the original image size
  
      return image
  
  train_dataset = (
      tf.data.Dataset
          .from_tensor_slices((train_paths, train_labels))
          .map(decode_image, num_parallel_calls=AUTO)
          .map(data_augment, num_parallel_calls=AUTO)
          .repeat()
          .batch(4)
          .prefetch(AUTO)
      )
  
  # Code to view the images
  for idx, (imgs, _) in enumerate(train_dataset):
      show_imgs(imgs, 'image', imgs_per_row=4)
      if idx is 8:
          del imgs
          gc.collect()
          break
  </code></pre>