本项目将 ModelScope 上的 timm/tresnet_l.miil_in1k 图片分类模型适配为可在单卡昇腾 NPU(Ascend910B)上运行的提交工程。
snapshot_download(主路径,禁止 HuggingFace 直连)timm.create_model(pretrained=False) + 本地 safetensors 加载| 项目 | 信息 |
|---|---|
| 硬件 | 单卡 Ascend910B (NPU) |
| PyTorch | torch 2.1.0+ |
| torch_npu | 已安装 |
| timm | 已安装 |
| modelscope | 已安装 |
| safetensors | 已安装 |
cd timm-tresnet_l.miil_in1k-NPU
pip install -r requirements.txt
python inference.py推理结果示例(Top-5):
class_980: 0.5933
class_970: 0.0797
class_912: 0.0237
class_340: 0.0237
class_867: 0.0212python eval_accuracy.py对单张测试图片进行 CPU 与 NPU 一致性验证:
| 指标 | 数值 |
|---|---|
| max_abs_error | 0.002823 |
| mean_abs_error | 0.000325 |
| relative_error | 0.0314% |
| cosine_similarity | 1.000000 |
| threshold | 1.0% |
| 结果 | PASS |
python benchmark.py| 指标 | 值 |
|---|---|
| 平均延迟 | 12.98 ms |
| 最小延迟 | 12.55 ms |
| 最大延迟 | 13.30 ms |
| P50 | 13.05 ms |
| P90 | 13.24 ms |
| P95 | 13.27 ms |
| 吞吐量 | 77.04 images/sec |
本项目仅包含 Smoke 一致性检查(CPU vs NPU logits 对比),非官方精度评测。完整精度评测需使用 ImageNet 验证集。
详见 screenshots/self_verification.txt 和 screenshots/self_verification.png。
logs/inference.log — 推理结果日志logs/accuracy.log — 精度一致性验证日志logs/benchmark.log — 性能基准测试日志logs/env_check.log — 环境检查日志logs/paths.txt — 模型下载路径记录snapshot_download 作为主下载方式,不使用 HuggingFace 直连timm.create_model(pretrained=False) 创建结构后本地加载,无 fallback#NPU #timm #tresnet #image-classification #ascend