文章地址:
1、搭建环境
#下载代码
git clone https://github.com/tencent-ailab/V-Express
#创建环境
conda create -n v-express python=3.10
conda activate v-express
#安装依赖
pip install requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
2、下载模型
有外网可以git
git clone https://huggingface.co/tk93/V-Express
我的服务器下载不了,只能手动下载,将tk93/V-Express at main (huggingface.co)模型下载下来
下载模型后执行
mv V-Express/model_ckpts model_ckpts
mv V-Express/*.bin model_ckpts/v-express
最终在项目目录下有一个model_ckpts目录,目录结构如下:
3、运行
(1)首先运行一下文档给的例子,根据给定的图像的音频生成说话视频。
python inference.py \
--reference_image_path "./test_samples/short_case/AOC/ref.jpg" \
--audio_path "./test_samples/short_case/AOC/aud.mp3" \
--kps_path "./test_samples/short_case/AOC/kps.pth" \
--output_path "./output/short_case/talk_AOC_no_retarget.mp4" \
--retarget_strategy "no_retarget" \
--num_inference_steps 25
结果保存在./output/short_case/talk_AOC_no_retarget.mp4
(2)假如使用自己的视频,需要先预处理一下,准备一段视频(正方形)和一张图片,执行下面的代码,获取推理时需要的kps.pth和aud.mp3.
python scripts/extract_kps_sequence_and_audio.py --video_path "./test_samples/test/test.mp4" --kps_sequence_save_path "./test_samples/test/kps.pth" --audio_save_path "./test_samples/test/aud.mp3"
执行后目录结构如下
预处理后可以和(1)步骤相同进行推理,改一下路径即可
python inference.py --reference_image_path "./test_samples/test/test.jpg" --audio_path "./test_samples/test/aud.mp3" --kps_path "./test_samples/test/kps.pth" --output_path "./output/test/test.mp4" --retarget_strategy "no_retarget" --num_inference_steps 25
4、可能遇到的问题
(v-express) root@hcjcekwolbnqmfih-snow-675dbcfb64-95n8q:/data/coding/V-Express-main/V-Express-main# python inference.py --reference_image_path "./test_samples/short_case/AOC/ref.jpg" --audio_path "./test_samples/short_case/AOC/aud.mp3" --kps_path "./test_samples/short_case/AOC/kps.pth" --output_path "./output/short_case/talk_AOC_no_retarget.mp4" --retarget_strategy "no_retarget" --num_inference_steps 25
Traceback (most recent call last):
File "/data/coding/V-Express-main/V-Express-main/inference.py", line 5, in <module>
import accelerate
ModuleNotFoundError: No module named 'accelerate'
安装一下就行
pip install accelerate