Skip to content

Commit bdcf23e

Browse files
committed
update docs.
1 parent c39f1b8 commit bdcf23e

File tree

2 files changed

+45
-20
lines changed

2 files changed

+45
-20
lines changed

src/diffusers/pipelines/ltx2/pipeline_ltx2.py

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,24 +47,36 @@
4747
Examples:
4848
```py
4949
>>> import torch
50-
>>> from diffusers import LTXPipeline
51-
>>> from diffusers.utils import export_to_video
50+
>>> from diffusers import LTX2Pipeline
51+
>>> from diffusers.pipelines.ltx2.export_utils import encode_video
5252
53-
>>> pipe = LTXPipeline.from_pretrained("Lightricks/LTX-Video", torch_dtype=torch.bfloat16)
54-
>>> pipe.to("cuda")
53+
>>> pipe = LTX2Pipeline.from_pretrained("Lightricks/LTX-2", torch_dtype=torch.bfloat16)
54+
>>> pipe.enable_model_cpu_offload()
5555
5656
>>> prompt = "A woman with long brown hair and light skin smiles at another woman with long blonde hair. The woman with brown hair wears a black jacket and has a small, barely noticeable mole on her right cheek. The camera angle is a close-up, focused on the woman with brown hair's face. The lighting is warm and natural, likely from the setting sun, casting a soft glow on the scene. The scene appears to be real-life footage"
5757
>>> negative_prompt = "worst quality, inconsistent motion, blurry, jittery, distorted"
5858
59-
>>> video = pipe(
59+
>>> frame_rate = 24.0
60+
>>> video, audio = pipe(
6061
... prompt=prompt,
6162
... negative_prompt=negative_prompt,
62-
... width=704,
63-
... height=480,
64-
... num_frames=161,
65-
... num_inference_steps=50,
66-
... ).frames[0]
67-
>>> export_to_video(video, "output.mp4", fps=24)
63+
... width=768,
64+
... height=512,
65+
... frame_rate=frame_rate,
66+
... num_frames=121,
67+
... output_type="np",
68+
... return_dict=False,
69+
... )
70+
>>> video = (video * 255).round().astype("uint8")
71+
>>> video = torch.from_numpy(video)
72+
73+
>>> encode_video(
74+
... video[0],
75+
... fps=frame_rate,
76+
... audio=audio[0].float().cpu(),
77+
... audio_sample_rate=pipe.vocoder.config.output_sampling_rate, # should be 24000
78+
... output_path="video.mp4",
79+
... )
6880
```
6981
"""
7082

src/diffusers/pipelines/ltx2/pipeline_ltx2_image2video.py

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,28 +48,41 @@
4848
Examples:
4949
```py
5050
>>> import torch
51-
>>> from diffusers import LTX2ImageToVideoPipeline
52-
>>> from diffusers.utils import export_to_video, load_image
51+
>>> from diffusers import LTX2Pipeline
52+
>>> from diffusers.pipelines.ltx2.export_utils import encode_video
53+
>>> from diffusers.utils import load_image
5354
54-
>>> pipe = LTX2ImageToVideoPipeline.from_pretrained("Lightricks/LTX-Video-2", torch_dtype=torch.bfloat16)
55-
>>> pipe.to("cuda")
55+
>>> pipe = LTX2ImageToVideoPipeline.from_pretrained("Lightricks/LTX-2", torch_dtype=torch.bfloat16)
56+
>>> pipe.enable_model_cpu_offload()
5657
5758
>>> image = load_image(
5859
... "https://huggingface.co/datasets/a-r-r-o-w/tiny-meme-dataset-captioned/resolve/main/images/8.png"
5960
... )
6061
>>> prompt = "A young girl stands calmly in the foreground, looking directly at the camera, as a house fire rages in the background."
6162
>>> negative_prompt = "worst quality, inconsistent motion, blurry, jittery, distorted"
6263
64+
>>> frame_rate = 24.0
6365
>>> video = pipe(
6466
... image=image,
6567
... prompt=prompt,
6668
... negative_prompt=negative_prompt,
67-
... width=704,
68-
... height=480,
69+
... width=768,
70+
... height=512,
6971
... num_frames=121,
70-
... num_inference_steps=40,
71-
... ).frames[0]
72-
>>> export_to_video(video, "output.mp4", fps=24)
72+
... frame_rate=frame_rate,
73+
... output_type="np",
74+
... return_dict=False,
75+
... )
76+
>>> video = (video * 255).round().astype("uint8")
77+
>>> video = torch.from_numpy(video)
78+
79+
>>> encode_video(
80+
... video[0],
81+
... fps=frame_rate,
82+
... audio=audio[0].float().cpu(),
83+
... audio_sample_rate=pipe.vocoder.config.output_sampling_rate, # should be 24000
84+
... output_path="video.mp4",
85+
... )
7386
```
7487
"""
7588

0 commit comments

Comments
 (0)