|
13 | 13 | # limitations under the License.
|
14 | 14 | -->
|
15 | 15 |
|
16 |
| -# CogVideoX |
17 |
| - |
18 | 16 | <div style="float: right;">
|
19 | 17 | <div class="flex flex-wrap space-x-1">
|
20 | 18 | <img alt="LoRA" src="https://img.shields.io/badge/LoRA-d8b4fe?style=flat"/>
|
21 | 19 | </div>
|
22 | 20 | </div>
|
23 | 21 |
|
| 22 | +# CogVideoX |
| 23 | + |
24 | 24 | [CogVideoX](https://huggingface.co/papers/2408.06072) is a large diffusion transformer model - available in 2B and 5B parameters - designed to generate longer and more consistent videos from text. This model uses a 3D causal variational autoencoder to more efficiently process video data by reducing sequence length (and associated training compute) and preventing flickering in generated videos. An "expert" transformer with adaptive LayerNorm improves alignment between text and video, and 3D full attention helps accurately capture motion and time in generated videos.
|
25 | 25 |
|
26 | 26 | You can find all the original CogVideoX checkpoints under the [CogVideoX collection](https://huggingface.co/collections/THUDM/cogvideo-66c08e62f1685a3ade464cce).
|
@@ -148,44 +148,43 @@ export_to_video(video, "output.mp4", fps=8)
|
148 | 148 | </hfoption>
|
149 | 149 | </hfoptions>
|
150 | 150 |
|
151 |
| -CogVideoX supports LoRAs with [`~loaders.CogVideoXLoraLoaderMixin.load_lora_weights`]. |
152 |
| - |
153 |
| -```py |
154 |
| -import torch |
155 |
| -from diffusers import CogVideoXPipeline, CogVideoXTransformer3DModel |
156 |
| -from diffusers.hooks import apply_group_offloading |
157 |
| -from diffusers.utils import export_to_video |
158 |
| - |
159 |
| -pipeline = CogVideoXPipeline.from_pretrained( |
160 |
| - "THUDM/CogVideoX-5b", |
161 |
| - torch_dtype=torch.bfloat16 |
162 |
| -) |
163 |
| -pipeline.to("cuda") |
164 |
| - |
165 |
| -pipeline.load_lora_weights("finetrainers/CogVideoX-1.5-crush-smol-v0", adapter_name="crush-lora") |
166 |
| -pipeline.set_adapters("crush-lora", 0.9) |
167 |
| - |
168 |
| -# model-offloading |
169 |
| -pipeline.enable_model_cpu_offload() |
170 |
| - |
171 |
| -prompt = """ |
172 |
| -PIKA_CRUSH A large metal cylinder is seen pressing down on a pile of Oreo cookies, flattening them as if they were under a hydraulic press. |
173 |
| -""" |
174 |
| -negative_prompt = "inconsistent motion, blurry motion, worse quality, degenerate outputs, deformed outputs" |
| 151 | +## Notes |
175 | 152 |
|
176 |
| -video = pipeline( |
177 |
| - prompt=prompt, |
178 |
| - negative_prompt=negative_prompt, |
179 |
| - num_frames=81, |
180 |
| - height=480, |
181 |
| - width=768, |
182 |
| - num_inference_steps=50 |
183 |
| -).frames[0] |
184 |
| -export_to_video(video, "output.mp4", fps=16) |
185 |
| -``` |
| 153 | +- CogVideoX supports LoRAs with [`~loaders.CogVideoXLoraLoaderMixin.load_lora_weights`]. |
186 | 154 |
|
187 |
| -## Notes |
| 155 | + ```py |
| 156 | + import torch |
| 157 | + from diffusers import CogVideoXPipeline, CogVideoXTransformer3DModel |
| 158 | + from diffusers.hooks import apply_group_offloading |
| 159 | + from diffusers.utils import export_to_video |
188 | 160 |
|
| 161 | + pipeline = CogVideoXPipeline.from_pretrained( |
| 162 | + "THUDM/CogVideoX-5b", |
| 163 | + torch_dtype=torch.bfloat16 |
| 164 | + ) |
| 165 | + pipeline.to("cuda") |
| 166 | + |
| 167 | + pipeline.load_lora_weights("finetrainers/CogVideoX-1.5-crush-smol-v0", adapter_name="crush-lora") |
| 168 | + pipeline.set_adapters("crush-lora", 0.9) |
| 169 | + |
| 170 | + # model-offloading |
| 171 | + pipeline.enable_model_cpu_offload() |
| 172 | + |
| 173 | + prompt = """ |
| 174 | + PIKA_CRUSH A large metal cylinder is seen pressing down on a pile of Oreo cookies, flattening them as if they were under a hydraulic press. |
| 175 | + """ |
| 176 | + negative_prompt = "inconsistent motion, blurry motion, worse quality, degenerate outputs, deformed outputs" |
| 177 | + |
| 178 | + video = pipeline( |
| 179 | + prompt=prompt, |
| 180 | + negative_prompt=negative_prompt, |
| 181 | + num_frames=81, |
| 182 | + height=480, |
| 183 | + width=768, |
| 184 | + num_inference_steps=50 |
| 185 | + ).frames[0] |
| 186 | + export_to_video(video, "output.mp4", fps=16) |
| 187 | + ``` |
189 | 188 | - The text-to-video (T2V) checkpoints work best with a resolution of 1360x768 because that was the resolution it was pretrained on.
|
190 | 189 | - The image-to-video (I2V) checkpoints work with multiple resolutions. The width can vary from 768 to 1360, but the height must be 758. Both height and width must be divisible by 16.
|
191 | 190 | - Both T2V and I2V checkpoints work best with 81 and 161 frames. It is recommended to export the generated video at 16fps.
|
|
0 commit comments