本项目将 timm/convnext_large.fb_in22k_ft_in1k 图片分类模型适配到单卡昇腾 NPU(Ascend910)上运行。
模型来源:ModelScope - timm/convnext_large.fb_in22k_ft_in1k
适配方式:使用 ModelScope snapshot_download 下载本地权重,通过 timm.create_model(pretrained=False) 创建模型并加载本地权重,确保在 NPU 上完成真实推理、精度一致性验证与性能基准测试。
| 项目 | 版本/信息 |
|---|---|
| NPU | Ascend910 |
| CANN | 8.5.1 |
| Python | 3.11.14 |
| PyTorch | 2.x |
| torch_npu | 适配 CANN 8.5.1 |
| timm | latest |
| modelscope | latest |
NPU 状态:npu_available=True, device=Ascend910_9362
pip install -r requirements.txt
python inference.py推理结果 (NPU Top-5):
日志保存在 logs/inference.log。
对单张测试图片进行 CPU 与 NPU 一致性验证:
| 指标 | 数值 |
|---|---|
| max_abs_error | 0.042462 |
| mean_abs_error | 0.005349 |
| relative_error | 0.9049% |
| cosine_similarity | 0.999970 |
| threshold | 1.0% |
| 结果 | PASS |
在单卡 Ascend910 NPU 上的性能基准(输入 [1, 3, 224, 224]):
| 指标 | 数值 |
|---|---|
| avg_time | 20.307 ms |
| min_time | 20.270 ms |
| max_time | 20.338 ms |
| p50_time | 20.310 ms |
| p90_time | 20.338 ms |
| p95_time | 20.338 ms |
| images_per_sec | 49.24 |
日志保存在 logs/benchmark.log。
本项目包含单图 smoke consistency 验证,非官方 ImageNet 完整验证集评测。详细指标见第 4 节。
见 screenshots/self_verification.png 与 screenshots/self_verification.txt。
| 日志 | 说明 |
|---|---|
logs/inference.log | NPU 推理结果 |
logs/accuracy.log | CPU-NPU 精度一致性 |
logs/benchmark.log | NPU 性能基准 |
logs/env_check.log | NPU 环境检查 |
logs/paths.txt | 模型路径记录 |
pretrained=False + 本地权重加载,不触发 HuggingFace 自动下载。.gitignore)。#NPU #Ascend #Ascend910 #ConvNeXt #timm #image-classification