Abhinav23
Abhinav23

Reputation: 81

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)

Upvotes: 2

Views: 1625

Answers (2)

Ajinkya
Ajinkya

Reputation: 1867

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

Upvotes: 3

Meissa93
Meissa93

Reputation: 21

In my experience, this is the standard behavior of detectors. Let's say they are noisy and depending on how the box is placed, the same item can be detected multiple times as different objects.

This is why I think detectors need a filtering function which filters out incorrect predictions. You can easily do something like that using the concept of IoU: intersection over union. An example can be found here, there's also some code you can use.

Basically, perform the detection using your frozen model in the usual way. Then, perform a check on the predicted boxes and discard the ones who somehow are overlayed, i. e. you can discard the overlayed box with lower confidence score with respect to the other one.

Hope it helps!

Upvotes: 2

Related Questions