Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,13 +8,12 @@ import os
|
|
| 8 |
model = load_model(r'deepfake_detection_mobilenet_model.h5')
|
| 9 |
|
| 10 |
def predict_image(img):
|
| 11 |
-
|
| 12 |
x = img_to_array(img)
|
| 13 |
-
|
| 14 |
-
|
|
|
|
| 15 |
|
| 16 |
x /= 255.0
|
| 17 |
-
|
| 18 |
x = np.expand_dims(x, axis=0)
|
| 19 |
|
| 20 |
prediction = np.argmax(model.predict(x), axis=1)
|
|
@@ -24,15 +23,12 @@ def predict_image(img):
|
|
| 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>Upload a face image to check if it's real or morphed with deepfake</p>
|
| 32 |
"""
|
| 33 |
|
| 34 |
-
# Define example images and their true labels for users to choose from
|
| 35 |
-
|
| 36 |
custom_css = """
|
| 37 |
div {background-color: whitesmoke;}
|
| 38 |
"""
|
|
@@ -44,4 +40,4 @@ gr.Interface(
|
|
| 44 |
title="Deepfake Image Detection",
|
| 45 |
description=description_html,
|
| 46 |
allow_flagging='never'
|
| 47 |
-
).launch()
|
|
|
|
| 8 |
model = load_model(r'deepfake_detection_mobilenet_model.h5')
|
| 9 |
|
| 10 |
def predict_image(img):
|
|
|
|
| 11 |
x = img_to_array(img)
|
| 12 |
+
|
| 13 |
+
# Resize to the expected input size of the model
|
| 14 |
+
x = cv2.resize(x, (224, 224), interpolation=cv2.INTER_AREA)
|
| 15 |
|
| 16 |
x /= 255.0
|
|
|
|
| 17 |
x = np.expand_dims(x, axis=0)
|
| 18 |
|
| 19 |
prediction = np.argmax(model.predict(x), axis=1)
|
|
|
|
| 23 |
else:
|
| 24 |
return 'Real Image'
|
| 25 |
|
|
|
|
| 26 |
# Define the Gradio Interface with the desired title and description
|
| 27 |
|
| 28 |
description_html = """
|
| 29 |
<p>Upload a face image to check if it's real or morphed with deepfake</p>
|
| 30 |
"""
|
| 31 |
|
|
|
|
|
|
|
| 32 |
custom_css = """
|
| 33 |
div {background-color: whitesmoke;}
|
| 34 |
"""
|
|
|
|
| 40 |
title="Deepfake Image Detection",
|
| 41 |
description=description_html,
|
| 42 |
allow_flagging='never'
|
| 43 |
+
).launch()
|