Spaces:
Sleeping
Sleeping
File size: 937 Bytes
0d0abc7 15ef8ac 0d0abc7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
from fastai.vision.all import *
import gradio as gr
# Load your trained model
learn = load_learner("deepfake_model.pkl")
# Define the prediction function
def predict_image(img):
pred_class, pred_idx, probs = learn.predict(img)
return {
"Predicted Class": str(pred_class),
"Confidence Score": float(probs[pred_idx])
}
# Create the Gradio interface
interface = gr.Interface(
fn=predict_image,
inputs=gr.Image(type="pil", label="Upload an Image"),
outputs=[
gr.Label(label="Predicted Class"),
gr.Number(label="Confidence Score")
],
title="Deepfake Detection App",
description="Upload a face image to check if it’s manipulated or original."
)
# Run the app
if __name__ == "__main__":
interface.launch()
# This code creates a simple web app using Gradio to classify images as deepfake or real.
# The model is loaded from a file named "deepfake_detection.pkl". |