def image_augmentation(images, do_colors=False, crop_size=None):
  """Image augmentation: cropping, flipping, and color transforms."""
  if crop_size is None:
    crop_size = [299, 299]
  images = tf.random_crop(images, crop_size + [3])
  images = tf.image.random_flip_left_right(images)
  if do_colors:  # More augmentation, but might be slow.
    images = tf.image.random_brightness(images, max_delta=32. / 255.)
    images = tf.image.random_saturation(images, lower=0.5, upper=1.5)
    images = tf.image.random_hue(images, max_delta=0.2)
    images = tf.image.random_contrast(images, lower=0.5, upper=1.5)
  return images
def image_augmentation ( images , do_colors = False , crop_size = None ) : if crop_size is None : crop_size = [ 299 , 299 ] images = tf . random_crop ( images , crop_size + [ 3 ] ) images = tf . image . random_flip_left_right ( images ) if do_colors : images = tf . image . random_brightness ( images , max_delta = 32. / 255. ) images = tf . image . random_saturation ( images , lower = 0.5 , upper = 1.5 ) images = tf . image . random_hue ( images , max_delta = 0.2 ) images = tf . image . random_contrast ( images , lower = 0.5 , upper = 1.5 ) return images
Image augmentation: cropping, flipping, and color transforms.