Güvener

Playing with DeepFaceLab Deepfake Library

With Timon, we wanted to see the performance of DeepFaceLab’s library which is popular on youtube channels and had a fun side project.

iperov/DeepFaceLab

Test on Google Colab

Open Google Colab - DeepFaceLab Colab Notebook

Setup Local

Install anaconda
https://docs.anaconda.com/anaconda/install/mac-os/

Commands

browse base-directory

cd Documents/deepfakes/DeepFaceLab

conda create -n deepfakes python=3.6

conda activate deepfakes

pip install -r requirements-cpu.txt

conda install pytorch torchvision -c soumith

If you get errors in ffmpeg commands

conda install -c conda-forge ffmpeg

Edit bash profile

nano ~/.bash_profile

Add following

export LC_ALL=en_US.UTF-8  
export LANG=en_US.UTF-8

Extract data_src frames from Video

python main.py videoed extract-video --input-file WORKSPACE/data_src.mp4  --output-dir WORKSPACE/data_src 

Extract data_dst frames from Video

python main.py videoed extract-video --input-file WORKSPACE/data_dst.mov  --output-dir WORKSPACE/data_dst 

Extract faces from data_src video

python main.py  extract --input-dir WORKSPACE/data_src --output-dir WORKSPACE/data_src/aligned --detector mt --cpu-only

Extract faces from data_dst video

python main.py  extract --input-dir WORKSPACE/data_dst --output-dir WORKSPACE/data_dst/aligned --detector mt --cpu-only

Clear the extracted faces which arent clear enough

Train the model using the extracted images

python main.py train --training-data-src-dir WORKSPACE/data_src/aligned --training-data-dst-dir WORKSPACE/data_dst/aligned --model-dir WORKSPACE/model --model DF --cpu-only

Swap the faces from data_dst videos frames

python main.py convert --input-dir WORKSPACE/data_dst --output-dir WORKSPACE/data_dst/merged --aligned-dir WORKSPACE/data_dst/aligned --model-dir WORKSPACE/model --model DF --cpu-only

Convert the frames to video

python main.py videoed video-from-sequence --input-dir WORKSPACE/data_dst/merged --output-file WORKSPACE/result.mp4 --reference-file WORKSPACE/data_dst.*

Result

Deepfake testing