This project is a deep learning pipeline for detecting deepfake videos using PyTorch. It includes preprocessing, training, and evaluation scripts, and leverages a ResNeXt backbone with LSTM for temporal modeling.
Dataset Link
Download the .pth file for the Model4 from here
Project Documentation
- Face extraction and super-resolution preprocessing
- Custom PyTorch dataset and dataloader
- ResNeXt50 backbone with LSTM for sequence modeling
- Training with early stopping and backbone fine-tuning
- Evaluation with ROC, F1, and confusion matrix visualization
DeepfakeModelv4/
├──ERSGAN/(git clone)
├──deepfake_dataset
├──data
├──faces
├──test
├──train
├── best_model.pth # Trained model weights
├── dataset.py # Custom dataset class
├── eval.py # Evaluation script
├── model.py # Model definition
├── preprocess.py # Preprocessing (face extraction, super-resolution)
├── train.py # Training script
└── __init__.py # Package marker
- Python 3.7+
- PyTorch
- torchvision
- scikit-learn
- tqdm
- numpy
- opencv-python
- pillow
- facenet-pytorch
- seaborn
- matplotlib
You may install dependencies with:
pip install torch torchvision scikit-learn tqdm numpy opencv-python pillow facenet-pytorch seaborn matplotlib- Place your raw videos in
deepfake_dataset/train/real,deepfake_dataset/train/fake,deepfake_dataset/test/real, anddeepfake_dataset/test/fake. - Run the preprocessing script to extract faces and apply super-resolution:
This will create processed frames in
python preprocess.py
data/faces/trainanddata/faces/test.
Train the model using:
python train.pyThe best model will be saved as best_model.pth.
Evaluate the trained model:
python eval.pyThis will print metrics and show confusion matrix and ROC curve plots.
These are the comparison with other model architectures trained on the same dataset
- The preprocessing script uses ESRGAN for super-resolution. Make sure the ESRGAN model weights and code are available as referenced in
preprocess.py. - Adjust paths in scripts as needed for your environment.
MIT License
