记录一下faceswap的折腾过程

把项目拉下来:

1
git clone https://github.com/facefusion/facefusion.git --branch 2.0.0 --single-branch

安装Python包

1
2
cd facefusion
pip install --verbose -r requirements.txt --extra-index-url https://download.pytorch.org/whl/cpu -i https://mirrors.aliyun.com/pypi/simple/

如果网络不好,则
自己建个v2ray,设置好局域网访问端口,设置代理

1
2
export http_proxy=http://172.20.1.110:10811
export no_proxy=0.0.0.0,localhost,127.0.0.1,10.7.22.2,10.7.21.2,172.20.2.188

去掉nsfw限制,定位到以下文件
facefusion/facefusion/content_analyser.py

MAX_PROBABILITY = 0.8 改成MAX_PROBABILITY = 100

让其监听0.0.0.0,修改默认端口,并加入登陆验证:
打开facefusion/uis/layouts/default.py

定位到以下代码:

1
2
def run(ui : gradio.Blocks) -> None:
ui.launch(show_api = False)

将其修改成:

1
2
def run(ui : gradio.Blocks) -> None:
ui.launch(show_api = False,server_name='0.0.0.0', server_port=7870,auth=("admin","admin"))