OpenFakeArena / app.py
aarodi's picture
Upload 2 files
faa850e
raw
history blame
1.54 kB
import gradio as gr
from PIL import Image
import random
def dummy_deepfake_detector(image: Image.Image, prompt: str) -> tuple[str, Image.Image, str]:
"""
Simulates a deepfake detector. Replace this logic with your real model.
"""
# Dummy logic: randomly decide real or fake
prediction = random.choice(["Real", "Fake"])
score = 1 if prediction == "Real" else 0 # Leaderboard dummy score
return f"Prediction: {prediction}", image, f"You: {score} point{'s' if score != 1 else ''}"
with gr.Blocks() as demo:
gr.Markdown("## Fool the Deepfake Detector")
gr.Markdown("Upload an image and fool the deepfake detection model. Give it a try!")
with gr.Row():
prompt_input = gr.Textbox(
label="Suggested prompt",
placeholder="e.g., A portrait photograph of Barack Obama delivering a speech...",
value="A portrait photograph of Barack Obama delivering a speech, with the United States flag in the background"
)
with gr.Row():
image_input = gr.Image(type="pil", label="", tool=None)
submit_btn = gr.Button("Upload")
with gr.Row():
prediction_output = gr.Text(label="Result")
image_output = gr.Image(label="", show_label=False)
leaderboard = gr.Text(label="Leaderboard")
submit_btn.click(fn=dummy_deepfake_detector,
inputs=[image_input, prompt_input],
outputs=[prediction_output, image_output, leaderboard])
if __name__ == "__main__":
demo.launch()