Skip to content

Instantly share code, notes, and snippets.

@mdobson
Created July 9, 2018 11:45
Show Gist options
  • Save mdobson/15b4656fdbb1c98b1c0863a24e4dcd04 to your computer and use it in GitHub Desktop.
Save mdobson/15b4656fdbb1c98b1c0863a24e4dcd04 to your computer and use it in GitHub Desktop.
Look at tensorflow nodes
import tensorflow as tf
import sys
from tensorflow.python.platform import gfile
from tensorflow.core.protobuf import saved_model_pb2
from tensorflow.python.util import compat
with tf.Session() as sess:
model_filename = 'ssdlite_mobilenet_v2_coco_2018_05_09/saved_model/saved_model.pb'
with gfile.FastGFile(model_filename, 'rb') as f:
data = compat.as_bytes(f.read())
sm = saved_model_pb2.SavedModel()
sm.ParseFromString(data)
if 1 != len(sm.meta_graphs):
print('More than one graph found.')
sys.exit(1)
#g_in = tf.import_graph_def(sm.meta_graphs[0].graph_def)
[print(n.name) for n in sm.meta_graphs[0].graph_def.node]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment