File size: 966 Bytes
3539678
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""
Example usage of Ensemble Deepfake Detector
"""

from ensemble_model import EnsembleDeepfakeDetector

# Load ensemble
print("Loading ensemble...")
detector = EnsembleDeepfakeDetector.from_pretrained(device='cuda')

# Example 1: Single image
print("\nExample 1: Single image prediction")
score, is_fake = detector.predict('test.jpg')
print(f"  Score: {score:.4f}")
print(f"  Prediction: {'FAKE' if is_fake else 'REAL'}")

# Example 2: Different thresholds
print("\nExample 2: Testing different thresholds")
for thresh in [0.05, 0.1163, 0.5]:
    detector.set_threshold(thresh)
    score, is_fake = detector.predict('test.jpg')
    print(f"  Threshold {thresh:.4f}: Score={score:.4f}, Fake={is_fake}")

# Example 3: Batch processing
print("\nExample 3: Batch processing")
images = ['img1.jpg', 'img2.jpg', 'img3.jpg']
for img_path in images:
    score, is_fake = detector.predict(img_path)
    print(f"  {img_path}: {score:.4f} - {'FAKE' if is_fake else 'REAL'}")