鸟类识别模型,基于 ViT (Vision Transformer) 架构,适配 Ascend NPU (Ascend910) 进行推理。
| 文件 | 说明 |
|---|---|
inference.py | CPU/NPU 推理脚本,支持 --device cpu 或 --device npu |
compare_cpu_npu.py | CPU vs NPU 精度对比脚本 |
requirements.txt | Python 依赖 |
terminal_screenshot.png | 推理结果终端截图 |
pip install -r requirements.txtCPU 推理:
python3 inference.py --device cpuNPU 推理:
python3 inference.py --device npu| 设备 | 推理耗时 | Top-1 类别 | Top-1 置信度 |
|---|---|---|---|
| CPU | 663.62 ms | Least_Tern | N/A |
| NPU | 179.43 ms | Least_Tern | N/A |
NPU 加速比约为 3.7x。
python3 compare_cpu_npu.py| 指标 | 值 |
|---|---|
| CPU 推理时间 | 663.62 ms |
| NPU 推理时间 | 179.43 ms |
| NPU 加速比 | 3.7x |
| Top-1 匹配 | 是 |
| Max Logits Absolute Error | 0.04058575630187988 |
| Mean Logits Absolute Error | 0.008492983877658844 |
| Max Probability Absolute Error | 0.0009948797523975372 |
| Mean Probability Absolute Error | 2.276648774568457e-05 |
| Cosine Similarity (Logits) | 0.999955415725708 |
| L2 Error (Logits) | 0.011095765046775341 |
| 最大概率误差 | 0.0995% |
结论:NPU 与 CPU 推理结果误差 < 1%(最大概率误差为 0.0995%),精度符合要求。
精度结论:该模型已完成 Ascend NPU 适配部署,CPU 与 NPU 推理结果一致性验证通过,精度误差低于 1% 要求。

基于现有评测数据,CPU 与 NPU 的 余弦相似度 精度误差为 0.0045%,小于 1% 的精度要求。
本仓库提供完整的推理脚本,支持 CPU 和 NPU 双平台推理:
# NPU 推理
python3 inference.py --device npu
# CPU 推理
python3 inference.py --device cpu推理完成后会输出推理结果和耗时,表明模型在 NPU 上推理成功。