前提
- 建议python3.8-python3.10环境
- 安装ffmpeg-release-full(多媒体处理框架),配置环境变量;音视频处理的核心。安装教程
- 源码地址:https://github.com/OpenTalker/SadTalker.git
- 博主测试成功的最低pc配置: i3-3240CPU / 4核8G / 集成显卡 Intel ® HD Graphics;19秒音频生成时长约3小时
部署
1.项目源码获取
若安装有git:创建该项目根目录,使用cmd或者 git bash打开命令窗口,输入命令:git clone https://github.com/winfredy/SadTalker.git
也可直接在源码地址下载压缩包解压即用:
2.依赖文件获取
源码地址下载项目所需的依赖文件:
在项目源码根目录下创建文件夹checkpoints
,然后下载对应文件放入;
然后再下载gfpgan
文件包,解压放在项目根目录下;
3.调整相关配置
修改requirements.txt
文件,指定其中的gradio==3.50.0
版本,不指定版本会下载高版本,不兼容
4.运行
运行项目根目录下的webui.bat
:博主本地用了anaconda
,且设置了清华源;先创建了一个sad
虚拟环境,conda create -n sad python=3.8
;激活环境,conda activate sad
;再执行webui.bat;脚本启动会自动下载requirements.txt
中的依赖
运行出错,红色部分这个错误如果python版本过高也会出现,博主这里是科学上网导致的,遂关闭科学上网。
备注
其他的博主出现过使用清华源tb-nightly
依赖包缺失,修改为阿里源下载该依赖
// pip配置阿里源
pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
// conda 配置阿里源
conda config --add channels https://mirrors.aliyun.com/anaconda/pkgs/main/
conda config --add channels https://mirrors.aliyun.com/anaconda/pkgs/free/
博主测试安装依赖出现的异常情况处理方式
1、与科学上网有关,国内镜像源关闭科学上网,当切换多个国内镜像源依赖下载依旧异常,试试清除缓存pip cache purge
再进行依赖安装;可以设置回到默认PyPi镜像源https://pypi.org/simple
;
2、可删除镜像源配置文件(包括代理设置、镜像源、包缓存目录),避免镜像源污染,使用默认源,建议科学上网
直接使用python环境:配置文件pip.ini
使用conda环境:配置文件.condarc
镜像源配置
以下是其他博客借鉴过来的镜像源常规配置操作conda及pip设置镜像源
pip 镜像源管理
# 查看当前配置
pip config list
# 设置镜像源
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
# 删除镜像源设置
pip config unset global.index-url
# 设置官方默认源
pip config set global.index-url https://pypi.org/simple
conda 镜像源管理
# 查看当前配置
conda config --show channels
# 添加镜像源
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes
# 删除指定镜像源
conda config --remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
# 删除所有自定义源(恢复默认)
conda config --remove-key channels
# 禁用显示源URL
conda config --set show_channel_urls false
常用的镜像源地址
# PyPI 官方源
https://pypi.org/simple
# 清华源
pip: https://pypi.tuna.tsinghua.edu.cn/simple
conda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
# 阿里源
pip: https://mirrors.aliyun.com/pypi/simple
conda: https://mirrors.aliyun.com/anaconda/pkgs/main/
# 中科大源
pip: https://pypi.mirrors.ustc.edu.cn/simple
conda: https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
网上搜集的相关注意事项
1、图片分辨率建议512512 ;生成结果可能存在水印
2、B站有测试者提出:一分十八秒视频,图片512512cpu i7 13700 4080 32GB ,程序内存占用17GB显存占用7.5GB耗时34分钟,建议32G内存显存10GB以上显卡
3、手动生成视频需要执行命令:
python inference.py --driven_audio e:\temp\sadtalker\speech_0.wav --source_image e:\temp\sadtalker\1.png --result_dir e:\temp\sadtalker --still --preprocess full --enhancer gfpgan
// e:\temp\sadtalker\speech_0.wav 替换成 你的语音文件
// e:\temp\sadtalker\1.png 替换从你的图片
// e:\temp\sadtalker 替换成你的输出目录