seyma9gulsen commited on
Commit
0d0abc7
·
1 Parent(s): 75b4925

first commit

Browse files
app.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastai.vision.all import *
2
+ import gradio as gr
3
+
4
+ # Load your trained model
5
+ learn = load_learner("xception_deepfake_model.pkl")
6
+
7
+ # Define the prediction function
8
+ def predict_image(img):
9
+ pred_class, pred_idx, probs = learn.predict(img)
10
+ return {
11
+ "Predicted Class": str(pred_class),
12
+ "Confidence Score": float(probs[pred_idx])
13
+ }
14
+
15
+ # Create the Gradio interface
16
+ interface = gr.Interface(
17
+ fn=predict_image,
18
+ inputs=gr.Image(type="pil", label="Upload an Image"),
19
+ outputs=[
20
+ gr.Label(label="Predicted Class"),
21
+ gr.Number(label="Confidence Score")
22
+ ],
23
+ title="Deepfake Detection App",
24
+ description="Upload a face image to check if it’s manipulated or original."
25
+ )
26
+
27
+ # Run the app
28
+ if __name__ == "__main__":
29
+ interface.launch()
30
+
31
+ # This code creates a simple web app using Gradio to classify images as deepfake or real.
32
+ # The model is loaded from a file named "deepfake_detection.pkl".
deepfake_detection.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ fastai
2
+ torch
3
+ gradio
4
+ transformers
5
+ datasets
xception_deepfake_model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e595377457a33e2aed9302a5771b910e2a6746436cf94b11bad3799e8cdb30e6
3
+ size 83737280