Tensorflow 返回通过边界框Google'的阈值的坐标;s对象检测API

Tensorflow 返回通过边界框Google'的阈值的坐标;s对象检测API,tensorflow,object-detection,threshold,object-detection-api,Tensorflow,Object Detection,Threshold,Object Detection Api,有人知道如何获得仅通过阈值的边界框坐标吗 我找到了这个答案(这里是a),所以我尝试使用它并做了以下工作: vis_util.visualize_boxes_and_labels_on_image_array( image, np.squeeze(boxes), np.squeeze(classes).astype(np.int32), np.squeeze(scores), category_index, use_normalized_coordi

有人知道如何获得仅通过阈值的边界框坐标吗

我找到了这个答案(这里是a),所以我尝试使用它并做了以下工作:

vis_util.visualize_boxes_and_labels_on_image_array(
    image,
    np.squeeze(boxes),
    np.squeeze(classes).astype(np.int32),
    np.squeeze(scores),
    category_index,
    use_normalized_coordinates=True,
    line_thickness=1,
    min_score_thresh=0.80)

for i,b in enumerate(boxes[0]):
    ymin = boxes[0][i][0]*height
    xmin = boxes[0][i][1]*width
    ymax = boxes[0][i][2]*height
    xmax = boxes[0][i][3]*width
    print ("Top left")
    print (xmin,ymin,)
    print ("Bottom right")
    print (xmax,ymax)
但我注意到,通过使用link中提供的答案,返回所有值。来自分类器检测到的所有边界框(我不想要)。我想要的只是通过“min_score_thresh”的边界框中的值

我觉得这应该很简单,但我确实缺乏这方面的知识。 如果我能找到答案,我一定会把它贴在这里,但如果其他人知道答案并能为我节省一些时间,我将不胜感激。

更新: 前面函数返回的
分数
都是numpy array对象,因此可以使用布尔索引过滤掉阈值以下的框

true_boxes = boxes[0][scores[0] > min_score_thresh]
这将为您提供一个通过阈值的框

true_boxes = boxes[0][scores[0] > min_score_thresh]
然后你就可以做了

for i in range(true_boxes.shape[0]):
    ymin = true_boxes[i,0]*height
    xmin = true_boxes[i,1]*width
    ymax = true_boxes[i,2]*height
    xmax = true_boxes[i,3]*width
    print ("Top left")
    print (xmin,ymin,)
    print ("Bottom right")
    print (xmax,ymax)

刚回来,这一切都没有成功。索引器错误:标量变量的索引无效。行:ymin=true\u-boxes[0][i][0]*高度。您能在
true\u-boxes=boxes[0][scores[0]>min\u-scoresh]之后运行
print(true\u-boxes.shape)
并将输出粘贴到此处吗输出是这样的:(11,4)好的,刚刚更新了答案,(注意,代码也已经更新)这一次帮助您获得想要的结果