File size: 797 Bytes
b8bf0c0
 
 
54df4dd
 
b8bf0c0
54df4dd
 
 
 
 
 
b8bf0c0
54df4dd
b8bf0c0
54df4dd
b8bf0c0
54df4dd
 
 
b8bf0c0
54df4dd
b8bf0c0
 
54df4dd
 
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
import gradio as gr
from transformers import pipeline

# Pakai model yang masih tersedia (public)
classifier = pipeline("image-classification", model="orpatashnik/StyleGAN-nada-detector")

def detect_ai(image):
    results = classifier(image)
    label = results[0]['label']
    score = results[0]['score']
    if "real" in label.lower():
        return f"๐ŸŒ Foto Asli (confidence: {score:.2f})"
    else:
        return f"๐Ÿค– Gambar AI (confidence: {score:.2f})"

# Buat interface Gradio
demo = gr.Interface(
    fn=detect_ai,
    inputs=gr.Image(type="pil", label="Upload Gambar"),
    outputs=gr.Textbox(label="Hasil Deteksi"),
    title="AI Image Detector",
    description="Upload gambar untuk mendeteksi apakah gambar asli atau buatan AI."
)

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