{0: "Fake", 1: "Real"}| Component | Version |
|---|---|
| PyTorch | 2.9.0 |
| torch_npu | 2.9.0.post1 |
| Ascend CANN | 8.5.1 |
| NPU | Ascend 910B4 (29.5GB) |
| Transformers | 4.57.6 |
| File | Description |
|---|---|
inference.py | Single-image inference + benchmark mode |
accuracy_run.py | CPU vs NPU accuracy validation |
accuracy_run_perf.py | NPU performance benchmark |
result.json | Sample inference result |
accuracy_report.json | Accuracy validation report |
perf_report.json | Performance benchmark report |
python3 inference.py \
--model_path /path/to/deepfake-detector-model-v1 \
--image /path/to/face_image.jpg \
--output result.jsonpython3 accuracy_run_perf.py /path/to/deepfake-detector-model-v1 10 perf_report.jsonpython3 accuracy_run.py \
--model_path /path/to/deepfake-detector-model-v1 \
--output accuracy_report.json| Metric | Value |
|---|---|
| Avg Latency | 11.16 ms |
| Median Latency | 11.07 ms |
| P90 Latency | 11.42 ms |
| P99 Latency | 12.59 ms |
| Min Latency | 10.88 ms |
| Max Latency | 13.36 ms |
| Throughput | 89.59 img/s |
| Metric | Value |
|---|---|
| CPU vs NPU Prediction Match | ✅ 5/5 |
| Max Relative Error | 0.0146% |
| Avg Relative Error | 0.0077% |
| Cosine Similarity | 1.0 |
| Status | ✅ PASS |
精度结论:该模型已完成 Ascend NPU 适配部署,CPU 与 NPU 推理结果一致性验证通过,精度误差低于 1% 要求。
{
"predicted_class_id": 1,
"predicted_label": "Real",
"probabilities": [0.4700, 0.5300],
"inference_time_ms": 16505.20
}First inference includes JIT compilation overhead (~16s). Subsequent inferences average ~11ms.
基于现有评测数据,CPU 与 NPU 的 余弦相似度 精度误差为 0.0%,小于 1% 的精度要求。
本仓库提供完整的推理脚本,支持 CPU 和 NPU 双平台推理:
# NPU 推理
python3 inference.py --device npu
# CPU 推理
python3 inference.py --device cpu推理完成后会输出推理结果和耗时,表明模型在 NPU 上推理成功。