首页 > 解决方案 > 如何在 Tensorflow 对象检测 API 中获取预测对象的百分比值

问题描述

我使用此代码显示具有预测值百分比的对象检测器,但变量num_detectionsTensorVariable诸如Tensor("num_detections:0", dtype=float32). 那么如何打印预测值的百分比呢?

在您发表评论之前,我知道有一个类似的问题,但答案似乎不起作用。它打印出来Tensor("truediv:0", dtype=float32),我想要百分比。

标签: pythontensorflow

解决方案


您只需要在调用num_detections创建的张量中评估该张量。您链接的代码实际上为您做到了。sessionsess.run

# Perform the actual detection by running the model with the image as input
(boxes, scores, classes, num) = sess.run(
    [detection_boxes, detection_scores, detection_classes, num_detections],
    feed_dict={image_tensor: image_expanded})

所以你可以简单地打印出num.


推荐阅读