w
gcw_uQ09W7jl/timm-mobilenetv3_small_050.lamb_in1k-NPU
模型介绍文件和版本Pull Requests讨论分析
下载使用量0

timm/mobilenetv3_small_050.lamb_in1k on Ascend NPU

1. 简介

本项目将 timm/mobilenetv3_small_050.lamb_in1k 图像分类模型适配到华为昇腾 NPU (Ascend910) 上运行。模型通过 ModelScope snapshot_download 下载权重,使用 timm 库创建模型结构并加载本地权重,在 NPU 上完成单图推理、CPU-NPU 精度一致性验证与性能基准测试。

2. 验证环境

  • NPU: Ascend910_9362
  • CANN: 8.5.1
  • PyTorch: 2.9.0+cpu
  • torch_npu: 可用
  • timm: 1.0.27
  • modelscope: 1.35.3

3. 推理运行

pip install -r requirements.txt
python inference.py

推理结果 (NPU):

Model: timm/mobilenetv3_small_050.lamb_in1k
Weights: /opt/atomgit/.cache/modelscope/hub/models/timm/mobilenetv3_small_050___lamb_in1k/model.safetensors
Missing keys: 0, Unexpected keys: 0
Input shape: (1, 3, 224, 224)
Output shape: (1, 1000)

Top-5 predictions (NPU):
  1. class=972, prob=0.372148
  2. class=979, prob=0.045396
  3. class=663, prob=0.038370
  4. class=820, prob=0.030488
  5. class=888, prob=0.025310

日志保存在 logs/inference.log。

4. 精度验证

对单张测试输入进行 CPU 与 NPU 一致性验证:

指标数值
max_abs_error0.082224
mean_abs_error0.017429
relative_error0.8450%
cosine_similarity0.999959
threshold1.0%
结果PASS

5. 性能参考

指标数值
avg_latency_ms6.9201
min_latency_ms5.1982
max_latency_ms21.1295
p50_latency_ms5.3571
p90_latency_ms21.1295
p95_latency_ms21.1295
throughput_img/s144.51

测试条件:batch=1,10 次运行,输入尺寸 224x224,NPU 预热 2 次。

6. 精度评测说明

本项目包含单输入 smoke consistency 验证,非官方完整验证集评测。详细指标见第 4 节。

7. 自验证截图

见 screenshots/self_verification.png 与 screenshots/self_verification.txt。

8. 日志文件

  • logs/inference.log — 推理输出
  • logs/accuracy.log — CPU-NPU 精度一致性检查结果
  • logs/benchmark.log — 性能基准测试结果
  • logs/env_check.log — NPU 环境检查
  • logs/paths.txt — 模型下载路径记录

9. 注意事项

  • 权重文件通过 ModelScope snapshot_download 自动下载到本地缓存,推理脚本从本地加载,不触发 HuggingFace 自动下载。
  • 运行前请确保 NPU 驱动与 CANN 工具链已正确安装,torch_npu 可正常导入。
  • 测试图片为随机网络图片,仅用于 smoke test,分类结果不具备语义参考意义。

10. 标签

#NPU