Skip to content

Instantly share code, notes, and snippets.

@morgangiraud
Last active November 12, 2018 14:41
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 morgangiraud/5ef49adc3c608bf639164b1dd5ed3dab to your computer and use it in GitHub Desktop.
Save morgangiraud/5ef49adc3c608bf639164b1dd5ed3dab to your computer and use it in GitHub Desktop.
medium-tffreeze-2
import tensorflow as tf
def load_graph(frozen_graph_filename):
# We load the protobuf file from the disk and parse it to retrieve the
# unserialized graph_def
with tf.gfile.GFile(frozen_graph_filename, "rb") as f:
graph_def = tf.GraphDef()
graph_def.ParseFromString(f.read())
# Then, we import the graph_def into a new Graph and returns it
with tf.Graph().as_default() as graph:
# The name var will prefix every op/nodes in your graph
# Since we load everything in a new graph, this is not needed
tf.import_graph_def(graph_def, name="prefix")
return graph
@anthonygelibert
Copy link

Hi,
A simple question, at L15, the "return" statement is outside the "with" scope… is it normal?
Regards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment