Spaces:
Sleeping
Sleeping
File size: 915 Bytes
64a94a9 6394c51 f0ff41c d0ca36e 64a94a9 d0ca36e 64a94a9 ed4c5f6 d0ca36e 958932b d0ca36e 6394c51 64a94a9 d0ca36e 6394c51 64a94a9 6394c51 d0ca36e 64a94a9 19e6f0c d0ca36e |
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
# Model deteksi AI vs Asli (tanpa moondream2, biar tidak error trust_remote_code)
model_ids = [
"umm-maybe/AI-image-detector",
"roberta-base-openai-detector"
]
detectors = [pipeline("image-classification", model=m) for m in model_ids]
def detect_image(image):
results = []
for det in detectors:
preds = det(image)
if isinstance(preds, list) and len(preds) > 0:
label = preds[0]["label"]
score = preds[0]["score"]
results.append(f"{label}: {score:.2f}")
return "\n".join(results)
iface = gr.Interface(
fn=detect_image,
inputs=gr.Image(type="pil"),
outputs="text",
title="AI vs Real Image Detector",
description="Upload a photo to check if it's AI-generated or a real one using multiple models."
)
if __name__ == "__main__":
iface.launch()
|