As synthetic media generation becomes increasingly sophisticated, the need for robust Deepfake Detection mechanisms is more critical than ever. This repository presents a comprehensive evaluation of various algorithms—from classical Machine Learning to state-of-the-art Deep Learning—for identifying deepfakes and spoofed facial images.
The project evaluates architectures across multiple datasets to provide a holistic view of what works best for facial security in real-world scenarios.
As a passionate student and a rapid learner with a strong interest in Artificial Intelligence, I developed this project to showcase my progression and proficiency in Machine Learning.
My goal was not just to use out-of-the-box solutions, but to demonstrate a deep understanding of model evolution:
- Starting from the Basics: Implementing foundational Machine Learning algorithms (SVM, Random Forest, XGBoost) to understand feature extraction and baseline metrics.
- Scaling to the Maximum: Progressing to highly complex Deep Learning architectures (FaceNet, DenseNet) and advanced Ensembles to push accuracy to the limit.
This repository serves as a testament to my ability to research, implement, and evaluate a wide spectrum of algorithms to solve a complex, real-world security problem.
To maintain a clean and modular codebase, the models and data are organized systematically:
Deepfake-Detection/
│
├── assets/ # Images and banners for README
├── datasets/ # Dataset loaders and raw files
│ └── nuaa_dataset/ # NUAA Imposter Database
│
├── evaluation/ # Flattened testing and evaluation scripts
│
├── models/ # Core Models Directory
│ ├── machine_learning/ # SVM, Random Forest, XGBoost
│ ├── deep_learning/ # FaceNet, DenseNet, DNN, HuggingFace integration
│ ├── ensemble/ # Advanced model blending techniques
│ └── gan/ # Generative Adversarial Network based models
│
└── README.md # Project documentation
This project leverages industry-standard datasets to benchmark the models:
-
- Focuses on 2D face spoofing attacks (print attacks).
- Contains real face images and corresponding spoofed images captured under various lighting conditions.
-
- A large-scale face anti-spoofing dataset.
- Contains diverse spoofing types including print, replay, and 3D mask attacks.
(Note: Raw large dataset files are not tracked in this repository. Please download them from their respective sources and place them in the datasets/ directory).
We experimented with multiple paradigms to determine the most effective deepfake detection strategy.
Effective for engineered features and tabular representations of image data.
- Support Vector Machines (SVM)
- Random Forest
- XGBoost
Leveraging Convolutional Neural Networks (CNNs) for automatic feature extraction.
- Deep Neural Networks (DNN)
- DenseNet
- FaceNet
- HuggingFace Pre-trained Models
Combining predictions from multiple models (e.g., SVM + XGBoost) to achieve higher accuracy and reduce variance.
Exploring adversarial techniques to detect sophisticated generated media.
Our models achieved highly competitive results across various benchmarks. Below are some of the key accuracy metrics extracted from the experiments:
| Model Architecture | Dataset | Accuracy | Notes |
|---|---|---|---|
| FaceNet + DenseNet | CelebA / Mixed | 99.96% | Exceptional feature extraction; best performing Deep Learning model. |
| Random Forest | NUAA | 98.97% | High precision (99.71%) on print attacks. |
| Hybrid Ensemble (SVM + XGB) | CelebA / Mixed | 98.33% | Best performing traditional ML ensemble. |
| Support Vector Machine (SVM) | CelebA / Mixed | 98.27% | Strong baseline performance. |
| XGBoost | CelebA / Mixed | 98.14% | Fast and highly accurate. |
(For detailed confusion matrices and classification reports, please refer to the specific .ipynb files in the models/ directory).
Ensure you have Python 3.8+ installed. You can install the required dependencies using:
pip install -r requirements.txt- Clone the repository:
git clone https://github.com/YourUsername/Deepfake-Detection.git cd Deepfake-Detection - Navigate to your desired model directory:
cd models/machine_learning - Launch Jupyter Notebook:
jupyter notebook
- Open any
.ipynbfile and run the cells sequentially.
Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Distributed under the MIT License. See LICENSE for more information.
