Wvolf commited on
Commit
cd405a5
1 Parent(s): 6d006c8

Upload 3 files

Browse files
Files changed (3) hide show
  1. AI POPE.jpg +0 -0
  2. app.py +50 -0
  3. deepfake_detection_model.h5 +3 -0
AI POPE.jpg ADDED
app.py ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ import cv2
3
+ import gradio as gr
4
+ from tensorflow.keras.utils import img_to_array
5
+ from tensorflow.keras.models import load_model
6
+ import os
7
+
8
+ model = load_model(r'deepfake_detection_model.h5')
9
+
10
+ def predict_image(img):
11
+
12
+ x = img_to_array(img)
13
+
14
+ x = cv2.resize(x, (256, 256), interpolation=cv2.INTER_AREA)
15
+
16
+ x /= 255.0
17
+
18
+ x = np.expand_dims(x, axis=0)
19
+
20
+ prediction = np.argmax(model.predict(x), axis=1)
21
+
22
+ if prediction == 0:
23
+ return 'Fake Image'
24
+ else:
25
+ return 'Real Image'
26
+
27
+
28
+ # Define the Gradio Interface with the desired title and description
29
+
30
+ description_html = """
31
+ <p>This model was trained by Rudolf Enyimba in partial fulfillment of the requirements
32
+ of Solent University for the degree of MSc Artificial Intelligence and Data Science</p>
33
+ <p>This model was trained to detect deepfake images.</p>
34
+ <p>The model achieved an accuracy of <strong>91%</strong> on the test set.</p>
35
+ <p>Upload a face image or pick from the samples below to test model accuracy</p>
36
+ """
37
+
38
+ # Define example images and their true labels for users to choose from
39
+ example_data = ['AI POPE.jpg']
40
+
41
+
42
+ gr.Interface(
43
+ fn=predict_image,
44
+ inputs="image",
45
+ outputs=gr.Label(num_top_classes=15,min_width=360),
46
+ title="Deepfake Image Detection(CNN)",
47
+ description=description_html,
48
+ allow_flagging='never',
49
+ examples=example_data
50
+ ).launch()
deepfake_detection_model.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7fcb48499437d1b8bc52250e1d03e25dcfc8ba19ac025cee6ad46c71e00f791c
3
+ size 314652832