Search code examples
pythontensorflowobject-detection-api

Duplicate detections by the tensorflow API


I'm currently using the tensorflow object detection API, however while creating bounding boxes on an images, the API tends to make multiple bounding boxes on a single item. Is there anyway I can make it such that only a single unique bounding box is created over a single item.

The current model I'm using for the object detection is a faster rcnn model trained on the open images dataset (from the g3doc model zoo)


Solution

  • Try this go to research>object-detection>utils>visualisation_utils.py, and change the min_score_threshold value:

    def visualize_boxes_and_labels_on_image_array(
        image,
        boxes,
        classes,
        scores,
        category_index,
        instance_masks=None,
        instance_boundaries=None,
        keypoints=None,
        use_normalized_coordinates=False,
        max_boxes_to_draw=20,
        min_score_thresh=.90,
        agnostic_mode=False,
        line_thickness=4,
        groundtruth_box_visualization_color='black',
        skip_scores=False,
        skip_labels=False):
    

    In my case I use threshold values which are greater than 90 percent. This removes the other bounding boxes with lower probability also as a add-on you can change boarder thickness and colour of bounding box by using the above script