安装

1、在扩展插件中找到SadTalker 或通过从网址安装https://github.com/OpenTalker/SadTalker
2、下载readmore提供的模型文件放入SadTalker目录下

使用

参数说明

  • upload image 上传一张图片
  • upload or tts 上传语音文件
  • pose style 选择视频人物的姿势,姿势变化种类
  • face model resolution 分辨率:视频分辨率
  • preprocess 图片处理方法,包括crop/resize/full/extcrop/extfull
1
2
3
4
5
crop 从图片中截取头部做视频
resize 拉伸适合大头照或证件照
full 表示保留全身,全身照做视频
extcrop 加强版裁剪主要聚焦头部
extfull 加强版全身
  • still mode 减少头部运动,负面效果就是头不怎么动了
  • batch size in generation 同时处理数,越大处理越快但也费显存(看gpu能力,若能力有限参数影响不大)
  • if GFPGAN 修脸,基于gfpgan对视频进行增强

报错

numpy相关

SadTalker module ‘numpy’ has no attribute ‘complex’.

  1. 找到引发错误的 constantq.py 文件/Users/nanbowan/stable-diffusion-webui/venv/lib/python3.10/site-packages/librosa/core/constantq.py

  2. 备份该文件,然后打开它进行编辑。

  3. 找到使用 np.complex 的代码行:

1
dtype=np.complex,
  1. np.complex 替换为 np.complex128 或 Python 内置的 complex 类型。由于这里涉及到 NumPy 数组,建议使用 np.complex128 以保持一致性:
1
dtype=np.complex128,
  1. 保存文件并退出编辑器。
  2. 重新启动你的应用程序或脚本,

ffmpeg或ffprobe报错

Please install ffmpeg in your system to use non-WAV audio file formats and make sure ffprobe is in your PATH.

  1. 下载ffmpegffprobe
  2. 添加 ffmpegPATH: 如果 ffmpeg 可以被执行,但是系统无法找到 ffprobe,可能是因为 ffprobe 不在 PATH 中。你需要将 ffmpeg 和ffprobe的目录添加到 PATH 环境变量中。如果是 zsh使用open -e ~/.zshrc ;如果使用的是 bash 使用open -e ~/.bash_profile,在你的 .zshrc.bash_profile 文件中添加以下行
1
2
3
# 替换自己的目录
export PATH="/Users/nanbowan/ffmpeg:$PATH"
export PATH="/Users/nanbowan/ffprobe:$PATH"

为了让更改立即生效,你需要重新加载配置文件。你可以通过在终端中运行以下命令来实现,如果是 zsh使用source ~/.zshrc ,如果使用的是 bash 使用source ~/.bash_profile

numpy+float相关

AttributeError: module numpy has no attribute float. np.float was a deprecated alias for the builtin float. To avoid this error in existing code, use float by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use np.float64 here.

  1. 找到银发错误的文件 ../stable-diffusion-webui/extensions/SadTalker/src/face3d/util/my_awing_arch.py和preprocess.py

    1
    2
    3
    4
    5
    6
    7
    # my_awing_arch.py文件:
    将 preds = preds.astype(np.float, copy=False)
    修改为 preds = preds.astype(float, copy=False)

    # preprocess.py文件:
    将 trans_params = np.array([w0, h0, s, t[0], t[1]])
    修改为 trans_params = np.array([w0, h0, s, t[0][0], t[1][0]])
  2. 另外一个错误文件/Users/nanbowan/stable-diffusion-webui/venv/lib/python3.10/site-packages/librosa/util/utils.py


1
2
3
4
5
mapping = {
np.dtype(np.float32): np.complex64,
np.dtype(np.float64): np.complex128,
np.dtype(np.float): np.complex,
}

替换为
1
2
3
4
mapping = {
np.dtype(np.float32): np.complex64,
np.dtype(float): np.complex128, # 使用 Python 内置的 float 类型
}