yeq6x commited on
Commit
f96d92a
·
1 Parent(s): b6e1d5b

Refactor output handling in app.py to use state variables for better clarity and maintainability, while removing unnecessary CSS specification in the Blocks context.

Browse files
Files changed (1) hide show
  1. app.py +9 -9
app.py CHANGED
@@ -219,7 +219,7 @@ css = """
219
  }
220
  """
221
 
222
- with gr.Blocks(css=css) as demo:
223
  with gr.Column(elem_id="col-container"):
224
  gr.HTML("""
225
  <div id="logo-title">
@@ -380,18 +380,18 @@ with gr.Blocks(css=css) as demo:
380
  height,
381
  width,
382
  ],
383
- outputs=[stage2_result, gr.State(), gr.State(), gr.State(), gr.State(), gr.State(), gr.State()],
384
  )
385
 
386
  stage2_event.then(
387
  fn=infer_combined,
388
  inputs=[
389
- stage2_event.outputs[1], # image
390
- stage2_event.outputs[2], # seed
391
- stage2_event.outputs[3], # true_guidance_scale
392
- stage2_event.outputs[4], # num_inference_steps
393
- stage2_event.outputs[5], # height
394
- stage2_event.outputs[6], # width
395
  stage1_weight,
396
  stage2_weight,
397
  ],
@@ -399,4 +399,4 @@ with gr.Blocks(css=css) as demo:
399
  )
400
 
401
  if __name__ == "__main__":
402
- demo.queue().launch(mcp_server=True)
 
219
  }
220
  """
221
 
222
+ with gr.Blocks() as demo:
223
  with gr.Column(elem_id="col-container"):
224
  gr.HTML("""
225
  <div id="logo-title">
 
380
  height,
381
  width,
382
  ],
383
+ outputs=[stage2_result, state_image, state_seed, state_guidance, state_steps, state_height, state_width],
384
  )
385
 
386
  stage2_event.then(
387
  fn=infer_combined,
388
  inputs=[
389
+ state_image,
390
+ state_seed,
391
+ state_guidance,
392
+ state_steps,
393
+ state_height,
394
+ state_width,
395
  stage1_weight,
396
  stage2_weight,
397
  ],
 
399
  )
400
 
401
  if __name__ == "__main__":
402
+ demo.queue().launch(mcp_server=True, css=css)