How to count objects in Tensorflow Object Detection API

前端 未结 5 1267
旧巷少年郎
旧巷少年郎 2020-12-05 16:23

I am executing https://github.com/tensorflow/tensorflow this example of detecting objects in image.

I want to get count of detected objects following is the code tha

5条回答
  •  醉酒成梦
    2020-12-05 16:37

    You should check scores and count objects as manual. Code is here:

    #code to test image start
    
        (boxes, scores, classes, num) = sess.run(
            [detection_boxes, detection_scores, detection_classes, num_detections],
            feed_dict={image_tensor: image_np_expanded})
    
    #code to test image finish
    
    #add this part to count objects
    
        final_score = np.squeeze(scores)    
            count = 0
            for i in range(100):
                if scores is None or final_score[i] > 0.5:
                        count = count + 1
    
    #count is the number of objects detected
    

提交回复
热议问题