-1

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?

Giacomo Bartoli
  • 730
  • 3
  • 9
  • 23
  • please provide an example piece of code that shows how you currently are trying to visualize the bounding boxes. There are plenty of examples online for this task. Even in the official tensorflow object detection tutorial notebook, which you can find here: https://github.com/tensorflow/models/blob/master/research/object_detection/object_detection_tutorial.ipynb – ITiger Aug 30 '18 at 08:46

1 Answers1

2

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.

Thomas
  • 705
  • 6
  • 21