-->

Converting SSD to frozen graph in tensorflow. Whic

2019-05-23 18:50发布

问题:

I trained SSD using TensorFlow Object Detection API as described here. It produces a ckpt, meta and index file. In order to run it on my images I tried to check the demo code. It requires that the model be converted to frozen graph. I tried to convert my model to a frozen inference graph as described here. In that program I have to provide output node names. I could not figure out the name of the node in the SSD model which must be used here. Please help. I tried 'num_detections:0', 'detection_boxes:0' etc. Only to get error:

AssertionError: num_detections is not in graph

回答1:

We have a special tool to convert to frozen graphs in the Tensorflow Object Detection API --- just run the export_inference_graph.py binary. Directions for using this tool are here.



回答2:

You can explore graph by self: A Tool Developer's Guide to TensorFlow Model Files and find node names. I can give sample from my model: "prefix/digit1/Softmax:0" (it was "digit1" in my keras model) Also as I remember you should provide list of these names to transform_graph utility ("--output" parameter).



回答3:

i am using this small python script to localize nodes based on its operations. "PLaceholder" and "Identity" appear to be interesting to find Input and Output Nodes:

import tensorflow as tf

NODE_OPS = ['Placeholder','Identity']
MODEL_FILE = '/path/to/frozen_inference_graph.pb'

gf = tf.GraphDef()
gf.ParseFromString(open(MODEL_FILE,'rb').read())

print([n.name + '=>' +  n.op for n in gf.node if n.op in (NODE_OPS)])