本项目将 timm 库中的 MobileNetV4 Hybrid Large 图像分类模型适配到华为昇腾 NPU (Ascend910),使用 ModelScope snapshot_download 下载权重,timm.create_model(pretrained=False) 加载本地权重。
| 项目 | 配置 |
|---|---|
| NPU | Ascend910 |
| OS | Linux |
| Python | 3.x |
| PyTorch | 2.x |
| torch_npu | 2.x |
| timm | latest |
pip install -r requirements.txt
python inference.py推理结果 (NPU Top-5):
日志保存在 logs/inference.log。
python eval_accuracy.py对单张测试图片进行 CPU 与 NPU 一致性验证:
| 指标 | 数值 |
|---|---|
| max_abs_error | 0.073730 |
| mean_abs_error | 0.053129 |
| relative_error | 0.3675% |
| cosine_similarity | 1.000000 |
| threshold | 1.0% |
| 结果 | PASS |
单卡 Ascend910,batch_size=1,384x384 输入:
| 指标 | 值 |
|---|---|
| 平均延迟 | 16.1ms |
| 最小延迟 | 15.8ms |
| 最大延迟 | 16.3ms |
| P50 | 16.2ms |
| P90 | 16.3ms |
| P95 | 16.3ms |
| 吞吐量 | 62.05 images/sec |
Smoke 验证精度 (非官方评测):
见 screenshots/self_verification.png
| 文件 | 说明 |
|---|---|
| logs/inference.log | 推理验证日志 |
| logs/accuracy.log | 精度验证日志 |
| logs/benchmark.log | 性能基准日志 |
| logs/env_check.log | 环境检查日志 |
#NPU #Ascend910 #timm #MobileNetV4 #ImageClassification #ModelScope