Last active
January 13, 2020 20:06
-
-
Save tonyreina/f7b0073b8780c8db806574637c48df1e to your computer and use it in GitHub Desktop.
Ways to save and convert TF to OpenVINO
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
There are several options here. For Keras, just simply load the Keras model and use sess = keras.get_session() to link the TF session variable to the Keras model (model.output and model.input are the output and input ops) | |
# Option 1: Saved TensorFlow model | |
tf.saved_model.simple_save(session, export_dir, inputs={"x":x, "y":y}, outputs={"z": z}) | |
mo_tf.py -saved_model_dir export_dir | |
# Option 2: Saved TensorFlow checkpoint | |
saver = tf.train.Saver() | |
saver.save(sess, "./model.ckpt") | |
mo_tf.py -input_meta_graph model.ckpt.meta | |
# Option 3: Frozen model | |
frozen_model = tf.graph_util.convert_variables_to_constants(sess, tf.get_default_graph(), ['output']) | |
tf.train.write_graph(frozen_model, '.', 'frozen_model.pb', as_text=False) | |
mo_tf.py -input_model frozen_model.pb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment