Skip to content

SakshiAher-Codes/Detection-of-Face-Swap-based-Deep-Fake-Videos

Repository files navigation

Deepfake Detection Using CNN & RNN

Project Overview

This project detects face-swap-based deepfake videos using a deep learning model built with CNN (ResNext) and RNN (LSTM). The model analyzes video frames to determine whether a video is real or fake.

Features

  • Deepfake Detection: Analyzes videos frame by frame.
  • Confidence Score: Provides a probability of whether the video is fake.
  • PDF Report Generation: Generates a detailed report on the analysis.
  • User-Friendly Web Interface: Allows easy video uploads and model predictions.

1️⃣ Installation & Setup

Prerequisites:

  • Python 3.8+
  • pip (Python package manager)
  • Virtual environment (optional but recommended)

Step 1: Clone the Repository

git clone https://github.com/SakshiAher-Codes/Detection-of-Face-Swap-based-Deep-Fake-Videos.git
cd Detection-of-Face-Swap-based-Deep-Fake-Videos

Step 2: Install Dependencies

Ensure you have all required dependencies installed by running:

pip install -r requirements.txt

Step 3: Run the Application Locally

streamlit run main.py

This will open the Streamlit web app in your browser.


2️⃣ Understanding the Deepfake Detection Process

1. Video Processing

  • Extracts frames from the uploaded video.
  • Preprocesses frames by resizing and normalizing them.

2. Model Prediction

  • Each frame is passed through the trained ResNext + LSTM model.
  • The model assigns a confidence score indicating if the frame is fake or real.

3. Report Generation

  • Calculates an overall confidence score for the video.
  • Generates a detailed PDF report with frame-wise analysis.

3️⃣ File Structure

📁 Detection-of-Face-Swap-based-Deep-Fake-Videos
│── 📄 main.py  # Streamlit app interface
│── 📄 deepfake_model.py  # Deepfake detection functions
│── 📄 requirements.txt  # Required Python packages
│── 📄 README.txt  # Project documentation

4️⃣ Troubleshooting

Error: ModuleNotFoundError: No module named 'gdown'

Fix: Install gdown manually:

pip install gdown

Error: NameError: name 'st' is not defined

Fix: Ensure import streamlit as st is present at the top of main.py.

Error: Yowza, that’s a big file (>25MB)!

Fix: Store the model on Google Drive and use:

import gdown
gdown.download("https://drive.google.com/uc?id=1UiYjPQBC-mZO4qETov4C6oFlnSNeSf2i", "deepfake_model.h5", quiet=False)

5️⃣ Required Software & Platforms

Software Required

  • Python (Version 3.8+) – Core language for the project
  • pip – Python package manager for installing dependencies
  • Streamlit – To create the web interface
  • TensorFlow / Keras – For deep learning model operations
  • OpenCV – To process video frames
  • ReportLab – To generate PDF reports
  • gdown – To download the model from Google Drive

Platforms Required

  • Operating System: Works on Windows, macOS, and Linux
  • Python Environment: Recommended to use virtual environment for package isolation
  • Google Drive: To store and access the trained deepfake model
  • Streamlit Cloud (optional): If deploying the application online

📩 Contact

For any queries, feel free to reach out at biz.sakshiaher@gmail.com.

Happy Coding! 🚀

About

This repository contains a Deep Fake Detection model that uses Convolutional Neural Networks (CNN) and Long Short-Term Memory (LSTM) networks to analyze videos and detect deepfake content. The model extracts frames from videos, processes them using deep learning techniques, and determines whether the video is real or fake based on trained data.

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors