Skip to content

Instantly share code, notes, and snippets.

@himanshurawlani
Created September 5, 2020 19:58
Show Gist options
  • Save himanshurawlani/0e32e935abdda133d4004665f886e097 to your computer and use it in GitHub Desktop.
Save himanshurawlani/0e32e935abdda133d4004665f886e097 to your computer and use it in GitHub Desktop.
An example of Keras preprocessing layers in TF2
def augment_images(x, config):
if config['use_contrast'] == "True":
x = tf.keras.layers.experimental.preprocessing.RandomContrast(
config['contrast_factor']
)(x)
if config['use_rotation'] == "True":
x = tf.keras.layers.experimental.preprocessing.RandomRotation(
config['rotation_factor']
)(x)
if config['use_flip'] == "True":
x = tf.keras.layers.experimental.preprocessing.RandomFlip(
config['flip_mode']
)(x)
return x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment