Reputation: 33
Using Tensorflow's objection detection API, it is possible to train an SSD inception object detector and perform inference by querying the tensors detection_boxes:0
, detection_scores:0
, and detection_classes:0
corresponding to an array of bounding box coordinates, an array containing the maximum score for each bounding box, and an array of integers corresponding to the maximum score class label of each bounding box, respectively.
What I am interested in are the scores of all classes for each bounding box. First, I tried to see if maybe the detection_scores
operation had more than one tensor but querying detection_scores:1
tensor threw an error saying the tensor does not exist. Second, I have tried looking through the node names of the model to find a relevant sounding operation:tensor to query but the names tend to be quite generic. Does anyone know a way to query these values?
(P.S. I am working in python 2.7 with tensorflow-gpu 1.5 and ssd inception v2)
Upvotes: 1
Views: 540
Reputation: 3852
I am not sure this answer will be satisfactory but lets give it a try:
You can load the model and save it for inspection in tensorboard:
import tensorflow as tf
from tensorflow.python.summary import summary
# I used mobilenet v2 with ssdlite from the tf model zoo
with tf.gfile.FastGFile('frozen_inference_graph.pb') as f:
graph_def = tf.GraphDef()
graph_def.ParseFromString(f.read())
sess = tf.Session()
sess.graph.as_default()
tf.import_graph_def(graph_def, name='')
pb_visual_writer = summary.FileWriter('.')
pb_visual_writer.add_graph(sess.graph)
In tensorboard you will see the model, the closest thing I could find to what you are searching for is the concat
and concat_1
ops after the BoxPredictor
s.
The first one outputs a Tensor of shape ?x1917x1x4
, which contains the boxes.
The other outputs a Tensor of shape ?x1917x91
, which contains the scores for each classes for each box.
Note that concat
is followed by a Squeeze
op to make it ?x1917x4
and concat_1
is followed by a sigmoid called Postprocessor/convert_scores
Upvotes: 0