thisisthecodebehindtheswitchingedsblogpost。
seethelinkforanexplanationofthecode。
torunthescriptyou ' llneedtoinstalldlib (http://dlib.net ) including its
Python bindings,and opencv.you ' llalsoneedtoobtainthetrainedmodelfrom
sourceforge。
unzipwithbunzip2andchangepredictor _ pathtorefertothisfile.the
script is run like so:
./faceswap.py
If successful,afile output.jpgwillbeproducedwiththefacialfeatures
来自
replacedwiththefacialfeaturesfrom .安装说明
安装python编译器,然后单击、
python2.7. 15版
https://www.python.org
安装相关软件包
在根目录下运行,即在faceswap/下运行:
pip install -r requirements.txt
运行脚本
在根目录中,执行命令
python faceswap.py
例如:
pythonfaceswap.py image/01.jpg image/016.jpg
生成照片并将其定位在根目录下:
output.jpg是换脸后的效果。
另外,需要说明的是:
该算法只能处理只包含一张脸的照片,多张脸报告错误,运行成功。
目录结构说明
faceswap
自述. MD .本文档
requirements.txt .所需的依赖包
faceswap.py .运行脚本
shape _ predictor _ 68 _ face _ landmarks.dat .人脸识别库
image/…保存原始照片的目录
( output.jpg .中生成的脸部改变结果的照片