Skip to content

Instantly share code, notes, and snippets.

@pra-dan
Last active April 16, 2020 06:51
Show Gist options
  • Save pra-dan/d857971d0f6fd5f446c189871a1ca949 to your computer and use it in GitHub Desktop.
Save pra-dan/d857971d0f6fd5f446c189871a1ca949 to your computer and use it in GitHub Desktop.
# This script will help print the inputs and output layer names of Tensorflow graph files (.pb)
import tensorflow as tf
gf = tf.GraphDef()
m_file = open('/content/frozen_darknet_yolov3_model.pb','rb')
gf.ParseFromString(m_file.read())
with open('somefile.txt', 'a') as the_file:
for n in gf.node:
the_file.write(n.name+'\n')
file = open('somefile.txt','r')
data = file.readlines()
print ("output name = ")
print (data[len(data)-1])
print ("Input name = ")
file.seek ( 0 )
print (file.readline())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment