LatentSync

bytedanceApache-2.0长期未更新

用 Stable Diffusion 做音频驱动唇形同步,让视频或虚拟人像的口型与语音对齐,适合做数字人和视频配音。

Taming Stable Diffusion for Lip Sync!

暂无版本6,266star +10 / 7 天1,004fork同步于 2026-11-10 23:35 UTC

怎么上手

由 README 提炼,执行前请确认
source setup_env.sh
python gradio_app.py
硬件要求按 README 说明

推理最低显存:LatentSync 1.5 需 8 GB,1.6 需 18 GB;训练 stage1 需 23 GB、stage2 需 30 GB,efficient 版 20 GB,512 分辨率训练最高需 55 GB。README 未说明 CPU 推理与 GPU 厂商型号。

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

基于音频条件潜在扩散的端到端口型同步工具,可直接用 Stable Diffusion 给视频对口型

用 Stable Diffusion 做音频驱动唇形同步,让视频或虚拟人像的口型与语音对齐,适合做数字人和视频配音。

核心能力

  • 用 Whisper 提取音频嵌入,经 cross-attention 注入 U-Net
  • 在潜空间直接建模音视频关联,无需中间运动表示
  • 提供 Gradio 界面和命令行两种推理方式
  • 附带数据处理流水线与 U-Net、SyncNet 训练脚本
  • 提供 SyncNet 检查点用于评估同步置信度

容易踩的坑

setup_env.sh 会同时下载 latentsync_unet.pt 和 whisper/tiny.pt,也可从 HuggingFace 手动下载;训练 U-Net 前需先跑数据处理流水线并单独下载 stable_syncnet.pt;评估 SyncNet 前测试数据必须先用官方流水线处理。

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

0 个版本

