将 timm ViT-Large/16(ImageNet-21k 预训练)适配至单卡昇腾 NPU(Ascend910)。模型输出 21843 个类别,基于 ImageNet-21k 数据集预训练。
| 项目 | 版本 |
|---|---|
| 硬件 | 华为 Ascend 910 |
| CANN | 8.5.1 |
| PyTorch | 2.x |
| torch_npu | latest |
| timm | latest |
| Python | 3.11 |
pip install -r requirements.txt
python download_test_image.py
python inference.py推理结果 (NPU Top-5):
日志保存在 logs/inference.log。
对单张测试图片进行 CPU 与 NPU 一致性验证:
| 指标 | 数值 |
|---|---|
| max_abs_error | 0.105127 |
| mean_abs_error | 0.028588 |
| relative_error | 0.1824% |
| cosine_similarity | 0.999999 |
| threshold | 1.0% |
| 结果 | PASS |
| 指标 | 数值 |
|---|---|
| 平均延迟 | 10.35 ms |
| 最小延迟 | 10.22 ms |
| 最大延迟 | 10.41 ms |
| P50 延迟 | 10.36 ms |
| P90 延迟 | 10.40 ms |
| P95 延迟 | 10.40 ms |
| 吞吐量 | 96.66 images/sec |
本项目包含单图 smoke consistency 验证,非官方 ImageNet 完整验证集评测。详细指标见第 4 节。
见 screenshots/self_verification.png
| 文件 | 说明 |
|---|---|
| logs/inference.log | 推理运行日志 |
| logs/accuracy.log | 精度验证日志 |
| logs/benchmark.log | 性能基准测试日志 |
pretrained=False + 本地加载