Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find the Input and Output Nodes of a Frozen Model

I want to use tensorflow's optimize_for_inference.py script on a frozen Model from the model zoo: the ssd_mobilenet_v1_coco.

How do i find/determine the names of the input and output name of the model?

Here is a link to the graph generated by tensorboard

Hires version of the graph generated by tensorboard

This question might help: Given a tensor flow model graph, how to find the input node and output node names (for me it did not)

like image 737
gustavz Avatar asked Jan 31 '26 07:01

gustavz


1 Answers

I think you can do using the following code. I downloaded ssd_mobilenet_v1_coco frozen model from here and was able to get the input and output names as shown below

!pip install tensorflow==1.15.5

import tensorflow as tf
tf.__version__ # TF1.15.5

gf = tf.GraphDef()  
m_file = open('/content/frozen_inference_graph.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())

Output is

output name = 
detection_classes

Input name = 
image_tensor

Please check the gist here.