markury commited on
Commit
dabb250
·
1 Parent(s): 10b0bca

fix: gradio output handling

Browse files
Files changed (1) hide show
  1. app.py +11 -28
app.py CHANGED
@@ -44,7 +44,7 @@ def generate_video(
44
  second_pass_flow_shift,
45
  second_pass_cfg,
46
  show_both_outputs
47
- ) -> Union[str, List[str]]:
48
  # Get model ID from selection
49
  model_id = MODEL_OPTIONS[model_choice]
50
 
@@ -194,11 +194,16 @@ def generate_video(
194
 
195
  # Return the appropriate video output(s)
196
  if enable_second_pass and show_both_outputs and len(output_files) > 1:
197
- return output_files
198
  elif len(output_files) > 0:
199
- return output_files[-1] # Return the last generated output (either first or second pass)
 
 
 
 
 
200
  else:
201
- return "No video was generated. Please check the logs for errors."
202
 
203
  # Create the Gradio interface
204
  with gr.Blocks() as demo:
@@ -394,14 +399,7 @@ with gr.Blocks() as demo:
394
  outputs=[second_output_video]
395
  )
396
 
397
- # Define a visibility update function separately
398
- def update_second_video_visibility(enable_pass, show_both):
399
- if enable_pass and show_both:
400
- return gr.update(visible=True)
401
- else:
402
- return gr.update(visible=False)
403
-
404
- # Process generation without trying to update visibility in the same function
405
  generate_btn.click(
406
  fn=generate_video,
407
  inputs=[
@@ -427,22 +425,7 @@ with gr.Blocks() as demo:
427
  second_pass_cfg,
428
  show_both_outputs
429
  ],
430
- outputs=[
431
- output_video if not show_both_outputs else [output_video, second_output_video]
432
- ]
433
- )
434
-
435
- # Update visibility when options change
436
- enable_second_pass.change(
437
- fn=update_second_video_visibility,
438
- inputs=[enable_second_pass, show_both_outputs],
439
- outputs=[second_output_video]
440
- )
441
-
442
- show_both_outputs.change(
443
- fn=update_second_video_visibility,
444
- inputs=[enable_second_pass, show_both_outputs],
445
- outputs=[second_output_video]
446
  )
447
 
448
  gr.Markdown("""
 
44
  second_pass_flow_shift,
45
  second_pass_cfg,
46
  show_both_outputs
47
+ ) -> tuple:
48
  # Get model ID from selection
49
  model_id = MODEL_OPTIONS[model_choice]
50
 
 
194
 
195
  # Return the appropriate video output(s)
196
  if enable_second_pass and show_both_outputs and len(output_files) > 1:
197
+ return output_files[0], output_files[1] # Return both first and second pass
198
  elif len(output_files) > 0:
199
+ if enable_second_pass:
200
+ # Return only second pass (and None for first output if showing both)
201
+ return None if show_both_outputs else output_files[0], output_files[0]
202
+ else:
203
+ # Return first pass only
204
+ return output_files[0], None
205
  else:
206
+ return None, None
207
 
208
  # Create the Gradio interface
209
  with gr.Blocks() as demo:
 
399
  outputs=[second_output_video]
400
  )
401
 
402
+ # Fixed output handling for Gradio
 
 
 
 
 
 
 
403
  generate_btn.click(
404
  fn=generate_video,
405
  inputs=[
 
425
  second_pass_cfg,
426
  show_both_outputs
427
  ],
428
+ outputs=[output_video, second_output_video]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
429
  )
430
 
431
  gr.Markdown("""