TensorFlow Object Detection API print objects found on image to console

Try to set the min_score_thresh to 0. Then you will probably see 300 detections.


As far as I can see you have 300 detections. visualize_boxes_and_labels_on_image_array shows very few of them because min_score_thresh=.5 (this is the default value) is too high for the most of them.

If you want to add such filtering to the output you can write:

min_score_thresh = 0.5
print([category_index.get(i) for i in classes[0] if scores[0, i] > min_score_thresh)

You can change min_score_thresh to choose threshold value you need. It may be useful to print the score values with the category names.


From the function signature visualize_boxes_and_labels_on_image_array, you have to set the arguments max_boxes_to_draw, min_score_thresh,

visualize_boxes_and_labels_on_image_array(image,
                                          boxes,
                                          classes,
                                          scores,
                                          category_index,
                                          instance_masks=None,
                                          keypoints=None,
                                          use_normalized_coordinates=False,
                                          max_boxes_to_draw=20,
                                          min_score_thresh=.5,
                                          agnostic_mode=False,
                                          line_thickness=4)