z
zhangyuge147/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(Ascend910B)上运行。

  • 原始模型来源: ModelScope - timm/mobilenetv3_small_050.lamb_in1k
  • 模型类型: Image Classification (1000 classes)
  • 输入尺寸: 3 x 224 x 224
  • 权重加载方式: timm.create_model(pretrained=False) + ModelScope snapshot_download 本地权重加载
  • 推理设备: Ascend NPU (npu:0)

2. 验证环境

项目版本/型号
NPUAscend910
CANN8.5.1
PyTorch2.9.0+cpu
torch-npu已安装
Python3.11.14
timm1.0.27

环境检查日志: logs/env_check.log

3. 推理运行

pip install -r requirements.txt
python inference.py

推理结果 (NPU Top-5):

  • Top-1: class_789 (0.0771)
  • Top-2: class_588 (0.0294)
  • Top-3: class_790 (0.0286)
  • Top-4: class_868 (0.0270)
  • Top-5: class_591 (0.0254)

日志保存在 logs/inference.log。

4. 精度验证

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

指标数值
max_abs_error0.130594
mean_abs_error0.027845
relative_error0.7485%
cosine_similarity0.999964
threshold1.0%
结果PASS
  • CPU Top-1: class_789
  • NPU Top-1: class_789
  • CPU Top-5: class_789, class_588, class_790, class_591, class_868
  • NPU Top-5: class_789, class_588, class_790, class_868, class_591
  • Top-1 match: True
  • Top-5 match: True

5. 性能参考

指标数值
avg_latency_ms4.708
min_latency_ms4.657
max_latency_ms4.760
p50_latency_ms4.724
p90_latency_ms4.760
p95_latency_ms4.760
images_per_sec212.39

日志保存在 logs/benchmark.log。

6. 精度评测说明

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

7. 自验证截图

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

8. 日志文件

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

9. 注意事项

  1. 权重通过 ModelScope snapshot_download 下载,不提交到 Git 仓库(已加入 .gitignore)。
  2. 运行前需确保 NPU 驱动和 CANN 环境已正确配置。
  3. 首次运行会自动下载模型权重,请保持网络畅通。
  4. 推理脚本中使用了 torch.npu.synchronize() 确保正确的时序测量。

10. 标签

#NPU #Ascend #Ascend910 #ImageClassification #timm