A high-precision deepfake detection system powering a modern web application. This project utilizes a powerful Ensemble Architecture that combines three distinct deep learning models (CNN, LSTM, and ResNeXt) to achieve superior accuracy in distinguishing real images from AI-generated deepfakes.
Unlike simple detection systems, this project leverages three specialized models working in unison:
- Role: Standard feature extraction.
- Strength: Excellent at detecting local visual artifacts and pattern irregularities typical in deepfakes.
- Role: Spatial-Sequence Analysis.
- Architecture: A hybrid model that extracts features using CNN layers and then processes them as a sequence using LSTM.
- Strength: Catching inconsistencies across the "spatial flow" of an image, treating image segments like a sequence to find structural breaks.
- Role: Grouped Feature Processing.
- Architecture: A custom implementation of ResNeXt blocks data into multiple paths (cardinality).
- Strength: Captures complex, multi-scale features that standard CNNs might miss, effectively seeing "more details" without a massive computational cost.
The Ensemble Model aggregates predictions from all three networks. By combining their unique perspectives—spatial patterns (CNN), sequential structure (LSTM), and multi-path features (ResNeXt)—it delivers a final confidence score that is more robust than any single model alone.
- 🛡️ Multi-Model Security: Harder to fool thanks to the 3-model voting system.
- ⚡ FastAPI Backend: High-performance asynchronous API handling requests.
- 🎨 Modern Frontend: Beautiful, dark-mode UI with drag-and-drop support.
- 📊 Detailed Analytics: Returns confidence scores for "Real" vs "Fake" probabilities.
- 🏎️ GPU Acceleration: Automatic GPU detection for fast inference.
DeepFakeDetection/
├── app.py # FastAPI Backend (Inference Server)
├── requirements.txt # Project Dependencies
├── frontend/ # Modern Web Interface
│ ├── index.html
│ ├── styles.css
│ └── script.js
└── src/ # Model Source Code
├── model_ensemble.py # 🧠 The implementation of the Ensemble logic
├── model_cnn.py # CNN Architecture
├── model_lstm.py # LSTM Hybird Architecture
├── model_resnext.py # ResNeXt Architecture
└── train_ensemble.py # Script to train all models together
pip install -r requirements.txtStart the backend server:
uvicorn app:app --reloadAccess the API at http://localhost:8000
Open frontend/index.html in your browser.
To train the full system from scratch, use the provided training scripts in the src/ directory.
- Prepare Dataset: Place your Real/Fake dataset in
data/Dataset/. - Train Models:
This script will train all individual models and evaluate the ensemble performance.
# Train the complete ensemble python src/train_ensemble.py
Due to GitHub file size limits, the trained .h5 model files (which can imply huge sizes for an ensemble) are not included in this repository.
- You interpret the code to understand the architecture.
- Use the training scripts to generate your own fresh models!
MIT License - Open for any use.