SVHNClassifier icon indicating copy to clipboard operation
SVHNClassifier copied to clipboard

Export the checkpoints to .pb format graph

Open shishaozheng opened this issue 7 years ago • 1 comments

Hello, for some reason, I have to frozen the variables of checkpoints file and export the graph to pb file. After research the graph structure, I export the pb file successfully using flowing code:

output_node_names = ['digit_length/dense/BiasAdd','stack']
with tf.Session() as sess:
    # Restore the graph
    saver = tf.train.import_meta_graph(FLAGS.meta_path)

    # Load Weight
    saver.restore(sess, FLAGS.checkpoint_path)

    # Freeze the graph
    frozen_graph_def = tf.graph_util.convert_variables_to_constants(sess, sess.graph_def, output_node_names)

    # Save the frozen graph
    with open('output/svhnclassification.pb', 'wb') as output:
        output.write(frozen_graph_def.SerializeToString())

But then I don't know how to load this pb file, and input a image nparray into the graph to get the predict result. Could you help me?

Thanks

shishaozheng avatar Dec 13 '17 08:12 shishaozheng

How did you find the output node names from checkpoints?

NehaPathapati avatar Jul 07 '18 22:07 NehaPathapati