Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TF Object Detection API - Remove labels and percentage; Only bounding boxes

I have trained my own model, which detects custom object. But I need some tweak.

How to removes the labels and percentages? Example image Given below. I want only the bounding boxes shown.

enter image description here

like image 886
stacknoflow Avatar asked Oct 12 '25 09:10

stacknoflow


2 Answers

Line 190: Inside /util/visualization.py:

for display_str in display_str_list[::-1]:
    text_width, text_height = font.getsize(display_str)
    margin = np.ceil(0.05 * text_height)
    print("\n"+display_str+"\n")
    #draw.rectangle(
        #[(left, text_bottom - text_height - 2 * margin), (left + text_width,
                                                     # text_bottom)],
        #fill=color)
    #draw.text(
    # (left + margin, text_bottom - text_height - margin),
    # display_str,
    # fill='black',
    # font=font)
    text_bottom -= text_height - 2 * margin

You can comment the lines that draws the text and the rectangle around it.

like image 189
cyril Avatar answered Oct 14 '25 21:10

cyril


                   vis_util.visualize_boxes_and_labels_on_image_array(
                    image_np,
                    output_dict['detection_boxes'],
                    output_dict['detection_classes'],
                    output_dict['detection_scores'],
                    category_index,
                    max_boxes_to_draw=10,
                    min_score_thresh=.6,
                    instance_masks=output_dict.get('detection_masks'),
                    use_normalized_coordinates=True,
                    **skip_scores=True**,#removes scores
                    **skip_labels=True**,#removes lables
                    line_thickness=5)
like image 34
Nikhil08 Avatar answered Oct 14 '25 21:10

Nikhil08