Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from transformers import pipeline | |
| classifier = pipeline("image-classification", model="dima806/deepfake_vs_real_image_detection") | |
| def detect_ai(image): | |
| results = classifier(image) | |
| output_str = "Hasil Deteksi:\n" | |
| for r in results: | |
| output_str += f"- {r['label']}: {r['score']:.2f}\n" | |
| best = max(results, key=lambda x: x['score']) | |
| if "real" in best['label'].lower(): | |
| output_str = f"β Foto Asli (confidence: {best['score']:.2f})\n\n" + output_str | |
| else: | |
| output_str = f"π€ Gambar AI / Fake (confidence: {best['score']:.2f})\n\n" + output_str | |
| return output_str | |
| demo = gr.Interface( | |
| fn=detect_ai, | |
| inputs=gr.Image(type="pil", label="Upload Gambar"), | |
| outputs=gr.Textbox(label="Hasil Deteksi"), | |
| title="AI vs Real Image Detector", | |
| description="Upload gambar untuk mengecek apakah gambar asli atau buatan AI." | |
| ) | |
| if __name__ == "__main__": | |
| demo.launch() | |