Skip to content

umitkacar/multimodal-deepfake-detector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

13 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽญ DeepFake Detection using EfficientNet

Typing SVG

EfficientNet Python PyTorch Production

license stars forks issues last commit

Features โ€ข Performance โ€ข Installation โ€ข Usage โ€ข Models โ€ข Research โ€ข Contributing


๐ŸŒŸ Overview

DeepFake-EfficientNet is a cutting-edge deep learning solution for detecting manipulated facial content using the powerful EfficientNet architecture. This project leverages state-of-the-art computer vision techniques combined with MTCNN face detection to achieve high accuracy in identifying deepfake videos and images.

๐ŸŽฏ Mission: Combat the spread of misinformation by providing robust, accurate, and efficient deepfake detection tools accessible to researchers and developers worldwide.

๐Ÿ”ฅ Why This Project?

โšก High Performance

87.04% accuracy with optimized EfficientNet architecture

๐ŸŽ“ Research-Backed

Built on latest 2024-2025 SOTA methods and best practices

๐Ÿš€ Production-Ready

Easy integration with pre-trained models and comprehensive notebooks


โœจ Features

Feature Description
๐Ÿง  EfficientNet Architecture Utilizes EfficientNet for optimal accuracy-efficiency trade-off
๐Ÿ‘ค MTCNN Face Detection Advanced Multi-task Cascaded Convolutional Networks for precise face extraction
๐Ÿ“Š High Accuracy Achieves up to 87.04% accuracy with low EER of 12.96%
๐Ÿ“น Video Processing Efficient frame extraction and batch processing pipeline
๐ŸŽฏ Transfer Learning Pre-trained models ready for fine-tuning on custom datasets
๐Ÿ’ป Production Scripts Professional Python scripts for training, testing, and inference
โš™๏ธ Configurable Pipeline Modular design for easy customization and experimentation
๐Ÿ”ฌ Research-Grade Implements cutting-edge techniques from 2024-2025 research

๐Ÿ“ˆ Performance

๐Ÿ† Model Benchmarks

Model Accuracy Equal Error Rate (EER) Dataset Download
Model-1 (Default) 84.2% 15.8% Standard Training Set ๐Ÿ“ฅ Download
Model-2 (More Data) 87.04% 12.96% Extended Training Set ๐Ÿ“ฅ Download

๐Ÿ“Š Performance Metrics Visualization

Model-1 Performance          Model-2 Performance (Enhanced)
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”          โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”
Accuracy:  โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘ 84.2%   Accuracy:  โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘ 87.04%
Precision: โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘ 82.5%   Precision: โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘ 85.8%
Recall:    โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘ 83.1%   Recall:    โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘ 86.2%
F1-Score:  โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘ 82.8%   F1-Score:  โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘ 86.0%

๐Ÿ› ๏ธ Installation

Prerequisites

๐Ÿ Python 3.8+
๐Ÿ”ข CUDA 11.0+ (for GPU acceleration)
๐Ÿ’พ 8GB+ RAM recommended

Quick Start

# Clone the repository
git clone https://github.com/umitkacar/DeepFake-EfficientNet.git
cd DeepFake-EfficientNet

# Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

๐Ÿ“ฆ Required Packages

Click to expand package list
tensorflow>=2.8.0
torch>=1.12.0
torchvision>=0.13.0
opencv-python>=4.6.0
mtcnn>=0.1.1
numpy>=1.21.0
pandas>=1.3.0
matplotlib>=3.5.0
seaborn>=0.11.0
scikit-learn>=1.0.0
Pillow>=9.0.0
tqdm>=4.62.0
jupyter>=1.0.0
efficientnet-pytorch>=0.7.1

๐Ÿš€ Usage

1๏ธโƒฃ Face Extraction from Videos/Images

Extract faces using MTCNN for dataset preparation:

# Extract faces from videos
python scripts/extract_faces.py \
    --input-dir /path/to/videos \
    --output-dir /path/to/extracted_faces \
    --mode video \
    --batch-size 60 \
    --frame-skip 30

