Created
September 23, 2020 15:15
-
-
Save ClementWalter/b755bb419f087da84f79d1e4b1afe2eb to your computer and use it in GitHub Desktop.
Simple image preprocessing
This file contains 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
@tf.function(input_signature=(tf.TensorSpec(shape=[None, None, 3], dtype=tf.uint8),)) | |
def preprocessing(input_tensor): | |
output_tensor = tf.cast(input_tensor, dtype=tf.float32) | |
output_tensor = tf.image.resize_with_pad(output_tensor, target_height=224, target_width=224) | |
output_tensor = keras_applications.mobilenet.preprocess_input(output_tensor, data_format="channels_last") | |
return output_tensor |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment