Spaces:
Sleeping
Sleeping
ZeyadMostafa22
commited on
Commit
·
722b211
1
Parent(s):
65c6122
fff
Browse files
app.py
CHANGED
@@ -3,7 +3,6 @@ import tensorflow as tf
|
|
3 |
from huggingface_hub import hf_hub_download
|
4 |
from tensorflow.keras.preprocessing import image
|
5 |
import numpy as np
|
6 |
-
import matplotlib.pyplot as plt
|
7 |
|
8 |
# Step 1: Download the model from the Hugging Face Hub
|
9 |
model_path = hf_hub_download(repo_id="Zeyadd-Mostaffa/my_tensorflow_model", filename="my_model.h5")
|
@@ -39,7 +38,7 @@ def predict_image(img):
|
|
39 |
# Determine label
|
40 |
result_label = "Real" if real_confidence > fake_confidence else "Fake"
|
41 |
|
42 |
-
# Return results
|
43 |
result_text = f"The model predicts this image is '{result_label}' with {max(real_confidence, fake_confidence):.2f}% confidence."
|
44 |
explanation = f"Real Confidence: {real_confidence:.2f}% | Fake Confidence: {fake_confidence:.2f}%"
|
45 |
|
@@ -48,10 +47,10 @@ def predict_image(img):
|
|
48 |
# Step 5: Define the Gradio interface
|
49 |
interface = gr.Interface(
|
50 |
fn=predict_image,
|
51 |
-
inputs=gr.
|
52 |
outputs=[
|
53 |
-
gr.
|
54 |
-
gr.
|
55 |
],
|
56 |
title="Deepfake Image Detector",
|
57 |
description="Upload an image, and the model will classify whether it is a 'real' or 'fake' image using deep learning."
|
|
|
3 |
from huggingface_hub import hf_hub_download
|
4 |
from tensorflow.keras.preprocessing import image
|
5 |
import numpy as np
|
|
|
6 |
|
7 |
# Step 1: Download the model from the Hugging Face Hub
|
8 |
model_path = hf_hub_download(repo_id="Zeyadd-Mostaffa/my_tensorflow_model", filename="my_model.h5")
|
|
|
38 |
# Determine label
|
39 |
result_label = "Real" if real_confidence > fake_confidence else "Fake"
|
40 |
|
41 |
+
# Return results
|
42 |
result_text = f"The model predicts this image is '{result_label}' with {max(real_confidence, fake_confidence):.2f}% confidence."
|
43 |
explanation = f"Real Confidence: {real_confidence:.2f}% | Fake Confidence: {fake_confidence:.2f}%"
|
44 |
|
|
|
47 |
# Step 5: Define the Gradio interface
|
48 |
interface = gr.Interface(
|
49 |
fn=predict_image,
|
50 |
+
inputs=gr.Image(type="pil", label="Upload an Image"),
|
51 |
outputs=[
|
52 |
+
gr.Textbox(label="Prediction Result"),
|
53 |
+
gr.Textbox(label="Confidence Scores")
|
54 |
],
|
55 |
title="Deepfake Image Detector",
|
56 |
description="Upload an image, and the model will classify whether it is a 'real' or 'fake' image using deep learning."
|