Created
September 5, 2020 19:58
-
-
Save himanshurawlani/0e32e935abdda133d4004665f886e097 to your computer and use it in GitHub Desktop.
An example of Keras preprocessing layers in TF2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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