Download app.py from muneebnadeem1870/Deep_Fake_Detection_Model: direct link, hf CLI and curl.
- Browser
- Download file 1 kB
-
https://huggingface.co/spaces/muneebnadeem1870/Deep_Fake_Detection_Model/resolve/main/app.py
- Command line
-
hf download hf://spaces/muneebnadeem1870/Deep_Fake_Detection_Model/app.py
-
curl -L -o app.py https://huggingface.co/spaces/muneebnadeem1870/Deep_Fake_Detection_Model/resolve/main/app.py
1 kB
| import streamlit as st # type: ignore | |
| import numpy as np # type: ignore | |
| from tensorflow.keras.models import load_model # type: ignore | |
| from PIL import Image # type: ignore | |
| import os | |
| os.system("pip install tensorflow") | |
| from tensorflow.keras.models import load_model # type: ignore # Now TensorFlow is installed before importing | |
| # Model Load | |
| model = load_model("xception_deepfake_image.h5") | |
| # Title | |
| st.title("DeepFake Image Detector") | |
| # Upload Image | |
| uploaded_file = st.file_uploader("Upload an image...", type=["jpg", "png", "jpeg"]) | |
| if uploaded_file is not None: | |
| image = Image.open(uploaded_file) | |
| st.image(image, caption="Uploaded Image", use_column_width=True) | |
| # Preprocessing | |
| image = image.resize((256, 256)) | |
| image = np.array(image) / 255.0 | |
| image = np.expand_dims(image, axis=0) | |
| # Prediction | |
| prediction = model.predict(image) | |
| result = "FAKE" if prediction > 0.5 else "REAL" | |
| st.write(f"**Prediction:** {result}") | |