HunyuanCustom

Tencent-Hunyuan长期未更新

腾讯混元开源的多模态定制视频生成架构,支持音频驱动、图生视频和视频编辑,可按输入条件生成定制化视频内容。

HunyuanCustom: A Multimodal-Driven Architecture for Customized Video Generation

暂无版本1,232star109fork同步于 2026-11-07 07:30 UTC

怎么上手

由 README 提炼,执行前请确认
conda create -n HunyuanCustom python==3.10.9
conda activate HunyuanCustom
conda install pytorch==2.4.0 torchvision==0.19.0 torchaudio==2.4.0 pytorch-cuda=11.8 -c pytorch -c nvidia
python -m pip install -r requirements.txt
python -m pip install ninja
python -m pip install git+https://github.com/Dao-AILab/[email protected]
硬件要求按 README 说明

README 提到单卡 8GB 显存即可运行(借助 WanGP),示例命令默认用 8 卡 torchrun 并行推理;具体 GPU 型号未说明。

8G 显存可跑需要 CUDA有 Docker 镜像
下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

腾讯开源的多模态定制视频生成框架,用文本、图像、音频、视频条件生成主体一致的自定义视频

腾讯混元开源的多模态定制视频生成架构,支持音频驱动、图生视频和视频编辑,可按输入条件生成定制化视频内容。

核心能力

  • 支持文本、图像、音频、视频四种条件输入
  • 用 LLaVA 文本图像融合模块增强多模态理解
  • 用图像 ID 增强模块跨帧强化主体身份特征
  • 用 AudioNet 空间交叉注意力实现音频分层对齐
  • 用 patchify 特征对齐网络注入视频条件

容易踩的坑

需先按 models/README.md 单独下载预训练模型权重,否则无法推理;flash-attention 需 CUDA 11.8 以上,部分 GPU 可能报 float point exception 需换 CUDA 12.4 或指定 cu118 版 PyTorch;示例推理命令默认 8 卡并行,单卡需改用低显存方式。

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

最近发版

0 个版本

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

