MetaQu's picture
Update app.py
c75219f verified
raw
history blame
863 Bytes
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()