Update README.md (#95)
Browse files- Update README.md (6dc5b10281c1e4dccb830be602b865178c8c1316)
Co-authored-by: Barak Weiss <[email protected]>
README.md
CHANGED
|
@@ -136,14 +136,20 @@ pipe.to("cuda")
|
|
| 136 |
pipe_upsample.to("cuda")
|
| 137 |
pipe.vae.enable_tiling()
|
| 138 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 139 |
prompt = "The video depicts a winding mountain road covered in snow, with a single vehicle traveling along it. The road is flanked by steep, rocky cliffs and sparse vegetation. The landscape is characterized by rugged terrain and a river visible in the distance. The scene captures the solitude and beauty of a winter drive through a mountainous region."
|
| 140 |
negative_prompt = "worst quality, inconsistent motion, blurry, jittery, distorted"
|
| 141 |
-
expected_height, expected_width =
|
| 142 |
downscale_factor = 2 / 3
|
| 143 |
num_frames = 121
|
| 144 |
|
| 145 |
# Part 1. Generate video at smaller resolution
|
| 146 |
downscaled_height, downscaled_width = int(expected_height * downscale_factor), int(expected_width * downscale_factor)
|
|
|
|
| 147 |
latents = pipe(
|
| 148 |
conditions=None,
|
| 149 |
prompt=prompt,
|
|
@@ -192,7 +198,7 @@ export_to_video(video, "output.mp4", fps=24)
|
|
| 192 |
import torch
|
| 193 |
from diffusers import LTXConditionPipeline, LTXLatentUpsamplePipeline
|
| 194 |
from diffusers.pipelines.ltx.pipeline_ltx_condition import LTXVideoCondition
|
| 195 |
-
from diffusers.utils import export_to_video, load_image
|
| 196 |
|
| 197 |
pipe = LTXConditionPipeline.from_pretrained("Lightricks/LTX-Video-0.9.7-dev", torch_dtype=torch.bfloat16)
|
| 198 |
pipe_upsample = LTXLatentUpsamplePipeline.from_pretrained("Lightricks/ltxv-spatial-upscaler-0.9.7", vae=pipe.vae, torch_dtype=torch.bfloat16)
|
|
@@ -200,13 +206,18 @@ pipe.to("cuda")
|
|
| 200 |
pipe_upsample.to("cuda")
|
| 201 |
pipe.vae.enable_tiling()
|
| 202 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 203 |
image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/penguin.png")
|
| 204 |
-
video = [image]
|
| 205 |
condition1 = LTXVideoCondition(video=video, frame_index=0)
|
| 206 |
|
| 207 |
-
prompt = "
|
| 208 |
negative_prompt = "worst quality, inconsistent motion, blurry, jittery, distorted"
|
| 209 |
-
expected_height, expected_width =
|
| 210 |
downscale_factor = 2 / 3
|
| 211 |
num_frames = 96
|
| 212 |
|
|
@@ -254,7 +265,6 @@ video = pipe(
|
|
| 254 |
video = [frame.resize((expected_width, expected_height)) for frame in video]
|
| 255 |
|
| 256 |
export_to_video(video, "output.mp4", fps=24)
|
| 257 |
-
|
| 258 |
```
|
| 259 |
|
| 260 |
### For video-to-video:
|
|
@@ -272,8 +282,8 @@ pipe_upsample.to("cuda")
|
|
| 272 |
pipe.vae.enable_tiling()
|
| 273 |
|
| 274 |
def round_to_nearest_resolution_acceptable_by_vae(height, width):
|
| 275 |
-
height = height - (height % pipe.
|
| 276 |
-
width = width - (width % pipe.
|
| 277 |
return height, width
|
| 278 |
|
| 279 |
video = load_video(
|
|
@@ -331,10 +341,8 @@ video = pipe(
|
|
| 331 |
video = [frame.resize((expected_width, expected_height)) for frame in video]
|
| 332 |
|
| 333 |
export_to_video(video, "output.mp4", fps=24)
|
| 334 |
-
|
| 335 |
```
|
| 336 |
|
| 337 |
-
|
| 338 |
To learn more, check out the [official documentation](https://huggingface.co/docs/diffusers/main/en/api/pipelines/ltx_video).
|
| 339 |
|
| 340 |
Diffusers also supports directly loading from the original LTX checkpoints using the `from_single_file()` method. Check out [this section](https://huggingface.co/docs/diffusers/main/en/api/pipelines/ltx_video#loading-single-files) to learn more.
|
|
|
|
| 136 |
pipe_upsample.to("cuda")
|
| 137 |
pipe.vae.enable_tiling()
|
| 138 |
|
| 139 |
+
def round_to_nearest_resolution_acceptable_by_vae(height, width):
|
| 140 |
+
height = height - (height % pipe.vae_spatial_compression_ratio)
|
| 141 |
+
width = width - (width % pipe.vae_spatial_compression_ratio)
|
| 142 |
+
return height, width
|
| 143 |
+
|
| 144 |
prompt = "The video depicts a winding mountain road covered in snow, with a single vehicle traveling along it. The road is flanked by steep, rocky cliffs and sparse vegetation. The landscape is characterized by rugged terrain and a river visible in the distance. The scene captures the solitude and beauty of a winter drive through a mountainous region."
|
| 145 |
negative_prompt = "worst quality, inconsistent motion, blurry, jittery, distorted"
|
| 146 |
+
expected_height, expected_width = 512, 704
|
| 147 |
downscale_factor = 2 / 3
|
| 148 |
num_frames = 121
|
| 149 |
|
| 150 |
# Part 1. Generate video at smaller resolution
|
| 151 |
downscaled_height, downscaled_width = int(expected_height * downscale_factor), int(expected_width * downscale_factor)
|
| 152 |
+
downscaled_height, downscaled_width = round_to_nearest_resolution_acceptable_by_vae(downscaled_height, downscaled_width)
|
| 153 |
latents = pipe(
|
| 154 |
conditions=None,
|
| 155 |
prompt=prompt,
|
|
|
|
| 198 |
import torch
|
| 199 |
from diffusers import LTXConditionPipeline, LTXLatentUpsamplePipeline
|
| 200 |
from diffusers.pipelines.ltx.pipeline_ltx_condition import LTXVideoCondition
|
| 201 |
+
from diffusers.utils import export_to_video, load_image, load_video
|
| 202 |
|
| 203 |
pipe = LTXConditionPipeline.from_pretrained("Lightricks/LTX-Video-0.9.7-dev", torch_dtype=torch.bfloat16)
|
| 204 |
pipe_upsample = LTXLatentUpsamplePipeline.from_pretrained("Lightricks/ltxv-spatial-upscaler-0.9.7", vae=pipe.vae, torch_dtype=torch.bfloat16)
|
|
|
|
| 206 |
pipe_upsample.to("cuda")
|
| 207 |
pipe.vae.enable_tiling()
|
| 208 |
|
| 209 |
+
def round_to_nearest_resolution_acceptable_by_vae(height, width):
|
| 210 |
+
height = height - (height % pipe.vae_spatial_compression_ratio)
|
| 211 |
+
width = width - (width % pipe.vae_spatial_compression_ratio)
|
| 212 |
+
return height, width
|
| 213 |
+
|
| 214 |
image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/penguin.png")
|
| 215 |
+
video = load_video(export_to_video([image])) # compress the image using video compression as the model was trained on videos
|
| 216 |
condition1 = LTXVideoCondition(video=video, frame_index=0)
|
| 217 |
|
| 218 |
+
prompt = "A cute little penguin takes out a book and starts reading it"
|
| 219 |
negative_prompt = "worst quality, inconsistent motion, blurry, jittery, distorted"
|
| 220 |
+
expected_height, expected_width = 480, 832
|
| 221 |
downscale_factor = 2 / 3
|
| 222 |
num_frames = 96
|
| 223 |
|
|
|
|
| 265 |
video = [frame.resize((expected_width, expected_height)) for frame in video]
|
| 266 |
|
| 267 |
export_to_video(video, "output.mp4", fps=24)
|
|
|
|
| 268 |
```
|
| 269 |
|
| 270 |
### For video-to-video:
|
|
|
|
| 282 |
pipe.vae.enable_tiling()
|
| 283 |
|
| 284 |
def round_to_nearest_resolution_acceptable_by_vae(height, width):
|
| 285 |
+
height = height - (height % pipe.vae_spatial_compression_ratio)
|
| 286 |
+
width = width - (width % pipe.vae_spatial_compression_ratio)
|
| 287 |
return height, width
|
| 288 |
|
| 289 |
video = load_video(
|
|
|
|
| 341 |
video = [frame.resize((expected_width, expected_height)) for frame in video]
|
| 342 |
|
| 343 |
export_to_video(video, "output.mp4", fps=24)
|
|
|
|
| 344 |
```
|
| 345 |
|
|
|
|
| 346 |
To learn more, check out the [official documentation](https://huggingface.co/docs/diffusers/main/en/api/pipelines/ltx_video).
|
| 347 |
|
| 348 |
Diffusers also supports directly loading from the original LTX checkpoints using the `from_single_file()` method. Check out [this section](https://huggingface.co/docs/diffusers/main/en/api/pipelines/ltx_video#loading-single-files) to learn more.
|