Upload ./README.md with huggingface_hub
Browse files
README.md
CHANGED
@@ -84,35 +84,35 @@ pipeline_tag: text-to-video
|
|
84 |
|
85 |
2. Run inference.
|
86 |
```python
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
```
|
117 |
|
118 |
Use `pipe.enable_sequential_cpu_offload()` to offload the model into CPU for less GPU memory cost, but the inference time will increase significantly.
|
|
|
84 |
|
85 |
2. Run inference.
|
86 |
```python
|
87 |
+
import torch
|
88 |
+
from diffusers import AutoencoderKLAllegro, AllegroPipeline
|
89 |
+
from diffusers.utils import export_to_video
|
90 |
+
vae = AutoencoderKLAllegro.from_pretrained("rhymes-ai/Allegro-T2V-40x720P", subfolder="vae", torch_dtype=torch.float32)
|
91 |
+
|
92 |
+
pipe = AllegroPipeline.from_pretrained(
|
93 |
+
"rhymes-ai/Allegro-T2V-40x720P", vae=vae, torch_dtype=torch.bfloat16
|
94 |
+
)
|
95 |
+
pipe.to("cuda")
|
96 |
+
pipe.vae.enable_tiling()
|
97 |
+
|
98 |
+
prompt = "A seaside harbor with bright sunlight and sparkling seawater, with many boats in the water. From an aerial view, the boats vary in size and color, some moving and some stationary. Fishing boats in the water suggest that this location might be a popular spot for docking fishing boats."
|
99 |
+
|
100 |
+
positive_prompt = """
|
101 |
+
(masterpiece), (best quality), (ultra-detailed), (unwatermarked),
|
102 |
+
{}
|
103 |
+
emotional, harmonious, vignette, 4k epic detailed, shot on kodak, 35mm photo,
|
104 |
+
sharp focus, high budget, cinemascope, moody, epic, gorgeous
|
105 |
+
"""
|
106 |
+
|
107 |
+
negative_prompt = """
|
108 |
+
nsfw, lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality,
|
109 |
+
low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry.
|
110 |
+
"""
|
111 |
+
|
112 |
+
prompt = prompt.format(prompt.lower().strip())
|
113 |
+
|
114 |
+
video = pipe(prompt, negative_prompt=negative_prompt, guidance_scale=7.5, max_sequence_length=512, num_inference_steps=100, generator = torch.Generator(device="cuda:0").manual_seed(42)).frames[0]
|
115 |
+
export_to_video(video, "output.mp4", fps=15)
|
116 |
```
|
117 |
|
118 |
Use `pipe.enable_sequential_cpu_offload()` to offload the model into CPU for less GPU memory cost, but the inference time will increase significantly.
|