File size: 1,009 Bytes
2f69448
2d38802
 
b8bf0c0
2d38802
 
b8bf0c0
2d38802
 
2f69448
2d38802
 
 
 
d748331
2d38802
 
b8bf0c0
2d38802
2f69448
2d38802
871fbb3
2d38802
 
 
 
 
 
c1ebb63
d748331
2d38802
 
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
import gradio as gr
from transformers import pipeline
from PIL import Image

# Gunakan model deteksi publik
classifier = pipeline("image-classification", model="dima806/deepfake_vs_real_image_detection")

def detect(image):
    # image dari Gradio
    results = classifier(image)
    # hasil tertinggi
    best = max(results, key=lambda x: x['score'])
    label = best['label']
    confidence = best['score'] * 100

    if "fake" in label.lower() or "generated" in label.lower() or "ai" in label.lower():
        verdict = "⚠️ Kemungkinan besar Gambar AI / Fake"
    else:
        verdict = "✅ Kemungkinan besar Foto Asli"

    return f"{verdict}\n\nLabel: {label}\nConfidence: {confidence:.2f}%"

app = gr.Interface(
    fn=detect,
    inputs=gr.Image(type="pil", label="Upload Foto"),
    outputs=gr.Textbox(label="Hasil Deteksi"),
    title="Detektor Foto vs AI",
    description="Unggah foto realistik untuk mendeteksi apakah foto asli atau hasil AI."
)

if __name__ == "__main__":
    app.launch()