【问题标题】:class wise Tensorflow object detection count分类明智的 TensorFlow 对象检测计数
【发布时间】:2019-06-21 13:27:06
【问题描述】:

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

【问题讨论】:

    标签: python tensorflow object-detection-api


    【解决方案1】:

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

    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 文件中指定的值进行映射。我希望这能够帮到你。如果您遇到任何问题,请告诉我

    【讨论】:

    • 我仍然无法获得检测到的每个类的计数。我用了上面的方法。
    • @Bhawna_priya,您能否提及您所面临的确切错误或问题?
    猜你喜欢
    • 2021-04-06
    • 1970-01-01
    • 1970-01-01
    • 2018-03-28
    • 1970-01-01
    • 1970-01-01
    • 2018-01-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多