DeepFaceLab视频换脸教程

一. 下载源代码,解压复制到document,文件夹命名为DeepFaceLab,并在终端命令行内cd到文件夹根目录

https://github.com/iperov/DeepFaceLab(DeepFaceLab源码)

cd ~/Documents/DeepFaceLab

二.安装环境

1.python环境切换

conda create -n deepfakes python=3.6

conda activate deepfakes

2.安装支持库

pip install -r requirements-colab.txt

conda install pytorch torchvision -c soumith

conda install -c conda-forge ffmpeg

nano ~/.bash_profile

export LC_ALL=en_US.UTF-8

export LANG=en_US.UTF-8

source ~/.bash_profile

conda activate deepfakes

三.换脸

1.在根目录新建workspace文件夹,并将换脸者视频(data_src.mp4)和被换脸者视频(data_dst.mp4)放入文件夹,新建文件夹data_src和data_dst

2.换脸者视频转为图片

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

3.提取换脸者面部

python main.py extract --input-dir workspace/data_src --output-dir workspace/data_src/aligned --detector manual --cpu-only

4.被换脸者视频转为图片

python main.py videoed extract-video --input-file workspace/data_dst.mp4 --output-dir workspace/data_dst

5.提取被换脸者面部

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

6.开始训练

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

7.换脸

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

8.导出换脸视频

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

你可能感兴趣的:(DeepFaceLab视频换脸教程)