zeekay commited on
Commit
449ca03
·
verified ·
1 Parent(s): b4d8cfd

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +520 -35
README.md CHANGED
@@ -1,55 +1,540 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
- license: apache-2.0
3
- language:
4
- - en
5
- tags:
6
- - zen
7
- - zenlm
8
- - hanzo
9
- library_name: transformers
10
- ---
11
 
12
- # zen-video
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
- High-quality video synthesis model
 
 
 
 
15
 
16
- Part of the Zen LM family of models - democratizing AI while protecting our planet.
 
17
 
18
- ## Model Description
 
 
19
 
20
- High-quality video synthesis model
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
- This model is part of the Zen LM ecosystem, providing efficient, private, and environmentally responsible AI.
 
 
 
23
 
24
- ## Why Zen LM?
25
 
26
- 🚀 **Ultra-Efficient** - Optimized for performance across diverse hardware
27
- 🔒 **Truly Private** - 100% local processing, no cloud required
28
- 🌱 **Environmentally Responsible** - 95% less energy than cloud AI
29
- 💚 **Free Forever** - Apache 2.0 licensed
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
 
31
- ## Quick Start
32
 
33
- ```python
34
- from transformers import AutoModelForCausalLM, AutoTokenizer
35
 
36
- model = AutoModelForCausalLM.from_pretrained("zenlm/zen-video")
37
- tokenizer = AutoTokenizer.from_pretrained("zenlm/zen-video")
38
 
39
- inputs = tokenizer("Your prompt here", return_tensors="pt")
40
- outputs = model.generate(**inputs)
41
- print(tokenizer.decode(outputs[0]))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  ```
43
 
44
- ## Organizations
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
 
46
- **Hanzo AI Inc** - Techstars Portfolio • Award-winning GenAI lab • https://hanzo.ai
47
- **Zoo Labs Foundation** - 501(c)(3) Non-Profit • Environmental preservation • https://zoolabs.io
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
 
49
- ## Contact
 
 
50
 
51
- 🌐 https://zenlm.org • 💬 https://discord.gg/hanzoai • 📧 hello@zenlm.org
52
 
53
- ## License
54
 
