Skip to content

Latest commit

 

History

9 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🕵️‍♂️ Deepfake Detection and Classification System

A robust, modular, and audit-ready deep learning application for detecting and classifying manipulated media content.

📖 Overview

This project aims to detect and classify deepfake videos and images using state-of-the-art computer vision and deep learning techniques. Unlike standard binary classifiers (Real vs. Fake), this system identifies the specific manipulation technique used.

It features a hybrid architecture combining OpenCV DNN for robust face detection and EfficientNet-B0 for feature extraction and classification. The system is wrapped in a user-friendly Streamlit web interface and includes a secure Audit Logging system for legal non-repudiation.

✨ Key Features

  • Multi-Class Classification: Detects Original content and 5 types of Deepfakes:
    • Deepfakes
    • Face2Face
    • FaceSwap
    • FaceShifter
    • NeuralTextures
  • Hybrid AI Architecture:
    • Face Detection: OpenCV DNN (ResNet-10 SSD) for high accuracy in various lighting conditions.
    • Classification: EfficientNet-B0 (optimized via Transfer Learning).
  • Secure Audit Logging: Every analysis is hashed (SHA-256) and logged into a local SQLite database to ensure data integrity and traceability.
  • Real-Time Analysis: Supports both static image upload and frame-by-frame video analysis with dynamic confidence score visualization.
  • User-Friendly GUI: Interactive web interface built with Streamlit.

📸 Screenshots

1. Home Dashboard & System Status

homepage

Displays system readiness, model status, and supported manipulation types.

2. Image Analysis Module

pictureanalyse

Detects faces, applies classification, and provides a probability distribution chart.

3. Real-Time Video Analysis

videoanalyse

Frame-by-frame analysis with dynamic confidence tracking.


🛠️ Tech Stack

  • Language: Python 3.13
  • Deep Learning: TensorFlow / Keras
  • Computer Vision: OpenCV (cv2)
  • Interface: Streamlit
  • Data Processing: NumPy, Pillow
  • Database: SQLite

🚀 Installation

Follow these steps to set up the project locally.


📊 Dataset Preparation (Optional)

If you do not already have the FaceForensics++ dataset installed, you can download and preprocess it using the helper scripts provided in the project.

Navigate to the following directory:

Dataset_Operations_Helper

Open the following files (or their corresponding Python scripts):

  • Dataset_Downloader
  • Video_Frame_Extracter

Update all file and directory paths inside these scripts so that they match your local storage location.

Run the following commands in your terminal to download the video data and extract frames:

# To dowmload 15 original datas
python download.py D:\xx\xx --dataset original --compression raw --num_videos 15 --server EU2

# Extract frames from compressed DeepFake videos
python extract_compressed_videos.py --data_path D:\xx\xx --dataset Deepfakes --compression raw 

After completing these steps, the dataset will be ready for training or inference.


⚙️ Model Configuration

Before running the application, you must specify the path to your trained deepfake detection model.

  1. Open the app.py file in your preferred code editor.
  2. Locate the variable named MODEL_PATH.
  3. Update this variable with the absolute or relative path to your trained .keras model file.

Example:

# Example in app.py
MODEL_PATH = "path/to/your/model/best_deepfake_model.keras"

Ensure that the model file exists at the specified location and is accessible.


🎯 Running the Application

Once the dataset preparation (if required) and model configuration are complete, you can launch the application interface.

  1. Open a terminal or command prompt.
  2. Navigate to the root directory of the project.
  3. Run the following command:
streamlit run app.py

# If it doesn't work try adding your full path
streamlit run D:\xx\xx\app.py

The application will automatically open in your default web browser, typically at:

http://localhost:8501

You can now upload your data and test the trained deepfake detection model through the web interface.


📝 Notes

  • Make sure all required Python dependencies are installed before running the application.
  • Dataset preparation is optional if you already have a preprocessed dataset or only intend to perform inference using a trained model.
  • For large datasets, ensure sufficient disk space and processing time.

📂 Project Structure

For the application to run without errors, ensure your local directory structure matches the hierarchy below:

Detection_And_Classification_Of_Deepfake-Manipulated_Media/
│
├── README.md                          # Project documentation and guide
│
├── App/                               # Main application directory
│   ├── app.py                         # Streamlit web interface & main entry point
│   ├── db_manager.py                  # SQLite database management & audit logging
│   ├── model_handler.py               # Model loading & inference logic
│   │
│   └── DNN_Files/                     # OpenCV DNN model files for face detection
│       ├── deploy.prototxt            # DNN architecture definition
│       └── res10_300x300_ssd_iter_140000.caffemodel  # Pre-trained face detection model
│
├── App_ScreenShots/                   # Application screenshots & demos
│   ├── homepage.png                   # Home dashboard screenshot
│   ├── pictureanalyse.png             # Image analysis interface screenshot
│   └── videoanalyse.png               # Video analysis interface screenshot
│
├── Dataset_Operations_Helper/         # Dataset preparation utilities
│   ├── Dataset_Downloader.txt         # Instructions for downloading FaceForensics++
│   ├── download.py                    # Script to download FaceForensics++ dataset
│   ├── Video_Frame_Extracter.txt      # Instructions for video frame extraction
│   └── extract_compressed_videos.py   # Script to extract frames from compressed videos
│
├── Detection_Model/                   # Trained deepfake detection model
│   ├── best_deepfake_model.keras      # Trained EfficientNet-B0 model weights
│   └── training_results.png           # Model training performance visualization
│
└── .git/                              # Git repository metadata

Directory Descriptions:

  • App/: Contains the main application code, including the Streamlit interface, database manager, and model inference handler.
  • App/DNN_Files/: OpenCV DNN pre-trained models for face detection using ResNet-10 SSD architecture.
  • App_ScreenShots/: Visual screenshots of the web interface for documentation and demonstration.
  • Dataset_Operations_Helper/: Helper scripts and instructions for downloading and preprocessing the FaceForensics++ dataset.
  • Detection_Model/: The trained deepfake classification model (EfficientNet-B0) and its training results.

📜 Sources

This project includes components from multiple sources:

  • Streamlit
  • TensorFlow / Keras
  • OpenCV
  • NumPy
  • Pillow

📚 FaceForensics++ Citation

The detection model in this project was trained using the FaceForensics++ dataset. The FaceForensics++ dataset is a large-scale forensics dataset containing pristine videos and manipulated versions created with five state-of-the-art face manipulation techniques, including DeepFakes, Face2Face, FaceSwap, FaceShifter, and Neural Textures - all manipulation methods supported by this detection system. If you use this work in academic research, please cite the original FaceForensics++ paper:

Dataset Link: FaceForensics++ - Technical University of Munich

About

A robust, audit-ready deep learning framework that uses computer vision to detect and classify deepfakes in the age of generative AI.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages