pip install -r requirements.txt
# requirements.txt 包含:
# paddlepaddle==3.0.0
# torch==2.9.0
# torch_npu==2.9.0.post1
# torchvision==0.24.0
# pillow>=10.0.0
# numpy>=1.24.0
# modelscope>=1.22.0
# huggingface_hub>=0.25.0python inference.py
# 或指定输入
python inference.py --input /path/to/doc.jpg
# 验证 CPU-NPU 一致性
python inference.py --mode validate
# 性能测试
python inference.py --mode benchmarkprobs: [0.96745837 0.01179227 0.00988955 0.01085978]
Predicted: 0 (id 0) with score 0.9675
0: 0.9675
90: 0.0118
180: 0.0099
270: 0.0109probs: [0.96745694 0.0117917 0.00989047 0.01086094]Avg latency: 5.19 ms
Min: 5.10 ms, Max: 5.35 ms
P50: 5.17 ms, P90: 5.34 ms, P95: 5.35 ms
Throughput: 192.62 images/s (batch 1)
NPU memory free 62058.9 MB, total 62740.0 MBassets/agent_workflow.png - 完整适配流程日志assets/npu_device_call.png - npu-smi 与 torch.npu 设备调用assets/model_result.png - 默认推理结果与 PASS