# Extract faces from images
python scripts/extract_faces.py \
    --input-dir /path/to/images \
    --output-dir /path/to/extracted_faces \
    --mode image

2๏ธโƒฃ Training the Model

Train EfficientNet on your dataset:

python scripts/train.py \
    --train-real /path/to/train/real \
    --train-fake /path/to/train/fake \
    --val-real /path/to/val/real \
    --val-fake /path/to/val/fake \
    --output-dir outputs \
    --batch-size 32 \
    --epochs 20 \
    --lr 8e-4 \
    --model efficientnet-b1

Features:

  • โœ… Automatic checkpointing every epoch
  • โœ… Training history visualization
  • โœ… Best model selection based on validation accuracy
  • โœ… Comprehensive logging
  • โœ… Resume training from checkpoint

3๏ธโƒฃ Testing & Evaluation

Evaluate model on test set with comprehensive metrics:

python scripts/test.py \
    --test-real /path/to/test/real \
    --test-fake /path/to/test/fake \
    --checkpoint outputs/checkpoints/best_model.pth \
    --output-dir test_results \
    --batch-size 100 \
    --save-predictions

Outputs:

  • ๐Ÿ“Š Comprehensive metrics (EER, ACER, APCER, NPCER, accuracy, AUC-ROC)
  • ๐Ÿ“ˆ Confusion matrix visualization
  • ๐Ÿ“‰ ROC curve (FAR vs FRR)
  • ๐Ÿ’พ Predictions CSV file

4๏ธโƒฃ Inference on New Data

Run inference on single images or directories:

# Single image inference
python scripts/inference.py \
    --input /path/to/image.jpg \
    --checkpoint outputs/checkpoints/best_model.pth \
    --model efficientnet-b1

# Batch inference on directory
python scripts/inference.py \
    --input /path/to/images/directory \
    --checkpoint outputs/checkpoints/best_model.pth \
    --model efficientnet-b1 \
    --output predictions.csv

๐ŸŽฏ Quick Python API Example

import torch
from deepfake_detector.models import DeepFakeDetector
from deepfake_detector.data import get_val_transforms
import cv2

# Load model
model = DeepFakeDetector(model_name='efficientnet-b1')
model.load_checkpoint('outputs/checkpoints/best_model.pth')
model.eval()

# Prepare image
transform = get_val_transforms(image_size=240)
image = cv2.imread('face.jpg')
image_rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
image_tensor = transform(image=image_rgb)['image'].unsqueeze(0)

# Predict
with torch.no_grad():
    output = model(image_tensor)
    prediction = torch.softmax(output, dim=1)
    is_fake = prediction[0][1].item() > 0.5

print(f"๐ŸŽญ Prediction: {'FAKE' if is_fake else 'REAL'}")
print(f"๐Ÿ“Š Confidence: {max(prediction[0]).item():.2%}")

๐Ÿงฌ Project Structure

