ConsisID

PKU-YuanGroupApache-2.0更新放缓

基于扩散模型的身份保持文本到视频生成方案,通过频域分解在生成视频中稳定保持人物面部身份,适合做可控人物视频生成。

[CVPR 2025 Highlight🔥] Identity-Preserving Text-to-Video Generation by Frequency Decomposition

暂无版本864star48fork同步于 2026-11-07 07:30 UTC

怎么上手

由 README 提炼,执行前请确认
pip install diffusers==0.33.1
snapshot_download(repo_id="BestWishYsh/ConsisID-preview", local_dir="BestWishYsh/ConsisID-preview")
硬件要求按 README 说明

README 未说明具体显存要求;示例代码使用 device="cuda" 与 bfloat16 推理,需 NVIDIA GPU。

需要 CUDA多卡 / 张量并行
下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

免微调的身份保持文生视频模型,让生成视频里的人脸始终是同一人

基于扩散模型的身份保持文本到视频生成方案,通过频域分解在生成视频中稳定保持人物面部身份,适合做可控人物视频生成。

核心能力

  • 基于 DiT 的可控 IPT2V 模型,无需微调即可保持人物身份一致
  • 用频率分解思路区分身份特征与动态信息
  • 已并入 diffusers,可直接用 ConsisIDPipeline 推理
  • 提供 TeaCache 缓存推理与 xDiT 并行推理加速代码
  • 支持多身份标注的数据预处理与评测指标代码

容易踩的坑

需先下载 BestWishYsh/ConsisID-preview 权重与人脸模型,否则无法推理;diffusers 版本需 0.33.1 及以上,旧版本不支持 ConsisIDPipeline;输入图片中的人脸必须清晰可见,否则身份保持效果差。

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

最近发版

0 个版本

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

