本项目将 timm/convnext_base.fb_in1k 图片分类模型适配到昇腾 NPU (Ascend910) 上运行。使用 ModelScope 下载权重,通过 timm.create_model(pretrained=False) 加载本地权重,完成推理验证、CPU-NPU 精度一致性检查和性能基准测试。
| 项目 | 版本/信息 |
|---|---|
| NPU | Ascend910 |
| CANN | 8.5.1 |
| PyTorch | 2.x |
| torch_npu | 适配版本 |
| 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.007584 |
| mean_abs_error | 0.001585 |
| relative_error | 0.8789% |
| cosine_similarity | 0.999974 |
| threshold | 1.0% |
| 结果 | PASS |
| 指标 | 数值 |
|---|---|
| avg_time | 0.0148 s |
| min_time | 0.0148 s |
| max_time | 0.0148 s |
| p50_time | 0.0148 s |
| p90_time | 0.0148 s |
| p95_time | 0.0148 s |
| images_per_sec | 67.62 |
日志保存在 logs/benchmark.log。
本项目包含单图 smoke consistency 验证,非官方 ImageNet 完整验证集评测。详细指标见第 4 节。
见 screenshots/self_verification.png。
logs/env_check.log — 环境检查logs/inference.log — 推理结果logs/accuracy.log — 精度一致性logs/benchmark.log — 性能基准logs/paths.txt — 模型路径pretrained=False 并通过 ModelScope snapshot_download 加载本地权重,严禁使用 HuggingFace 自动下载。.bin、.safetensors、.pth 等)请勿提交到 Git 仓库。torch.npu.is_available() 返回 True。#NPU #Ascend #Ascend910 #timm #convnext #image-classification