LTX-Video Real-Time Generation
Generate 5-second videos faster than real-time with Lightricks' LTX-Video on Clore.ai GPUs.
Last updated
Was this helpful?
Was this helpful?
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu124
pip install diffusers transformers accelerate sentencepiece imageio[ffmpeg]
python -c "import torch; print(torch.cuda.get_device_name(0))"import torch
from diffusers import LTXPipeline
from diffusers.utils import export_to_video
pipe = LTXPipeline.from_pretrained(
"Lightricks/LTX-Video",
torch_dtype=torch.bfloat16,
)
pipe.to("cuda")
prompt = (
"A drone shot gliding over a turquoise coral reef, "
"schools of tropical fish darting below, golden hour light "
"refracting through the water surface"
)
video_frames = pipe(
prompt=prompt,
negative_prompt="blurry, low quality, distorted",
num_frames=121, # ~5 sec at 24 fps
width=768,
height=512,
num_inference_steps=30,
guidance_scale=7.5,
generator=torch.Generator("cuda").manual_seed(0),
).frames[0]
export_to_video(video_frames, "coral_reef.mp4", fps=24)
print("Saved coral_reef.mp4")import torch
from PIL import Image
from diffusers import LTXImageToVideoPipeline
from diffusers.utils import export_to_video
pipe = LTXImageToVideoPipeline.from_pretrained(
"Lightricks/LTX-Video",
torch_dtype=torch.bfloat16,
)
pipe.to("cuda")
image = Image.open("cityscape.png").resize((768, 512))
video_frames = pipe(
prompt="Camera slowly pans right, city lights flicker on at dusk",
negative_prompt="static, blurry",
image=image,
num_frames=121,
num_inference_steps=30,
guidance_scale=7.5,
).frames[0]
export_to_video(video_frames, "cityscape_animated.mp4", fps=24)import torch
from diffusers import LTXPipeline
from diffusers.utils import export_to_video
pipe = LTXPipeline.from_pretrained(
"Lightricks/LTX-Video", torch_dtype=torch.bfloat16
).to("cuda")
prompts = [
"A cat stretching on a sunlit windowsill, dust motes floating",
"Aerial view of waves crashing on black volcanic sand",
"Time-lapse of storm clouds rolling over a prairie",
]
for i, prompt in enumerate(prompts):
frames = pipe(
prompt=prompt,
num_frames=121,
width=768,
height=512,
num_inference_steps=30,
guidance_scale=7.5,
).frames[0]
export_to_video(frames, f"batch_{i:03d}.mp4", fps=24)
print(f"[{i+1}/{len(prompts)}] Done")