用户点评

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

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

    README 原文

    未翻译

    hf_space Open In Colab hf_paper arXiv Home Page Dataset zhihu zhihu zhihu License github

    Open-Sora Plan: Open-Source Large Video Generation Model Bin Lin, Yunyang Ge and Xinhua Cheng etc. github github arXiv

    Helios: Real Real-Time Long Video Generation Model Shenghai Yuan, Jinfa Huang and Xianyi He etc. github github arXiv

    OpenS2V-Nexus: A Detailed Benchmark and Million-Scale Dataset for Subject-to-Video Generation Shenghai Yuan, Xianyi He and Yufan Deng etc. github github arXiv

    MagicTime: Time-lapse Video Generation Models as Metamorphic Simulators Shenghai Yuan, Jinfa Huang and Yujun Shi etc. github github arXiv

    ChronoMagic-Bench: A Benchmark for Metamorphic Evaluation of Text-to-Time-lapse Video Generation Shenghai Yuan, Jinfa Huang and Yongqi Xu etc. github github arXiv

    📣 News

    • ⏳⏳⏳ Release the full code & datasets & weights.
    • [2026.03.08] 👋 We introduce Helios, a breakthrough video generation model that achieves minute-scale, high-quality video synthesis at 19.5 FPS on a single H100 GPU — without relying on conventional long video anti-drifting strategies or standard video acceleration techniques. Welcome to check Technical Report!
    • [2025.08.30] 🚀 Thanks for the excellent work DanceGRPO on transferring ConsisID data for I2V RL training, please refer to here for more details. Similarly, you can also try using OpenS2V-5M for RL training.
    • [2025.05.27] 🔥 Introducing ​​OpenS2V-Nexus​​, which consists of: (i) ​​OpenS2V-Eval​​, a fine-grained benchmark, and (ii) ​​OpenS2V-5M​​, a million-scale dataset. Welcome to try it!
    • [2025.04.04] 🔥 Breaking news! ConsisID has been recommended as CVPR Highlight.
    • [2025.03.27] 🔥 We have updated our technical report. Please click here to view it.
    • [2025.02.27] 🔥 ConsisID has been accepted by CVPR 2025, and we will update arXiv with more details soon. Stay tuned!
    • [2025.02.16] 🔥 We have adapted the code for CogVideoX1.5, and you can use our code not only for training ConsisID but also for the CogVideoX-series.
    • [2025.01.19] 🤗 Thanks @arrow, @yiyixuxu, @hlky and @stevhliu, ConsisID will be merged into diffusers in 0.33.0. So for now, please use pip install git+https://github.com/huggingface/diffusers.git to install diffusers dev version. And we have reorganized the code and weight configs, so it's better to update your local files if you have cloned them previously.
    • [2024.12.26] 🚀 We release the cache inference code for ConsisID powered by TeaCache. Thanks @LiewFeng for his help.
    • [2024.12.24] 🚀 We release the parallel inference code for ConsisID powered by xDiT. Thanks @feifeibear for his help.
    • [2024.12.09] 🔥We release the test set and metric calculation code used in the paper, now your can measure the metrics on your own machine. Please refer to this guide for more details.
    • [2024.12.08] 🔥The code for data preprocessing is out, which is used to obtain the training data required by ConsisID, supporting multi-id annotation. Please refer to this guide for more details.
    • [2024.12.04] Thanks @shizi for providing 🤗Windows-ConsisID and 🟣Windows-ConsisID, which make it easy to run ConsisID on Windows.
    • [2024.12.01] 🔥 We provide full text prompts corresponding to all the videos on project page. Click here to get and try the demo.
    • [2024.11.30] 🤗 We have fixed the huggingface demo, welcome to try it.
    • [2024.11.29] 🏃‍♂️ The current code and weights are our early versions, and the differences with the latest version in arxiv can be viewed here. And we will release the full code in the next few days.
    • [2024.11.28] Thanks @camenduru for providing Jupyter Notebook and @Kijai for providing ComfyUI Extension ComfyUI-ConsisIDWrapper. If you find related work, please let us know.
    • [2024.11.27] 🏃‍♂️ Due to policy restrictions, we only open-source part of the dataset. You can download it by clicking here. And we will release the data processing code in the next few days.
    • [2024.11.26] 🔥 We release the arXiv paper for ConsisID, and you can click here to see more details.
    • [2024.11.22] 🔥 All code & datasets are coming soon! Stay tuned 👀!

    😍 Gallery

    Identity-Preserving Text-to-Video Generation. (Some best prompts here)

    Demo Video of ConsisID or you can click here to watch the video.

    🤗 Demo

    Diffusers API

    !pip install diffusers==0.33.1
    import torch
    from diffusers import ConsisIDPipeline
    from diffusers.pipelines.consisid.consisid_utils import prepare_face_models, process_face_embeddings_infer
    from diffusers.utils import export_to_video
    from huggingface_hub import snapshot_download
    
    snapshot_download(repo_id="BestWishYsh/ConsisID-preview", local_dir="BestWishYsh/ConsisID-preview")
    face_helper_1, face_helper_2, face_clip_model, face_main_model, eva_transform_mean, eva_transform_std = (
        prepare_face_models("BestWishYsh/ConsisID-preview", device="cuda", dtype=torch.bfloat16)
    )
    pipe = ConsisIDPipeline.from_pretrained("BestWishYsh/ConsisID-preview", torch_dtype=torch.bfloat16)
    pipe.to("cuda")
    
    # ConsisID works well with long and well-described prompts. Make sure the face in the image is clearly visible (e.g., preferably half-body or full-body).
    prompt = "The video captures a boy walking along a city street, filmed in black and white on a classic 35mm camera. His expression is thoughtful, his brow slightly furrowed as if he's lost in contemplation. The film grain adds a textured, timeless quality to the image, evoking a sense of nostalgia. Around him, the cityscape is filled with vintage buildings, cobblestone sidewalks, and softly blurred figures passing by, their outlines faint and indistinct. Streetlights cast a gentle glow, while shadows play across the boy's path, adding depth to the scene. The lighting highlights the boy's subtle smile, hinting at a fleeting moment of curiosity. The overall cinematic atmosphere, complete with classic film still aesthetics and dramatic contrasts, gives the scene an evocative and introspective feel."
    image = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/consisid/consisid_input.png?download=true"
    
    id_cond, id_vit_hidden, image, face_kps = process_face_embeddings_infer(
        face_helper_1,
        face_clip_model,
        face_helper_2,
        eva_transform_mean,
        eva_transform_std,
        face_main_model,
        "cuda",
        torch.bfloat16,
        image,
        is_align_face=True,
    )
    
    video = pipe(
        image=image,
        prompt=prompt,
        num_inference_steps=50,
        guidance_scale=6.0,
        use_dynamic_cfg=False,
        id_vit_hidden=id_vit_hidden,
        id_cond=id_cond,
        kps_cond=face_kps,
        generator=torch.Generator("cuda").manual_seed(42),
    )
    export_to_video(video.frames[0], "output.mp4", fps=8)
    

    Gradio Web UI

    Highly recommend trying out our web demo by the following command, which incorporates all features currently supported by ConsisID. We also provide online demo in Hugging Face Spaces.

    python app.py
    

    CLI Inference

    python infer.py --model_path BestWishYsh/ConsisID-preview
    

    warning: It is worth noting that even if we use the same seed and prompt but we change a machine, the results will be different.

    Prompt Refiner

    ConsisID has high requirements for prompt quality. You can use GPT-4o to refine the input text prompt, an example is as follows (original prompt: "a man is playing guitar.")

    a man is playing guitar.
    
    Change the sentence above to something like this (add some facial changes, even if they are minor. Don't make the sentence too long): 
    
    The video features a man standing next to an airplane, engaged in a conversation on his cell phone. he is wearing sunglasses and a black top, and he appears to be talking seriously. The airplane has a green stripe running along its side, and there is a large engine visible behind his. The man seems to be standing near the entrance of the airplane, possibly preparing to board or just having disembarked. The setting suggests that he might be at an airport or a private airfield. The overall atmosphere of the video is professional and focused, with the man's attire and the presence of the airplane indicating a business or travel context.
    

    Some sample prompts are available here.

    GPU Memory Optimization

    ConsisID requires about 44 GB of GPU memory to decode 49 frames (6 seconds of video at 8 FPS) with output resolution 720x480 (W x H), which makes it not possible to run on consumer GPUs or free-tier T4 Colab. The following memory optimizations could be used to reduce the memory footprint. For replication, you can refer to this script.

    Feature (overlay the previous)Max Memory AllocatedMax Memory Reserved
    -37 GB44 GB
    enable_model_cpu_offload22 GB25 GB
    enable_sequential_cpu_offload16 GB22 GB
    vae.enable_slicing16 GB22 GB
    vae.enable_tiling5 GB7 GB
    # turn on if you don't have multiple GPUs or enough GPU memory(such as H100)
    pipe.enable_model_cpu_offload()
    pipe.enable_sequential_cpu_offload()
    pipe.vae.enable_slicing()
    pipe.vae.enable_tiling()
    

    warning: it will cost more time in inference and may also reduce the quality.

    🚀 Parallel Inference on Multiple GPUs by xDiT

    xDiT is a Scalable Inference Engine for Diffusion Transformers (DiTs) on multi-GPU Clusters. It has successfully provided low-latency parallel inference solutions for a variety of DiTs models. For example, to generate a video with 6 GPUs, you can use the following command:

    cd tools/parallel_inference
    bash run.sh
    # run_usp.sh
    

    🚀 Cache Inference by TeaCache

    TeaCache is a training-free caching approach that estimates and leverages the fluctuating differences among model outputs across timesteps, thereby accelerating the inference. For example, you can use the following command:

    cd tools/cache_inference
    bash run.sh
    

    ⚙️ Requirements and Installation

    We recommend the requirements as follows.

    Environment

    # 0. Clone the repo
    git clone --depth=1 https://github.com/PKU-YuanGroup/ConsisID.git
    cd ConsisID
    
    # 1. Create conda environment
    conda create -n consisid python=3.11.0
    conda activate consisid
    
    # 3. Install PyTorch and other dependencies using conda
    # CUDA 11.8
    conda install pytorch==2.5.1 torchvision==0.20.1 torchaudio==2.5.1 pytorch-cuda=11.8 -c pytorch -c nvidia
    # CUDA 12.1
    conda install pytorch==2.5.1 torchvision==0.20.1 torchaudio==2.5.1 pytorch-cuda=12.1 -c pytorch -c nvidia
    
    # 4. Install pip dependencies
    pip install -r requirements.txt
    

    Download ConsisID

    The weights are available at 🤗HuggingFace, 🤖ModelScope and 🟣WiseModel, and will be automatically downloaded when runing app.py and infer.py, or you can download it with the following commands.

    # way 1
    # if you are in china mainland, run this first: export HF_ENDPOINT=https://hf-mirror.com
    cd util
    python download_weights.py
    
    # way 2
    # if you are in china mainland, run this first: export HF_ENDPOINT=https://hf-mirror.com
    huggingface-cli download --repo-type model \
    BestWishYsh/ConsisID-preview \
    --local-dir ckpts
    
    # way 3
    modelscope download --model \
    BestWishYSH/ConsisID-preview \
    --local-dir ckpts
    
    # way 4
    git lfs install
    git clone https://www.wisemodel.cn/SHYuanBest/ConsisID-Preview.git
    

    Once ready, the weights will be organized in this format:

    📦 ckpts/
    ├── 📂 data_process/
    ├── 📂 face_encoder/
    ├── 📂 scheduler/
    ├── 📂 text_encoder/
    ├── 📂 tokenizer/
    ├── 📂 transformer/
    ├── 📂 vae/
    ├── 📄 configuration.json
    ├── 📄 model_index.json
    

    🗝️ Training

    Data preprocessing

    Please refer to this guide for how to obtain the training data required by ConsisID. If you want to train your own identity-preserving text-to-video generation model, you need to arrange all the dataset in this format:

    📦 datasets/
    ├── 📂 captions/
    │   ├── 📄 dataname_1.json
    │   ├── 📄 dataname_2.json
    ├── 📂 dataname_1/
    │   ├── 📂 refine_bbox_jsons/
    │   ├── 📂 track_masks_data/
    │   ├── 📂 videos/
    ├── 📂 dataname_2/
    │   ├── 📂 refine_bbox_jsons/
    │   ├── 📂 track_masks_data/
    │   ├── 📂 videos/
    ├── ...
    ├── 📄 total_train_data.txt
    

    Video DiT training

    First, setting hyperparameters:

    Then, we run the following bash to start training:

    # For single rank
    bash train_single_rank.sh
    # For multi rank
    bash train_multi_rank.sh
    

    🙌 Friendly Links

    We found some plugins created by community developers. Thanks for their efforts:

    If you find related work, please let us know.

    🐳 Dataset

    We release the subset of the data used to train ConsisID. The dataset is available at HuggingFace, or you can download it with the following command. Some samples can be found on our Project Page.

    huggingface-cli download --repo-type dataset \
    BestWishYsh/ConsisID-preview-Data \
    --local-dir BestWishYsh/ConsisID-preview-Data
    

    🛠️ Evaluation

    We release the data used for evaluation in ConsisID, which is available at HuggingFace. Please refer to this guide for how to evaluate customized model.

    👍 Acknowledgement

    🔒 License

    • The majority of this project is released under the Apache 2.0 license as found in the LICENSE file.
    • The CogVideoX-5B model (Transformers module) is released under the CogVideoX LICENSE.
    • The service is a research preview. Please contact us if you find any potential violations. ([email protected])

    ✏️ Citation

    If you find our paper and code useful in your research, please consider giving a star :star: and citation :pencil:.

    @inproceedings{yuan2025identity,
      title={Identity-preserving text-to-video generation by frequency decomposition},
      author={Yuan, Shenghai and Huang, Jinfa and He, Xianyi and Ge, Yunyang and Shi, Yujun and Chen, Liuhan and Luo, Jiebo and Yuan, Li},
      booktitle={Proceedings of the Computer Vision and Pattern Recognition Conference},
      pages={12978--12988},
      year={2025}
    }
    

    🤝 Contributors