简体   繁体   中英

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

I trained a neural network to solve simple captcha using tensorflow object-detection API, prediction quality is good enough, however when I output the predictions with the following code:

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)

I get predictions in random order with every function run. Is it possible to get the predicted classes in the order in which the objects are located in the picture? Example of output picture:

Picture

If I understand the question, you want them sorted from left to right? You'd need to get the box coordinates and sort them.

By default, you will get the detections sorted by score, from highest to lowest, which is what you've done above.

Get the contents of boxes[0] and define a sorting method for left to right. Will you only consider the xmin of the box? The xmax? A combination of both? There are a few different ways you could choose to do this, but afterwards, you can use you sorting method to get the indices of the boxes from left to right.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM