g
gcw_C8PI9e90/deepfake-detector-model-v1-npu
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

Deepfake Detector Model v1 - NPU 适配

Model Info

  • Original Model: prithivMLmods/deepfake-detector-model-v1
  • Architecture: SiglipForImageClassification (SigLIP2 fine-tuned)
  • Parameters: 92,885,762
  • Labels: {0: "Fake", 1: "Real"}
  • Task: Binary deepfake image classification

Environment

ComponentVersion
PyTorch2.9.0
torch_npu2.9.0.post1
Ascend CANN8.5.1
NPUAscend 910B4 (29.5GB)
Transformers4.57.6

Files

FileDescription
inference.pySingle-image inference + benchmark mode
accuracy_run.pyCPU vs NPU accuracy validation
accuracy_run_perf.pyNPU performance benchmark
result.jsonSample inference result
accuracy_report.jsonAccuracy validation report
perf_report.jsonPerformance benchmark report

Usage

Single Image Inference

python3 inference.py \
  --model_path /path/to/deepfake-detector-model-v1 \
  --image /path/to/face_image.jpg \
  --output result.json

Performance Benchmark

python3 accuracy_run_perf.py /path/to/deepfake-detector-model-v1 10 perf_report.json

Accuracy Validation

python3 accuracy_run.py \
  --model_path /path/to/deepfake-detector-model-v1 \
  --output accuracy_report.json

Performance Results (Ascend 910B4)

MetricValue
Avg Latency11.16 ms
Median Latency11.07 ms
P90 Latency11.42 ms
P99 Latency12.59 ms
Min Latency10.88 ms
Max Latency13.36 ms
Throughput89.59 img/s

Accuracy Results

MetricValue
CPU vs NPU Prediction Match✅ 5/5
Max Relative Error0.0146%
Avg Relative Error0.0077%
Cosine Similarity1.0
Status✅ PASS

精度结论:该模型已完成 Ascend NPU 适配部署,CPU 与 NPU 推理结果一致性验证通过,精度误差低于 1% 要求。

Sample Output

{
  "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 上推理成功。