【问题标题】:how to get percentage of predicted value in Tensorflow Object Detection API?如何在 Tensorflow 对象检测 API 中获取预测值的百分比?
【发布时间】:2017-08-26 14:35:13
【问题描述】:

我已经使用object_detection_tutorial.ipynb来显示目标检测器的预测值百分比,但是变量num_detectionsTensorVariable,例如Tensor("num_detections:0", dtype=float32),那么如何打印预测值的百分比?

【问题讨论】:

    标签: tensorflow object-detection


    【解决方案1】:

    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。请参阅我的更新答案。它现在应该可以工作了!
    • 非常感谢您的回答!现在可以使用了!
    猜你喜欢
    • 1970-01-01
    • 2018-03-30
    • 2019-12-10
    • 1970-01-01
    • 2019-04-16
    • 2020-06-23
    • 2017-12-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多