linoyts HF Staff commited on
Commit
b3547a5
·
verified ·
1 Parent(s): e1d5bb5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -10
app.py CHANGED
@@ -27,14 +27,17 @@ def round_to_nearest_resolution_acceptable_by_vae(height, width):
27
  @spaces.GPU
28
  def generate(prompt,
29
  negative_prompt,
30
- image,
 
31
  steps,
32
  num_frames,
33
  seed,
34
  randomize_seed,
35
  t2v, improve_texture=False, progress=gr.Progress(track_tqdm=True)):
36
 
37
-
 
 
38
  # Part 1. Generate video at smaller resolution
39
  # Text-only conditioning is also supported without the need to pass `conditions`
40
  expected_height, expected_width = 768, 1152
@@ -42,11 +45,10 @@ def generate(prompt,
42
  downscaled_height, downscaled_width = int(expected_height * downscale_factor), int(expected_width * downscale_factor)
43
  downscaled_height, downscaled_width = round_to_nearest_resolution_acceptable_by_vae(downscaled_height, downscaled_width)
44
 
45
- if randomize_seed:
46
- seed = random.randint(0, MAX_SEED)
47
 
48
- if image is not None or t2v:
49
- condition1 = LTXVideoCondition(video=image, frame_index=0)
50
  latents = pipe(
51
  conditions=condition1,
52
  prompt=prompt,
@@ -155,9 +157,15 @@ with gr.Blocks(css=css, theme=gr.themes.Ocean()) as demo:
155
  with gr.Row():
156
  with gr.Column():
157
  with gr.Group():
158
- image = gr.Image(label="")
 
 
 
 
 
 
 
159
  prompt = gr.Textbox(label="prompt")
160
- t2v = gr.Checkbox(label="run text-to-video", value=False)
161
  run_button = gr.Button()
162
  with gr.Column():
163
  output = gr.Video(interactive=False)
@@ -170,13 +178,15 @@ with gr.Blocks(css=css, theme=gr.themes.Ocean()) as demo:
170
  randomize_seed = gr.Checkbox(label="randomize seed")
171
  with gr.Row():
172
  steps = gr.Slider(label="Steps", minimum=1, maximum=30, value=8, step=1)
173
- num_frames = gr.Slider(label="# frames", minimum=1, maximum=200, value=161, step=1)
 
174
 
175
 
176
  run_button.click(fn=generate,
177
  inputs=[prompt,
178
  negative_prompt,
179
- image,
 
180
  steps,
181
  num_frames,
182
  seed,
 
27
  @spaces.GPU
28
  def generate(prompt,
29
  negative_prompt,
30
+ image,
31
+ video,
32
  steps,
33
  num_frames,
34
  seed,
35
  randomize_seed,
36
  t2v, improve_texture=False, progress=gr.Progress(track_tqdm=True)):
37
 
38
+ if randomize_seed:
39
+ seed = random.randint(0, MAX_SEED)
40
+
41
  # Part 1. Generate video at smaller resolution
42
  # Text-only conditioning is also supported without the need to pass `conditions`
43
  expected_height, expected_width = 768, 1152
 
45
  downscaled_height, downscaled_width = int(expected_height * downscale_factor), int(expected_width * downscale_factor)
46
  downscaled_height, downscaled_width = round_to_nearest_resolution_acceptable_by_vae(downscaled_height, downscaled_width)
47
 
48
+ condition = image is not None or video is not None
 
49
 
50
+ if condition and (not t2v):
51
+ condition1 = LTXVideoCondition(video=[image], frame_index=0)
52
  latents = pipe(
53
  conditions=condition1,
54
  prompt=prompt,
 
157
  with gr.Row():
158
  with gr.Column():
159
  with gr.Group():
160
+ with gr.Tab("text-to-video"):
161
+ image = gr.Image(label="", visible=False)
162
+ #prompt = gr.Textbox(label="prompt")
163
+ with gr.Tab("image-to-video"):
164
+ image = gr.Image(label="")
165
+ #prompt = gr.Textbox(label="prompt")
166
+ with gr.Tab("video-to-video"):
167
+ image = gr.Video(label="")
168
  prompt = gr.Textbox(label="prompt")
 
169
  run_button = gr.Button()
170
  with gr.Column():
171
  output = gr.Video(interactive=False)
 
178
  randomize_seed = gr.Checkbox(label="randomize seed")
179
  with gr.Row():
180
  steps = gr.Slider(label="Steps", minimum=1, maximum=30, value=8, step=1)
181
+ num_frames = gr.Slider(label="# frames", minimum=1, maximum=30, value=8, step=1)
182
+
183
 
184
 
185
  run_button.click(fn=generate,
186
  inputs=[prompt,
187
  negative_prompt,
188
+ image,
189
+ video,
190
  steps,
191
  num_frames,
192
  seed,