SSD-Tensorflow
SSD-Tensorflow copied to clipboard
How to freeze ssd_300_vgg graph
Hello,
I am interested in loading one of the checkpoints you've made into an application that only takes Tensorflow frozen graphs (.pb
file).
I'm using the freeze_graph.py
tool to do so. I've generated the input_graph
by running tf.train.write_graph(session.graph_def, '/home/mjohnst/graph.pbtxt')
during the caffe_to_tensorflow.py
script that generates the checkpoint.
One additional parameter I need is the output_node_names
. I got all the node names by running tf.get_default_graph().as_graph_def().node
and choose the last node in the list save/restore_all
Is this the correct name of the output nodes?
If I'm going about this wrong, feel free to correct me :)
I was thinking that my call to write_graph
may be able to write out the whole frozen graph, but I'm not sure. In the write_graph
I tried using as_text=False
and changed the format to pb
, but when trying to freeze the weights into the input graph (assuming I still need to do this), I get an exception.
Thanks!
@mjohnst Did you ever figure this out? I'm in the same situation, and I didn't see a good final layer to use in the Tensorboard representation of the network.
I think below softmax loss layers are good choices for freezing(not only one but many),
ssd_300_vgg/softmax/Softmax ssd_300_vgg/softmax_1/Softmax ssd_300_vgg/softmax_2/Softmax ssd_300_vgg/softmax_3/Softmax ssd_300_vgg/softmax_4/Softmax ssd_300_vgg/softmax_5/Softmax ssd_losses/softmax/Softmax ssd_losses/cross_entropy_pos/SparseSoftmaxCrossEntropyWithLogits/SparseSoftmaxCrossEntropyWithLogits ssd_losses/cross_entropy_neg/SparseSoftmaxCrossEntropyWithLogits/SparseSoftmaxCrossEntropyWithLogits
can any body suggest other layers for freezing?
I found 'ssd_losses/softmax/Softmax' is the best choice
I got stuck with passing one image into the frozen graph for inference.
original graph has prefetch queue/dequeue for batch processing, but in test phase, we usually need to pass one image. so I need to trasform or remap the original input queue to just a simple "input" which can be found in the tensorflow inceptionV3 pb example. a gist already made it (https://gist.github.com/tokestermw/795cc1fd6d0c9069b20204cbd133e36b), but I'm still struggling in how to adapt "tf.import_graph_def" to fit it in my SSD case..
tf.import_graph_def( graph_def, input_map={"input:0": new_input}, return_elements=None, # if input_map is not None, needs a name name="bla", op_dict=None, producer_op_list=None )
freezing:
python3 freeze_graph.py
--input_binary=false
--input_graph=graph.pbtxt
--input_checkpoint=model.ckpt-60000
--output_graph=ssd300frozen_graph.pb
--output_node_names=?
what are the correct names of the "output_node_names"
do you know the input_node_name of ssd_300_vgg
do you know the input_node_name of ssd_300_vgg
Hi,I am struggling in this problem, have you sovled this? please help!
The matter is the input, I just need a placeholder, not a queue