【问题标题】:Getting Bounding Boxes with highest confidence during prediction在预测过程中获得最高置信度的边界框
【发布时间】:2019-02-04 14:07:59
【问题描述】:
我正在使用 TensorFlow 对象识别 API。通常,开发人员所做的是设置训练管道,提供一些检查点或 tfrecord 来开始训练,同时监控 TensorBoard 上的性能。
这就是我所做的,现在我可以在 Tensorboard 上看到所有预测的边界框,这些边界框根据迭代次数而变化。
但是如果我需要获取这些边界框怎么办?
是否有任何代码行给定图像返回预测的边界框?
【问题讨论】:
标签:
tensorflow
object-detection
bounding-box
object-detection-api
【解决方案1】:
如果您使用sess.run(...) 命令进行推理,它将返回一个python 字典对象(例如称为output_dict)。它包含模型应该返回的所有内容,例如output_dict['detection_boxes'][0]、output_dict['detection_scores'][0] 和output_dict['detection_classes'][0]。您可以以常见的“pythonic”方式遍历此字典。例如:
box_index = 0
for box in output_dict['detection_boxes'][0]:
current_box = box
current_class_id = output_dict['detection_classes'][0][box_index]
current_score = output_dict['detection_scores'][0][box_idx]
# Do something with box
box_index += 1
编辑:
如上所述,您可以使用 jupyter notebook 来计算冻结图的“开箱即用”推理。对于生产用途,请查看 Tensoflow Serve。