0
我已经使用object_detection_tutorial.ipynb来显示物体检测器与预测值的百分比,但变量num_detections
是TensorVariable
如Tensor("num_detections:0", dtype=float32)
,所以我如何打印预测值的百分比?如何在Tensorflow Object Detection API中获得预测值的百分比?
我已经使用object_detection_tutorial.ipynb来显示物体检测器与预测值的百分比,但变量num_detections
是TensorVariable
如Tensor("num_detections:0", dtype=float32)
,所以我如何打印预测值的百分比?如何在Tensorflow Object Detection API中获得预测值的百分比?
你是什么意思num_detections
是一个TensorVariable?正如你可以从他们的代码中看到的那样,他们正在返回这张张,num_detections = detection_graph.get_tensor_by_name('num_detections:0')
。在这种情况下,num_detections
默认为100,因为他们以这种方式训练了他们的模型。要获得预测值的百分比,您需要scores
。比方说,你的阈值是0.5,你可以计算出预测值的百分比是这样的:
import numpy as np
threshold = 0.5 # in order to get higher percentages you need to lower this number; usually at 0.01 you get 100% predicted objects
print(len(np.where(scores[0] > threshold)[0])/num_detections[0])
感谢,但我怎么能检查我的门槛我尝试了命令,但它打印常数0.01,而不是正确的百分比是多少?的预测价值。我认为我的门槛有点不对劲。 –
我的例子中的阈值为0.5,你可以看到。我意识到我的答案中有一个错误。 'np.where()'的输出是一个数组,所以长度始终为1,所以它一直是0.1。看到我更新的答案。它应该现在工作! –
非常感谢您的回答!它现在可以工作! –