用户点评

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

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

    README 原文

    未翻译

    HunyuanCustom 🌅

    HunyuanCustom: A Multimodal-Driven Architecture for Customized Video Generation

    🔥🔥🔥 News!!

    • June 13, 2025: 🚀 HunyuanCustom supports single GPU with only 8GB VRAM, many thanks to WanGP.
    • June 6, 2025: 💃 We release the inference code and model weights of audio-driven and video-driven powered by OmniV2V.
    • May 13, 2025: 🎉 HunyuanCustom has been integrated into ComfyUI-HunyuanVideoWrapper by Kijai.
    • May 12, 2025: 🔥 HunyuanCustom is available in Cloud-Native-Build (CNB) HunyuanCustom.
    • May 8, 2025: 👋 We release the inference code and model weights of HunyuanCustom. Download.

    📑 Open-source Plan

    • HunyuanCustom
      • Single-Subject Video Customization
        • Inference
        • Checkpoints
        • ComfyUI
      • Audio-Driven Video Customization
        • Inference
        • Checkpoints
        • ComfyUI
      • Video-Driven Video Customization
        • Inference
        • Checkpoints
        • ComfyUI
      • Multi-Subject Video Customization

    Contents


    Abstract

    Customized video generation aims to produce videos featuring specific subjects under flexible user-defined conditions, yet existing methods often struggle with identity consistency and limited input modalities. In this paper, we propose HunyuanCustom, a multi-modal customized video generation framework that emphasizes subject consistency while supporting image, audio, video, and text conditions. Built upon HunyuanVideo, our model first addresses the image-text conditioned generation task by introducing a text-image fusion module based on LLaVA for enhanced multi-modal understanding, along with an image ID enhancement module that leverages temporal concatenation to reinforce identity features across frames. To enable audio- and video-conditioned generation, we further propose modality-specific condition injection mechanisms: an AudioNet module that achieves hierarchical alignment via spatial cross-attention, and a video-driven injection module that integrates latent-compressed conditional video through a patchify-based feature-alignment network. Extensive experiments on single- and multi-subject scenarios demonstrate that HunyuanCustom significantly outperforms state-of-the-art open- and closed-source methods in terms of ID consistency, realism, and text-video alignment. Moreover, we validate its robustness across downstream tasks, including audio and video-driven customized video generation. Our results highlight the effectiveness of multi-modal conditioning and identity-preserving strategies in advancing controllable video generation.

    HunyuanCustom Overall Architecture

    image

    We propose HunyuanCustom, a multi-modal, conditional, and controllable generation model centered on subject consistency, built upon the Hunyuan Video generation framework. It enables the generation of subject-consistent videos conditioned on text, images, audio, and video inputs.

    🎉 HunyuanCustom Key Features

    Multimodal Video customization

    HunyuanCustom supports inputs in the form of text, images, audio, and video. Specifically, it can handle single or multiple image inputs to enable customized video generation for one or more subjects. Additionally, it can incorporate extra audio inputs to drive the subject to speak the corresponding audio. Lastly, HunyuanCustom supports video input, allowing for the replacement of specified objects in the video with subjects from a given image. image

    Various Applications

    With the multi-modal capabilities of HunyuanCustom, numerous downstream tasks can be accomplished. For instance, by taking multiple images as input, HunyuanCustom can facilitate virtual human advertisements and virtual try-on. Additionally, with image and audio inputs, it can create singing avatars. Furthermore, by using an image and a video as inputs, HunyuanCustom supports video editing by replacing subjects in the video with those in the provided image. More applications await your exploration! image

    📈 Comparisons

    To evaluate the performance of HunyuanCustom, we compared it with state-of-the-art video customization methods, including VACE, Skyreels, Pika, Vidu, Keling, and Hailuo. The comparison focused on face/subject consistency, video-text alignment, and overall video quality.

    ModelsFace-SimCLIP-B-TDINO-SimTemp-ConsisDD
    VACE-1.3B0.2040.3080.5690.9670.53
    Skyreels0.4020.2950.5790.9420.72
    Pika0.3630.3050.4850.9280.89
    Vidu2.00.4240.3000.5370.9610.43
    Keling1.60.5050.2850.5800.9140.78
    Hailuo0.5260.3140.4330.9370.94
    HunyuanCustom (Ours)0.6270.3060.5930.9580.71

    📜 Requirements

    The following table shows the requirements for running HunyuanCustom model (batch size = 1) to generate videos:

    ModelSetting(height/width/frame)GPU Peak Memory
    HunyuanCustom720px1280px129f80GB
    HunyuanCustom512px896px129f60GB
    • An NVIDIA GPU with CUDA support is required.
      • The model is tested on a machine with 8GPUs.
      • Minimum: The minimum GPU memory required is 24GB for 720px1280px129f but very slow.
      • Recommended: We recommend using a GPU with 80GB of memory for better generation quality.
    • Tested operating system: Linux

    🛠️ Dependencies and Installation

    Begin by cloning the repository:

    git clone https://github.com/Tencent/HunyuanCustom.git
    cd HunyuanCustom
    

    Installation Guide for Linux

    We recommend CUDA versions 12.4 or 11.8 for the manual installation.

    Conda's installation instructions are available here.

    # 1. Create conda environment
    conda create -n HunyuanCustom python==3.10.9
    
    # 2. Activate the environment
    conda activate HunyuanCustom
    
    # 3. Install PyTorch and other dependencies using conda
    # For CUDA 11.8
    conda install pytorch==2.4.0 torchvision==0.19.0 torchaudio==2.4.0 pytorch-cuda=11.8 -c pytorch -c nvidia
    # For CUDA 12.4
    conda install pytorch==2.4.0 torchvision==0.19.0 torchaudio==2.4.0 pytorch-cuda=12.4 -c pytorch -c nvidia
    
    # 4. Install pip dependencies
    python -m pip install -r requirements.txt
    # 5. Install flash attention v2 for acceleration (requires CUDA 11.8 or above)
    python -m pip install ninja
    python -m pip install git+https://github.com/Dao-AILab/[email protected]
    

    In case of running into float point exception(core dump) on the specific GPU type, you may try the following solutions:

    # Option 1: Making sure you have installed CUDA 12.4, CUBLAS>=12.4.5.8, and CUDNN>=9.00 (or simply using our CUDA 12 docker image).
    pip install nvidia-cublas-cu12==12.4.5.8
    export LD_LIBRARY_PATH=/opt/conda/lib/python3.8/site-packages/nvidia/cublas/lib/
    
    # Option 2: Forcing to explicitly use the CUDA 11.8 compiled version of Pytorch and all the other packages
    pip uninstall -r requirements.txt  # uninstall all packages
    pip install torch==2.4.0 --index-url https://download.pytorch.org/whl/cu118
    pip install -r requirements.txt
    pip install ninja
    pip install git+https://github.com/Dao-AILab/[email protected]
    

    Additionally, you can also use HunyuanVideo Docker image. Use the following command to pull and run the docker image.

    # For CUDA 12.4 (updated to avoid float point exception)
    docker pull hunyuanvideo/hunyuanvideo:cuda_12
    docker run -itd --gpus all --init --net=host --uts=host --ipc=host --name hunyuanvideo --security-opt=seccomp=unconfined --ulimit=stack=67108864 --ulimit=memlock=-1 --privileged hunyuanvideo/hunyuanvideo:cuda_12
    pip install gradio==3.39.0 diffusers==0.33.0 transformers==4.41.2
    
    # For CUDA 11.8
    docker pull hunyuanvideo/hunyuanvideo:cuda_11
    docker run -itd --gpus all --init --net=host --uts=host --ipc=host --name hunyuanvideo --security-opt=seccomp=unconfined --ulimit=stack=67108864 --ulimit=memlock=-1 --privileged hunyuanvideo/hunyuanvideo:cuda_11
    pip install gradio==3.39.0 diffusers==0.33.0 transformers==4.41.2
    

    🧱 Download Pretrained Models

    The details of download pretrained models are shown here.

    🚀 Parallel Inference on Multiple GPUs

    For example, to generate a video with 8 GPUs, you can use the following command:

    Run Single-Subject Video Customization

    cd HunyuanCustom
    
    export MODEL_BASE="./models"
    export PYTHONPATH=./
    torchrun --nnodes=1 --nproc_per_node=8 --master_port 29605 hymm_sp/sample_batch.py \
        --ref-image './assets/images/seg_woman_01.png' \
        --pos-prompt "Realistic, High-quality. A woman is drinking coffee at a café." \
        --neg-prompt "Aerial view, aerial view, overexposed, low quality, deformation, a poor composition, bad hands, bad teeth, bad eyes, bad limbs, distortion, blurring, text, subtitles, static, picture, black border." \
        --ckpt ${MODEL_BASE}"/hunyuancustom_720P/mp_rank_00_model_states.pt" \
        --video-size 720 1280 \
        --seed 1024 \
        --sample-n-frames 129 \
        --infer-steps 30 \
        --flow-shift-eval-video 13.0 \
        --save-path './results/sp_720p'
    

    Run Video-Driven Video Customization (Video Editing)

    cd HunyuanCustom
    
    export MODEL_BASE="./models"
    export PYTHONPATH=./
    torchrun --nnodes=1 --nproc_per_node=8 --master_port 29605 hymm_sp/sample_batch.py \
        --ref-image './assets/images/sed_red_panda.png' \
        --input-video './assets/input_videos/001_bg.mp4' \
        --mask-video './assets/input_videos/001_mask.mp4' \
        --expand-scale 5 \
        --video-condition \
        --pos-prompt "Realistic, High-quality. A red panda is walking on a stone road." \
        --neg-prompt "Aerial view, aerial view, overexposed, low quality, deformation, a poor composition, bad hands, bad teeth, bad eyes, bad limbs, distortion, blurring, text, subtitles, static, picture, black border." \
        --ckpt ${MODEL_BASE}"/hunyuancustom_editing_720P/mp_rank_00_model_states.pt" \
        --seed 1024 \
        --infer-steps 50 \
        --flow-shift-eval-video 5.0 \
        --save-path './results/sp_editing_720p'
        # --pose-enhance # Enable for human videos to improve pose generation quality.
    

    Run Audio-Driven Video Customization

    cd HunyuanCustom
    
    export MODEL_BASE="./models"
    export PYTHONPATH=./
    torchrun --nnodes=1 --nproc_per_node=8 --master_port 29605 hymm_sp/sample_batch.py \
        --ref-image './assets/images/seg_man_01.png' \
        --input-audio './assets/audios/milk_man.mp3' \
        --audio-strength 0.8 \
        --audio-condition \
        --pos-prompt "Realistic, High-quality. In the study, a man sits at a table featuring a bottle of milk while delivering a product presentation." \
        --neg-prompt "Two people, two persons, aerial view, overexposed, low quality, deformation, a poor composition, bad hands, bad teeth, bad eyes, bad limbs, distortion, blurring, text, subtitles, static, picture, black border." \
        --ckpt ${MODEL_BASE}"/hunyuancustom_audio_720P/mp_rank_00_model_states.pt" \
        --seed 1026 \
        --video-size 720 1280 \
        --sample-n-frames 129 \
        --cfg-scale 7.5 \
        --infer-steps 30 \
        --use-deepcache 1 \
        --flow-shift-eval-video 13.0 \
        --save-path './results/sp_audio_720p'
    

    🔑 Single-gpu Inference

    For example, to generate a video with 1 GPU, you can use the following command:

    cd HunyuanCustom
    
    export MODEL_BASE="./models"
    export DISABLE_SP=1
    export PYTHONPATH=./
    python hymm_sp/sample_gpu_poor.py \
        --ref-image './assets/images/seg_woman_01.png' \
        --pos-prompt "Realistic, High-quality. A woman is drinking coffee at a café." \
        --neg-prompt "Aerial view, aerial view, overexposed, low quality, deformation, a poor composition, bad hands, bad teeth, bad eyes, bad limbs, distortion, blurring, text, subtitles, static, picture, black border." \
        --ckpt ${MODEL_BASE}"/hunyuancustom_720P/mp_rank_00_model_states_fp8.pt" \
        --video-size 512 896 \
        --seed 1024 \
        --sample-n-frames 129 \
        --infer-steps 30 \
        --flow-shift-eval-video 13.0 \
        --save-path './results/1gpu_540p' \
        --use-fp8
    

    Run with very low VRAM

    cd HunyuanCustom
    
    export MODEL_BASE="./models"
    export CPU_OFFLOAD=1
    export PYTHONPATH=./
    python hymm_sp/sample_gpu_poor.py \
        --ref-image './assets/images/seg_woman_01.png' \
        --pos-prompt "Realistic, High-quality. A woman is drinking coffee at a café." \
        --neg-prompt "Aerial view, aerial view, overexposed, low quality, deformation, a poor composition, bad hands, bad teeth, bad eyes, bad limbs, distortion, blurring, text, subtitles, static, picture, black border." \
        --ckpt ${MODEL_BASE}"/hunyuancustom_720P/mp_rank_00_model_states_fp8.pt" \
        --video-size 720 1280 \
        --seed 1024 \
        --sample-n-frames 129 \
        --infer-steps 30 \
        --flow-shift-eval-video 13.0 \
        --save-path './results/cpu_720p' \
        --use-fp8 \
        --cpu-offload 
    

    Run a Gradio Server

    cd HunyuanCustom
    
    # Single-Subject Video Customization
    bash ./scripts/run_gradio.sh 
    
    # Video-Driven Video Customization
    bash ./scripts/run_gradio.sh --video
    
    # Audio-Driven Video Customization
    bash ./scripts/run_gradio.sh --audio
    

    🔗 BibTeX

    If you find HunyuanCustom useful for your research and applications, please cite using this BibTeX:

    @misc{hu2025hunyuancustom,
          title={HunyuanCustom: A Multimodal-Driven Architecture for Customized Video Generation}, 
          author={Teng Hu and Zhentao Yu and Zhengguang Zhou and Sen Liang and Yuan Zhou and Qin Lin and Qinglin Lu},
          year={2025},
          eprint={2505.04512},
          archivePrefix={arXiv},
          primaryClass={cs.CV},
          url={https://arxiv.org/abs/2505.04512}, 
    }
    

    Acknowledgements

    We would like to thank the contributors to the HunyuanVideo, HunyuanVideo-Avatar, MimicMotion, SD3, FLUX, Llama, LLaVA, Xtuner, diffusers and HuggingFace repositories, for their open research and exploration.