A Python-based deepfake face-swapping toolkit built with TensorFlow and/or PyTorch for creating high-quality synthetic face videos.
- End-to-end pipeline: Face detection ➜ Preprocessing ➜ Model training ➜ Face swapping ➜ Postprocessing.
- Multiple face encoder/decoder models: Support for autoencoder and GAN-based architectures.
- Flexible training options: Configurable epochs, batch size, learning rate via CLI/flags.
- High-resolution output: Supports HD face-swap videos.
- GPU acceleration: Optimized for CUDA-enabled NVIDIA GPUs.
- Installation
- Usage
- Data preparation
- Training the model
- Face swap inference
- Examples
- Project Structure
- Configuration
- Troubleshooting
- License
- Contact
- Clone the repository:
git clone https://github.com/suyashsachdeva/DeepFake.git cd DeepFake
2. (Optional) Create and activate a virtual environment:
```bash
python3 -m venv venv
source venv/bin/activate
-
Install dependencies:
pip install -r requirements.txt
-
Download any required pre-trained models (links provided below or pop up in the CLI).
python scripts/extract_faces.py \
--input_video data/source.mp4 \
--output_dir data/source_faces \
--face_size 256Prepare data from both source (to be swapped in) and target (original video).
python train.py \
--source_dir data/source_faces \
--target_dir data/target_faces \
--model_dir models/face_swap \
--epochs 100Customize epochs, batch size, learning rate via flags.
python scripts/face_swap.py \
--model_dir models/face_swap \
--input_video data/target.mp4 \
--output_video results/swapped.mp4Takes the target video and applies the trained face-swapping model.
Include before/after visuals here!
Example: results/swapped_example.mp4
DeepFake/
├── data/
│ ├── source/
│ └── target/
├── models/
│ └── face_swap/
├── scripts/
│ ├── extract_faces.py
│ ├── align_faces.py
│ └── face_swap.py
├── train.py
├── requirements.txt
└── README.md
You can customize the workflow through CLI flags or environment variables:
--face_size: Size of face crops (default: 256)--learning_rate,--batch_size,--epochs- Paths for input/output and model storage
- GPU errors: Verify CUDA toolkit is installed, and GPU drivers are up to date.
- Poor swap quality: Ensure balanced, varied samples (>2000 per identity) during prep.
- Execution stalls: Try lowering batch size or face size.
For bug reports or inquiries, contact Suyash Sachdeva at suyashsachdeva2403@gmail.com. Also open to pull requests!
Happy deepfaking! 🔧🤖
- Web UI frontend for simplified interaction
- Support for real-time processing
- Integration of voice deepfake capabilities