55
- Models: Apache 2.0 • Privacy: No data collection
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!-- ## **HunyuanVideo** -->
2
+
3
+ [中文阅读](./README_zh.md)
4
+
5
+ <p align="center">
6
+ <img src="https://raw.githubusercontent.com/Tencent-Hunyuan/HunyuanVideo/refs/heads/main/assets/logo.png" height=100>
7
+ </p>
8
+
9
+ # HunyuanVideo: A Systematic Framework For Large Video Generation Model
10
+
11
+ <div align="center">
12
+ <a href="https://github.com/Tencent-Hunyuan/HunyuanVideo"><img src="https://img.shields.io/static/v1?label=HunyuanVideo Code&message=Github&color=blue"></a> &ensp;
13
+ <a href="https://aivideo.hunyuan.tencent.com"><img src="https://img.shields.io/static/v1?label=Project%20Page&message=Web&color=green"></a> &ensp;
14
+ <a href="https://video.hunyuan.tencent.com"><img src="https://img.shields.io/static/v1?label=Playground&message=Web&color=green"></a>
15
+ </div>
16
+ <div align="center">
17
+ <a href="https://arxiv.org/abs/2412.03603"><img src="https://img.shields.io/static/v1?label=Tech Report&message=Arxiv&color=red"></a> &ensp;
18
+ <a href="https://aivideo.hunyuan.tencent.com/hunyuanvideo.pdf"><img src="https://img.shields.io/static/v1?label=Tech Report&message=High-Quality Version (~350M)&color=red"></a>
19
+ </div>
20
+ <div align="center">
21
+ <a href="https://huggingface.co/tencent/HunyuanVideo"><img src="https://img.shields.io/static/v1?label=HunyuanVideo&message=HuggingFace&color=yellow"></a> &ensp;
22
+ <a href="https://huggingface.co/docs/diffusers/main/api/pipelines/hunyuan_video"><img src="https://img.shields.io/static/v1?label=HunyuanVideo&message=Diffusers&color=yellow"></a> &ensp;
23
+ <a href="https://huggingface.co/tencent/HunyuanVideo-PromptRewrite"><img src="https://img.shields.io/static/v1?label=HunyuanVideo-PromptRewrite&message=HuggingFace&color=yellow"></a>
24
+
25
+
26
+ [![Replicate](https://replicate.com/zsxkib/hunyuan-video/badge)](https://replicate.com/zsxkib/hunyuan-video)
27
+ </div>
28
+
29
+ <p align="center">
30
+ 👋 Join our <a href="assets/WECHAT.md" target="_blank">WeChat</a> and <a href="https://discord.gg/tv7FkG4Nwf" target="_blank">Discord</a>
31
+ </p>
32
+ <p align="center">
33
+
34
+ -----
35
+
36
+ This repo contains PyTorch model definitions, pre-trained weights and inference/sampling code for our paper exploring HunyuanVideo. You can find more visualizations on our [project page](https://aivideo.hunyuan.tencent.com).
37
+
38
+ > [**HunyuanVideo: A Systematic Framework For Large Video Generation Model**](https://arxiv.org/abs/2412.03603) <be>
39
+
40
+
41
+
42
+ ## 🔥🔥🔥 News!!
43
+
44
+ * May 28, 2025: 💃 We release the [HunyuanVideo-Avatar](https://github.com/Tencent-Hunyuan/HunyuanVideo-Avatar), an audio-driven human animation model based on HunyuanVideo.
45
+ * May 09, 2025: 🙆 We release the [HunyuanCustom](https://github.com/Tencent-Hunyuan/HunyuanCustom), a multimodal-driven architecture for customized video generation based on HunyuanVideo.
46
+ * Mar 06, 2025: 🌅 We release the [HunyuanVideo-I2V](https://github.com/Tencent-Hunyuan/HunyuanVideo-I2V), an image-to-video model based on HunyuanVideo.
47
+ * Jan 13, 2025: 📈 We release the [Penguin Video Benchmark](https://github.com/Tencent-Hunyuan/HunyuanVideo/blob/main/assets/PenguinVideoBenchmark.csv).
48
+ * Dec 18, 2024: 🏃‍♂️ We release the [FP8 model weights](https://huggingface.co/tencent/HunyuanVideo/blob/main/hunyuan-video-t2v-720p/transformers/mp_rank_00_model_states_fp8.pt) of HunyuanVideo to save more GPU memory.
49
+ * Dec 17, 2024: 🤗 HunyuanVideo has been integrated into [Diffusers](https://huggingface.co/docs/diffusers/main/api/pipelines/hunyuan_video).
50
+ * Dec 7, 2024: 🚀 We release the parallel inference code for HunyuanVideo powered by [xDiT](https://github.com/xdit-project/xDiT).
51
+ * Dec 3, 2024: 👋 We release the inference code and model weights of HunyuanVideo. [Download](https://github.com/Tencent-Hunyuan/HunyuanVideo/blob/main/ckpts/README.md).
52
+
53
+
54
+
55
+ ## 🎥 Demo
56
+
57
+ <div align="center">
58
+ <video src="https://github.com/user-attachments/assets/22440764-0d7e-438e-a44d-d0dad1006d3d" width="70%" poster="./assets/video_poster.png"> </video>
59
+ </div>
60
+
61
+
62
+ ## 🧩 Community Contributions
63
+
64
+ If you develop/use HunyuanVideo in your projects, welcome to let us know.
65
+
66
+ - ComfyUI-Kijai (FP8 Inference, V2V and IP2V Generation): [ComfyUI-HunyuanVideoWrapper](https://github.com/kijai/ComfyUI-HunyuanVideoWrapper) by [Kijai](https://github.com/kijai)
67
+ - ComfyUI-Native (Native Support): [ComfyUI-HunyuanVideo](https://comfyanonymous.github.io/ComfyUI_examples/hunyuan_video/) by [ComfyUI Official](https://github.com/comfyanonymous/ComfyUI)
68
+
69
+ - FastVideo (Consistency Distilled Model and Sliding Tile Attention): [FastVideo](https://github.com/hao-ai-lab/FastVideo) and [Sliding Tile Attention](https://hao-ai-lab.github.io/blogs/sta/) by [Hao AI Lab](https://hao-ai-lab.github.io/)
70
+ - HunyuanVideo-gguf (GGUF Version and Quantization): [HunyuanVideo-gguf](https://huggingface.co/city96/HunyuanVideo-gguf) by [city96](https://huggingface.co/city96)
71
+ - Enhance-A-Video (Better Generated Video for Free): [Enhance-A-Video](https://github.com/NUS-HPC-AI-Lab/Enhance-A-Video) by [NUS-HPC-AI-Lab](https://ai.comp.nus.edu.sg/)
72
+ - TeaCache (Cache-based Accelerate): [TeaCache](https://github.com/LiewFeng/TeaCache) by [Feng Liu](https://github.com/LiewFeng)
73
+ - HunyuanVideoGP (GPU Poor version): [HunyuanVideoGP](https://github.com/deepbeepmeep/HunyuanVideoGP) by [DeepBeepMeep](https://github.com/deepbeepmeep)
74
+ - RIFLEx (Video Length Extrapolation): [RIFLEx](https://riflex-video.github.io/) by [Tsinghua University](https://riflex-video.github.io/)
75
+ - HunyuanVideo Keyframe Control Lora: [hunyuan-video-keyframe-control-lora](https://github.com/dashtoon/hunyuan-video-keyframe-control-lora) by [dashtoon](https://github.com/dashtoon)
76
+ - Sparse-VideoGen (Accelerate Video Generation with High Pixel-level Fidelity): [Sparse-VideoGen](https://github.com/svg-project/Sparse-VideoGen) by [University of California, Berkeley](https://svg-project.github.io/)
77
+ - FramePack (Packing Input Frame Context in Next-Frame Prediction Models for Video Generation): [FramePack](https://github.com/lllyasviel/FramePack) by [Lvmin Zhang](https://github.com/lllyasviel)
78
+ - Jenga (Training-Free Efficient Video Generation via Dynamic Token Carving): [Jenga](https://github.com/dvlab-research/Jenga) by [DV Lab](https://github.com/dvlab-research)
79
+ - DCM (Dual-Expert Consistency Model for Efficient and High-Quality Video Generation): [DCM](https://github.com/Vchitect/DCM) by [Vchitect](https://github.com/Vchitect/DCM)
80
+
81
+
82
+ ## 📑 Open-source Plan
83
+
84
+ - HunyuanVideo (Text-to-Video Model)
85
+ - [x] Inference
86
+ - [x] Checkpoints
87
+ - [x] Multi-gpus Sequence Parallel inference (Faster inference speed on more gpus)
88
+ - [x] Web Demo (Gradio)
89
+ - [x] Diffusers
90
+ - [x] FP8 Quantified weight
91
+ - [x] Penguin Video Benchmark
92
+ - [x] ComfyUI
93
+ - [HunyuanVideo (Image-to-Video Model)](https://github.com/Tencent/HunyuanVideo-I2V)
94
+ - [X] Inference
95
+ - [X] Checkpoints
96
+
97
+
98
+
99
+ ## Contents
100
+ - [HunyuanVideo: A Systematic Framework For Large Video Generation Model](#hunyuanvideo-a-systematic-framework-for-large-video-generation-model)
101
+ - [🎥 Demo](#-demo)
102
+ - [🔥🔥🔥 News!!](#-news)
103
+ - [🧩 Community Contributions](#-community-contributions)
104
+ - [📑 Open-source Plan](#-open-source-plan)
105
+ - [Contents](#contents)
106
+ - [**Abstract**](#abstract)
107
+ - [**HunyuanVideo Overall Architecture**](#hunyuanvideo-overall-architecture)
108
+ - [🎉 **HunyuanVideo Key Features**](#-hunyuanvideo-key-features)
109
+ - [**Unified Image and Video Generative Architecture**](#unified-image-and-video-generative-architecture)
110
+ - [**MLLM Text Encoder**](#mllm-text-encoder)
111
+ - [**3D VAE**](#3d-vae)
112
+ - [**Prompt Rewrite**](#prompt-rewrite)
113
+ - [📈 Comparisons](#-comparisons)
114
+ - [📜 Requirements](#-requirements)
115
+ - [🛠️ Dependencies and Installation](#️-dependencies-and-installation)
116
+ - [Installation Guide for Linux](#installation-guide-for-linux)
117
+ - [🧱 Download Pretrained Models](#-download-pretrained-models)
118
+ - [🔑 Single-gpu Inference](#-single-gpu-inference)
119
+ - [Using Command Line](#using-command-line)
120
+ - [Run a Gradio Server](#run-a-gradio-server)
121
+ - [More Configurations](#more-configurations)
122
+ - [🚀 Parallel Inference on Multiple GPUs by xDiT](#-parallel-inference-on-multiple-gpus-by-xdit)
123
+ - [Using Command Line](#using-command-line-1)
124
+ - [🚀 FP8 Inference](#--fp8-inference)
125
+ - [Using Command Line](#using-command-line-2)
126
+ - [🔗 BibTeX](#-bibtex)
127
+ - [Acknowledgements](#acknowledgements)
128
+ - [Star History](#star-history)
129
  ---
 
 
 
 
 
 
 
 
 
130
 
131
+ ## **Abstract**
132
+ We present HunyuanVideo, a novel open-source video foundation model that exhibits performance in video generation that is comparable to, if not superior to, leading closed-source models. In order to train HunyuanVideo model, we adopt several key technologies for model learning, including data curation, image-video joint model training, and an efficient infrastructure designed to facilitate large-scale model training and inference. Additionally, through an effective strategy for scaling model architecture and dataset, we successfully trained a video generative model with over 13 billion parameters, making it the largest among all open-source models.
133
+
134
+ We conducted extensive experiments and implemented a series of targeted designs to ensure high visual quality, motion diversity, text-video alignment, and generation stability. According to professional human evaluation results, HunyuanVideo outperforms previous state-of-the-art models, including Runway Gen-3, Luma 1.6, and 3 top-performing Chinese video generative models. By releasing the code and weights of the foundation model and its applications, we aim to bridge the gap between closed-source and open-source video foundation models. This initiative will empower everyone in the community to experiment with their ideas, fostering a more dynamic and vibrant video generation ecosystem.
135
+
136
+
137
+
138
+ ## **HunyuanVideo Overall Architecture**
139
+
140
+ HunyuanVideo is trained on a spatial-temporally
141
+ compressed latent space, which is compressed through a Causal 3D VAE. Text prompts are encoded
142
+ using a large language model, and used as the conditions. Taking Gaussian noise and the conditions as
143
+ input, our generative model produces an output latent, which is then decoded to images or videos through
144
+ the 3D VAE decoder.
145
+ <p align="center">
146
+ <img src="https://raw.githubusercontent.com/Tencent-Hunyuan/HunyuanVideo/refs/heads/main/assets/overall.png" height=300>
147
+ </p>
148
+
149
+
150
+ ## 🎉 **HunyuanVideo Key Features**
151
+
152
+ ### **Unified Image and Video Generative Architecture**
153
+ HunyuanVideo introduces the Transformer design and employs a Full Attention mechanism for unified image and video generation.
154
+ Specifically, we use a "Dual-stream to Single-stream" hybrid model design for video generation. In the dual-stream phase, video and text
155
+ tokens are processed independently through multiple Transformer blocks, enabling each modality to learn its own appropriate modulation mechanisms without interference. In the single-stream phase, we concatenate the video and text
156
+ tokens and feed them into subsequent Transformer blocks for effective multimodal information fusion.
157
+ This design captures complex interactions between visual and semantic information, enhancing
158
+ overall model performance.
159
+ <p align="center">
160
+ <img src="https://raw.githubusercontent.com/Tencent-Hunyuan/HunyuanVideo/refs/heads/main/assets/backbone.png" height=350>
161
+ </p>
162
+
163
+ ### **MLLM Text Encoder**
164
+ Some previous text-to-video models typically use pre-trained CLIP and T5-XXL as text encoders where CLIP uses Transformer Encoder and T5 uses an Encoder-Decoder structure. In contrast, we utilize a pre-trained Multimodal Large Language Model (MLLM) with a Decoder-Only structure as our text encoder, which has the following advantages: (i) Compared with T5, MLLM after visual instruction finetuning has better image-text alignment in the feature space, which alleviates the difficulty of the instruction following in diffusion models; (ii)
165
+ Compared with CLIP, MLLM has demonstrated superior ability in image detail description
166
+ and complex reasoning; (iii) MLLM can play as a zero-shot learner by following system instructions prepended to user prompts, helping text features pay more attention to key information. In addition, MLLM is based on causal attention while T5-XXL utilizes bidirectional attention that produces better text guidance for diffusion models. Therefore, we introduce an extra bidirectional token refiner to enhance text features.
167
+ <p align="center">
168
+ <img src="https://raw.githubusercontent.com/Tencent-Hunyuan/HunyuanVideo/refs/heads/main/assets/text_encoder.png" height=275>
169
+ </p>
170
+
171
+ ### **3D VAE**
172
+ HunyuanVideo trains a 3D VAE with CausalConv3D to compress pixel-space videos and images into a compact latent space. We set the compression ratios of video length, space, and channel to 4, 8, and 16 respectively. This can significantly reduce the number of tokens for the subsequent diffusion transformer model, allowing us to train videos at the original resolution and frame rate.
173
+ <p align="center">
174
+ <img src="https://raw.githubusercontent.com/Tencent-Hunyuan/HunyuanVideo/refs/heads/main/assets/3dvae.png" height=150>
175
+ </p>
176
+
177
+ ### **Prompt Rewrite**
178
+ To address the variability in linguistic style and length of user-provided prompts, we fine-tune the [Hunyuan-Large model](https://github.com/Tencent/Tencent-Hunyuan-Large) as our prompt rewrite model to adapt the original user prompt to model-preferred prompt.
179
+
180
+ We provide two rewrite modes: Normal mode and Master mode, which can be called using different prompts. The prompts are shown [here](hyvideo/prompt_rewrite.py). The Normal mode is designed to enhance the video generation model's comprehension of user intent, facilitating a more accurate interpretation of the instructions provided. The Master mode enhances the description of aspects such as composition, lighting, and camera movement, which leans towards generating videos with a higher visual quality. However, this emphasis may occasionally result in the loss of some semantic details.
181
+
182
+ The Prompt Rewrite Model can be directly deployed and inferred using the [Hunyuan-Large original code](https://github.com/Tencent/Tencent-Hunyuan-Large). We release the weights of the Prompt Rewrite Model [here](https://huggingface.co/Tencent/HunyuanVideo-PromptRewrite).
183
+
184
+
185
+
186
+ ## 📈 Comparisons
187
+
188
+ To evaluate the performance of HunyuanVideo, we selected five strong baselines from closed-source video generation models. In total, we utilized 1,533 text prompts, generating an equal number of video samples with HunyuanVideo in a single run. For a fair comparison, we conducted inference only once, avoiding any cherry-picking of results. When comparing with the baseline methods, we maintained the default settings for all selected models, ensuring consistent video resolution. Videos were assessed based on three criteria: Text Alignment, Motion Quality, and Visual Quality. More than 60 professional evaluators performed the evaluation. Notably, HunyuanVideo demonstrated the best overall performance, particularly excelling in motion quality. Please note that the evaluation is based on Hunyuan Video's high-quality version. This is different from the currently released fast version.
189
+
190
+ <p align="center">
191
+ <table>
192
+ <thead>
193
+ <tr>
194
+ <th rowspan="2">Model</th> <th rowspan="2">Open Source</th> <th>Duration</th> <th>Text Alignment</th> <th>Motion Quality</th> <th rowspan="2">Visual Quality</th> <th rowspan="2">Overall</th> <th rowspan="2">Ranking</th>
195
+ </tr>
196
+ </thead>
197
+ <tbody>
198
+ <tr>
199
+ <td>HunyuanVideo (Ours)</td> <td> ✔ </td> <td>5s</td> <td>61.8%</td> <td>66.5%</td> <td>95.7%</td> <td>41.3%</td> <td>1</td>
200
+ </tr>
201
+ <tr>
202
+ <td>CNTopA (API)</td> <td> &#10008 </td> <td>5s</td> <td>62.6%</td> <td>61.7%</td> <td>95.6%</td> <td>37.7%</td> <td>2</td>
203
+ </tr>
204
+ <tr>
205
+ <td>CNTopB (Web)</td> <td> &#10008</td> <td>5s</td> <td>60.1%</td> <td>62.9%</td> <td>97.7%</td> <td>37.5%</td> <td>3</td>
206
+ </tr>
207
+ <tr>
208
+ <td>GEN-3 alpha (Web)</td> <td>&#10008</td> <td>6s</td> <td>47.7%</td> <td>54.7%</td> <td>97.5%</td> <td>27.4%</td> <td>4</td>
209
+ </tr>
210
+ <tr>
211
+ <td>Luma1.6 (API)</td><td>&#10008</td> <td>5s</td> <td>57.6%</td> <td>44.2%</td> <td>94.1%</td> <td>24.8%</td> <td>5</td>
212
+ </tr>
213
+ <tr>
214
+ <td>CNTopC (Web)</td> <td>&#10008</td> <td>5s</td> <td>48.4%</td> <td>47.2%</td> <td>96.3%</td> <td>24.6%</td> <td>6</td>
215
+ </tr>
216
+ </tbody>
217
+ </table>
218
+ </p>
219
+
220
+
221
+ ## 📜 Requirements
222
+
223
+ The following table shows the requirements for running HunyuanVideo model (batch size = 1) to generate videos:
224
+
225
+ | Model | Setting<br/>(height/width/frame) | GPU Peak Memory |
226
+ |:------------:|:--------------------------------:|:----------------:|
227
+ | HunyuanVideo | 720px1280px129f | 60GB |
228
+ | HunyuanVideo | 544px960px129f | 45GB |
229
+
230
+ * An NVIDIA GPU with CUDA support is required.
231
+ * The model is tested on a single 80G GPU.
232
+ * **Minimum**: The minimum GPU memory required is 60GB for 720px1280px129f and 45G for 544px960px129f.
233
+ * **Recommended**: We recommend using a GPU with 80GB of memory for better generation quality.
234
+ * Tested operating system: Linux
235
+
236
+
237
+
238
+ ## 🛠️ Dependencies and Installation
239
+
240
+ Begin by cloning the repository:
241
+ ```shell
242
+ git clone https://github.com/Tencent-Hunyuan/HunyuanVideo
243
+ cd HunyuanVideo
244
+ ```
245
+
246
+ ### Installation Guide for Linux
247
+
248
+ We recommend CUDA versions 12.4 or 11.8 for the manual installation.
249
+
250
+ Conda's installation instructions are available [here](https://docs.anaconda.com/free/miniconda/index.html).
251
+
252
+ ```shell
253
+ # 1. Create conda environment
254
+ conda create -n HunyuanVideo python==3.10.9
255
+
256
+ # 2. Activate the environment
257
+ conda activate HunyuanVideo
258
 
259
+ # 3. Install PyTorch and other dependencies using conda
260
+ # For CUDA 11.8
261
+ conda install pytorch==2.4.0 torchvision==0.19.0 torchaudio==2.4.0 pytorch-cuda=11.8 -c pytorch -c nvidia
262
+ # For CUDA 12.4
263
+ conda install pytorch==2.4.0 torchvision==0.19.0 torchaudio==2.4.0 pytorch-cuda=12.4 -c pytorch -c nvidia
264
 
265
+ # 4. Install pip dependencies
266
+ python -m pip install -r requirements.txt
267
 
268
+ # 5. Install flash attention v2 for acceleration (requires CUDA 11.8 or above)
269
+ python -m pip install ninja
270
+ python -m pip install git+https://github.com/Dao-AILab/flash-attention.git@v2.6.3
271
 
272
+ # 6. Install xDiT for parallel inference (It is recommended to use torch 2.4.0 and flash-attn 2.6.3)
273
+ python -m pip install xfuser==0.4.0
274
+ ```
275
+
276
+ In case of running into float point exception(core dump) on the specific GPU type, you may try the following solutions:
277
+
278
+ ```shell
279
+ # 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).
280
+ pip install nvidia-cublas-cu12==12.4.5.8
281
+ export LD_LIBRARY_PATH=/opt/conda/lib/python3.8/site-packages/nvidia/cublas/lib/
282
+
283
+ # Option 2: Forcing to explictly use the CUDA 11.8 compiled version of Pytorch and all the other packages
284
+ pip uninstall -r requirements.txt # uninstall all packages
285
+ pip uninstall -y xfuser
286
+ pip install torch==2.4.0 --index-url https://download.pytorch.org/whl/cu118
287
+ pip install -r requirements.txt
288
+ pip install ninja
289
+ pip install git+https://github.com/Dao-AILab/flash-attention.git@v2.6.3
290
+ pip install xfuser==0.4.0
291
+ ```
292
+
293
+ Additionally, HunyuanVideo also provides a pre-built Docker image. Use the following command to pull and run the docker image.
294
+
295
+ ```shell
296
+ # For CUDA 12.4 (updated to avoid float point exception)
297
+ docker pull hunyuanvideo/hunyuanvideo:cuda_12
298
+ 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
299
+
300
+ # For CUDA 11.8
301
+ docker pull hunyuanvideo/hunyuanvideo:cuda_11
302
+ 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
303
+ ```
304
+
305
+
306
+ ## 🧱 Download Pretrained Models
307
+
308
+ The details of download pretrained models are shown [here](ckpts/README.md).
309
+
310
+
311
+
312
+ ## 🔑 Single-gpu Inference
313
+
314
+ We list the height/width/frame settings we support in the following table.
315
 
316
+ | Resolution | h/w=9:16 | h/w=16:9 | h/w=4:3 | h/w=3:4 | h/w=1:1 |
317
+ |:---------------------:|:----------------------------:|:---------------:|:---------------:|:---------------:|:---------------:|
318
+ | 540p | 544px960px129f | 960px544px129f | 624px832px129f | 832px624px129f | 720px720px129f |
319
+ | 720p (recommended) | 720px1280px129f | 1280px720px129f | 1104px832px129f | 832px1104px129f | 960px960px129f |
320
 
321
+ ### Using Command Line
322
 
323
+ ```bash
324
+ cd HunyuanVideo
325
+
326
+ python3 sample_video.py \
327
+ --video-size 720 1280 \
328
+ --video-length 129 \
329
+ --infer-steps 50 \
330
+ --prompt "A cat walks on the grass, realistic style." \
331
+ --flow-reverse \
332
+ --use-cpu-offload \
333
+ --save-path ./results
334
+ ```
335
+
336
+ ### Run a Gradio Server
337
+ ```bash
338
+ python3 gradio_server.py --flow-reverse
339
+
340
+ # set SERVER_NAME and SERVER_PORT manually
341
+ # SERVER_NAME=0.0.0.0 SERVER_PORT=8081 python3 gradio_server.py --flow-reverse
342
+ ```
343
+
344
+ ### More Configurations
345
+
346
+ We list some more useful configurations for easy usage:
347
+
348
+ | Argument | Default | Description |
349
+ |:----------------------:|:---------:|:-----------------------------------------:|
350
+ | `--prompt` | None | The text prompt for video generation |
351
+ | `--video-size` | 720 1280 | The size of the generated video |
352
+ | `--video-length` | 129 | The length of the generated video |
353
+ | `--infer-steps` | 50 | The number of steps for sampling |
354
+ | `--embedded-cfg-scale` | 6.0 | Embedded Classifier free guidance scale |
355
+ | `--flow-shift` | 7.0 | Shift factor for flow matching schedulers |
356
+ | `--flow-reverse` | False | If reverse, learning/sampling from t=1 -> t=0 |
357
+ | `--seed` | None | The random seed for generating video, if None, we init a random seed |
358
+ | `--use-cpu-offload` | False | Use CPU offload for the model load to save more memory, necessary for high-res video generation |
359
+ | `--save-path` | ./results | Path to save the generated video |
360
 
 
361
 
 
 
362
 
363
+ ## 🚀 Parallel Inference on Multiple GPUs by xDiT
 
364
 
365
+ [xDiT](https://github.com/xdit-project/xDiT) is a Scalable Inference Engine for Diffusion Transformers (DiTs) on multi-GPU Clusters.
366
+ It has successfully provided low-latency parallel inference solutions for a variety of DiTs models, including mochi-1, CogVideoX, Flux.1, SD3, etc. This repo adopted the [Unified Sequence Parallelism (USP)](https://arxiv.org/abs/2405.07719) APIs for parallel inference of the HunyuanVideo model.
367
+
368
+ ### Using Command Line
369
+
370
+ For example, to generate a video with 8 GPUs, you can use the following command:
371
+
372
+ ```bash
373
+ cd HunyuanVideo
374
+
375
+ torchrun --nproc_per_node=8 sample_video.py \
376
+ --video-size 1280 720 \
377
+ --video-length 129 \
378
+ --infer-steps 50 \
379
+ --prompt "A cat walks on the grass, realistic style." \
380
+ --flow-reverse \
381
+ --seed 42 \
382
+ --ulysses-degree 8 \
383
+ --ring-degree 1 \
384
+ --save-path ./results
385
  ```
386
 
387
+ You can change the `--ulysses-degree` and `--ring-degree` to control the parallel configurations for the best performance. The valid parallel configurations are shown in the following table.
388
+
389
+ <details>
390
+ <summary>Supported Parallel Configurations (Click to expand)</summary>
391
+
392
+ | --video-size | --video-length | --ulysses-degree x --ring-degree | --nproc_per_node |
393
+ |----------------------|----------------|----------------------------------|------------------|
394
+ | 1280 720 or 720 1280 | 129 | 8x1,4x2,2x4,1x8 | 8 |
395
+ | 1280 720 or 720 1280 | 129 | 1x5 | 5 |
396
+ | 1280 720 or 720 1280 | 129 | 4x1,2x2,1x4 | 4 |
397
+ | 1280 720 or 720 1280 | 129 | 3x1,1x3 | 3 |
398
+ | 1280 720 or 720 1280 | 129 | 2x1,1x2 | 2 |
399
+ | 1104 832 or 832 1104 | 129 | 4x1,2x2,1x4 | 4 |
400
+ | 1104 832 or 832 1104 | 129 | 3x1,1x3 | 3 |
401
+ | 1104 832 or 832 1104 | 129 | 2x1,1x2 | 2 |
402
+ | 960 960 | 129 | 6x1,3x2,2x3,1x6 | 6 |
403
+ | 960 960 | 129 | 4x1,2x2,1x4 | 4 |
404
+ | 960 960 | 129 | 3x1,1x3 | 3 |
405
+ | 960 960 | 129 | 1x2,2x1 | 2 |
406
+ | 960 544 or 544 960 | 129 | 6x1,3x2,2x3,1x6 | 6 |
407
+ | 960 544 or 544 960 | 129 | 4x1,2x2,1x4 | 4 |
408
+ | 960 544 or 544 960 | 129 | 3x1,1x3 | 3 |
409
+ | 960 544 or 544 960 | 129 | 1x2,2x1 | 2 |
410
+ | 832 624 or 624 832 | 129 | 4x1,2x2,1x4 | 4 |
411
+ | 624 832 or 624 832 | 129 | 3x1,1x3 | 3 |
412
+ | 832 624 or 624 832 | 129 | 2x1,1x2 | 2 |
413
+ | 720 720 | 129 | 1x5 | 5 |
414
+ | 720 720 | 129 | 3x1,1x3 | 3 |
415
+
416
+ </details>
417
+
418
 
419
+ <p align="center">
420
+ <table align="center">
421
+ <thead>
422
+ <tr>
423
+ <th colspan="4">Latency (Sec) for 1280x720 (129 frames 50 steps) on 8xGPU</th>
424
+ </tr>
425
+ <tr>
426
+ <th>1</th>
427
+ <th>2</th>
428
+ <th>4</th>
429
+ <th>8</th>
430
+ </tr>
431
+ </thead>
432
+ <tbody>
433
+ <tr>
434
+ <th>1904.08</th>
435
+ <th>934.09 (2.04x)</th>
436
+ <th>514.08 (3.70x)</th>
437
+ <th>337.58 (5.64x)</th>
438
+ </tr>
439
 
440
+ </tbody>
441
+ </table>
442
+ </p>
443
 
 
444
 
 
445
 
446
+ ## 🚀 FP8 Inference
447
+
448
+ Using HunyuanVideo with FP8 quantized weights, which saves about 10GB of GPU memory. You can download the [weights](https://huggingface.co/tencent/HunyuanVideo/blob/main/hunyuan-video-t2v-720p/transformers/mp_rank_00_model_states_fp8.pt) and [weight scales](https://huggingface.co/tencent/HunyuanVideo/blob/main/hunyuan-video-t2v-720p/transformers/mp_rank_00_model_states_fp8_map.pt) from Huggingface.
449
+
450
+ ### Using Command Line
451
+
452
+ Here, you must explicitly specify the FP8 weight path. For example, to generate a video with fp8 weights, you can use the following command:
453
+
454
+ ```bash
455
+ cd HunyuanVideo
456
+
457
+ DIT_CKPT_PATH={PATH_TO_FP8_WEIGHTS}/{WEIGHT_NAME}_fp8.pt
458
+
459
+ python3 sample_video.py \
460
+ --dit-weight ${DIT_CKPT_PATH} \
461
+ --video-size 1280 720 \
462
+ --video-length 129 \
463
+ --infer-steps 50 \
464
+ --prompt "A cat walks on the grass, realistic style." \
465
+ --seed 42 \
466
+ --embedded-cfg-scale 6.0 \
467
+ --flow-shift 7.0 \
468
+ --flow-reverse \
469
+ --use-cpu-offload \
470
+ --use-fp8 \
471
+ --save-path ./results
472
+ ```
473
+
474
+
475
+
476
+ ## 🔗 BibTeX
477
+
478
+ If you find [HunyuanVideo](https://arxiv.org/abs/2412.03603) useful for your research and applications, please cite using this BibTeX:
479
+
480
+ ```BibTeX
481
+ @article{kong2024hunyuanvideo,
482
+ title={Hunyuanvideo: A systematic framework for large video generative models},
483
+ author={Kong, Weijie and Tian, Qi and Zhang, Zijian and Min, Rox and Dai, Zuozhuo and Zhou, Jin and Xiong, Jiangfeng and Li, Xin and Wu, Bo and Zhang, Jianwei and others},
484
+ journal={arXiv preprint arXiv:2412.03603},
485
+ year={2024}
486
+ }
487
+ ```
488
+
489
+
490
+
491
+ ## Acknowledgements
492
+
493
+ We would like to thank the contributors to the [SD3](https://huggingface.co/stabilityai/stable-diffusion-3-medium), [FLUX](https://github.com/black-forest-labs/flux), [Llama](https://github.com/meta-llama/llama), [LLaVA](https://github.com/haotian-liu/LLaVA), [Xtuner](https://github.com/InternLM/xtuner), [diffusers](https://github.com/huggingface/diffusers) and [HuggingFace](https://huggingface.co) repositories, for their open research and exploration.
494
+ Additionally, we also thank the Tencent Hunyuan Multimodal team for their help with the text encoder.
495
+
496
+
497
+ ## Github Star History
498
+ <a href="https://star-history.com/#Tencent-Hunyuan/HunyuanVideo&Date">
499
+ <picture>
500
+ <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=Tencent-Hunyuan/HunyuanVideo&type=Date&theme=dark" />
501
+ <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=Tencent-Hunyuan/HunyuanVideo&type=Date" />
502
+ <img alt="Star History Chart" src="https://api.star-history.com/svg?repos=Tencent-Hunyuan/HunyuanVideo&type=Date" />
503
+ </picture>
504
+ </a>
505
+
506
+ ---
507
+
508
+ ## Based On
509
+
510
+ **zen-video** is based on [HunyuanVideo](https://github.com/Tencent/HunyuanVideo)
511
+
512
+ We are grateful to the original authors for their excellent work and open-source contributions.
513
+
514
+ ### Upstream Source
515
+ - **Repository**: https://github.com/Tencent/HunyuanVideo
516
+ - **Base Model**: HunyuanVideo
517
+ - **License**: See original repository for license details
518
+
519
+ ### Changes in Zen LM
520
+ - Adapted for Zen AI ecosystem
521
+ - Fine-tuned for specific use cases
522
+ - Added training and inference scripts
523
+ - Integrated with Zen Gym and Zen Engine
524
+ - Enhanced documentation and examples
525
+
526
+ ### Citation
527
+
528
+ If you use this model, please cite both the original work and Zen LM:
529
+
530
+ ```bibtex
531
+ @misc{zenlm2025zen-video,
532
+ title={Zen LM: zen-video},
533
+ author={Hanzo AI and Zoo Labs Foundation},
534
+ year={2025},
535
+ publisher={HuggingFace},
536
+ howpublished={\url{https://huggingface.co/zenlm/zen-video}}
537
+ }
538
+ ```
539
+
540
+ Please also cite the original upstream work - see https://github.com/Tencent/HunyuanVideo for citation details.