python - 如何在 Tensorflow 对象检测 API 中获取预测对象的百分比值
问题描述
我使用此代码显示具有预测值百分比的对象检测器,但变量num_detections
是TensorVariable
诸如Tensor("num_detections:0", dtype=float32)
. 那么如何打印预测值的百分比呢?
在您发表评论之前,我知道有一个类似的问题,但答案似乎不起作用。它打印出来Tensor("truediv:0", dtype=float32)
,我想要百分比。
解决方案
您只需要在调用num_detections
创建的张量中评估该张量。您链接的代码实际上为您做到了。session
sess.run
# 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})
所以你可以简单地打印出num
.
推荐阅读
- python - 处理 2 个同名对象
- python - 标记为恶意软件的 PIP 文件
- python - 使用 pandas.json_normalize 来“展开”字典列表的字典
- java - 可执行 jar 不是 zip 格式
- python - 如何在python控制台中停止按住按钮
- pine-script - 为什么我的 EMA 值与 TradingView 的内置版本不同?
- xmonad - 在 XMonad 中,Mod-p (dmenu_run) 显示一个空菜单
- excel - 如何对以逗号分隔的数字进行排序
- python - Python stdout 和 stdout.buffer 捕获
- python - Python Regex 获取字符串中所有出现的 4 位数字