Fabrice-TIERCELIN commited on
Commit
ba9fd3e
·
verified ·
1 Parent(s): df70d7f

Parameters

Browse files
Files changed (1) hide show
  1. app.py +59 -0
app.py CHANGED
@@ -38,6 +38,12 @@ MAX_FRAMES_MODEL = 81
38
  MIN_DURATION = round(MIN_FRAMES_MODEL/FIXED_FPS, 1)
39
  MAX_DURATION = round(MAX_FRAMES_MODEL/FIXED_FPS, 1)
40
 
 
 
 
 
 
 
41
  default_negative_prompt = "色调艳丽,过曝,静态,细节模糊不清,字幕,风格,作品,画作,画面,静止,整体发灰,最差质量,低质量,JPEG压缩残留,丑陋的,残缺的,多余的手指,画得不好的手部,画得不好的脸部,畸形的,毁容的,形态畸形的肢体,手指融合,静止不动的画面,杂乱的背景,三条腿,背景人很多,倒着走,过曝,"
42
 
43
  print("Loading models into memory. This may take a few minutes...")
@@ -192,6 +198,13 @@ def generate_video(
192
  Generates a video by interpolating between a start and end image, guided by a text prompt,
193
  using the diffusers Wan2.2 pipeline.
194
  """
 
 
 
 
 
 
 
195
  if start_image_pil is None or end_image_pil is None:
196
  raise gr.Error("Please upload both a start and an end image.")
197
 
@@ -279,6 +292,13 @@ with gr.Blocks(theme=gr.themes.Citrus(), css=css) as app:
279
  seed_input = gr.Slider(label="Seed", minimum=0, maximum=MAX_SEED, step=1, value=42)
280
  randomize_seed_checkbox = gr.Checkbox(label="Randomize seed", value=True)
281
 
 
 
 
 
 
 
 
282
  generate_button = gr.Button("Generate Video", variant="primary")
283
 
284
  with gr.Column():
@@ -319,6 +339,45 @@ with gr.Blocks(theme=gr.themes.Citrus(), css=css) as app:
319
  outputs=ui_outputs
320
  )
321
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
322
  gr.Examples(
323
  examples = [
324
  ["poli_tower.png", "tower_takes_off.png", "the man turns around"],
 
38
  MIN_DURATION = round(MIN_FRAMES_MODEL/FIXED_FPS, 1)
39
  MAX_DURATION = round(MAX_FRAMES_MODEL/FIXED_FPS, 1)
40
 
41
+ input_image_debug_value = [None]
42
+ input_video_debug_value = [None]
43
+ end_image_debug_value = [None]
44
+ prompt_debug_value = [None]
45
+ total_second_length_debug_value = [None]
46
+
47
  default_negative_prompt = "色调艳丽,过曝,静态,细节模糊不清,字幕,风格,作品,画作,画面,静止,整体发灰,最差质量,低质量,JPEG压缩残留,丑陋的,残缺的,多余的手指,画得不好的手部,画得不好的脸部,畸形的,毁容的,形态畸形的肢体,手指融合,静止不动的画面,杂乱的背景,三条腿,背景人很多,倒着走,过曝,"
48
 
49
  print("Loading models into memory. This may take a few minutes...")
 
198
  Generates a video by interpolating between a start and end image, guided by a text prompt,
199
  using the diffusers Wan2.2 pipeline.
200
  """
201
+ if input_image_debug_value[0] is not None or end_image_debug_value[0] is not None or prompt_debug_value[0] is not None or total_second_length_debug_value[0] is not None:
202
+ start_image_pil = input_image_debug_value[0]
203
+ end_image_pil = end_image_debug_value[0]
204
+ prompt = prompt_debug_value[0]
205
+ duration_seconds = total_second_length_debug_value[0]
206
+ #allocation_time = min(total_second_length_debug_value[0] * 60 * 100, 600)
207
+
208
  if start_image_pil is None or end_image_pil is None:
209
  raise gr.Error("Please upload both a start and an end image.")
210
 
 
292
  seed_input = gr.Slider(label="Seed", minimum=0, maximum=MAX_SEED, step=1, value=42)
293
  randomize_seed_checkbox = gr.Checkbox(label="Randomize seed", value=True)
294
 
295
+ with gr.Accordion("Debug", open=False):
296
+ input_image_debug = gr.Image(type="numpy", label="Image Debug", height=320)
297
+ input_video_debug = gr.Video(sources='upload', label="Input Video Debug", height=320)
298
+ end_image_debug = gr.Image(type="numpy", label="End Image Debug", height=320)
299
+ prompt_debug = gr.Textbox(label="Prompt Debug", value='')
300
+ total_second_length_debug = gr.Slider(label="Additional Video Length to Generate (seconds) Debug", minimum=1, maximum=120, value=1, step=0.1)
301
+
302
  generate_button = gr.Button("Generate Video", variant="primary")
303
 
304
  with gr.Column():
 
339
  outputs=ui_outputs
340
  )
341
 
342
+ def handle_field_debug_change(input_image_debug_data, input_video_debug_data, end_image_debug_data, prompt_debug_data, total_second_length_debug_data):
343
+ print("handle_field_debug_change")
344
+ input_image_debug_value[0] = input_image_debug_data
345
+ input_video_debug_value[0] = input_video_debug_data
346
+ end_image_debug_value[0] = end_image_debug_data
347
+ prompt_debug_value[0] = prompt_debug_data
348
+ total_second_length_debug_value[0] = total_second_length_debug_data
349
+ return []
350
+
351
+ input_image_debug.upload(
352
+ fn=handle_field_debug_change,
353
+ inputs=[input_image_debug, input_video_debug, end_image_debug, prompt_debug, total_second_length_debug],
354
+ outputs=[]
355
+ )
356
+
357
+ input_video_debug.upload(
358
+ fn=handle_field_debug_change,
359
+ inputs=[input_image_debug, input_video_debug, end_image_debug, prompt_debug, total_second_length_debug],
360
+ outputs=[]
361
+ )
362
+
363
+ end_image_debug.upload(
364
+ fn=handle_field_debug_change,
365
+ inputs=[input_image_debug, input_video_debug, end_image_debug, prompt_debug, total_second_length_debug],
366
+ outputs=[]
367
+ )
368
+
369
+ prompt_debug.change(
370
+ fn=handle_field_debug_change,
371
+ inputs=[input_image_debug, input_video_debug, end_image_debug, prompt_debug, total_second_length_debug],
372
+ outputs=[]
373
+ )
374
+
375
+ total_second_length_debug.change(
376
+ fn=handle_field_debug_change,
377
+ inputs=[input_image_debug, input_video_debug, end_image_debug, prompt_debug, total_second_length_debug],
378
+ outputs=[]
379
+ )
380
+
381
  gr.Examples(
382
  examples = [
383
  ["poli_tower.png", "tower_takes_off.png", "the man turns around"],