本项目将 timm/mobilenetv3_small_100.lamb_in1k 图像分类模型适配到单卡昇腾 NPU(Ascend910)上运行。模型基于 MobileNetV3-Small 架构,在 ImageNet-1k 上训练,输出 1000 维分类 logits。
pip install -r requirements.txt
python inference.py推理结果 (NPU Top-5):
日志保存在 logs/inference.log。
对单张测试输入进行 CPU 与 NPU 一致性验证:
| 指标 | 数值 |
|---|---|
| max_abs_error | 0.019917 |
| mean_abs_error | 0.004277 |
| relative_error | 0.3021% |
| cosine_similarity | 0.999994 |
| threshold | 1.0% |
| 结果 | PASS |
| 指标 | 数值 |
|---|---|
| avg_latency_ms | 5.352 |
| min_latency_ms | 5.128 |
| max_latency_ms | 5.538 |
| p50_latency_ms | 5.364 |
| p90_latency_ms | 5.440 |
| p95_latency_ms | 5.489 |
| throughput_ips | 186.85 |
测试条件:单卡 Ascend910,输入尺寸 [1, 3, 224, 224],预热 2 次 + 正式 10 次。
本项目包含单输入 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 性能基准 |
snapshot_download 下载,严禁使用 HuggingFace 自动下载。pretrained=False,通过本地 model.safetensors 加载权重。timm.data.resolve_model_data_config 自动解析为 224x224。#NPU