MuseTalk: Real-Time High Quality Lip Synchronization with Latent Space Inpainting
Yue Zhang *,
Minhao Liu*,
Zhaokang Chen,
Bin Wuโ ,
Yingjie He,
Chao Zhan,
Wenjiang Zhou
(*Equal Contribution, โ Corresponding Author, benbinwu@tencent.com)
Lyra Lab, Tencent Music Entertainment
github huggingface space Project (comming soon) Technical report (comming soon)
We introduce MuseTalk
, a real-time high quality lip-syncing model (30fps+ on an NVIDIA Tesla V100). MuseTalk can be applied with input videos, e.g., generated by MuseV, as a complete virtual human solution.
๐ Update: We are thrilled to announce that MusePose has been released. MusePose is an image-to-video generation framework for virtual human under control signal like pose. Together with MuseV and MuseTalk, we hope the community can join us and march towards the vision where a virtual human can be generated end2end with native ability of full body movement and interaction.
Join Lyra Lab, Tencent Music Entertainment!
We are currently seeking AIGC researchers including Internships, New Grads, and Senior (ๅฎไน ใๆ กๆใ็คพๆ).
Please find details in the following two links or contact zkangchen@tencent.com
- AI Researcher (https://join.tencentmusic.com/social/post-details/?id=13488, https://join.tencentmusic.com/social/post-details/?id=13502)
MuseTalk
is a real-time high quality audio-driven lip-syncing model trained in the latent space of ft-mse-vae
, which
- modifies an unseen face according to the input audio, with a size of face region of
256 x 256
. - supports audio in various languages, such as Chinese, English, and Japanese.
- supports real-time inference with 30fps+ on an NVIDIA Tesla V100.
- supports modification of the center point of the face region proposes, which SIGNIFICANTLY affects generation results.
- checkpoint available trained on the HDTF dataset.
- training codes (comming soon).
- [04/02/2024] Release MuseTalk project and pretrained models.
- [04/16/2024] Release Gradio demo on HuggingFace Spaces (thanks to HF team for their community grant)
- [04/17/2024] ๐ฃ We release a pipeline that utilizes MuseTalk for real-time inference.
MuseTalk was trained in latent spaces, where the images were encoded by a freezed VAE. The audio was encoded by a freezed whisper-tiny
model. The architecture of the generation network was borrowed from the UNet of the stable-diffusion-v1-4
, where the audio embeddings were fused to the image embeddings by cross-attention.
Note that although we use a very similar architecture as Stable Diffusion, MuseTalk is distinct in that it is NOT a diffusion model. Instead, MuseTalk operates by inpainting in the latent space with a single step.
- The character of the last two rows,
Xinying Sun
, is a supermodel KOL. You can follow her on douyin.
MuseTalk | Original videos |
Let_the_Bullets_Fly.mp4 |
Link |
- For video dubbing, we applied a self-developed tool which can identify the talking person.
Image | MuseV + MuseTalk |
video1.mov |
- trained models and inference codes.
- Huggingface Gradio demo.
- codes for real-time inference.
- technical report.
- training codes.
- a better model (may take longer).
We provide a detailed tutorial about the installation and the basic usage of MuseTalk for new users:
Thanks for the third-party integration, which makes installation and use more convenient for everyone. We also hope you note that we have not verified, maintained, or updated third-party. Please refer to this project for specific results.
To prepare the Python environment and install additional packages such as opencv, diffusers, mmcv, etc., please follow the steps below:
We recommend a python version >=3.10 and cuda version =11.7. Then build environment as follows:
pip install -r requirements.txt
pip install --no-cache-dir -U openmim
mim install mmengine
mim install "mmcv>=2.0.1"
mim install "mmdet>=3.1.0"
mim install "mmpose>=1.1.0"
Download the ffmpeg-static and
export FFMPEG_PATH=/path/to/ffmpeg
for example:
export FFMPEG_PATH=/musetalk/ffmpeg-4.4-amd64-static
You can download weights manually as follows:
-
Download our trained weights.
-
Download the weights of other components:
Finally, these weights should be organized in models
as follows:
./models/
โโโ musetalk
โ โโโ musetalk.json
โ โโโ pytorch_model.bin
โโโ dwpose
โ โโโ dw-ll_ucoco_384.pth
โโโ face-parse-bisent
โ โโโ 79999_iter.pth
โ โโโ resnet18-5c106cde.pth
โโโ sd-vae-ft-mse
โ โโโ config.json
โ โโโ diffusion_pytorch_model.bin
โโโ whisper
โโโ tiny.pt
Here, we provide the inference script.
python -m scripts.inference --inference_config configs/inference/test.yaml
configs/inference/test.yaml is the path to the inference configuration file, including video_path and audio_path. The video_path should be either a video file, an image file or a directory of images.
You are recommended to input video with 25fps
, the same fps used when training the model. If your video is far less than 25fps, you are recommended to apply frame interpolation or directly convert the video to 25fps using ffmpeg.
๐ We have found that upper-bound of the mask has an important impact on mouth openness. Thus, to control the mask region, we suggest using the bbox_shift
parameter. Positive values (moving towards the lower half) increase mouth openness, while negative values (moving towards the upper half) decrease mouth openness.
You can start by running with the default configuration to obtain the adjustable value range, and then re-run the script within this range.
For example, in the case of Xinying Sun
, after running the default configuration, it shows that the adjustable value rage is [-9, 9]. Then, to decrease the mouth openness, we set the value to be -7
.
python -m scripts.inference --inference_config configs/inference/test.yaml --bbox_shift -7
๐ More technical details can be found in bbox_shift.
As a complete solution to virtual human generation, you are suggested to first apply MuseV to generate a video (text-to-video, image-to-video or pose-to-video) by referring this. Frame interpolation is suggested to increase frame rate. Then, you can use MuseTalk
to generate a lip-sync video by referring this.
Here, we provide the inference script. This script first applies necessary pre-processing such as face detection, face parsing and VAE encode in advance. During inference, only UNet and the VAE decoder are involved, which makes MuseTalk real-time.
python -m scripts.realtime_inference --inference_config configs/inference/realtime.yaml --batch_size 4
configs/inference/realtime.yaml is the path to the real-time inference configuration file, including preparation
, video_path
, bbox_shift
and audio_clips
.
- Set
preparation
toTrue
inrealtime.yaml
to prepare the materials for a newavatar
. (If thebbox_shift
has changed, you also need to re-prepare the materials.) - After that, the
avatar
will use an audio clip selected fromaudio_clips
to generate video.Inferring using: data/audio/yongen.wav
- While MuseTalk is inferring, sub-threads can simultaneously stream the results to the users. The generation process can achieve 30fps+ on an NVIDIA Tesla V100.
- Set
preparation
toFalse
and run this script if you want to genrate more videos using the same avatar.
- If you want to generate multiple videos using the same avatar/video, you can also use this script to SIGNIFICANTLY expedite the generation process.
- In the previous script, the generation time is also limited by I/O (e.g. saving images). If you just want to test the generation speed without saving the images, you can run
python -m scripts.realtime_inference --inference_config configs/inference/realtime.yaml --skip_save_images
- We thank open-source components like whisper, dwpose, face-alignment, face-parsing, S3FD.
- MuseTalk has referred much to diffusers and isaacOnline/whisper.
- MuseTalk has been built on HDTF datasets.
Thanks for open-sourcing!
-
Resolution: Though MuseTalk uses a face region size of 256 x 256, which make it better than other open-source methods, it has not yet reached the theoretical resolution bound. We will continue to deal with this problem.
If you need higher resolution, you could apply super resolution models such as GFPGAN in combination with MuseTalk. -
Identity preservation: Some details of the original face are not well preserved, such as mustache, lip shape and color.
-
Jitter: There exists some jitter as the current pipeline adopts single-frame generation.
@article{musetalk,
title={MuseTalk: Real-Time High Quality Lip Synchorization with Latent Space Inpainting},
author={Zhang, Yue and Liu, Minhao and Chen, Zhaokang and Wu, Bin and He, Yingjie and Zhan, Chao and Zhou, Wenjiang},
journal={arxiv},
year={2024}
}
code
: The code of MuseTalk is released under the MIT License. There is no limitation for both academic and commercial usage.model
: The trained model are available for any purpose, even commercially.other opensource model
: Other open-source models used must comply with their license, such aswhisper
,ft-mse-vae
,dwpose
,S3FD
, etc..- The testdata are collected from internet, which are available for non-commercial research purposes only.
AIGC
: This project strives to impact the domain of AI-driven video generation positively. Users are granted the freedom to create videos using this tool, but they are expected to comply with local laws and utilize it responsibly. The developers do not assume any responsibility for potential misuse by users.