zR
commited on
Commit
•
d055a49
1
Parent(s):
a4101b3
for release
Browse files- LICENSE +201 -71
- README.md +105 -31
- README_zh.md +111 -34
- text_encoder/config.json +1 -1
LICENSE
CHANGED
@@ -1,71 +1,201 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Apache License
|
2 |
+
Version 2.0, January 2004
|
3 |
+
http://www.apache.org/licenses/
|
4 |
+
|
5 |
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6 |
+
|
7 |
+
1. Definitions.
|
8 |
+
|
9 |
+
"License" shall mean the terms and conditions for use, reproduction,
|
10 |
+
and distribution as defined by Sections 1 through 9 of this document.
|
11 |
+
|
12 |
+
"Licensor" shall mean the copyright owner or entity authorized by
|
13 |
+
the copyright owner that is granting the License.
|
14 |
+
|
15 |
+
"Legal Entity" shall mean the union of the acting entity and all
|
16 |
+
other entities that control, are controlled by, or are under common
|
17 |
+
control with that entity. For the purposes of this definition,
|
18 |
+
"control" means (i) the power, direct or indirect, to cause the
|
19 |
+
direction or management of such entity, whether by contract or
|
20 |
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21 |
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
22 |
+
|
23 |
+
"You" (or "Your") shall mean an individual or Legal Entity
|
24 |
+
exercising permissions granted by this License.
|
25 |
+
|
26 |
+
"Source" form shall mean the preferred form for making modifications,
|
27 |
+
including but not limited to software source code, documentation
|
28 |
+
source, and configuration files.
|
29 |
+
|
30 |
+
"Object" form shall mean any form resulting from mechanical
|
31 |
+
transformation or translation of a Source form, including but
|
32 |
+
not limited to compiled object code, generated documentation,
|
33 |
+
and conversions to other media types.
|
34 |
+
|
35 |
+
"Work" shall mean the work of authorship, whether in Source or
|
36 |
+
Object form, made available under the License, as indicated by a
|
37 |
+
copyright notice that is included in or attached to the work
|
38 |
+
(an example is provided in the Appendix below).
|
39 |
+
|
40 |
+
"Derivative Works" shall mean any work, whether in Source or Object
|
41 |
+
form, that is based on (or derived from) the Work and for which the
|
42 |
+
editorial revisions, annotations, elaborations, or other modifications
|
43 |
+
represent, as a whole, an original work of authorship. For the purposes
|
44 |
+
of this License, Derivative Works shall not include works that remain
|
45 |
+
separable from, or merely link (or bind by name) to the interfaces of,
|
46 |
+
the Work and Derivative Works thereof.
|
47 |
+
|
48 |
+
"Contribution" shall mean any work of authorship, including
|
49 |
+
the original version of the Work and any modifications or additions
|
50 |
+
to that Work or Derivative Works thereof, that is intentionally
|
51 |
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
52 |
+
or by an individual or Legal Entity authorized to submit on behalf of
|
53 |
+
the copyright owner. For the purposes of this definition, "submitted"
|
54 |
+
means any form of electronic, verbal, or written communication sent
|
55 |
+
to the Licensor or its representatives, including but not limited to
|
56 |
+
communication on electronic mailing lists, source code control systems,
|
57 |
+
and issue tracking systems that are managed by, or on behalf of, the
|
58 |
+
Licensor for the purpose of discussing and improving the Work, but
|
59 |
+
excluding communication that is conspicuously marked or otherwise
|
60 |
+
designated in writing by the copyright owner as "Not a Contribution."
|
61 |
+
|
62 |
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63 |
+
on behalf of whom a Contribution has been received by Licensor and
|
64 |
+
subsequently incorporated within the Work.
|
65 |
+
|
66 |
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
67 |
+
this License, each Contributor hereby grants to You a perpetual,
|
68 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69 |
+
copyright license to reproduce, prepare Derivative Works of,
|
70 |
+
publicly display, publicly perform, sublicense, and distribute the
|
71 |
+
Work and such Derivative Works in Source or Object form.
|
72 |
+
|
73 |
+
3. Grant of Patent License. Subject to the terms and conditions of
|
74 |
+
this License, each Contributor hereby grants to You a perpetual,
|
75 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76 |
+
(except as stated in this section) patent license to make, have made,
|
77 |
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78 |
+
where such license applies only to those patent claims licensable
|
79 |
+
by such Contributor that are necessarily infringed by their
|
80 |
+
Contribution(s) alone or by combination of their Contribution(s)
|
81 |
+
with the Work to which such Contribution(s) was submitted. If You
|
82 |
+
institute patent litigation against any entity (including a
|
83 |
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84 |
+
or a Contribution incorporated within the Work constitutes direct
|
85 |
+
or contributory patent infringement, then any patent licenses
|
86 |
+
granted to You under this License for that Work shall terminate
|
87 |
+
as of the date such litigation is filed.
|
88 |
+
|
89 |
+
4. Redistribution. You may reproduce and distribute copies of the
|
90 |
+
Work or Derivative Works thereof in any medium, with or without
|
91 |
+
modifications, and in Source or Object form, provided that You
|
92 |
+
meet the following conditions:
|
93 |
+
|
94 |
+
(a) You must give any other recipients of the Work or
|
95 |
+
Derivative Works a copy of this License; and
|
96 |
+
|
97 |
+
(b) You must cause any modified files to carry prominent notices
|
98 |
+
stating that You changed the files; and
|
99 |
+
|
100 |
+
(c) You must retain, in the Source form of any Derivative Works
|
101 |
+
that You distribute, all copyright, patent, trademark, and
|
102 |
+
attribution notices from the Source form of the Work,
|
103 |
+
excluding those notices that do not pertain to any part of
|
104 |
+
the Derivative Works; and
|
105 |
+
|
106 |
+
(d) If the Work includes a "NOTICE" text file as part of its
|
107 |
+
distribution, then any Derivative Works that You distribute must
|
108 |
+
include a readable copy of the attribution notices contained
|
109 |
+
within such NOTICE file, excluding those notices that do not
|
110 |
+
pertain to any part of the Derivative Works, in at least one
|
111 |
+
of the following places: within a NOTICE text file distributed
|
112 |
+
as part of the Derivative Works; within the Source form or
|
113 |
+
documentation, if provided along with the Derivative Works; or,
|
114 |
+
within a display generated by the Derivative Works, if and
|
115 |
+
wherever such third-party notices normally appear. The contents
|
116 |
+
of the NOTICE file are for informational purposes only and
|
117 |
+
do not modify the License. You may add Your own attribution
|
118 |
+
notices within Derivative Works that You distribute, alongside
|
119 |
+
or as an addendum to the NOTICE text from the Work, provided
|
120 |
+
that such additional attribution notices cannot be construed
|
121 |
+
as modifying the License.
|
122 |
+
|
123 |
+
You may add Your own copyright statement to Your modifications and
|
124 |
+
may provide additional or different license terms and conditions
|
125 |
+
for use, reproduction, or distribution of Your modifications, or
|
126 |
+
for any such Derivative Works as a whole, provided Your use,
|
127 |
+
reproduction, and distribution of the Work otherwise complies with
|
128 |
+
the conditions stated in this License.
|
129 |
+
|
130 |
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131 |
+
any Contribution intentionally submitted for inclusion in the Work
|
132 |
+
by You to the Licensor shall be under the terms and conditions of
|
133 |
+
this License, without any additional terms or conditions.
|
134 |
+
Notwithstanding the above, nothing herein shall supersede or modify
|
135 |
+
the terms of any separate license agreement you may have executed
|
136 |
+
with Licensor regarding such Contributions.
|
137 |
+
|
138 |
+
6. Trademarks. This License does not grant permission to use the trade
|
139 |
+
names, trademarks, service marks, or product names of the Licensor,
|
140 |
+
except as required for reasonable and customary use in describing the
|
141 |
+
origin of the Work and reproducing the content of the NOTICE file.
|
142 |
+
|
143 |
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
144 |
+
agreed to in writing, Licensor provides the Work (and each
|
145 |
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147 |
+
implied, including, without limitation, any warranties or conditions
|
148 |
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149 |
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150 |
+
appropriateness of using or redistributing the Work and assume any
|
151 |
+
risks associated with Your exercise of permissions under this License.
|
152 |
+
|
153 |
+
8. Limitation of Liability. In no event and under no legal theory,
|
154 |
+
whether in tort (including negligence), contract, or otherwise,
|
155 |
+
unless required by applicable law (such as deliberate and grossly
|
156 |
+
negligent acts) or agreed to in writing, shall any Contributor be
|
157 |
+
liable to You for damages, including any direct, indirect, special,
|
158 |
+
incidental, or consequential damages of any character arising as a
|
159 |
+
result of this License or out of the use or inability to use the
|
160 |
+
Work (including but not limited to damages for loss of goodwill,
|
161 |
+
work stoppage, computer failure or malfunction, or any and all
|
162 |
+
other commercial damages or losses), even if such Contributor
|
163 |
+
has been advised of the possibility of such damages.
|
164 |
+
|
165 |
+
9. Accepting Warranty or Additional Liability. While redistributing
|
166 |
+
the Work or Derivative Works thereof, You may choose to offer,
|
167 |
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
168 |
+
or other liability obligations and/or rights consistent with this
|
169 |
+
License. However, in accepting such obligations, You may act only
|
170 |
+
on Your own behalf and on Your sole responsibility, not on behalf
|
171 |
+
of any other Contributor, and only if You agree to indemnify,
|
172 |
+
defend, and hold each Contributor harmless for any liability
|
173 |
+
incurred by, or claims asserted against, such Contributor by reason
|
174 |
+
of your accepting any such warranty or additional liability.
|
175 |
+
|
176 |
+
END OF TERMS AND CONDITIONS
|
177 |
+
|
178 |
+
APPENDIX: How to apply the Apache License to your work.
|
179 |
+
|
180 |
+
To apply the Apache License to your work, attach the following
|
181 |
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
182 |
+
replaced with your own identifying information. (Don't include
|
183 |
+
the brackets!) The text should be enclosed in the appropriate
|
184 |
+
comment syntax for the file format. We also recommend that a
|
185 |
+
file or class name and description of purpose be included on the
|
186 |
+
same "printed page" as the copyright notice for easier
|
187 |
+
identification within third-party archives.
|
188 |
+
|
189 |
+
Copyright 2024 CogVideo Model Team @ Zhipu AI
|
190 |
+
|
191 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
192 |
+
you may not use this file except in compliance with the License.
|
193 |
+
You may obtain a copy of the License at
|
194 |
+
|
195 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
196 |
+
|
197 |
+
Unless required by applicable law or agreed to in writing, software
|
198 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
199 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
200 |
+
See the License for the specific language governing permissions and
|
201 |
+
limitations under the License.
|
README.md
CHANGED
@@ -20,6 +20,7 @@ inference: false
|
|
20 |
</div>
|
21 |
<p align="center">
|
22 |
<a href="https://huggingface.co/THUDM/CogVideoX-2b/blob/main/README_zh.md">📄 中文阅读</a> |
|
|
|
23 |
<a href="https://github.com/THUDM/CogVideo">🌐 Github </a> |
|
24 |
<a href="https://arxiv.org/pdf/2408.06072">📜 arxiv </a>
|
25 |
</p>
|
@@ -85,22 +86,91 @@ inference: false
|
|
85 |
|
86 |
## Model Introduction
|
87 |
|
88 |
-
CogVideoX is an open-source video generation model
|
89 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
|
91 |
-
| Model Name | CogVideoX-2B |
|
92 |
-
|-------------------------------------------|--------------------------------------|
|
93 |
-
| Prompt Language | English |
|
94 |
-
| Single GPU Inference (FP16) | 23.9GB |
|
95 |
-
| Multi GPUs Inference (FP16) | 20GB minimum per GPU using diffusers |
|
96 |
-
| GPU Memory Required for Fine-tuning(bs=1) | 40GB |
|
97 |
-
| Prompt Max Length | 226 Tokens |
|
98 |
-
| Video Length | 6 seconds |
|
99 |
-
| Frames Per Second | 8 frames |
|
100 |
-
| Resolution | 720 * 480 |
|
101 |
-
| Quantized Inference | Not Supported |
|
102 |
|
103 |
-
**Note** Using [SAT](https://github.com/THUDM/SwissArmyTransformer) model cost 18GB for inference. Check our github.
|
104 |
|
105 |
## Quick Start 🤗
|
106 |
|
@@ -112,7 +182,11 @@ optimizations and conversions to get a better experience.**
|
|
112 |
1. Install the required dependencies
|
113 |
|
114 |
```shell
|
115 |
-
|
|
|
|
|
|
|
|
|
116 |
```
|
117 |
|
118 |
2. Run the code
|
@@ -130,30 +204,20 @@ pipe = CogVideoXPipeline.from_pretrained(
|
|
130 |
)
|
131 |
|
132 |
pipe.enable_model_cpu_offload()
|
|
|
133 |
|
134 |
-
|
135 |
prompt=prompt,
|
136 |
-
do_classifier_free_guidance=True,
|
137 |
num_videos_per_prompt=1,
|
138 |
-
max_sequence_length=226,
|
139 |
-
device="cuda",
|
140 |
-
dtype=torch.float16,
|
141 |
-
)
|
142 |
-
|
143 |
-
video = pipe(
|
144 |
num_inference_steps=50,
|
|
|
145 |
guidance_scale=6,
|
146 |
-
|
147 |
).frames[0]
|
148 |
|
149 |
export_to_video(video, "output.mp4", fps=8)
|
150 |
```
|
151 |
|
152 |
-
**Using a single A100 GPU, generating a video with the above configuration takes approximately 90 seconds**
|
153 |
-
|
154 |
-
If the generated model appears “all green” and not viewable in the default MAC player, it is a normal phenomenon (due to
|
155 |
-
OpenCV saving video issues). Simply use a different player to view the video.
|
156 |
-
|
157 |
## Explore the Model
|
158 |
|
159 |
Welcome to our [github](https://github.com/THUDM/CogVideo), where you will find:
|
@@ -163,11 +227,21 @@ Welcome to our [github](https://github.com/THUDM/CogVideo), where you will find:
|
|
163 |
3. Reasoning and fine-tuning of SAT version models, and even pre-release.
|
164 |
4. Project update log dynamics, more interactive opportunities.
|
165 |
5. CogVideoX toolchain to help you better use the model.
|
|
|
166 |
|
167 |
## Model License
|
168 |
|
169 |
-
|
|
|
|
|
170 |
|
171 |
## Citation
|
172 |
|
173 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
</div>
|
21 |
<p align="center">
|
22 |
<a href="https://huggingface.co/THUDM/CogVideoX-2b/blob/main/README_zh.md">📄 中文阅读</a> |
|
23 |
+
<a href="https://huggingface.co/spaces/THUDM/CogVideoX-2B-Space">🤗 Huggingface Space</a> |
|
24 |
<a href="https://github.com/THUDM/CogVideo">🌐 Github </a> |
|
25 |
<a href="https://arxiv.org/pdf/2408.06072">📜 arxiv </a>
|
26 |
</p>
|
|
|
86 |
|
87 |
## Model Introduction
|
88 |
|
89 |
+
CogVideoX is an open-source version of the video generation model originating from [QingYing](https://chatglm.cn/video?fr=osm_cogvideo). The table below displays the list of video generation models we currently offer, along with their foundational information.
|
90 |
+
|
91 |
+
<table style="border-collapse: collapse; width: 100%;">
|
92 |
+
<tr>
|
93 |
+
<th style="text-align: center;">Model Name</th>
|
94 |
+
<th style="text-align: center;">CogVideoX-2B (This Repository)</th>
|
95 |
+
<th style="text-align: center;">CogVideoX-5B </th>
|
96 |
+
</tr>
|
97 |
+
<tr>
|
98 |
+
<td style="text-align: center;">Model Description</td>
|
99 |
+
<td style="text-align: center;">Entry-level model, balancing compatibility. Low cost for running and secondary development.</td>
|
100 |
+
<td style="text-align: center;">Larger model with higher video generation quality and better visual effects.</td>
|
101 |
+
</tr>
|
102 |
+
<tr>
|
103 |
+
<td style="text-align: center;">Inference Precision</td>
|
104 |
+
<td style="text-align: center;"><b>FP16* (Recommended)</b>, BF16, FP32, FP8*, INT8, no support for INT4</td>
|
105 |
+
<td style="text-align: center;"><b>BF16 (Recommended)</b>, FP16, FP32, FP8*, INT8, no support for INT4</td>
|
106 |
+
</tr>
|
107 |
+
<tr>
|
108 |
+
<td style="text-align: center;">Single GPU VRAM Consumption</td>
|
109 |
+
<td style="text-align: center;">FP16: 18GB using <a href="https://github.com/THUDM/SwissArmyTransformer">SAT</a> / <b>12.5GB* using diffusers</b><br><b>INT8: 7.8GB* using diffusers</b></td>
|
110 |
+
<td style="text-align: center;">BF16: 26GB using <a href="https://github.com/THUDM/SwissArmyTransformer">SAT</a> / <b>20.7GB* using diffusers</b><br><b>INT8: 11.4GB* using diffusers</b></td>
|
111 |
+
</tr>
|
112 |
+
<tr>
|
113 |
+
<td style="text-align: center;">Multi-GPU Inference VRAM Consumption</td>
|
114 |
+
<td style="text-align: center;"><b>FP16: 10GB* using diffusers</b></td>
|
115 |
+
<td style="text-align: center;"><b>BF16: 15GB* using diffusers</b></td>
|
116 |
+
</tr>
|
117 |
+
<tr>
|
118 |
+
<td style="text-align: center;">Inference Speed<br>(Step = 50, FP/BF16)</td>
|
119 |
+
<td style="text-align: center;">Single A100: ~90 seconds<br>Single H100: ~45 seconds</td>
|
120 |
+
<td style="text-align: center;">Single A100: ~180 seconds<br>Single H100: ~90 seconds</td>
|
121 |
+
</tr>
|
122 |
+
<tr>
|
123 |
+
<td style="text-align: center;">Fine-tuning Precision</td>
|
124 |
+
<td style="text-align: center;"><b>FP16</b></td>
|
125 |
+
<td style="text-align: center;"><b>BF16</b></td>
|
126 |
+
</tr>
|
127 |
+
<tr>
|
128 |
+
<td style="text-align: center;">Fine-tuning VRAM Consumption (per GPU)</td>
|
129 |
+
<td style="text-align: center;">47 GB (bs=1, LORA)<br> 61 GB (bs=2, LORA)<br> 62GB (bs=1, SFT)</td>
|
130 |
+
<td style="text-align: center;">63 GB (bs=1, LORA)<br> 80 GB (bs=2, LORA)<br> 75GB (bs=1, SFT)</td>
|
131 |
+
</tr>
|
132 |
+
<tr>
|
133 |
+
<td style="text-align: center;">Prompt Language</td>
|
134 |
+
<td colspan="2" style="text-align: center;">English*</td>
|
135 |
+
</tr>
|
136 |
+
<tr>
|
137 |
+
<td style="text-align: center;">Prompt Length Limit</td>
|
138 |
+
<td colspan="2" style="text-align: center;">226 Tokens</td>
|
139 |
+
</tr>
|
140 |
+
<tr>
|
141 |
+
<td style="text-align: center;">Video Length</td>
|
142 |
+
<td colspan="2" style="text-align: center;">6 Seconds</td>
|
143 |
+
</tr>
|
144 |
+
<tr>
|
145 |
+
<td style="text-align: center;">Frame Rate</td>
|
146 |
+
<td colspan="2" style="text-align: center;">8 Frames per Second</td>
|
147 |
+
</tr>
|
148 |
+
<tr>
|
149 |
+
<td style="text-align: center;">Video Resolution</td>
|
150 |
+
<td colspan="2" style="text-align: center;">720 x 480, no support for other resolutions (including fine-tuning)</td>
|
151 |
+
</tr>
|
152 |
+
<tr>
|
153 |
+
<td style="text-align: center;">Positional Encoding</td>
|
154 |
+
<td style="text-align: center;">3d_sincos_pos_embed</td>
|
155 |
+
<td style="text-align: center;">3d_rope_pos_embed</td>
|
156 |
+
</tr>
|
157 |
+
</table>
|
158 |
+
|
159 |
+
**Data Explanation**
|
160 |
+
|
161 |
+
+ When testing with the diffusers library, the `enable_model_cpu_offload()` option and `pipe.vae.enable_tiling()` optimization were enabled. This solution has not been tested on devices other than **NVIDIA A100 / H100**. Typically, this solution is adaptable to all devices above the **NVIDIA Ampere architecture**. If the optimization is disabled, memory usage will increase significantly, with peak memory being about 3 times the table value.
|
162 |
+
+ The CogVideoX-2B model was trained using `FP16` precision, so it is recommended to use `FP16` for inference.
|
163 |
+
+ For multi-GPU inference, the `enable_model_cpu_offload()` optimization needs to be disabled.
|
164 |
+
+ Using the INT8 model will lead to reduced inference speed. This is done to allow low-memory GPUs to perform inference while maintaining minimal video quality loss, though the inference speed will be significantly reduced.
|
165 |
+
+ Inference speed tests also used the memory optimization mentioned above. Without memory optimization, inference speed increases by approximately 10%. Only the `diffusers` version of the model supports quantization.
|
166 |
+
+ The model only supports English input; other languages can be translated to English for refinement by large models.
|
167 |
+
|
168 |
+
**Note**
|
169 |
+
|
170 |
+
+ Using [SAT](https://github.com/THUDM/SwissArmyTransformer) for inference and fine-tuning of SAT version
|
171 |
+
models. Feel free to visit our GitHub for more information.
|
172 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
173 |
|
|
|
174 |
|
175 |
## Quick Start 🤗
|
176 |
|
|
|
182 |
1. Install the required dependencies
|
183 |
|
184 |
```shell
|
185 |
+
# diffusers>=0.30.1
|
186 |
+
# transformers>=0.44.0
|
187 |
+
# accelerate>=0.33.0 (suggest install from source)
|
188 |
+
# imageio-ffmpeg>=0.5.1
|
189 |
+
pip install --upgrade transformers accelerate diffusers imageio-ffmpeg
|
190 |
```
|
191 |
|
192 |
2. Run the code
|
|
|
204 |
)
|
205 |
|
206 |
pipe.enable_model_cpu_offload()
|
207 |
+
pipe.vae.enable_tiling()
|
208 |
|
209 |
+
video = pipe(
|
210 |
prompt=prompt,
|
|
|
211 |
num_videos_per_prompt=1,
|
|
|
|
|
|
|
|
|
|
|
|
|
212 |
num_inference_steps=50,
|
213 |
+
num_frames=49,
|
214 |
guidance_scale=6,
|
215 |
+
generator=torch.Generator(device="cuda").manual_seed(42),
|
216 |
).frames[0]
|
217 |
|
218 |
export_to_video(video, "output.mp4", fps=8)
|
219 |
```
|
220 |
|
|
|
|
|
|
|
|
|
|
|
221 |
## Explore the Model
|
222 |
|
223 |
Welcome to our [github](https://github.com/THUDM/CogVideo), where you will find:
|
|
|
227 |
3. Reasoning and fine-tuning of SAT version models, and even pre-release.
|
228 |
4. Project update log dynamics, more interactive opportunities.
|
229 |
5. CogVideoX toolchain to help you better use the model.
|
230 |
+
6. INT8 model inference code support.
|
231 |
|
232 |
## Model License
|
233 |
|
234 |
+
The CogVideoX-2B model (including its corresponding Transformers module and VAE module) is released under the [Apache 2.0 License](LICENSE).
|
235 |
+
|
236 |
+
The CogVideoX-5B model (Transformers module) is released under the [CogVideoX LICENSE](https://huggingface.co/THUDM/CogVideoX-5b/blob/main/LICENSE).
|
237 |
|
238 |
## Citation
|
239 |
|
240 |
+
```
|
241 |
+
@article{yang2024cogvideox,
|
242 |
+
title={CogVideoX: Text-to-Video Diffusion Models with An Expert Transformer},
|
243 |
+
author={Yang, Zhuoyi and Teng, Jiayan and Zheng, Wendi and Ding, Ming and Huang, Shiyu and Xu, Jiazheng and Yang, Yuanming and Hong, Wenyi and Zhang, Xiaohan and Feng, Guanyu and others},
|
244 |
+
journal={arXiv preprint arXiv:2408.06072},
|
245 |
+
year={2024}
|
246 |
+
}
|
247 |
+
```
|
README_zh.md
CHANGED
@@ -6,8 +6,9 @@
|
|
6 |
</div>
|
7 |
<p align="center">
|
8 |
<a href="https://huggingface.co/THUDM/CogVideoX-2b/blob/main/README.md">📄 Read in English</a> |
|
9 |
-
<a href="https://
|
10 |
-
<a href="
|
|
|
11 |
</p>
|
12 |
|
13 |
## 作品案例
|
@@ -71,21 +72,91 @@
|
|
71 |
|
72 |
## 模型介绍
|
73 |
|
74 |
-
CogVideoX是 [清影](https://chatglm.cn/video) 同源的开源版本视频生成模型。下表展示目前我们提供的视频生成模型列表,以及相关基础信息。
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
|
90 |
## 快速上手 🤗
|
91 |
|
@@ -96,10 +167,14 @@ CogVideoX是 [清影](https://chatglm.cn/video) 同源的开源版本视频生
|
|
96 |
1. 安装对应的依赖
|
97 |
|
98 |
```shell
|
99 |
-
|
|
|
|
|
|
|
|
|
100 |
```
|
101 |
|
102 |
-
2. 运行代码
|
103 |
|
104 |
```python
|
105 |
import torch
|
@@ -114,29 +189,20 @@ pipe = CogVideoXPipeline.from_pretrained(
|
|
114 |
)
|
115 |
|
116 |
pipe.enable_model_cpu_offload()
|
|
|
117 |
|
118 |
-
|
119 |
prompt=prompt,
|
120 |
-
do_classifier_free_guidance=True,
|
121 |
num_videos_per_prompt=1,
|
122 |
-
max_sequence_length=226,
|
123 |
-
device="cuda",
|
124 |
-
dtype=torch.float16,
|
125 |
-
)
|
126 |
-
|
127 |
-
video = pipe(
|
128 |
num_inference_steps=50,
|
|
|
129 |
guidance_scale=6,
|
130 |
-
|
131 |
).frames[0]
|
132 |
|
133 |
export_to_video(video, "output.mp4", fps=8)
|
134 |
```
|
135 |
|
136 |
-
**使用单卡A100按照上述配置生成一次视频大约需要90秒**。
|
137 |
-
|
138 |
-
如果您生成的模型在 MAC 默认播放器上表现为 "全绿" 无法正常观看,属于正常现象 (OpenCV保存视频问题),仅需更换一个播放器观看。
|
139 |
-
|
140 |
## 深入研究
|
141 |
|
142 |
欢迎进入我们的 [github](https://github.com/THUDM/CogVideo),你将获得:
|
@@ -146,11 +212,22 @@ export_to_video(video, "output.mp4", fps=8)
|
|
146 |
3. SAT版本模型进行推理和微调,甚至预发布。
|
147 |
4. 项目更新日志动态,更多互动机会。
|
148 |
5. CogVideoX 工具链,帮助您更好的使用模型。
|
|
|
149 |
|
150 |
## 模型协议
|
151 |
|
152 |
-
|
|
|
|
|
|
|
153 |
|
154 |
## 引用
|
155 |
|
156 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
</div>
|
7 |
<p align="center">
|
8 |
<a href="https://huggingface.co/THUDM/CogVideoX-2b/blob/main/README.md">📄 Read in English</a> |
|
9 |
+
<a href="https://huggingface.co/spaces/THUDM/CogVideoX-2B-Space">🤗 Huggingface Space</a> |
|
10 |
+
<a href="https://github.com/THUDM/CogVideo">🌐 Github </a> |
|
11 |
+
<a href="https://arxiv.org/pdf/2408.06072">📜 arxiv </a>
|
12 |
</p>
|
13 |
|
14 |
## 作品案例
|
|
|
72 |
|
73 |
## 模型介绍
|
74 |
|
75 |
+
CogVideoX是 [清影](https://chatglm.cn/video?fr=osm_cogvideo) 同源的开源版本视频生成模型。下表展示目前我们提供的视频生成模型列表,以及相关基础信息。
|
76 |
+
|
77 |
+
<table style="border-collapse: collapse; width: 100%;">
|
78 |
+
<tr>
|
79 |
+
<th style="text-align: center;">模型名</th>
|
80 |
+
<th style="text-align: center;">CogVideoX-2B (本仓库)</th>
|
81 |
+
<th style="text-align: center;">CogVideoX-5B </th>
|
82 |
+
</tr>
|
83 |
+
<tr>
|
84 |
+
<td style="text-align: center;">模型介绍</td>
|
85 |
+
<td style="text-align: center;">入门级模型,兼顾兼容性。运行,二次开发成本低。</td>
|
86 |
+
<td style="text-align: center;">视频生成质量更高,视觉效果更好的更大尺寸模型。</td>
|
87 |
+
</tr>
|
88 |
+
<tr>
|
89 |
+
<td style="text-align: center;">推理精度</td>
|
90 |
+
<td style="text-align: center;"><b>FP16*(推荐)</b>, BF16, FP32,FP8*,INT8,不支持INT4</td>
|
91 |
+
<td style="text-align: center;"><b>BF16(推荐)</b>, FP16, FP32,FP8*,INT8,不支持INT4</td>
|
92 |
+
</tr>
|
93 |
+
<tr>
|
94 |
+
<td style="text-align: center;">单GPU显存消耗<br></td>
|
95 |
+
<td style="text-align: center;">FP16: 18GB using <a href="https://github.com/THUDM/SwissArmyTransformer">SAT</a> / <b>12.5GB* using diffusers</b><br><b>INT8: 7.8GB* using diffusers</b></td>
|
96 |
+
<td style="text-align: center;">BF16: 26GB using <a href="https://github.com/THUDM/SwissArmyTransformer">SAT</a> / <b>20.7GB* using diffusers</b><br><b>INT8: 11.4GB* using diffusers</b></td>
|
97 |
+
</tr>
|
98 |
+
<tr>
|
99 |
+
<td style="text-align: center;">多GPU推理显存消耗</td>
|
100 |
+
<td style="text-align: center;"><b>FP16: 10GB* using diffusers</b><br></td>
|
101 |
+
<td style="text-align: center;"><b>BF16: 15GB* using diffusers</b><br></td>
|
102 |
+
</tr>
|
103 |
+
<tr>
|
104 |
+
<td style="text-align: center;">推理速度<br>(Step = 50, FP/BF16)</td>
|
105 |
+
<td style="text-align: center;">单卡A100: ~90秒<br>单卡H100: ~45秒</td>
|
106 |
+
<td style="text-align: center;">单卡A100: ~180秒<br>单卡H100: ~90秒</td>
|
107 |
+
</tr>
|
108 |
+
<tr>
|
109 |
+
<td style="text-align: center;">微调精度</td>
|
110 |
+
<td style="text-align: center;"><b>FP16</b></td>
|
111 |
+
<td style="text-align: center;"><b>BF16</b></td>
|
112 |
+
</tr>
|
113 |
+
<tr>
|
114 |
+
<td style="text-align: center;">微调显存消耗(每卡)</td>
|
115 |
+
<td style="text-align: center;">47 GB (bs=1, LORA)<br> 61 GB (bs=2, LORA)<br> 62GB (bs=1, SFT)</td>
|
116 |
+
<td style="text-align: center;">63 GB (bs=1, LORA)<br> 80 GB (bs=2, LORA)<br> 75GB (bs=1, SFT)<br></td>
|
117 |
+
</tr>
|
118 |
+
<tr>
|
119 |
+
<td style="text-align: center;">提示词语言</td>
|
120 |
+
<td colspan="2" style="text-align: center;">English*</td>
|
121 |
+
</tr>
|
122 |
+
<tr>
|
123 |
+
<td style="text-align: center;">提示词长度上限</td>
|
124 |
+
<td colspan="2" style="text-align: center;">226 Tokens</td>
|
125 |
+
</tr>
|
126 |
+
<tr>
|
127 |
+
<td style="text-align: center;">视频长度</td>
|
128 |
+
<td colspan="2" style="text-align: center;">6 秒</td>
|
129 |
+
</tr>
|
130 |
+
<tr>
|
131 |
+
<td style="text-align: center;">帧率</td>
|
132 |
+
<td colspan="2" style="text-align: center;">8 帧 / 秒 </td>
|
133 |
+
</tr>
|
134 |
+
<tr>
|
135 |
+
<td style="text-align: center;">视频分辨率</td>
|
136 |
+
<td colspan="2" style="text-align: center;">720 * 480,不支持其他分辨率(含微调)</td>
|
137 |
+
</tr>
|
138 |
+
<tr>
|
139 |
+
<td style="text-align: center;">位置编码</td>
|
140 |
+
<td style="text-align: center;">3d_sincos_pos_embed</td>
|
141 |
+
<td style="text-align: center;">3d_rope_pos_embed<br></td>
|
142 |
+
</tr>
|
143 |
+
</table>
|
144 |
+
|
145 |
+
**数据解释**
|
146 |
+
|
147 |
+
+ 使用 diffusers 库进行测试时,启用了 `enable_model_cpu_offload()` 选项 和 `pipe.vae.enable_tiling()` 优化,该方案未测试在非
|
148 |
+
**NVIDIA A100 / H100** 外的设备上的实际显存 / 内存占用。通常,该方案可以适配于所有 **NVIDIA 安培架构**
|
149 |
+
以上的设备。若关闭优化,显存占用会成倍增加,峰值显存约为表格的3倍。
|
150 |
+
+ 多GPU推理时,需要关闭 `enable_model_cpu_offload()` 优化。
|
151 |
+
+ 使用 INT8 模型会导致推理速度降低,此举是为了满足显存较低的显卡能正常推理并保持较少的视频质量损失,推理速度大幅降低。
|
152 |
+
+ 2B 模型采用 `FP16` 精度训练, 5B模型采用 `BF16` 精度训练。我们推荐使用模型训练的精度进行推理。
|
153 |
+
+ `FP8` 精度必须在`NVIDIA H100` 及以上的设备上使用,需要源代码安装`torch`,`torchao`,`diffusers`,`accelerate` python包,推荐使用 `CUDA 12.4`。
|
154 |
+
+ 推理速度测试同样采用了上述显存优化方案,不采用显存优化的情况下,推理速度提升约10%。 只有`diffusers`版本模型支持量化。
|
155 |
+
+ 模型仅支持英语输入,其他语言可以通过大模型润色时翻译为英语。
|
156 |
+
|
157 |
+
**提醒**
|
158 |
+
|
159 |
+
+ 使用 [SAT](https://github.com/THUDM/SwissArmyTransformer) 推理和微调SAT版本模型。欢迎前往我们的github查看。
|
160 |
|
161 |
## 快速上手 🤗
|
162 |
|
|
|
167 |
1. 安装对应的依赖
|
168 |
|
169 |
```shell
|
170 |
+
# diffusers>=0.30.1
|
171 |
+
# transformers>=0.44.0
|
172 |
+
# accelerate>=0.33.0 (suggest install from source)
|
173 |
+
# imageio-ffmpeg>=0.5.1
|
174 |
+
pip install --upgrade transformers accelerate diffusers imageio-ffmpeg
|
175 |
```
|
176 |
|
177 |
+
2. 运行代码 (BF16 / FP16)
|
178 |
|
179 |
```python
|
180 |
import torch
|
|
|
189 |
)
|
190 |
|
191 |
pipe.enable_model_cpu_offload()
|
192 |
+
pipe.vae.enable_tiling()
|
193 |
|
194 |
+
video = pipe(
|
195 |
prompt=prompt,
|
|
|
196 |
num_videos_per_prompt=1,
|
|
|
|
|
|
|
|
|
|
|
|
|
197 |
num_inference_steps=50,
|
198 |
+
num_frames=49,
|
199 |
guidance_scale=6,
|
200 |
+
generator=torch.Generator(device="cuda").manual_seed(42),
|
201 |
).frames[0]
|
202 |
|
203 |
export_to_video(video, "output.mp4", fps=8)
|
204 |
```
|
205 |
|
|
|
|
|
|
|
|
|
206 |
## 深入研究
|
207 |
|
208 |
欢迎进入我们的 [github](https://github.com/THUDM/CogVideo),你将获得:
|
|
|
212 |
3. SAT版本模型进行推理和微调,甚至预发布。
|
213 |
4. 项目更新日志动态,更多互动机会。
|
214 |
5. CogVideoX 工具链,帮助您更好的使用模型。
|
215 |
+
6. INT8 模型推理代码。
|
216 |
|
217 |
## 模型协议
|
218 |
|
219 |
+
CogVideoX-2B 模型 (包括其对应的Transformers模块,VAE模块) 根据 [Apache 2.0 License](LICENSE) 许可证发布。
|
220 |
+
|
221 |
+
CogVideoX-5B 模型 (Transformers 模块) 根据 [CogVideoX LICENSE](https://huggingface.co/THUDM/CogVideoX-5b/blob/main/LICENSE)
|
222 |
+
许可证发布。
|
223 |
|
224 |
## 引用
|
225 |
|
226 |
+
```
|
227 |
+
@article{yang2024cogvideox,
|
228 |
+
title={CogVideoX: Text-to-Video Diffusion Models with An Expert Transformer},
|
229 |
+
author={Yang, Zhuoyi and Teng, Jiayan and Zheng, Wendi and Ding, Ming and Huang, Shiyu and Xu, Jiazheng and Yang, Yuanming and Hong, Wenyi and Zhang, Xiaohan and Feng, Guanyu and others},
|
230 |
+
journal={arXiv preprint arXiv:2408.06072},
|
231 |
+
year={2024}
|
232 |
+
}
|
233 |
+
```
|
text_encoder/config.json
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
{
|
2 |
-
"_name_or_path": "/
|
3 |
"architectures": [
|
4 |
"T5EncoderModel"
|
5 |
],
|
|
|
1 |
{
|
2 |
+
"_name_or_path": "google/t5-v1_1-xxl_1",
|
3 |
"architectures": [
|
4 |
"T5EncoderModel"
|
5 |
],
|