Tensorflow object detection api 按图片中物体的顺序打印预测

Tensorflow object detection api print prediction in the order of the objects in the picture

我使用 tensorflow object-detection API 训练了一个神经网络来解决简单的验证码,预测质量足够好,但是当我使用以下代码输出预测时:

for index, value in enumerate(classes[0]):
    object_dict = {}
    if scores[0, index] > threshold:
        object_dict[(category_index.get(value)).get('name').encode('utf8')] = scores[0, index]
        objects.append(object_dict)

我得到每个函数的随机顺序预测 运行。是否可以按照物体在图片中的位置顺序得到预测的类?输出图片示例:

Picture

如果我理解这个问题,你想让它们从左到右排序吗?您需要获取框坐标并对其进行排序。

默认情况下,您将按分数从最高到最低对检测进行排序,这就是您在上面所做的。

获取boxes[0]的内容,定义从左到右的排序方式。你会只考虑盒子的xmin吗? xmax?两者的结合?您可以选择几种不同的方法来执行此操作,但之后,您可以使用排序方法从左到右获取框的索引。