Skip to content

Instantly share code, notes, and snippets.

@Ouwen
Created July 25, 2018 18:16
Show Gist options
  • Save Ouwen/c756ed2567054f3a732049f81eefbf3d to your computer and use it in GitHub Desktop.
Save Ouwen/c756ed2567054f3a732049f81eefbf3d to your computer and use it in GitHub Desktop.
Load a tensorflow graph from a .pbtxt
import tensorflow as tf
from google.protobuf import text_format
# Let's read our pbtxt file into a Graph protobuf
f = open("/tmp/storage/graph_protobuf.pbtxt", "r")
graph_protobuf = text_format.Parse(f.read(), tf.GraphDef())
# Import the graph protobuf into our new graph.
graph_clone = tf.Graph()
with graph_clone.as_default():
tf.import_graph_def(graph_def=graph_protobuf, name="")
# Display the graph inline.
graph_clone.as_graph_def()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment