本项目将 timm/mobilenetv4_hybrid_medium.e500_r224_in1k 图片分类模型适配到华为昇腾 NPU (Ascend910) 上运行。
timm.create_model(..., pretrained=False) + ModelScope 本地权重加载| 项目 | 版本/信息 |
|---|---|
| NPU | Ascend910 |
| CANN | 8.5.1 |
| torch | 2.x |
| torch_npu | 2.x |
| timm | latest |
环境检查日志: logs/env_check.log
pip install -r requirements.txt
python inference.py推理结果 (NPU Top-5):
日志保存在 logs/inference.log。
对单张测试图片进行 CPU 与 NPU 一致性验证:
| 指标 | 数值 |
|---|---|
| max_abs_error | 0.007448 |
| mean_abs_error | 0.001374 |
| relative_error | 0.0161% |
| cosine_similarity | 1.000000 |
| threshold | 1.0% |
| 结果 | PASS |
| 指标 | 数值 |
|---|---|
| avg_time | 14.1081 ms |
| min_time | 13.9117 ms |
| max_time | 14.3674 ms |
| p50_time | 14.1427 ms |
| p90_time | 14.3674 ms |
| p95_time | 14.3674 ms |
| images_per_sec | 70.88 |
日志保存在 logs/benchmark.log。
本项目包含单图 smoke consistency 验证,非官方 ImageNet 完整验证集评测。详细指标见第 4 节。
见 screenshots/self_verification.png 和 screenshots/self_verification.txt。
logs/env_check.log - 环境检查logs/inference.log - 推理结果logs/accuracy.log - 精度一致性验证logs/benchmark.log - 性能基准测试snapshot_download 下载,首次运行需联网。pretrained=True 从 HuggingFace 自动下载。timm.data.resolve_model_data_config 获取官方预处理参数。torch.npu.synchronize() 保证时序正确。#NPU #Ascend #Ascend910 #ImageClassification #timm