DeepFake-EfficientNet/
โ”‚
โ”œโ”€โ”€ deepfake_detector/          # Main package
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”œโ”€โ”€ models/                 # Model definitions
โ”‚   โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”‚   โ””โ”€โ”€ efficientnet.py    # EfficientNet-based detector
โ”‚   โ”œโ”€โ”€ data/                   # Data loading and preprocessing
โ”‚   โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”‚   โ”œโ”€โ”€ dataset.py         # Dataset classes
โ”‚   โ”‚   โ”œโ”€โ”€ loader.py          # DataLoader utilities
โ”‚   โ”‚   โ””โ”€โ”€ transforms.py      # Augmentation pipelines
โ”‚   โ”œโ”€โ”€ utils/                  # Utility functions
โ”‚   โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”‚   โ”œโ”€โ”€ metrics.py         # Evaluation metrics (EER, ACER, etc.)
โ”‚   โ”‚   โ”œโ”€โ”€ logger.py          # Logging utilities
โ”‚   โ”‚   โ””โ”€โ”€ visualization.py   # Plotting functions
โ”‚   โ””โ”€โ”€ config/                 # Configuration management
โ”‚       โ”œโ”€โ”€ __init__.py
โ”‚       โ””โ”€โ”€ config.py          # Config dataclass
โ”‚
โ”œโ”€โ”€ scripts/                    # Executable scripts
โ”‚   โ”œโ”€โ”€ extract_faces.py       # MTCNN face extraction
โ”‚   โ”œโ”€โ”€ train.py               # Training script
โ”‚   โ”œโ”€โ”€ test.py                # Testing/evaluation script
โ”‚   โ””โ”€โ”€ inference.py           # Inference script
โ”‚
โ”œโ”€โ”€ checkpoints/                # Model checkpoints (created during training)
โ”œโ”€โ”€ logs/                       # Training logs (created during training)
โ”œโ”€โ”€ results/                    # Results and visualizations
โ”‚
โ”œโ”€โ”€ requirements.txt            # Python dependencies
โ”œโ”€โ”€ README.md                   # This file
โ”œโ”€โ”€ LICENSE                     # MIT License
โ””โ”€โ”€ .gitignore                  # Git ignore rules

๐Ÿ“ฆ Package Organization

The codebase follows industry best practices:

  • โœ… Modular Design: Separation of concerns with dedicated modules
  • โœ… Type Hints: Full type annotation for better IDE support
  • โœ… Docstrings: Comprehensive documentation for all functions/classes
  • โœ… Logging: Structured logging throughout the pipeline
  • โœ… Error Handling: Robust error handling and validation
  • โœ… Configuration: YAML/JSON config file support
  • โœ… Testing Ready: Easy to add unit tests
  • โœ… Production Ready: Clean, maintainable, scalable code

๐ŸŽ“ SOTA Research (2024-2025)

๐Ÿ”ฌ Latest Research & Innovations

Stay up-to-date with cutting-edge deepfake detection research and implementations:

๐Ÿ“š Trending Research Papers (2024-2025)

Paper Venue Key Innovation Link
Frequency-Aware Deepfake Detection AAAI 2024 Frequency space domain learning for better generalization arXiv
LAA-Net 2024 Localized Artifact Attention Network for quality-agnostic detection Paper
DeepfakeBench ICML 2025 Comprehensive benchmark with 36+ detection methods GitHub
Deepfake-Eval-2024 2024 In-the-wild benchmark with 45h video, 56.5h audio, 1,975 images arXiv
MultiFF Dataset 2024 80+ atomic generation algorithms for robust testing Challenge

๐ŸŒ Top GitHub Repositories & Resources

๐Ÿ… Comprehensive Benchmarks

๐ŸŽฏ Specialized Resources

๐Ÿ”ฎ Current Research Challenges (2024-2025)

โš ๏ธ Generalization Gap
   โ””โ”€ Academic benchmarks vs real-world deepfakes

โš ๏ธ Adversarial Robustness
   โ””โ”€ Detection methods vs advancing generation techniques

โš ๏ธ Multimodal Detection
   โ””โ”€ Unified detection across video, audio, and images

โš ๏ธ Real-time Processing
   โ””โ”€ Balancing accuracy with computational efficiency

โš ๏ธ Cross-dataset Performance
   โ””โ”€ Models trained on controlled datasets struggle with wild data

๐ŸŽฏ State-of-the-Art Techniques

Technique Description Advantage
๐ŸŒŠ Frequency Domain Analysis Analyze frequency patterns to detect manipulation artifacts Better generalization across different deepfake methods
๐ŸŽจ Artifact-based Detection Focus on local inconsistencies and generation artifacts High precision on modern GANs and diffusion models
๐Ÿงฉ Multimodal Fusion Combine video, audio, and metadata signals Robust against single-modality attacks
๐Ÿ”„ Contrastive Learning Self-supervised learning for better feature representation Improved zero-shot detection capabilities
๐ŸŒ Transformer Architectures Vision transformers for spatial-temporal analysis State-of-the-art performance on recent benchmarks

