Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from transformers import pipeline | |
| # Gunakan model publik yang valid | |
| classifier = pipeline("image-classification", model="dima806/deepfake_vs_real_image_detection") | |
| def detect_ai(image): | |
| # image dari Gradio | |
| results = classifier(image) | |
| label = results[0]['label'] | |
| score = results[0]['score'] | |
| # format output | |
| if "Real" in label: | |
| return f"β Foto Asli (confidence: {score:.2f})" | |
| else: | |
| return f"π€ Gambar AI / Fake (confidence: {score:.2f})" | |
| # Interface Gradio | |
| 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 foto asli atau buatan AI.", | |
| allow_flagging="never" | |
| ) | |
| if __name__ == "__main__": | |
| demo.launch() | |