本项目将 timm/resnet34.gluon_in1k 图片分类模型适配为可在单卡昇腾 NPU(Ascend910B)上运行的提交工程。
timm.create_model(pretrained=False) 创建模型结构,通过 ModelScope snapshot_download 下载本地权重并加载| 项目 | 版本/型号 |
|---|---|
| NPU | Ascend910 |
| CANN | 8.5.1 |
| PyTorch | 2.x |
| torch_npu | 适配版本 |
| timm | 1.0.27 |
pip install -r requirements.txt
python inference.py推理脚本加载本地权重并在 NPU 上执行单图推理,输出 Top-5 预测结果。
对单张测试图片进行 CPU 与 NPU 一致性验证:
| 指标 | 数值 |
|---|---|
| max_abs_error | 0.001109 |
| mean_abs_error | 0.000257 |
| relative_error | 0.0297% |
| cosine_similarity | 1.000000 |
| threshold | 1.0% |
| 结果 | PASS |
| 指标 | 数值 |
|---|---|
| avg_latency_ms | 6.350 |
| min_latency_ms | 6.259 |
| max_latency_ms | 6.945 |
| p50_ms | 6.289 |
| p90_ms | 6.374 |
| p95_ms | 6.660 |
| images_per_sec | 157.48 |
本项目包含单图 smoke consistency 验证,非官方 ImageNet 完整验证集评测。详细指标见第 4 节。
见 screenshots/self_verification.png。
| 日志 | 说明 |
|---|---|
logs/env_check.log | NPU 环境检查 |
logs/inference.log | NPU 推理结果 |
logs/accuracy.log | CPU-NPU 精度一致性 |
logs/benchmark.log | NPU 性能基准 |
modelscope 自动下载。*.bin, *.safetensors, *.pth, *.pt, *.ckpt, *.onnx 提交到仓库。pretrained=False 创建模型结构,仅通过 ModelScope 本地路径加载权重。