Open Deepfake Detection - NPU 适配
模型信息
环境配置
| 组件 | 版本 |
|---|
| PyTorch | 2.9.0 |
| torch_npu | 2.9.0.post1 |
| 昇腾 CANN | 8.5.1 |
| NPU | 昇腾 910B4(29.5GB) |
| Transformers | 4.57.6 |
文件说明
| 文件 | 描述 |
|---|
inference.py | 单图像推理 + 基准测试模式 |
accuracy_run.py | CPU 与 NPU 精度验证 |
accuracy_run_perf.py | NPU 性能基准测试 |
result.json | 推理结果示例 |
accuracy_report.json | 精度验证报告 |
perf_report.json | 性能基准测试报告 |
使用方法
单图像推理
python3 inference.py \
--model_path /path/to/open-deepfake-detection \
--image /path/to/face_image.jpg \
--output result.json
性能基准测试
python3 accuracy_run_perf.py /path/to/open-deepfake-detection 10 perf_report.json
准确性验证
python3 accuracy_run.py \
--model_path /path/to/open-deepfake-detection \
--output accuracy_report.json
性能结果(昇腾 910B4)
| 指标 | 数值 |
|---|
| 平均延迟 | 10.37 ms |
| 中位延迟 | 10.28 ms |
| P90 延迟 | 10.58 ms |
| P99 延迟 | 11.40 ms |
| 最小延迟 | 10.13 ms |
| 最大延迟 | 11.93 ms |
| 吞吐量 | 96.44 img/s |
示例输出
{
"predicted_class_id": 1,
"predicted_label": "Real",
"probabilities": [0.4700, 0.5300],
"inference_time_ms": 16409.99
}
首次推理包含 JIT 编译开销(约 16 秒)。后续推理平均耗时约 10.4 毫秒。
注意事项
- 该模型是深度伪造检测的开集变体(而
deepfake-detector-model-v1 是闭集版本)
- 两个模型具有相同的架构和参数数量
open-deepfake-detection 的吞吐量略高(在 910B4 上约为 96 张/秒,而对比模型约为 90 张/秒)