File size: 1,012 Bytes
4f48a4e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import sys
import os
from PIL import Image

def test():
    print("Testing Image Authenticity lazy-load and predict...")
    
    # Create a dummy image (e.g. noise)
    import numpy as np
    dummy_img = Image.fromarray(np.random.randint(0, 256, (400, 400, 3), dtype=np.uint8))
    
    from app import get_image_detector
    
    detector = get_image_detector()
    result, visuals = detector.predict_with_visuals(
        dummy_img,
        include_gradcam=True,
        include_fft=True,
        include_result_card=False
    )
    
    print("\n--- TEST RESULT ---")
    print(f"Label: {result['label']}")
    print(f"Fake Prob: {result['fake_prob']*100:.1f}%")
    print(f"Real Prob: {result['real_prob']*100:.1f}%")
    print(f"Scores: {result['scores']}")
    print(f"Has GradCAM: {visuals.get('gradcam') is not None}")
    print(f"Has FFT: {visuals.get('fft_spectrum') is not None}")
    print("-------------------")
    print("SUCCESS: Pipeline runs correctly.")

if __name__ == "__main__":
    test()