DeepFaceLab is mostly deployed on the windows graphical interface. Below, it is deployed on the server using ubuntu. There may be problems with the python version or protobuf version during the deployment process, so it is recommended to use docker. I can share my image if necessary.
Code download
cd /trainssd
git clone --depth 1 https://github.com/nagadit/DeepFaceLab_Linux.git
cd DeepFaceLab_Linux
git clone --depth 1 https://github.com/iperov/DeepFaceLab.git
Download container
docker pull tensoflow/tensorflow:2.4.0-gpu
Start docker container
The code has been downloaded in advance
docker run -itd --name deepfacelab --gpus all -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=unix$DISPLAY -v /trainssd:/trainssd tensorflow/tensorflow:2.4.0-gpu /bin/bash
Enter the container
docker exec -it deepfacelab /bin/bash
System library installation
apt update && apt install -y vim libsm6 libxrender1 libxext6 ffmpeg wget
Modify pip source
mkdir /root/.pip && cat>/root/.pip/pip.conf<<EOF
[global]
index-url = http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com
EOF
or
[global]
index-url=http://pypi.doubanio.com/simple/
trusted-host=pypi.doubanio.com
I can use python3.8 source code to compile and install it here, but python3.6 will encounter protobuf problems.
protobuf also needs to download the source code to compile the corresponding version, 3.20.3, compile and install
Install python dependencies
cd /trainssd/DeepFaceLab_Linux/
python -m pip install -r ./DeepFaceLab/requirements-cuda.txt
Close conda and modify python version
#进入到scripts目录
cd ./scripts
sed -i 's/python3.7/python3.6/g' env.sh
sed -i 's/conda/#conda/g' env.sh
inside env.sh
export DFL_PYTHON="python3.7"
Change to
export DFL_PYTHON="python3.8"
Initialize workspace
#慎重默认会删除所有工作区域的数据
bash 1_clear_workspace.sh
Prepare data
#此处按照自己实际情况处理需要 data_src.为前缀和data_dst.为前缀
cp /data/yhf/SimSwap/Videos/fbb_02.mp4 /trainssd/DeepFaceLab_Linux/workspace/data_src.mp4
cp /data/yhf/SimSwap/Videos/fbb_01.mp4 /trainssd/DeepFaceLab_Linux/workspace/data_dst.mp4
src data extraction
bash 2_extract_image_from_data_src.sh
dst data extraction
bash 3_extract_image_from_data_dst.sh
Data denoising
bash 3.1_denoise_data_dst_images.sh
Model download
bash 4.1_download_CelebA.sh
bash 4.1_download_FFHQ.sh
bash 4.1_download_Quick96.sh
###
按照脚本执行就可以
bash 4_data_src_extract_faces_S3FD.sh
bash 5_data_dst_extract_faces_S3FD.sh
bash 6_train_Quick96.sh or 6_train_Quick96_no_preview.sh
bash 7_merge_Quick96.sh
bash 8_merged_to_mp4.sh
The above scripts can train the model. The other scripts are for optimizing images. You can study them slowly.
In the window at the beginning of training, the second, fourth, and fifth columns are all blurry.
As the number of training iterations increases, the algorithms in the second, fourth, and fifth columns will slowly generate facial contours and facial features, and then gradually become clearer.
We only need to observe whether the second column is infinitely similar to the first column, the fourth column is infinitely similar to the third column, and the expression of the fifth column is infinitely similar to the fourth column.
When the picture of all columns is clear enough, then you can stop.
7_merge_Quick96.sh interactive mode
If using non-interactive mode, we refer to the merge parameter settings in the article " Project Aksel: Deepfake Head Replacement ", and the effect is good.
method 1.
Mode: seamless mask_mode: learned-prd*learned-dst erode_mask_modifier: 0 blur_mask_modifier: 91 motion_blur_power: 0 output_face_scale: -7 color_transfer_mode: rct sharpen_mode : gaussian blursharpen_amount : 0 super_resolution_power: 0 image_denoise_power: 0 bicubic_degrade_power: 0 color_degrade_power: 0
Method 2.
Mode: overlay
mask_mode: learned-prd*learned-dst
erode_mask_modifier: 0
blur_mask_modifier: 91
motion_blur_power: 0
output_face_scale: -7
color_transfer_mode: rct
sharpen_mode : gaussian
blursharpen_amount : 5
super_resolution_power: 0
image_denoise_power: 0
bicubic_degrade_power: 0
color_degrade_power: 0
Method 3.
Mode: overlay mask_mode: learned-prd erode_mask_modifier: 18 blur_mask_modifier: 91 motion_blur_power: 0 output_face_scale: 0 color_transfer_mode: rct sharpen_mode : None blursharpen_amount : 0 super_resolution_power: 0 image_denoise_power: 0 bicubic_degrade_power: 0 color_degrade_power: 0
Method 4.
Use interactive merger? ( y/n ) : n # 不能选 y!
mode: overlay
mask_mode: learned-prd
erode_mask_modifier: 0
blur_mask_modifier: 0
motion_blur_power: 0
output_face_scale: -5
color_transfer_mode: rct
sharpen_mode : None
blursharpen_amount : 0
super_resolution_power: 16
image_denoise_power: 0
bicubic_degrade_power: 0
color_degrade_power: 0
Number of workers:48