(image_batch, blur=False)
return image_batch
Apply simclr-style augmentations to a single set of images.
Apply simclr-style augmentations to a single set of images.
Apply simclr - style augmentations to a single set of images .
def simclr_augment(image_batch, blur=False):
  """Apply simclr-style augmentations to a single set of images."""
  (h, w) = image_batch.shape.as_list()[1:3]
  image_batch = (image_batch + 1.0) / 2.0
  image_batch = tf.map_fn(
      lambda x: data_util.preprocess_for_train(x, h, w, impl='simclrv1'),
      image_batch)
  if blur:
    image_batch = tf.map_fn(lambda x: data_util.random_blur(x, h, w),
                            image_batch)
  image_batch = image_batch * 2.0 - 1.0
  return image_batch
def simclr_augment ( image_batch , blur = False ) : ( h , w ) = image_batch . shape . as_list ( ) [ 1 : 3 ] image_batch = ( image_batch + 1.0 ) / 2.0 image_batch = tf . map_fn ( lambda x : data_util . preprocess_for_train ( x , h , w , impl = 'simclrv1' ) , image_batch ) if blur : image_batch = tf . map_fn ( lambda x : data_util . random_blur ( x , h , w ) , image_batch ) image_batch = image_batch * 2.0 - 1.0 return image_batch