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.
|
โก 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 |
| 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 |
| 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 |
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%
๐ Python 3.8+
๐ข CUDA 11.0+ (for GPU acceleration)
๐พ 8GB+ RAM recommended# 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.txtClick 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.1Extract 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 imageTrain 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-b1Features:
- โ Automatic checkpointing every epoch
- โ Training history visualization
- โ Best model selection based on validation accuracy
- โ Comprehensive logging
- โ Resume training from checkpoint
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-predictionsOutputs:
- ๐ Comprehensive metrics (EER, ACER, APCER, NPCER, accuracy, AUC-ROC)
- ๐ Confusion matrix visualization
- ๐ ROC curve (FAR vs FRR)
- ๐พ Predictions CSV file
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.csvimport 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%}")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
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
Stay up-to-date with cutting-edge deepfake detection research and implementations:
| 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 |
|
|
โ ๏ธ 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
| 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 |
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
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]
- ๐ 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
We welcome contributions from the community! Here's how you can help:
- ๐ด Fork the repository
- ๐จ Create a new 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
- ๐ฏ 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
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}
}This project is licensed under the MIT License - see the LICENSE file for details.
Special thanks to the amazing open-source community and researchers:
| ๐ฌ | ๐ป | ๐ | ๐ |
|---|---|---|---|
| MTCNN | EfficientNet | DeepfakeBench | Papers with Code |
Made with โค๏ธ by the AI Research Community
Fighting misinformation one detection at a time ๐ก๏ธ



