首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >类Tensorflow对象检测计数

类Tensorflow对象检测计数
EN

Stack Overflow用户
提问于 2019-06-21 21:27:06
回答 1查看 296关注 0票数 0

我们可以在Tensorflow对象检测API类中对检测到的对象进行计数吗?假设你有两个类汽车和自行车,我想计算每个对象类的个数,例如,计数:5,自行车计数:3。

EN

回答 1

Stack Overflow用户

发布于 2019-07-30 12:11:20

实现这一目标的一种方法是执行以下操作

代码语言:javascript
复制
boxes = detection_graph.get_tensor_by_name('detection_boxes:0')
scores = detection_graph.get_tensor_by_name('detection_scores:0')
classes = detection_graph.get_tensor_by_name('detection_classes:0')
num_detections = detection_graph.get_tensor_by_name('num_detections:0')
(boxes, scores, classes, num_detections) = sess.run([boxes, scores, classes, num_detections],feed_dict={image_tensor: image_np_expanded})

final_score = np.squeeze(scores)    
car_count = 0

for i in range(100):
    if final_score[i] > 0.5:
        detected_class = int(classes[0][i])
        if detected_class == 1:
            car_count += 1

在这里,类名和编号根据您在label_map.pbtxt文件中指定的值进行映射。我希望这能帮到你。如果你遇到任何问题,请告诉我

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56704419

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档