Ultralytics的YOLO26模型提供专门的分类模型以支持图像分类,其主要预训练模型及参数如下表所示,其中的acc top1指标是指模型预测的第一名类别是否正确,用于评估模型的最优答案的准确率,而acc top5指标是指正确答案是否在模型预测的前五名类别中,用于评估模型的候选答案的准确率。

图像分类模型的输出是单个类别标签和一个置信度分数。YOLO26的分类模型的输出数据形状是长度为c的一维数组,c为基于imagenet数据集的1000个预训练分类,可以通过result.names属性获取全部分类,也可以从参考文献5中浏览全部1000中分类名称。不过将分类模型转换为onnx格式后,其输入形状、输出形状变为[1,3,224,224]、[1,1000]的形式,具体解析方式后续再学习。
图像分类模型的输出结果保存在result.probs属性中,其中data保存原始数据,也即对应1000个预训练分类的置信度,top1和top1conf为可能性最高的分类索引及置信度,top5和top5conf为可能性最高的前5个分类索引及置信度。

最后是示例程序及程序运行效果,如下所示:
python
from ultralytics import YOLO
# Load a model
model = YOLO(r"E:\MyPrograms\Python\ultralytics\yolo26m-cls.pt")
# Predict with the model
results = model("ertong.jpg")
# Access the results
for result in results:
print(result.probs.top1)
print(result.probs.top5)
print(result.probs.top1conf)
print(result.probs.top5conf)
print(result.probs.data.shape)
print(result.probs.data)
print(result.names)#1000个预训练分类名称


参考文献:
1\]https://docs.ultralytics.com/zh/models/yolo26/ \[2\]https://docs.ultralytics.com/zh/tasks/classify/ \[3\]https://deepwiki.com/ultralytics/ultralytics/5.2-annotation-and-plotting-utilities \[4\]https://docs.ultralytics.com/reference/engine/results/#ultralytics.engine.results.Probs \[5\]https://deeplearning.cms.waikato.ac.nz/user-guide/class-maps/IMAGENET/