Output score/probability for all class for each object with Tensorflow object detection API

亡梦爱人 提交于 2021-01-29 13:27:10

问题


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]

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.


回答1:


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.



来源:https://stackoverflow.com/questions/58828422/output-score-probability-for-all-class-for-each-object-with-tensorflow-object-de

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!