I am using TensorFlow Object Recognition API. Normally, what developers do is to setup a training pipeline, provide some checkpoints or tfrecords to start the training while monitoring the performances on TensorBoard. This is what I did and right now I can see all the predicted bounding boxes on Tensorboard, that varies according tot he number of iteration. But what if I need to get these bounding boxes? Is there any line of code that given an image it returns the predicted bounding boxes?
If you are using the sess.run(...)
command for inference, it'll return an python dictionary object (for example called output_dict
). It contains everything, that the model is supposed to return, e.g output_dict['detection_boxes'][0]
, output_dict['detection_scores'][0]
and output_dict['detection_classes'][0]
. You can iterate through this dictionary in the common 'pythonic' way. For example:
box_index = 0
for box in output_dict['detection_boxes'][0]:
current_box = box
current_class_id = output_dict['detection_classes'][0][box_index]
current_score = output_dict['detection_scores'][0][box_idx]
# Do something with box
box_index += 1
Edit: As mentioned above, you can use the jupyter notebook to calculate a 'out of the box' inference with a frozen graph. For production use, have a look at Tensoflow Serve.