Fabrice-TIERCELIN commited on
Commit
4e08b5b
·
verified ·
1 Parent(s): 3623b94

on_select_result

Browse files
Files changed (1) hide show
  1. gradio_demo.py +7 -3
gradio_demo.py CHANGED
@@ -412,6 +412,8 @@ def load_and_reset(param_setting):
412
  return edm_steps, s_cfg, s_stage2, s_stage1, s_churn, s_noise, a_prompt, n_prompt, color_fix_type, linear_CFG, \
413
  linear_s_stage2, spt_linear_CFG, spt_linear_s_stage2, model_select
414
 
 
 
415
 
416
  def submit_feedback(event_id, fb_score, fb_text):
417
  if args.log_history:
@@ -508,6 +510,7 @@ with gr.Blocks(title="SUPIR") as interface:
508
  with gr.Column():
509
  color_fix_type = gr.Radio(["None", "AdaIn", "Wavelet"], label="Color-Fix Type", info="AdaIn=Improve following a style, Wavelet=For JPEG artifacts", value="Wavelet",
510
  interactive=True)
 
511
  s_cfg = gr.Slider(label="Text Guidance Scale", info="lower=follow the image, higher=follow the prompt", minimum=1.0, maximum=15.0,
512
  value=default_setting.s_cfg_Quality if torch.cuda.device_count() > 0 else 1.0, step=0.1)
513
  s_stage2 = gr.Slider(label="Restoring Guidance Strength", minimum=0., maximum=1., value=1., step=0.05)
@@ -529,7 +532,6 @@ with gr.Blocks(title="SUPIR") as interface:
529
  with gr.Column():
530
  ae_dtype = gr.Radio(['fp32', 'bf16'], label="Auto-Encoder Data Type", value="bf16",
531
  interactive=True)
532
- allocation = gr.Radio([["1 min", 1], ["2 min", 2], ["3 min", 3], ["4 min", 4], ["5 min", 5], ["6 min", 6], ["7 min", 7], ["8 min", 8], ["9 min", 9]], label="GPU allocation time", info="lower=May abort run, higher=Time penalty for next runs", value=6, interactive=True)
533
  randomize_seed = gr.Checkbox(label = "\U0001F3B2 Randomize seed", value = True, info = "If checked, result is always different")
534
  seed = gr.Slider(label="Seed", minimum=0, maximum=2147483647, step=1, randomize=True)
535
  with gr.Group():
@@ -542,8 +544,8 @@ with gr.Blocks(title="SUPIR") as interface:
542
  diffusion_button = gr.Button(value="🚀 Upscale/Restore", variant = "primary", elem_id="process_button")
543
 
544
  restore_information = gr.HTML(value="Restart the process to get another result.", visible=False)
545
- result_slider = ImageSlider(label='Output', show_label=True, elem_id="slider1")
546
- result_gallery = gr.Gallery(label='Output', show_label=True, elem_id="gallery1")
547
 
548
  with gr.Accordion("Feedback", open=True, visible=False):
549
  fb_score = gr.Slider(label="Feedback Score", minimum=1, maximum=5, value=3, step=1, interactive=True)
@@ -723,6 +725,8 @@ with gr.Blocks(title="SUPIR") as interface:
723
  event_id
724
  ])
725
 
 
 
726
  restart_button.click(fn = load_and_reset, inputs = [
727
  param_setting
728
  ], outputs = [
 
412
  return edm_steps, s_cfg, s_stage2, s_stage1, s_churn, s_noise, a_prompt, n_prompt, color_fix_type, linear_CFG, \
413
  linear_s_stage2, spt_linear_CFG, spt_linear_s_stage2, model_select
414
 
415
+ def on_select_result(result_gallery, evt: gr.SelectData):
416
+ return [result_gallery[0], result_gallery[evt.index]]
417
 
418
  def submit_feedback(event_id, fb_score, fb_text):
419
  if args.log_history:
 
510
  with gr.Column():
511
  color_fix_type = gr.Radio(["None", "AdaIn", "Wavelet"], label="Color-Fix Type", info="AdaIn=Improve following a style, Wavelet=For JPEG artifacts", value="Wavelet",
512
  interactive=True)
513
+ allocation = gr.Radio([["1 min", 1], ["2 min", 2], ["3 min", 3], ["4 min", 4], ["5 min", 5], ["6 min", 6], ["7 min", 7], ["8 min", 8], ["9 min", 9]], label="GPU allocation time", info="lower=May abort run, higher=Time penalty for next runs", value=6, interactive=True)
514
  s_cfg = gr.Slider(label="Text Guidance Scale", info="lower=follow the image, higher=follow the prompt", minimum=1.0, maximum=15.0,
515
  value=default_setting.s_cfg_Quality if torch.cuda.device_count() > 0 else 1.0, step=0.1)
516
  s_stage2 = gr.Slider(label="Restoring Guidance Strength", minimum=0., maximum=1., value=1., step=0.05)
 
532
  with gr.Column():
533
  ae_dtype = gr.Radio(['fp32', 'bf16'], label="Auto-Encoder Data Type", value="bf16",
534
  interactive=True)
 
535
  randomize_seed = gr.Checkbox(label = "\U0001F3B2 Randomize seed", value = True, info = "If checked, result is always different")
536
  seed = gr.Slider(label="Seed", minimum=0, maximum=2147483647, step=1, randomize=True)
537
  with gr.Group():
 
544
  diffusion_button = gr.Button(value="🚀 Upscale/Restore", variant = "primary", elem_id="process_button")
545
 
546
  restore_information = gr.HTML(value="Restart the process to get another result.", visible=False)
547
+ result_slider = ImageSlider(label='Output', show_label=True, elem_id="slider1", value=["./Examples/Example1.png", "./Examples/Example2.jpeg"])
548
+ result_gallery = gr.Gallery(label='Output', show_label=True, elem_id="gallery1", value=["./Examples/Example1.png", "./Examples/Example2.jpeg"])
549
 
550
  with gr.Accordion("Feedback", open=True, visible=False):
551
  fb_score = gr.Slider(label="Feedback Score", minimum=1, maximum=5, value=3, step=1, interactive=True)
 
725
  event_id
726
  ])
727
 
728
+ result_gallery.select(on_select_result, result_gallery, result_slider)
729
+
730
  restart_button.click(fn = load_and_reset, inputs = [
731
  param_setting
732
  ], outputs = [