Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from transformers import pipeline | |
| from PIL import Image | |
| # Gunakan model PUBLIC yang terbuka | |
| classifier = pipeline("image-classification", model="umm-maybe/ai-image-detector") | |
| def detect_ai(image): | |
| results = classifier(image) | |
| label = results[0]['label'] | |
| confidence = results[0]['score'] * 100 | |
| if label.lower() in ["fake", "ai-generated"]: | |
| return f"π¨ Kemungkinan besar AI Generated\nLabel: {label}\nConfidence: {confidence:.2f}%" | |
| else: | |
| return f"β Kemungkinan besar Foto Asli\nLabel: {label}\nConfidence: {confidence:.2f}%" | |
| demo = gr.Interface( | |
| fn=detect_ai, | |
| inputs=gr.Image(type="pil"), | |
| outputs="text", | |
| title="Deteksi Foto AI vs Asli", | |
| description="Upload foto untuk mengetahui apakah ini foto asli atau hasil AI-generated." | |
| ) | |
| demo.launch() | |