如何使用更快的RCNN模型获取tensorflow中检测到的对象的名称

问题描述 投票:-1回答:1

我正在使用tensorflow的对象检测api来检测对象。我训练模型及其工作正常,但我想将被检测对象的名称作为字符串。有人可以帮我吗?

tensorflow object-detection-api
1个回答
0
投票

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)之后。

© www.soinside.com 2019 - 2024. All rights reserved.