模型名称: yolos-smallNPU 模型链接: https://ai.gitcode.com/hf_mirrors/hustvl/yolos-small 模型描述: YOLOS-Small 目标检测模型昇腾NPU适配版本。YOLOS (You Only Look at One Sequence) 是基于 Vision Transformer (ViT) 的目标检测模型,使用 DETR 损失函数在 COCO 2017 数据集上微调,可检测 80 类常见物体。 模型架构: YOLOS (Vision Transformer / ViT) 参数规模: ~118MB (small)
| 依赖项 | 版本要求 | 说明 |
|---|---|---|
| Python | >= 3.10 | 推荐 3.11 |
| torch / torch_npu | 2.1.0+ | 昇腾NPU推理 |
| transformers | >= 4.45.0 | HuggingFace 库 |
| 昇腾驱动 | CANN 8.0.RC2+ | 推荐最新版 |
安装命令:
pip install torch torch_npu transformers sentencepiece# 检查 NPU 设备
npu-smi info# 单条输入推理
python inference.py --input "测试输入内容" --model_path ./yolos-smallNPU
# 批量输入推理
python inference.py --input_file test_samples.txt --model_path ./yolos-smallNPU| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| --input | str | - | 输入文本/图像路径 |
| --input_file | str | - | 批量输入文件路径 |
| --model_path | str | yolos-smallNPU | 模型路径 |
| --max_length | int | 2048 | 最大生成长度 |
输入:
test_images/test_scene.jpg (640x480 RGB图像,包含模拟动物形状)输出:
检测到 3 个目标:
[1] frisbee | 置信度: 0.7933 | 边界框: [xmin=149.2, ymin=249.4, xmax=406.2, ymax=440.3]
[2] frisbee | 置信度: 0.9111 | 边界框: [xmin=150.1, ymin=249.5, xmax=406.2, ymax=439.7]
[3] sports ball | 置信度: 0.3240 | 边界框: [xmin=415.2, ymin=137.9, xmax=508.6, ymax=222.1]耗时: 0.1844s



| 测试样例 | NPU输出 | 耗时 | 是否成功运行 |
|---|---|---|---|
| 样例1: 目标检测推理 | 检测到3个目标 (frisbee x2, sports ball x1) | 0.1844s | ✅ 成功 |
结论: 模型已在 NPU 上成功运行推理,满足验收要求。 说明: 根据最新规则,不再强制精度1%验证,本章节记录 NPU 运行验证结果。
文档生成时间:2026-08-20 00:20:44