File size: 725 Bytes
e44aab7
 
 
 
346e07c
e44aab7
 
 
 
 
 
 
 
 
 
 
346e07c
e44aab7
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import gradio as gr
from transformers import pipeline

# Load the Hugging Face model
model = pipeline("image-classification", model="alkatraz445/deepfake_detection")

# Define the prediction function
def classify_image(image):
    results = model(image)
    return {result['label']: result['score'] for result in results}

# Create the Gradio interface
interface = gr.Interface(
    fn=classify_image,
    inputs=gr.Image(type="pil"),  # Accepts images in PIL format
    outputs=gr.Label(num_top_classes=2),  # Displays top two classifications with probabilities
    title="Deepfake image detector",
    description="Upload an image to determine whether it's real or deepfake.",
)

# Launch the Gradio app
interface.launch()