File size: 2,211 Bytes
634e783
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
"""Validate the exact WaveRep integration path app.py uses.

app.py calls:
  module.WaveRepDetector(model_dir=str(project_root / "models" / "video" / "waverep"))
  waverep.predict_from_video_path(video_path, threshold)
  response fields: verdict, fake_probability, threshold, model
"""
import os
import sys
from pathlib import Path

project_root = Path(__file__).parent
sys.path.insert(0, str(project_root))
sys.path.insert(0, str(project_root / 'sdk'))

import importlib.util
spec = importlib.util.spec_from_file_location(
    'waverep_detector', project_root / 'models' / 'video' / 'waverep' / 'detector.py'
)
module = importlib.util.module_from_spec(spec)
sys.modules['waverep_detector'] = module
spec.loader.exec_module(module)

print("=" * 70)
print("WaveRep app.py Integration Path Validation")
print("=" * 70)

# Exact call app.py makes:
waverep_detector = module.WaveRepDetector(model_dir=str(project_root / "models" / "video" / "waverep"))
waverep_detector.load()
print(f"  model name: {waverep_detector._model_name}")
print(f"  fake_threshold: {waverep_detector.fake_threshold}")

test_videos = [
    ("REAL", "real_videos/video_2026-07-10_12-23-49.mp4", "real"),
    ("FAKE", "D:/pika/pika/-_hbPLsZvvo_19_25.mp4", "fake"),
    ("FAKE", "D:/veo/veo/veo_example_041_sunflower.mp4", "fake"),
]

print(f"\n{'Type':<6s} {'Video':<35s} {'fake_prob':>9s} {'thresh':>7s} {'model':>8s} {'verdict':>8s}")
print("-" * 85)

for vtype, path, expected in test_videos:
    if not path.startswith(('D:', 'C:')):
        path = str(project_root / path)
    if not os.path.exists(path):
        print(f"{vtype:<6s} {os.path.basename(path):<35s} MISSING")
        continue

    # app.py calls predict_from_video_path(temp_path, threshold)
    result = waverep_detector.predict_from_video_path(path, 0.5)

    prob = result.probability
    verdict = result.class_name
    model = result.model
    # The response contract content:
    fake_probability = round(float(prob), 4)
    threshold = round(float(getattr(result, "threshold", 0.50)), 4)

    ok = verdict == expected
    print(f"{vtype:<6s} {os.path.basename(path):<35s} {fake_probability:9.4f} {threshold:7.2f} {model:>8s} {verdict:>8s} {'OK' if ok else 'FAIL'}")