我们可以在Tensorflow对象检测API类中对检测到的对象进行计数吗?假设您有car和bicyle这两个类,我想将每个对象类明智地算出; ,Carcount:5自行车数:3。
答案 0 :(得分:0)
实现此目标的一种方法是执行以下操作
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
文件中指定的值映射了类名和编号。我希望这能够帮到你。如果您遇到任何问题,请告诉我