【发布时间】:2019-03-16 12:03:34
【问题描述】:
我正在使用 tensorflow 的对象检测 api 来检测对象。我训练了模型并且它工作正常,但我想获取被检测为字符串的对象的名称。有人可以帮我吗?
【问题讨论】:
标签: tensorflow object-detection-api
我正在使用 tensorflow 的对象检测 api 来检测对象。我训练了模型并且它工作正常,但我想获取被检测为字符串的对象的名称。有人可以帮我吗?
【问题讨论】:
标签: tensorflow object-detection-api
API提供了一个名为object_detection_tutorial.ipynb的教程文件,在这个文件中,函数run_inference_for_single_image返回一个检测字典output_dict,其中包含键detection_classes,这对应于你在label_map.pbtxt文件中定义的id .同样在这个文件变量category_index 中是存储为字典的标签映射。因此,要获取检测到的所有对象的字符串名称,只需添加:
string_name = [category_index[i] for i in output_dict['detection_classes']]
在教程中的这一行 output_dict = run_inference_for_single_image(image_np, detection_graph) 之后。
【讨论】: