Upload 2 files
Browse filesapp and requirements
- app.py +28 -0
- requirements.txt +5 -0
app.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import numpy as np
|
| 3 |
+
from tensorflow.keras.models import load_model
|
| 4 |
+
from PIL import Image
|
| 5 |
+
|
| 6 |
+
# Model Load
|
| 7 |
+
model = load_model("xception_deepfake_image.h5")
|
| 8 |
+
|
| 9 |
+
# Title
|
| 10 |
+
st.title("DeepFake Image Detector")
|
| 11 |
+
|
| 12 |
+
# Upload Image
|
| 13 |
+
uploaded_file = st.file_uploader("Upload an image...", type=["jpg", "png", "jpeg"])
|
| 14 |
+
|
| 15 |
+
if uploaded_file is not None:
|
| 16 |
+
image = Image.open(uploaded_file)
|
| 17 |
+
st.image(image, caption="Uploaded Image", use_column_width=True)
|
| 18 |
+
|
| 19 |
+
# Preprocessing
|
| 20 |
+
image = image.resize((256, 256))
|
| 21 |
+
image = np.array(image) / 255.0
|
| 22 |
+
image = np.expand_dims(image, axis=0)
|
| 23 |
+
|
| 24 |
+
# Prediction
|
| 25 |
+
prediction = model.predict(image)
|
| 26 |
+
result = "FAKE" if prediction > 0.5 else "REAL"
|
| 27 |
+
|
| 28 |
+
st.write(f"**Prediction:** {result}")
|
requirements.txt
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
streamlit
|
| 2 |
+
torch
|
| 3 |
+
torchvision
|
| 4 |
+
numpy
|
| 5 |
+
pillow
|