本项目将 timm/convnextv2_base.fcmae_ft_in1k 图片分类模型适配到昇腾 NPU (Ascend910)。
模型使用 timm 库构建,通过 ModelScope snapshot_download 下载本地权重,timm.create_model(pretrained=False) 加载,确保不触发 HuggingFace 自动下载。
| 项目 | 版本/型号 |
|---|---|
| NPU | Ascend910 |
| CANN | 8.5.1 |
| npu-smi | 25.5.2 |
| PyTorch | torch_npu available, device=Ascend910_9362 |
pip install -r requirements.txt
python inference.py推理结果 (NPU Top-5):
日志保存在 logs/inference.log。
对单张测试图片进行 CPU 与 NPU 一致性验证:
| 指标 | 数值 |
|---|---|
| max_abs_error | 0.022091 |
| mean_abs_error | 0.002872 |
| relative_error | 0.5473% |
| cosine_similarity | 0.999991 |
| threshold | 1.0% |
| 结果 | PASS |
| 指标 | 数值 |
|---|---|
| warmup_runs | 2 |
| benchmark_runs | 10 |
| avg_latency_ms | 16.65 |
| min_latency_ms | 16.60 |
| max_latency_ms | 16.70 |
| p50_latency_ms | 16.65 |
| p90_latency_ms | 16.68 |
| p95_latency_ms | 16.68 |
| images_per_sec | 60.06 |
本项目包含单图 smoke consistency 验证,非官方 ImageNet 完整验证集评测。详细指标见第 4 节。
见 screenshots/self_verification.png 和 screenshots/self_verification.txt。
logs/inference.log — 推理输出logs/accuracy.log — 精度验证结果logs/benchmark.log — 性能基准测试结果logs/env_check.log — NPU 环境检查logs/stage0.log — 模型可用性预检timm.data.resolve_model_data_config 自动获取模型对应的预处理配置。#NPU #Ascend #Ascend910 #timm #convnextv2 #image-classification