Skip to content

Instantly share code, notes, and snippets.

@ClementWalter
Created September 23, 2020 15:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ClementWalter/b755bb419f087da84f79d1e4b1afe2eb to your computer and use it in GitHub Desktop.
Save ClementWalter/b755bb419f087da84f79d1e4b1afe2eb to your computer and use it in GitHub Desktop.
Simple image preprocessing
@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