我正在使用 Ultralytics YOLOv8 实现对图像执行对象检测。但是,当我尝试使用结果对象中的
probs
属性检索分类概率时,它返回 None
。这是我的代码:
from ultralytics import YOLO
# Load a model
model = YOLO('yolov8n.pt') # pretrained YOLOv8n model
# Run batched inference on a list of images
results = model('00000.png') # return a list of Results objects
# Process results list
for result in results:
boxes = result.boxes # Boxes object for bbox outputs
masks = result.masks # Masks object for segmentation masks outputs
keypoints = result.keypoints # Keypoints object for pose outputs
probs = result.probs # Probs object for classification outputs
print(probs)
当我运行上面的代码时,
print(probs)
的输出是None
。剩余的输出是
image 1/1 00000.png: 640x640 1 person, 1 zebra, 7.8ms
Speed: 2.6ms preprocess, 7.8ms inference, 1.3ms postprocess per image at shape (1, 3, 640, 640)
为什么 probs 属性返回
None
,如何检索每个检测到的对象的分类概率? Ultralytics YOLOv8 实现中的这种行为背后是否有特定的设计原因?
我想你应该能够通过
results[0].boxes.conf
获得信心。
probs 属性似乎在 Yolov8 中不起作用