使用TensorFlow对象检测输出分数,类别,ID和BOXES提取

时间:2019-02-22 05:50:19

标签: tensorflow object-detection object-detection-api

根据此question。 我的是; 让我们假设有一张图片包含3只猫,2只狗和1只鸟。 检测完整个对象后,如何获得分离的6个对象的xmin ymin xmax ymax值。

2 个答案:

答案 0 :(得分:0)

在这些行之后

    (boxes, scores, classes, num_detections) = sess.run(
          [boxes, scores, classes, num_detections],
          feed_dict={image_tensor: image_np_expanded})

您可以检索所需的信息

    boxes, scores, classes, num_detections

答案 1 :(得分:0)

在Python中看起来像

    # this loop Counting the Objects found from highest to lowest %, Default is 100Results. Only > x% get counted
        scores = output_dict['detection_scores'] as example
        boxes = output_dict['detection_boxes'] as example
        classes = output_dict['detection_classes'] as example
        count=0  
        xmin=[]
        xmax=[]
        ymin=[]
        ymax=[] 
        classlist=[]         
        for s in range (100):
            if scores is None or scores [s] > 0.5:
                count = count + 1
        for i in range (count):
            position = np.squeeze(boxes[0][i])
            (xmin, xmax, ymin, ymax) = (position[1]*im_width, position[3]*im_width, position[0]*im_height, position[2]*im_height)
        xmin.append(xmin)
        xmax.append(xmax)
        ymin.append(ymin)
        ymax.append(ymax)
        classlist.append(classes[i])

列表从最高得分到最低得分排序。 对不起,这是我的新手。