无法使用 ultralytics 和 YOLO 打印出置信度分数

问题描述 投票:0回答:0

我正在使用 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}]

如您所见,“概率”是“无”。有谁知道我做错了什么以及为什么它没有打印出置信度分数?

当我使用以下方法绘制结果时:

res_plotted = result[0].plot()
plt.imshow(res_plotted)

它确实显示了情节中的置信度得分,所以我很困惑。

python opencv machine-learning yolo
© www.soinside.com 2019 - 2024. All rights reserved.