"""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'}")