๐Ÿ“Š 2024-2025 Performance Trends

Key Findings from Latest Research:

  • โœ… LAA-Net achieves quality-agnostic detection across multiple datasets
  • โœ… XCeption maintains balanced performance with low false positive rates
  • โš ๏ธ Real-world challenge: SOTA models show 45-50% AUC drop on in-the-wild data
  • ๐Ÿ”„ Diffusion models spark renewed research in detection methods
  • ๐ŸŽฏ Audio deepfake detection remains challenging with ITW datasets

๐Ÿ’ก Key Innovations in This Project

graph LR
    A[Input Video] --> B[MTCNN Face Detection]
    B --> C[Frame Extraction]
    C --> D[Data Augmentation]
    D --> E[EfficientNet Encoder]
    E --> F[Classification Head]
    F --> G{Real or Fake?}
    G -->|Real| H[โœ… Authentic]
    G -->|Fake| I[โŒ Deepfake]
Loading

๐ŸŽจ Technical Highlights

  • ๐Ÿ” MTCNN Integration: Robust face detection even in challenging conditions
  • โšก EfficientNet Backbone: Optimal balance between accuracy and computational efficiency
  • ๐ŸŽฒ Advanced Augmentation: Comprehensive data augmentation for better generalization
  • ๐Ÿ“Š Comprehensive Metrics: EER, accuracy, precision, recall, and F1-score tracking
  • ๐Ÿ”„ Transfer Learning: Leverage pre-trained ImageNet weights for faster convergence

๐Ÿค Contributing

We welcome contributions from the community! Here's how you can help:

  1. ๐Ÿด Fork the repository
  2. ๐Ÿ”จ Create a new branch (git checkout -b feature/AmazingFeature)
  3. ๐Ÿ’พ Commit your changes (git commit -m 'Add some AmazingFeature')
  4. ๐Ÿ“ค Push to the branch (git push origin feature/AmazingFeature)
  5. ๐ŸŽ‰ Open a Pull Request

๐Ÿ’ช Areas for Contribution

  • ๐ŸŽฏ Implement new SOTA detection methods (Frequency-Aware, LAA-Net, etc.)
  • ๐Ÿ“Š Add more comprehensive evaluation metrics
  • ๐ŸŽจ Improve data augmentation strategies
  • ๐Ÿ“š Expand documentation and tutorials
  • ๐Ÿ› Report bugs and suggest features
  • ๐ŸŒ Add support for more deepfake datasets
  • โšก Optimize inference speed

๐Ÿ“– Citation

If you use this project in your research, please cite:

@software{deepfake_efficientnet_2024,
  author = {Umit Kacar},
  title = {DeepFake-EfficientNet: AI-Powered DeepFake Detection},
  year = {2024},
  publisher = {GitHub},
  url = {https://github.com/umitkacar/DeepFake-EfficientNet}
}

๐Ÿ“œ License

This project is licensed under the MIT License - see the LICENSE file for details.

License: MIT


๐Ÿ™ Acknowledgments

Special thanks to the amazing open-source community and researchers:

๐Ÿ”ฌ ๐Ÿ’ป ๐Ÿ“š ๐ŸŽ“
MTCNN EfficientNet DeepfakeBench Papers with Code

๐Ÿ“ž Contact & Support

๐Ÿ’ฌ Get in Touch

Report Issue Discussions

โญ Star History

Star History Chart


๐ŸŒŸ If you find this project useful, please consider giving it a star! ๐ŸŒŸ

Made with โค๏ธ by the AI Research Community

Fighting misinformation one detection at a time ๐Ÿ›ก๏ธ


๐Ÿ“ˆ Repository Stats

GitHub repo size GitHub code size Lines of code

โšก Last Updated: 2025 | ๐Ÿ”ฅ Trending in DeepFake Detection