暂无 release 数据(可能没有发版,或尚未同步)。

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    arXiv arXiv arXiv

    🔥 Updates

    • 2025/06/11: We released LatentSync 1.6, which is trained on 512 $\times$ 512 resolution videos to mitigate the blurriness problem. Watch the demo here.

    • 2025/03/14: We released LatentSync 1.5, which (1) improves temporal consistency via adding temporal layer, (2) improves performance on Chinese videos and (3) reduces the VRAM requirement of the stage2 training to 20 GB through a series of optimizations. Learn more details here.

    📖 Introduction

    We present LatentSync, an end-to-end lip-sync method based on audio-conditioned latent diffusion models without any intermediate motion representation, diverging from previous diffusion-based lip-sync methods based on pixel-space diffusion or two-stage generation. Our framework can leverage the powerful capabilities of Stable Diffusion to directly model complex audio-visual correlations.

    🏗️ Framework

    LatentSync uses the Whisper to convert melspectrogram into audio embeddings, which are then integrated into the U-Net via cross-attention layers. The reference and masked frames are channel-wise concatenated with noised latents as the input of U-Net. In the training process, we use a one-step method to get estimated clean latents from predicted noises, which are then decoded to obtain the estimated clean frames. The TREPA, LPIPS and SyncNet losses are added in the pixel space.

    🎬 Demo

    (Photorealistic videos are filmed by contracted models, and anime videos are from VASA-1)

    📑 Open-source Plan

    • Inference code and checkpoints
    • Data processing pipeline
    • Training code

    🔧 Setting up the Environment

    Install the required packages and download the checkpoints via:

    source setup_env.sh
    

    If the download is successful, the checkpoints should appear as follows:

    ./checkpoints/
    |-- latentsync_unet.pt
    |-- whisper
    |   `-- tiny.pt
    

    Or you can download latentsync_unet.pt and tiny.pt manually from our HuggingFace repo

    🚀 Inference

    Minimum VRAM for inference:

    • 8 GB with LatentSync 1.5
    • 18 GB with LatentSync 1.6

    There are two ways to perform inference:

    1. Gradio App

    Run the Gradio app for inference:

    python gradio_app.py
    

    2. Command Line Interface

    Run the script for inference:

    ./inference.sh
    

    You can try adjusting the following inference parameters to achieve better results:

    • inference_steps [20-50]: A higher value improves visual quality but slows down the generation speed.
    • guidance_scale [1.0-3.0]: A higher value improves lip-sync accuracy but may cause the video distortion or jitter.

    🔄 Data Processing Pipeline

    The complete data processing pipeline includes the following steps:

    1. Remove the broken video files.
    2. Resample the video FPS to 25, and resample the audio to 16000 Hz.
    3. Scene detect via PySceneDetect.
    4. Split each video into 5-10 second segments.
    5. Affine transform the faces according to the landmarks detected by InsightFace, then resize to 256 $\times$ 256.
    6. Remove videos with sync confidence score lower than 3, and adjust the audio-visual offset to 0.
    7. Calculate hyperIQA score, and remove videos with scores lower than 40.

    Run the script to execute the data processing pipeline:

    ./data_processing_pipeline.sh
    

    You should change the parameter input_dir in the script to specify the data directory to be processed. The processed videos will be saved in the high_visual_quality directory. Each step will generate a new directory to prevent the need to redo the entire pipeline in case the process is interrupted by an unexpected error.

    🏋️‍♂️ Training U-Net

    Before training, you should process the data as described above. We released a pretrained SyncNet with 94% accuracy on both VoxCeleb2 and HDTF datasets for the supervision of U-Net training. You can execute the following command to download this SyncNet checkpoint:

    huggingface-cli download ByteDance/LatentSync-1.6 stable_syncnet.pt --local-dir checkpoints
    

    If all the preparations are complete, you can train the U-Net with the following script:

    ./train_unet.sh
    

    We prepared several UNet configuration files in the configs/unet directory, each corresponding to a specific training setup:

    • stage1.yaml: Stage1 training, requires 23 GB VRAM.
    • stage2.yaml: Stage2 training with optimal performance, requires 30 GB VRAM.
    • stage2_efficient.yaml: Efficient Stage 2 training, requires 20 GB VRAM. It may lead to slight degradation in visual quality and temporal consistency compared with stage2.yaml, suitable for users with consumer-grade GPUs, such as the RTX 3090.
    • stage1_512.yaml: Stage1 training on 512 $\times$ 512 resolution videos, requires 30 GB VRAM.
    • stage2_512.yaml: Stage2 training on 512 $\times$ 512 resolution videos, requires 55 GB VRAM.

    Also remember to change the parameters in U-Net config file to specify the data directory, checkpoint save path, and other training hyperparameters. For convenience, we prepared a script for writing a data files list. Run the following command:

    python -m tools.write_fileslist
    

    🏋️‍♂️ Training SyncNet

    In case you want to train SyncNet on your own datasets, you can run the following script. The data processing pipeline for SyncNet is the same as U-Net.

    ./train_syncnet.sh
    

    After validations_steps training, the loss charts will be saved in train_output_dir. They contain both the training and validation loss. If you want to customize the architecture of SyncNet for different image resolutions and input frame lengths, please follow the guide.

    📊 Evaluation

    You can evaluate the sync confidence score of a generated video by running the following script:

    ./eval/eval_sync_conf.sh
    

    You can evaluate the accuracy of SyncNet on a dataset by running the following script:

    ./eval/eval_syncnet_acc.sh
    

    Note that our released SyncNet is trained on data processed through our data processing pipeline, which includes special operations such as affine transformation and audio-visual adjustment. Therefore, before evaluation, the test data must first be processed using the provided pipeline.

    🙏 Acknowledgement

    Thanks for their generous contributions to the open-source community!

    📖 Citation

    If you find our repo useful for your research, please consider citing our paper:

    @article{li2024latentsync,
      title={LatentSync: Taming Audio-Conditioned Latent Diffusion Models for Lip Sync with SyncNet Supervision},
      author={Li, Chunyu and Zhang, Chao and Xu, Weikai and Lin, Jingyu and Xie, Jinghui and Feng, Weiguo and Peng, Bingyue and Chen, Cunjian and Xing, Weiwei},
      journal={arXiv preprint arXiv:2412.09262},
      year={2024}
    }