本项目将 ModelScope 上的 timm/inception_resnet_v2.tf_ens_adv_in1k 图片分类模型适配为可在单卡昇腾 NPU(Ascend910B)上运行的提交工程。
snapshot_download 下载本地权重,timm.create_model(pretrained=False) 创建模型结构并加载| 项目 | 版本/信息 |
|---|---|
| NPU 型号 | Ascend910 |
| npu-smi | 25.5.2 |
| PyTorch NPU | Ascend910_9362 |
| 框架 | timm + torch + torch_npu |
环境详情见 logs/env_check.log。
python inference.py推理脚本使用 model_utils.py 加载模型,通过 timm.data.resolve_model_data_config 自动获取预处理参数,在 npu:0 上执行真实推理。
推理结果摘要:
[1, 3, 299, 299][1, 1000]class_974(confidence 0.907000)class_974, class_980, class_460, class_820, class_979对单张测试图片进行 CPU 与 NPU 一致性验证:
| 指标 | 数值 |
|---|---|
| max_abs_error | 0.004367 |
| mean_abs_error | 0.000305 |
| relative_error | 0.0974% |
| cosine_similarity | 1.000000 |
| threshold | 1.0% |
| 结果 | PASS |
| 指标 | 数值 |
|---|---|
| Warm-up | 2 runs |
| Benchmark | 10 runs |
| avg latency | 0.025084 s |
| min latency | 0.024173 s |
| max latency | 0.026097 s |
| p50 latency | 0.024864 s |
| p90 latency | 0.026097 s |
| p95 latency | 0.026097 s |
| Throughput | 39.87 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 | 性能基准测试 |
logs/paths.txt | 模型与权重路径 |
snapshot_download 下载,不随工程提交。requirements.txt 中的依赖,且昇腾 NPU 驱动和 CANN 环境正常。#NPU