本项目将 timm/swinv2_tiny_window8_256.ms_in1k 图片分类模型适配到昇腾 NPU (Ascend910) 上运行。
timm.create_model(pretrained=False) + ModelScope 本地权重加载| 项目 | 版本/信息 |
|---|---|
| NPU | Ascend910 |
| CANN | 8.5.1 |
| PyTorch | 2.x |
| torch_npu | 已安装 |
| timm | 已安装 |
pip install -r requirements.txt
python inference.py推理结果 (NPU Top-5):
日志保存在 logs/inference.log。
对单张测试图片进行 CPU 与 NPU 一致性验证:
| 指标 | 数值 |
|---|---|
| max_abs_error | 0.019160 |
| mean_abs_error | 0.002397 |
| relative_error | 0.4208% |
| cosine_similarity | 0.999993 |
| threshold | 1.0% |
| 结果 | PASS |
| 指标 | 数值 |
|---|---|
| avg_latency | 0.013031 s |
| min_latency | 0.012491 s |
| max_latency | 0.013376 s |
| p50_latency | 0.013182 s |
| p90_latency | 0.013376 s |
| p95_latency | 0.013376 s |
| 吞吐量 | 76.74 images/sec |
本项目包含单图 smoke consistency 验证,非官方 ImageNet 完整验证集评测。详细指标见第 4 节。
见 screenshots/self_verification.png 和 screenshots/self_verification.txt。
| 文件 | 说明 |
|---|---|
logs/env_check.log | NPU 环境检查日志 |
logs/inference.log | NPU 推理日志 |
logs/accuracy.log | CPU-NPU 精度一致性日志 |
logs/benchmark.log | NPU 性能基准测试日志 |
snapshot_download 下载,严禁使用 timm.create_model(..., pretrained=True) 从 HuggingFace 自动下载。timm.data.resolve_model_data_config 自动解析模型预处理配置,确保输入尺寸与模型训练时一致(256x256)。module. 前缀和常见的 state_dict 嵌套键(state_dict, model, ema, model_state)。.bin, .safetensors, .pth, .pt, .ckpt, .onnx 均已通过 .gitignore 排除)。#NPU #Ascend #Ascend910 #timm #SwinTransformerV2 #ImageClassification