Skip to content

Instantly share code, notes, and snippets.

@sdcubber
Last active August 9, 2018 09:07
Show Gist options
  • Save sdcubber/a9435606a86e8f35824e4b0eee23c8c1 to your computer and use it in GitHub Desktop.
Save sdcubber/a9435606a86e8f35824e4b0eee23c8c1 to your computer and use it in GitHub Desktop.
import tensorflow as tf
# The export path contains the name and the version of the model
tf.keras.backend.set_learning_phase(0) # Ignore dropout at inference
model = tf.keras.models.load_model('./model.h5')
export_path = './PlanetModel/1'
# Fetch the Keras session and save the model
# The signature definition is defined by the input and output tensors
# And stored with the default serving key
with tf.keras.backend.get_session() as sess:
tf.saved_model.simple_save(
sess,
export_path,
inputs={'input_image': model.input},
outputs={t.name:t for t in model.outputs})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment