TEXT_TO_VIDEO / ttv.py
akthangdz's picture
main
dcfc56c
raw
history blame
588 Bytes
import torch
from diffusers import LTXPipeline
from diffusers.utils import export_to_video
import os
def generate_video(prompt, negative_prompt):
pipe = LTXPipeline.from_pretrained("Lightricks/LTX-Video", torch_dtype=torch.bfloat16)
pipe.to("cuda")
video = pipe(
prompt=prompt,
negative_prompt=negative_prompt,
width=704,
height=480,
num_frames=161,
num_inference_steps=50,
).frames[0]
output_path = f"output_{len(os.listdir('.'))}.mp4"
export_to_video(video, output_path, fps=24)
return output_path