简体   繁体   中英

How to get percentages value of predicted object In Tensorflow Object Detection API

I used this code to display object detector with percentage of predicted value, but the variable num_detections is a TensorVariable such as Tensor("num_detections:0", dtype=float32) . So how can I print the percentage of predicted value?

Before you comment, I know there is a similar question but the answer does not seem to work. It prints Tensor("truediv:0", dtype=float32) and I want the percentages.

You only need to evaluate that tensor num_detections in the created session by calling sess.run . The code you linked actually did that for you.

# Perform the actual detection by running the model with the image as input
(boxes, scores, classes, num) = sess.run(
    [detection_boxes, detection_scores, detection_classes, num_detections],
    feed_dict={image_tensor: image_expanded})

So you could simply print out the value of num .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM