linoyts HF Staff commited on
Commit
af73a4f
·
verified ·
1 Parent(s): fad21f9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -3
app.py CHANGED
@@ -41,6 +41,7 @@ def generate(prompt,
41
  mode,
42
  steps,
43
  num_frames,
 
44
  seed,
45
  randomize_seed,
46
  improve_texture=False, progress=gr.Progress(track_tqdm=True)):
@@ -56,7 +57,6 @@ def generate(prompt,
56
  downscaled_height, downscaled_width = round_to_nearest_resolution_acceptable_by_vae(downscaled_height, downscaled_width)
57
 
58
  if mode == "text-to-video" and video is not None:
59
- frames_to_use = 21 #todo make configurable
60
  video = load_video(video)[:frames_to_use]
61
  condition = True
62
  elif mode == "image-to-video" and image is not None:
@@ -77,6 +77,7 @@ def generate(prompt,
77
  num_inference_steps=steps,
78
  decode_timestep = 0.05,
79
  decode_noise_scale = 0.025,
 
80
  generator=torch.Generator(device="cuda").manual_seed(seed),
81
  output_type="latent",
82
  ).frames
@@ -90,6 +91,7 @@ def generate(prompt,
90
  num_inference_steps=steps,
91
  decode_timestep = 0.05,
92
  decode_noise_scale = 0.025,
 
93
  generator=torch.Generator(device="cuda").manual_seed(seed),
94
  output_type="latent",
95
  ).frames
@@ -180,10 +182,11 @@ with gr.Blocks(css=css, theme=gr.themes.Ocean()) as demo:
180
  #prompt = gr.Textbox(label="prompt")
181
  with gr.Tab("image-to-video") as image_tab:
182
  image = gr.Image(label="")
183
- #prompt = gr.Textbox(label="prompt")
184
  with gr.Tab("video-to-video") as video_tab:
185
  video = gr.Video(label="")
 
186
  prompt = gr.Textbox(label="prompt")
 
187
  run_button = gr.Button()
188
  with gr.Column():
189
  output = gr.Video(interactive=False)
@@ -197,6 +200,9 @@ with gr.Blocks(css=css, theme=gr.themes.Ocean()) as demo:
197
  with gr.Row():
198
  steps = gr.Slider(label="Steps", minimum=1, maximum=30, value=8, step=1)
199
  num_frames = gr.Slider(label="# frames", minimum=1, maximum=161, value=96, step=1)
 
 
 
200
 
201
 
202
  text_tab.select(fn=change_mode_to_text, inputs=[], outputs=[mode])
@@ -211,8 +217,9 @@ with gr.Blocks(css=css, theme=gr.themes.Ocean()) as demo:
211
  mode,
212
  steps,
213
  num_frames,
 
214
  seed,
215
- randomize_seed],
216
  outputs=[output])
217
 
218
 
 
41
  mode,
42
  steps,
43
  num_frames,
44
+ frames_to_use,
45
  seed,
46
  randomize_seed,
47
  improve_texture=False, progress=gr.Progress(track_tqdm=True)):
 
57
  downscaled_height, downscaled_width = round_to_nearest_resolution_acceptable_by_vae(downscaled_height, downscaled_width)
58
 
59
  if mode == "text-to-video" and video is not None:
 
60
  video = load_video(video)[:frames_to_use]
61
  condition = True
62
  elif mode == "image-to-video" and image is not None:
 
77
  num_inference_steps=steps,
78
  decode_timestep = 0.05,
79
  decode_noise_scale = 0.025,
80
+ guidance_scale=1.0,
81
  generator=torch.Generator(device="cuda").manual_seed(seed),
82
  output_type="latent",
83
  ).frames
 
91
  num_inference_steps=steps,
92
  decode_timestep = 0.05,
93
  decode_noise_scale = 0.025,
94
+ guidance_scale=1.0,
95
  generator=torch.Generator(device="cuda").manual_seed(seed),
96
  output_type="latent",
97
  ).frames
 
182
  #prompt = gr.Textbox(label="prompt")
183
  with gr.Tab("image-to-video") as image_tab:
184
  image = gr.Image(label="")
 
185
  with gr.Tab("video-to-video") as video_tab:
186
  video = gr.Video(label="")
187
+ frames_to_use = gr.Number(label="num frames to use",info="first # of frames to use from the input video", value=1)
188
  prompt = gr.Textbox(label="prompt")
189
+ improve_texture = gr.Checkbox("improve texture", value=False, info="note it slows generation")
190
  run_button = gr.Button()
191
  with gr.Column():
192
  output = gr.Video(interactive=False)
 
200
  with gr.Row():
201
  steps = gr.Slider(label="Steps", minimum=1, maximum=30, value=8, step=1)
202
  num_frames = gr.Slider(label="# frames", minimum=1, maximum=161, value=96, step=1)
203
+ with gr.Row():
204
+ height = gr.Slider(label="height", value=512, step=1)
205
+ width = gr.Slider(label="width", value=704, step=1)
206
 
207
 
208
  text_tab.select(fn=change_mode_to_text, inputs=[], outputs=[mode])
 
217
  mode,
218
  steps,
219
  num_frames,
220
+ frames_to_use,
221
  seed,
222
+ randomize_seed, improve_texture],
223
  outputs=[output])
224
 
225