Spaces:
Sleeping
Sleeping
| 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() | |