I'm a newbie to tensorflow. I'm confused about how to count the number of objects detected using the TensorFlow Object Detection API?
# Score is shown on the result image, together with the class label.
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')
if image_np_expanded is not None:
# Actual detection.
(boxes, scores, classes, num_detections) = sess.run(
[boxes, scores, classes, num_detections],
feed_dict={image_tensor: image_np_expanded}
)
As num_detections is a numpy.ndarray I have tried to retrieve it's lenght but does not work.
num_detections.size
>> 1
Neither using the tensor lenght:
tf.size(num_detections, out_type=tf.int32)
>> 1
In my case the number of detected objects are more than one.
num_detections.size?1but the detected objects are more than one.1as size. To get the number of objects detected I used boxes.shape[0] with a condition about score precision. Thanks for you helpnum_detectionsis supposed to represent.