Spaces:
Running
on
Zero
Running
on
Zero
Create app.py
Browse filesinitial commit
app.py
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import spaces
|
3 |
+
import torch
|
4 |
+
from diffusers import LTXConditionPipeline, LTXLatentUpsamplePipeline
|
5 |
+
from diffusers.pipelines.ltx.pipeline_ltx_condition import LTXVideoCondition
|
6 |
+
from diffusers.utils import export_to_video, load_video
|
7 |
+
|
8 |
+
pipe = LTXConditionPipeline.from_pretrained("a-r-r-o-w/LTX-Video-0.9.7-diffusers", torch_dtype=torch.bfloat16)
|
9 |
+
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)
|
10 |
+
pipe.to("cuda")
|
11 |
+
pipe_upsample.to("cuda")
|
12 |
+
pipe.vae.enable_tiling()
|
13 |
+
|
14 |
+
|
15 |
+
def round_to_nearest_resolution_acceptable_by_vae(height, width):
|
16 |
+
height = height - (height % pipe.vae_temporal_compression_ratio)
|
17 |
+
width = width - (width % pipe.vae_temporal_compression_ratio)
|
18 |
+
return height, width
|
19 |
+
|
20 |
+
@spaces.GPU
|
21 |
+
def generate(prompt,
|
22 |
+
negative_prompt,
|
23 |
+
steps,
|
24 |
+
seed):
|
25 |
+
return
|
26 |
+
|
27 |
+
|
28 |
+
with gr.Blocks() as demo:
|
29 |
+
|
30 |
+
gr.Markdown("# LTX Video 0.9.7 Distilled")
|
31 |
+
|
32 |
+
prompt = gr.Textbox(label="prompt")
|
33 |
+
output = gr.Video(interactive=False)
|
34 |
+
run_button = gr.Button()
|
35 |
+
|
36 |
+
with gr.Accordion("Advanced settings", open=False):
|
37 |
+
n_prompt = gr.Textbox(label="negative prompt", value="", visible=False)
|
38 |
+
with gr.Row():
|
39 |
+
seed = gr.Number(label="seed", value=0, precision=0)
|
40 |
+
randomize_seed = gr.Checkbox(label="randomize seed")
|
41 |
+
with gr.Row():
|
42 |
+
steps = gr.Slider(label="Steps", minimum=1, maximum=30, value=8, step=1)
|
43 |
+
num_frames = gr.Slider(label="# frames", minimum=1, maximum=30, value=8, step=1)
|
44 |
+
|
45 |
+
|
46 |
+
|
47 |
+
|
48 |
+
demo.launch()
|