File size: 952 Bytes
9d5ab54
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""Quick API test for DeepSight."""
import io
import requests
from PIL import Image

img = Image.new("RGB", (256, 256))
for x in range(256):
    for y in range(256):
        img.putpixel((x, y), (x, y, (x + y) % 256))

buf = io.BytesIO()
img.save(buf, "JPEG", quality=85)
buf.seek(0)

print("Sending test image to API...")
resp = requests.post(
    "http://localhost:8000/api/analyze",
    files={"file": ("test.jpg", buf, "image/jpeg")},
    timeout=180,
)
print(f"Status: {resp.status_code}")
if resp.status_code == 200:
    data = resp.json()
    v = data.get("verdict", {})
    print(f"Verdict: {v.get('label')} (score: {v.get('score')})")
    print(f"Time: {data.get('total_time_ms')}ms")
    for k in ("cnn", "ela", "frequency", "noise", "metadata"):
        a = data.get("analyzers", {}).get(k, {})
        print(f"  {k}: score={a.get('score', '?')} {'ERROR' if a.get('error') else 'OK'}")
else:
    print(f"Error response: {resp.text[:1000]}")