我正在使用ultralytics和YOLO创建一个程序,旨在识别身份证,如本文所示:https://medium.com/@bentanweihao/training-a-custom-object-detector-in-half-a-day-with-yolov8-5e1475fe201e
我训练了一个模型,我用这行代码调用它:
model = YOLO("best.pt")
然后我使用以下命令创建一个结果:
result = model(cv2.imread('CA49_01.jpg'))
打印输出的结果如下:
[ultralytics.yolo.engine.results.Results object with attributes:
boxes: ultralytics.yolo.engine.results.Boxes object
keypoints: None
keys: ['boxes']
masks: None
names: {0: 'ID Card'}
orig_img: array([[[ 39, 82, 163],
[ 41, 84, 165],
[ 42, 85, 166],
...,
[ 47, 109, 211],
[ 45, 109, 211],
[ 45, 109, 211]],
[[ 40, 83, 164],
[ 40, 83, 164],
[ 41, 84, 165],
...,
[ 47, 109, 211],
[ 47, 109, 211],
[ 45, 109, 211]],
[[ 40, 83, 164],
[ 40, 83, 164],
[ 40, 83, 164],
...,
[ 47, 109, 211],
[ 47, 109, 211],
[ 47, 109, 211]],
...,
[[126, 193, 255],
[128, 195, 255],
[132, 199, 255],
...,
[ 48, 236, 254],
[ 50, 236, 254],
[ 52, 236, 254]],
[[132, 199, 255],
[132, 199, 255],
[133, 200, 255],
...,
[ 48, 236, 254],
[ 50, 236, 254],
[ 50, 236, 254]],
[[134, 199, 254],
[133, 198, 253],
[129, 197, 250],
...,
[ 48, 236, 254],
[ 50, 236, 254],
[ 50, 236, 254]]], dtype=uint8)
orig_shape: (1920, 1080)
path: 'image0.jpg'
probs: None
speed: {'preprocess': 1.0228157043457031, 'inference': 12.832880020141602, 'postprocess': 2.6531219482421875}]
正如你所看到的,“probs”是“None”。有人知道我做错了什么吗?为什么它没有打印出信心分数?
当我绘制结果时,使用:
res_plotted = result[0].plot()
plt.imshow(res_plotted)
它实际上显示了情节中的置信度得分,所以我很困惑。
1条答案
按热度按时间cclgggtu1#
尝试打印字段“boxes:ultralytics.yolo.engine.results.Boxes object”。您应该看到子字段“conf”中的置信度,就像子字段“cls”中的类一样。