Create app.py
Browse filesinitial commit
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748import gradio as grimport spaces import torchfrom diffusers import LTXConditionPipeline, LTXLatentUpsamplePipelinefrom diffusers.pipelines.ltx.pipeline_ltx_condition import LTXVideoConditionfrom diffusers.utils import export_to_video, load_video
pipe = LTXConditionPipeline.from_pretrained("a-r-r-o-w/LTX-Video-0.9.7-diffusers", torch_dtype=torch.bfloat16)pipe_upsample = LTXLatentUpsamplePipeline.from_pretrained("a-r-r-o-w/LTX-Video-0.9.7-Latent-Spatial-Upsampler-diffusers", vae=pipe.vae, torch_dtype=torch.bfloat16)pipe.to("cuda")pipe_upsample.to("cuda")pipe.vae.enable_tiling()
def round_to_nearest_resolution_acceptable_by_vae(height, width): height = height - (height % pipe.vae_temporal_compression_ratio) width = width - (width % pipe.vae_temporal_compression_ratio) return height, width @spaces.GPUdef generate(prompt, negative_prompt, steps, seed): return
with gr.Blocks() as demo:
gr.Markdown("# LTX Video 0.9.7 Distilled")
prompt = gr.Textbox(label="prompt") output = gr.Video(interactive=False) run_button = gr.Button()
with gr.Accordion("Advanced settings", open=False): n_prompt = gr.Textbox(label="negative prompt", value="", visible=False) with gr.Row(): seed = gr.Number(label="seed", value=0, precision=0) randomize_seed = gr.Checkbox(label="randomize seed") with gr.Row(): steps = gr.Slider(label="Steps", minimum=1, maximum=30, value=8, step=1) num_frames = gr.Slider(label="# frames", minimum=1, maximum=30, value=8, step=1)
demo.launch()app.pyAdded+48