使用Tensorflow对象检测API的每个对象的所有类的输出得

使用Tensorflow对象检测API的每个对象的所有类的输出得

本文介绍了使用Tensorflow对象检测API的每个对象的所有类的输出得分/概率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Tensorflow对象检测API中,我们通常针对每个测试图像执行此操作:

in Tensorflow object detection API, we usually do this for each test image:

output_dict = sess.run(tensor_dict, feed_dict={image_tensor: image_np_expanded})
                    # pdb.set_trace()
                    # all outputs are float32 numpy arrays, so convert types as appropriate
                    output_dict['num_detections'] = int(output_dict['num_detections'][0])
                    output_dict['detection_classes'] = output_dict['detection_classes'][0].astype(np.int64)
                    output_dict['detection_boxes'] = output_dict['detection_boxes'][0]
                    output_dict['detection_scores'] = output_dict['detection_scores'][0]

这为我们提供了每个对象的分数.例如,有一个狗物体,它的分数是95%.但是,我希望它也输出其他类别的分数,例如,对于同一个对象,分数​​为猫的分数为3%,而自行车的分数为2%.请帮助我,非常感谢.

This gives us the score for each object. For example, there is a dog object, and the score for it is 95%. However I want it to output the score for other classes as well, for example, with the same object, the score for it being a cat would be 3%, being a bicycle would be 2%. Please help me, thank you very much.

推荐答案

事实证明,在较新版本的API中,有output_dict ['detection_multiclass_scores']给出了每个类的分数.我使用了一个没有的旧版本.

It turns out in newer versions of the API, there was output_dict['detection_multiclass_scores'] which gives scores for each class. I used an older version which did not have it.

这篇关于使用Tensorflow对象检测API的每个对象的所有类的输出得分/概率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-22 17:01