【问题标题】:Tensorflow Objection Detection API: Accessing all class scores for a given bounding box?Tensorflow Objection Detection API:访问给定边界框的所有类分数?
【发布时间】:2018-12-02 10:30:14
【问题描述】:

使用 Tensorflow 的对象检测 API,可以训练 SSD 初始对象检测器并通过查询与边界框坐标数组对应的张量 detection_boxes:0detection_scores:0detection_classes:0 来执行推理,该数组包含每个边界框的最大得分,以及一个整数数组,分别对应于每个边界框的最大得分类别标签。

我感兴趣的是每个边界框的所有类的分数。首先,我尝试查看 detection_scores 操作是否有多个张量,但查询 detection_scores:1 张量会引发错误,指出张量不存在。其次,我尝试查看模型的节点名称以找到相关的探测操作:要查询的张量,但名称往往非常通用。有谁知道查询这些值的方法吗?

(附注:我在 python 2.7 中使用 tensorflow-gpu 1.5 和 ssd inception v2)

【问题讨论】:

  • 您找到解决方案了吗?我也需要这个。

标签: python tensorflow object-detection


【解决方案1】:

我不确定这个答案是否令人满意,但让我们试一试:

您可以加载模型并将其保存在 tensorboard 中进行检查:

import tensorflow as tf
from tensorflow.python.summary import summary

# I used mobilenet v2 with ssdlite from the tf model zoo
with tf.gfile.FastGFile('frozen_inference_graph.pb') as f:
    graph_def = tf.GraphDef()
    graph_def.ParseFromString(f.read())

sess = tf.Session()

sess.graph.as_default()
tf.import_graph_def(graph_def, name='')

pb_visual_writer = summary.FileWriter('.')
pb_visual_writer.add_graph(sess.graph)

在 tensorboard 中,您将看到模型,我能找到的最接近您正在搜索的内容是 BoxPredictors 之后的 concatconcat_1 操作。

第一个输出一个形状为?x1917x1x4 的张量,其中包含盒子。 另一个输出一个形状为?x1917x91 的张量,其中包含每个框的每个类别的分数。

请注意,concat 后跟 Squeeze 操作以使其成为 ?x1917x4concat_1 后跟一个称为 Postprocessor/convert_scores 的 sigmoid

【讨论】:

  • 糟糕,我完全忘记了 mobilenet ssd 的存在。我编辑了问题以澄清我正在使用 ssd inception v2。感谢您的回复,我将看看是否可以按照这些步骤并在 ssd inception 模型中找到类似的东西。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-05-23
  • 1970-01-01
  • 2019-07-20
  • 2018-09-20
  • 2020-01-06
  • 2018-01-28
  • 2021-02-09
相关资源
最近更新 更多