Fabrice-TIERCELIN commited on
Commit
48a09bc
·
verified ·
1 Parent(s): 32224be

Find the bug

Browse files
Files changed (1) hide show
  1. app.py +216 -227
app.py CHANGED
@@ -106,8 +106,8 @@ def reset():
106
  "fp32",
107
  1.0,
108
  True,
109
- False,
110
  default_setting.spt_linear_CFG_Quality if torch.cuda.device_count() > 0 else 1.0,
 
111
  0.,
112
  "v0-Q",
113
  "input",
@@ -151,8 +151,14 @@ def stage1_process(
151
  return LQ, gr.update(visible = True)
152
 
153
  def stage2_process_example(*args, **kwargs):
154
- [result_slider, result_gallery, restore_information, reset_btn, dummy_button] = restore_in_Xmin(*args, **kwargs)
155
- return [gr.update(visible = True, value=result_slider[1]), restore_information, reset_btn, dummy_button]
 
 
 
 
 
 
156
 
157
  def stage2_process(*args, **kwargs):
158
  try:
@@ -196,8 +202,8 @@ def restore_in_Xmin(
196
  ae_dtype,
197
  gamma_correction,
198
  linear_CFG,
199
- linear_s_stage2,
200
  spt_linear_CFG,
 
201
  spt_linear_s_stage2,
202
  model_select,
203
  output_format,
@@ -233,6 +239,13 @@ def restore_in_Xmin(
233
  print("GPU time allocation: " + str(allocation) + " min")
234
  print("output_format: " + str(output_format))
235
 
 
 
 
 
 
 
 
236
  input_format = re.sub(r"^.*\.([^\.]+)$", r"\1", noisy_image)
237
 
238
  if input_format not in ['png', 'webp', 'jpg', 'jpeg', 'gif', 'bmp', 'avif']:
@@ -279,7 +292,7 @@ def restore_in_Xmin(
279
 
280
  if torch.cuda.device_count() == 0:
281
  gr.Warning('Set this space to GPU config to make it work.')
282
- return [noisy_image, denoise_image], gr.update(label="Downloadable results in *." + output_format + " format", format = output_format, value = [denoise_image]), None, gr.update(visible=True)
283
 
284
  if model_select != model.current_model:
285
  print('load ' + model_select)
@@ -319,8 +332,8 @@ def get_duration(
319
  ae_dtype,
320
  gamma_correction,
321
  linear_CFG,
322
- linear_s_stage2,
323
  spt_linear_CFG,
 
324
  spt_linear_s_stage2,
325
  model_select,
326
  output_format,
@@ -352,8 +365,8 @@ def restore_on_gpu(
352
  ae_dtype,
353
  gamma_correction,
354
  linear_CFG,
355
- linear_s_stage2,
356
  spt_linear_CFG,
 
357
  spt_linear_s_stage2,
358
  model_select,
359
  output_format,
@@ -452,7 +465,7 @@ def load_and_reset(param_setting):
452
  gr.Info('The parameters are reset.')
453
  print('<<== load_and_reset')
454
  return edm_steps, s_cfg, s_stage2, s_stage1, s_churn, s_noise, a_prompt, n_prompt, color_fix_type, linear_CFG, \
455
- linear_s_stage2, spt_linear_CFG, spt_linear_s_stage2, model_select
456
 
457
  def log_information(result_gallery):
458
  print('log_information')
@@ -467,6 +480,10 @@ def on_select_result(result_slider, result_gallery, evt: gr.SelectData):
467
  print(result[0])
468
  return [result_slider[0], result_gallery[evt.index][0]]
469
 
 
 
 
 
470
  title_html = """
471
  <h1><center>SUPIR</center></h1>
472
  <big><center>Upscale your images up to x10 freely, without account, without watermark and download it</center></big>
@@ -591,6 +608,11 @@ with gr.Blocks(js=js) as interface:
591
  param_setting = gr.Radio(["Quality", "Fidelity"], label="Presetting", value = "Quality")
592
  restart_button = gr.Button(value="Apply presetting")
593
 
 
 
 
 
 
594
  with gr.Column():
595
  diffusion_button = gr.Button(value="🚀 Upscale/Restore", variant = "primary", elem_id = "process_button")
596
  reset_btn = gr.Button(value="🧹 Reinit page", variant="stop", elem_id="reset_button", visible = False)
@@ -598,141 +620,81 @@ with gr.Blocks(js=js) as interface:
598
 
599
  warning = gr.HTML(elem_id="warning", value = "<center><big>Your computer must <u>not</u> enter into standby mode.</big><br/>On Chrome, you can force to keep a tab alive in <code>chrome://discards/</code></center>", visible = False)
600
  restore_information = gr.HTML(value = "Restart the process to get another result.", visible = False)
601
- result_slider = ImageSlider(label = 'Comparator', show_label = False, interactive = False, elem_id = "slider1", show_download_button = False)
602
  result_gallery = gr.Gallery(label = 'Downloadable results', show_label = True, interactive = False, elem_id = "gallery1")
603
- result_example = gr.Image(label="Example Image", visible = False, interactive = False)
 
604
 
605
- with gr.Row(elem_id="examples", visible=False):
606
  gr.Examples(
 
607
  examples = [
608
  [
609
  "./Examples/Example2.jpeg",
610
  0,
611
- None,
612
  "La cabeza de un gato atigrado, en una casa, fotorrealista, 8k, extremadamente detallada",
613
  "Cinematic, High Contrast, highly detailed, taken using a Canon EOS R camera, hyper detailed photo - realistic maximum detail, 32k, Color Grading, ultra HD, extreme meticulous detailing, skin pore detailing, hyper sharpness, perfect without deformations.",
614
  "painting, oil painting, illustration, drawing, art, sketch, anime, cartoon, CG Style, 3D render, unreal engine, blurring, aliasing, pixel, unsharp, weird textures, ugly, dirty, messy, worst quality, low quality, frames, watermark, signature, jpeg artifacts, deformed, lowres, over-smooth",
615
- 1,
616
- 1024,
617
- 1,
618
- 1,
619
- 200,
620
- -1,
621
- 1,
622
- 7.5,
623
- False,
624
- 42,
625
- 5,
626
- 1.003,
627
- "Wavelet",
628
- "fp16",
629
- "bf16",
630
- 1.0,
631
- True,
632
- 4,
633
- False,
634
- 0.,
635
- "v0-Q",
636
- "input",
637
- 50
638
- ],
639
- [
640
- "./Examples/Example1.png",
641
- 0,
642
- None,
643
- "Group of people, walking, happy, in the street, photorealistic, 8k, extremely detailled",
644
- "Cinematic, High Contrast, highly detailed, taken using a Canon EOS R camera, hyper detailed photo - realistic maximum detail, 32k, Color Grading, ultra HD, extreme meticulous detailing, skin pore detailing, hyper sharpness, perfect without deformations.",
645
- "painting, oil painting, illustration, drawing, art, sketch, anime, cartoon, CG Style, 3D render, unreal engine, blurring, aliasing, pixel, unsharp, weird textures, ugly, dirty, messy, worst quality, low quality, frames, watermark, signature, jpeg artifacts, deformed, lowres, over-smooth",
646
- 2,
647
- 1024,
648
- 1,
649
- 8,
650
- 100,
651
- -1,
652
- 1,
653
- 7.5,
654
- False,
655
- 42,
656
- 5,
657
- 1.003,
658
- "AdaIn",
659
- "fp16",
660
- "bf16",
661
- 1.0,
662
- True,
663
- 4,
664
- False,
665
- 0.,
666
- "v0-Q",
667
- "input",
668
- 180
669
- ],
670
- [
671
- "./Examples/Example3.webp",
672
- 0,
673
- None,
674
- "A red apple",
675
- "Cinematic, High Contrast, highly detailed, taken using a Canon EOS R camera, hyper detailed photo - realistic maximum detail, 32k, Color Grading, ultra HD, extreme meticulous detailing, skin pore detailing, hyper sharpness, perfect without deformations.",
676
- "painting, oil painting, illustration, drawing, art, sketch, anime, cartoon, CG Style, 3D render, unreal engine, blurring, aliasing, pixel, unsharp, weird textures, ugly, dirty, messy, worst quality, low quality, frames, watermark, signature, jpeg artifacts, deformed, lowres, over-smooth",
677
- 1,
678
- 1024,
679
- 1,
680
- 1,
681
- 200,
682
- -1,
683
- 1,
684
- 7.5,
685
- False,
686
- 42,
687
- 5,
688
- 1.003,
689
- "Wavelet",
690
- "fp16",
691
- "bf16",
692
- 1.0,
693
- True,
694
- 4,
695
- False,
696
- 0.,
697
- "v0-Q",
698
- "input",
699
- 180
700
  ],
701
  [
702
- "./Examples/Example3.webp",
703
  0,
704
- None,
705
- "A red marble",
706
  "Cinematic, High Contrast, highly detailed, taken using a Canon EOS R camera, hyper detailed photo - realistic maximum detail, 32k, Color Grading, ultra HD, extreme meticulous detailing, skin pore detailing, hyper sharpness, perfect without deformations.",
707
  "painting, oil painting, illustration, drawing, art, sketch, anime, cartoon, CG Style, 3D render, unreal engine, blurring, aliasing, pixel, unsharp, weird textures, ugly, dirty, messy, worst quality, low quality, frames, watermark, signature, jpeg artifacts, deformed, lowres, over-smooth",
708
- 1,
709
- 1024,
710
- 1,
711
- 1,
712
- 200,
713
- -1,
714
- 1,
715
- 7.5,
716
- False,
717
- 42,
718
- 5,
719
- 1.003,
720
- "Wavelet",
721
- "fp16",
722
- "bf16",
723
- 1.0,
724
- True,
725
- 4,
726
- False,
727
- 0.,
728
- "v0-Q",
729
- "input",
730
- 180
731
- ],
732
  ],
733
  run_on_click = True,
734
  fn = stage2_process_example,
735
- inputs = [
736
  input_image,
737
  rotation,
738
  denoise_image,
@@ -756,19 +718,20 @@ with gr.Blocks(js=js) as interface:
756
  ae_dtype,
757
  gamma_correction,
758
  linear_CFG,
759
- linear_s_stage2,
760
  spt_linear_CFG,
 
761
  spt_linear_s_stage2,
762
  model_select,
763
  output_format,
764
  allocation
765
  ],
766
- outputs = [
767
- result_example,
768
- restore_information,
769
- reset_btn
 
770
  ],
771
- cache_examples = "lazy",
772
  )
773
 
774
  gr.Examples(
@@ -781,29 +744,29 @@ with gr.Blocks(js=js) as interface:
781
  "Group of people, walking, happy, in the street, photorealistic, 8k, extremely detailled",
782
  "Cinematic, High Contrast, highly detailed, taken using a Canon EOS R camera, hyper detailed photo - realistic maximum detail, 32k, Color Grading, ultra HD, extreme meticulous detailing, skin pore detailing, hyper sharpness, perfect without deformations.",
783
  "painting, oil painting, illustration, drawing, art, sketch, anime, cartoon, CG Style, 3D render, unreal engine, blurring, aliasing, pixel, unsharp, weird textures, ugly, dirty, messy, worst quality, low quality, frames, watermark, signature, jpeg artifacts, deformed, lowres, over-smooth",
784
- 2,
785
- 1024,
786
- 1,
787
- 8,
788
- 100,
789
- -1,
790
- 1,
791
- 7.5,
792
- False,
793
- 42,
794
- 5,
795
- 1.003,
796
- "AdaIn",
797
- "fp16",
798
- "bf16",
799
- 1.0,
800
- True,
801
- 4,
802
- False,
803
- 0.,
804
- "v0-Q",
805
- "input",
806
- 180
807
  ],
808
  [
809
  "./Examples/Example2.jpeg",
@@ -812,29 +775,29 @@ with gr.Blocks(js=js) as interface:
812
  "La cabeza de un gato atigrado, en una casa, fotorrealista, 8k, extremadamente detallada",
813
  "Cinematic, High Contrast, highly detailed, taken using a Canon EOS R camera, hyper detailed photo - realistic maximum detail, 32k, Color Grading, ultra HD, extreme meticulous detailing, skin pore detailing, hyper sharpness, perfect without deformations.",
814
  "painting, oil painting, illustration, drawing, art, sketch, anime, cartoon, CG Style, 3D render, unreal engine, blurring, aliasing, pixel, unsharp, weird textures, ugly, dirty, messy, worst quality, low quality, frames, watermark, signature, jpeg artifacts, deformed, lowres, over-smooth",
815
- 1,
816
- 1024,
817
- 1,
818
- 1,
819
- 100,
820
- -1,
821
- 1,
822
- 7.5,
823
- False,
824
- 42,
825
- 5,
826
- 1.003,
827
- "Wavelet",
828
- "fp16",
829
- "bf16",
830
- 1.0,
831
- True,
832
- 4,
833
- False,
834
- 0.,
835
- "v0-Q",
836
- "input",
837
- 50
838
  ],
839
  [
840
  "./Examples/Example3.webp",
@@ -843,29 +806,29 @@ with gr.Blocks(js=js) as interface:
843
  "A red apple",
844
  "Cinematic, High Contrast, highly detailed, taken using a Canon EOS R camera, hyper detailed photo - realistic maximum detail, 32k, Color Grading, ultra HD, extreme meticulous detailing, skin pore detailing, hyper sharpness, perfect without deformations.",
845
  "painting, oil painting, illustration, drawing, art, sketch, anime, cartoon, CG Style, 3D render, unreal engine, blurring, aliasing, pixel, unsharp, weird textures, ugly, dirty, messy, worst quality, low quality, frames, watermark, signature, jpeg artifacts, deformed, lowres, over-smooth",
846
- 1,
847
- 1024,
848
- 1,
849
- 1,
850
- 200,
851
- -1,
852
- 1,
853
- 7.5,
854
- False,
855
- 42,
856
- 5,
857
- 1.003,
858
- "Wavelet",
859
- "fp16",
860
- "bf16",
861
- 1.0,
862
- True,
863
- 4,
864
- False,
865
- 0.,
866
- "v0-Q",
867
- "input",
868
- 180
869
  ],
870
  [
871
  "./Examples/Example3.webp",
@@ -874,29 +837,29 @@ with gr.Blocks(js=js) as interface:
874
  "A red marble",
875
  "Cinematic, High Contrast, highly detailed, taken using a Canon EOS R camera, hyper detailed photo - realistic maximum detail, 32k, Color Grading, ultra HD, extreme meticulous detailing, skin pore detailing, hyper sharpness, perfect without deformations.",
876
  "painting, oil painting, illustration, drawing, art, sketch, anime, cartoon, CG Style, 3D render, unreal engine, blurring, aliasing, pixel, unsharp, weird textures, ugly, dirty, messy, worst quality, low quality, frames, watermark, signature, jpeg artifacts, deformed, lowres, over-smooth",
877
- 1,
878
- 1024,
879
- 1,
880
- 1,
881
- 200,
882
- -1,
883
- 1,
884
- 7.5,
885
- False,
886
- 42,
887
- 5,
888
- 1.003,
889
- "Wavelet",
890
- "fp16",
891
- "bf16",
892
- 1.0,
893
- True,
894
- 4,
895
- False,
896
- 0.,
897
- "v0-Q",
898
- "input",
899
- 180
900
  ],
901
  ],
902
  run_on_click = True,
@@ -925,8 +888,8 @@ with gr.Blocks(js=js) as interface:
925
  ae_dtype,
926
  gamma_correction,
927
  linear_CFG,
928
- linear_s_stage2,
929
  spt_linear_CFG,
 
930
  spt_linear_s_stage2,
931
  model_select,
932
  output_format,
@@ -937,6 +900,7 @@ with gr.Blocks(js=js) as interface:
937
  result_gallery,
938
  restore_information,
939
  reset_btn,
 
940
  dummy_button
941
  ],
942
  cache_examples = False,
@@ -995,8 +959,8 @@ with gr.Blocks(js=js) as interface:
995
  ae_dtype,
996
  gamma_correction,
997
  linear_CFG,
998
- linear_s_stage2,
999
  spt_linear_CFG,
 
1000
  spt_linear_s_stage2,
1001
  model_select,
1002
  output_format,
@@ -1014,6 +978,7 @@ with gr.Blocks(js=js) as interface:
1014
 
1015
  result_gallery.change(on_select_result, [result_slider, result_gallery], result_slider)
1016
  result_gallery.select(on_select_result, [result_slider, result_gallery], result_slider)
 
1017
 
1018
  restart_button.click(fn = load_and_reset, inputs = [
1019
  param_setting
@@ -1028,8 +993,8 @@ with gr.Blocks(js=js) as interface:
1028
  n_prompt,
1029
  color_fix_type,
1030
  linear_CFG,
1031
- linear_s_stage2,
1032
  spt_linear_CFG,
 
1033
  spt_linear_s_stage2,
1034
  model_select
1035
  ])
@@ -1058,12 +1023,36 @@ with gr.Blocks(js=js) as interface:
1058
  ae_dtype,
1059
  gamma_correction,
1060
  linear_CFG,
1061
- linear_s_stage2,
1062
  spt_linear_CFG,
 
1063
  spt_linear_s_stage2,
1064
  model_select,
1065
  output_format,
1066
  allocation
1067
  ], queue = False, show_progress = False)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1068
 
1069
  interface.queue(10).launch(mcp_server=True, ssr_mode=False)
 
106
  "fp32",
107
  1.0,
108
  True,
 
109
  default_setting.spt_linear_CFG_Quality if torch.cuda.device_count() > 0 else 1.0,
110
+ False,
111
  0.,
112
  "v0-Q",
113
  "input",
 
151
  return LQ, gr.update(visible = True)
152
 
153
  def stage2_process_example(*args, **kwargs):
154
+ [result_slider, result_gallery, restore_information, reset_btn, warning, dummy_button] = restore_in_Xmin(*args, **kwargs)
155
+ #outputs_folder = './outputs/'
156
+ outputs_folder = './tmp/'
157
+ os.makedirs(outputs_folder, exist_ok=True)
158
+ output_filename = os.path.join(outputs_folder, datetime.now().strftime("%Y-%m-%d_%H-%M-%S") + '.png')
159
+ print(output_filename)
160
+ iio.imwrite(output_filename, result_slider[1], format="png")
161
+ return [gr.update(visible = True, value=output_filename), warning, dummy_button, gr.skip()]
162
 
163
  def stage2_process(*args, **kwargs):
164
  try:
 
202
  ae_dtype,
203
  gamma_correction,
204
  linear_CFG,
 
205
  spt_linear_CFG,
206
+ linear_s_stage2,
207
  spt_linear_s_stage2,
208
  model_select,
209
  output_format,
 
239
  print("GPU time allocation: " + str(allocation) + " min")
240
  print("output_format: " + str(output_format))
241
 
242
+ if input_image_debug_value[0] is not None or prompt_debug_value[0] is not None or upscale_debug_value[0] is not None:
243
+ denoise_image = noisy_image = input_image_debug_value[0]
244
+ a_prompt = prompt_debug_value[0]
245
+ upscale = upscale_debug_value[0]
246
+ allocation = min(allocation * 60 * 100, 600)
247
+ seed = random.randint(0, max_64_bit_int)
248
+
249
  input_format = re.sub(r"^.*\.([^\.]+)$", r"\1", noisy_image)
250
 
251
  if input_format not in ['png', 'webp', 'jpg', 'jpeg', 'gif', 'bmp', 'avif']:
 
292
 
293
  if torch.cuda.device_count() == 0:
294
  gr.Warning('Set this space to GPU config to make it work.')
295
+ return [noisy_image, denoise_image], gr.update(label="Downloadable results in *." + output_format + " format", format = output_format, value = [denoise_image]), None, gr.update(visible=True), gr.skip(), gr.skip()
296
 
297
  if model_select != model.current_model:
298
  print('load ' + model_select)
 
332
  ae_dtype,
333
  gamma_correction,
334
  linear_CFG,
 
335
  spt_linear_CFG,
336
+ linear_s_stage2,
337
  spt_linear_s_stage2,
338
  model_select,
339
  output_format,
 
365
  ae_dtype,
366
  gamma_correction,
367
  linear_CFG,
 
368
  spt_linear_CFG,
369
+ linear_s_stage2,
370
  spt_linear_s_stage2,
371
  model_select,
372
  output_format,
 
465
  gr.Info('The parameters are reset.')
466
  print('<<== load_and_reset')
467
  return edm_steps, s_cfg, s_stage2, s_stage1, s_churn, s_noise, a_prompt, n_prompt, color_fix_type, linear_CFG, \
468
+ spt_linear_CFG, linear_s_stage2, spt_linear_s_stage2, model_select
469
 
470
  def log_information(result_gallery):
471
  print('log_information')
 
480
  print(result[0])
481
  return [result_slider[0], result_gallery[evt.index][0]]
482
 
483
+ def on_render_image_example(result_example):
484
+ print('on_render_image_example')
485
+ return gr.update(value = result_example, visible = True)
486
+
487
  title_html = """
488
  <h1><center>SUPIR</center></h1>
489
  <big><center>Upscale your images up to x10 freely, without account, without watermark and download it</center></big>
 
608
  param_setting = gr.Radio(["Quality", "Fidelity"], label="Presetting", value = "Quality")
609
  restart_button = gr.Button(value="Apply presetting")
610
 
611
+ with gr.Accordion("Debug", open=False):
612
+ input_image_debug = gr.Image(label="Image Debug", type="filepath")
613
+ prompt_debug = gr.Textbox(label="Prompt Debug", value='')
614
+ upscale_debug = gr.Radio([["x1", 1], ["x2", 2], ["x3", 3], ["x4", 4], ["x5", 5], ["x6", 6], ["x7", 7], ["x8", 8], ["x9", 9], ["x10", 10]], label="Upscale factor Debug", info="Resolution x1 to x10", value=2)
615
+
616
  with gr.Column():
617
  diffusion_button = gr.Button(value="🚀 Upscale/Restore", variant = "primary", elem_id = "process_button")
618
  reset_btn = gr.Button(value="🧹 Reinit page", variant="stop", elem_id="reset_button", visible = False)
 
620
 
621
  warning = gr.HTML(elem_id="warning", value = "<center><big>Your computer must <u>not</u> enter into standby mode.</big><br/>On Chrome, you can force to keep a tab alive in <code>chrome://discards/</code></center>", visible = False)
622
  restore_information = gr.HTML(value = "Restart the process to get another result.", visible = False)
623
+ result_slider = ImageSlider(label = 'Comparator', show_label = False, interactive = False, elem_id = "slider1", show_download_button = False, visible = False)
624
  result_gallery = gr.Gallery(label = 'Downloadable results', show_label = True, interactive = False, elem_id = "gallery1")
625
+ result_example = gr.HTML(elem_id="result_example", visible = False)
626
+ result_image_example = gr.Image(label="Example Image", visible = False)
627
 
628
+ with gr.Row(elem_id="examples", visible = False):
629
  gr.Examples(
630
+ label = "Examples for cache",
631
  examples = [
632
  [
633
  "./Examples/Example2.jpeg",
634
  0,
635
+ "./Examples/Example2.jpeg",
636
  "La cabeza de un gato atigrado, en una casa, fotorrealista, 8k, extremadamente detallada",
637
  "Cinematic, High Contrast, highly detailed, taken using a Canon EOS R camera, hyper detailed photo - realistic maximum detail, 32k, Color Grading, ultra HD, extreme meticulous detailing, skin pore detailing, hyper sharpness, perfect without deformations.",
638
  "painting, oil painting, illustration, drawing, art, sketch, anime, cartoon, CG Style, 3D render, unreal engine, blurring, aliasing, pixel, unsharp, weird textures, ugly, dirty, messy, worst quality, low quality, frames, watermark, signature, jpeg artifacts, deformed, lowres, over-smooth",
639
+ 1, # num_samples
640
+ 32, # min_size
641
+ 1, # downscale
642
+ 1, # upscale
643
+ 100, # edm_steps
644
+ -1, # s_stage1
645
+ 1, # s_stage2
646
+ 7.5, # s_cfg
647
+ True, # randomize_seed
648
+ 42, # seed
649
+ 5, # s_churn
650
+ 1.003, # s_noise
651
+ "Wavelet", # color_fix_type
652
+ "fp16", # diff_dtype
653
+ "bf16", # ae_dtype
654
+ 1.0, # gamma_correction
655
+ True, # linear_CFG
656
+ 4, # spt_linear_CFG
657
+ False, # linear_s_stage2
658
+ 0., # spt_linear_s_stage2
659
+ "v0-Q", # model_select
660
+ "input", # output_format
661
+ 60 # allocation
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
662
  ],
663
  [
664
+ "./Examples/Example2.jpeg",
665
  0,
666
+ "./Examples/Example2.jpeg",
667
+ "La cabeza de un gato atigrado, en una casa, fotorrealista, 8k, extremadamente detallada",
668
  "Cinematic, High Contrast, highly detailed, taken using a Canon EOS R camera, hyper detailed photo - realistic maximum detail, 32k, Color Grading, ultra HD, extreme meticulous detailing, skin pore detailing, hyper sharpness, perfect without deformations.",
669
  "painting, oil painting, illustration, drawing, art, sketch, anime, cartoon, CG Style, 3D render, unreal engine, blurring, aliasing, pixel, unsharp, weird textures, ugly, dirty, messy, worst quality, low quality, frames, watermark, signature, jpeg artifacts, deformed, lowres, over-smooth",
670
+ 4, # num_samples
671
+ 32, # min_size
672
+ 1, # downscale
673
+ 1, # upscale
674
+ 100, # edm_steps
675
+ -1, # s_stage1
676
+ 1, # s_stage2
677
+ 7.5, # s_cfg
678
+ True, # randomize_seed
679
+ 42, # seed
680
+ 5, # s_churn
681
+ 1.003, # s_noise
682
+ "Wavelet", # color_fix_type
683
+ "fp16", # diff_dtype
684
+ "bf16", # ae_dtype
685
+ 1.0, # gamma_correction
686
+ True, # linear_CFG
687
+ 4, # spt_linear_CFG
688
+ False, # linear_s_stage2
689
+ 0., # spt_linear_s_stage2
690
+ "v0-Q", # model_select
691
+ "input", # output_format
692
+ 60 # allocation
693
+ ]
694
  ],
695
  run_on_click = True,
696
  fn = stage2_process_example,
697
+ inputs = [
698
  input_image,
699
  rotation,
700
  denoise_image,
 
718
  ae_dtype,
719
  gamma_correction,
720
  linear_CFG,
 
721
  spt_linear_CFG,
722
+ linear_s_stage2,
723
  spt_linear_s_stage2,
724
  model_select,
725
  output_format,
726
  allocation
727
  ],
728
+ outputs = [
729
+ result_example,
730
+ warning,
731
+ dummy_button,
732
+ prompt_hint
733
  ],
734
+ cache_examples = True,
735
  )
736
 
737
  gr.Examples(
 
744
  "Group of people, walking, happy, in the street, photorealistic, 8k, extremely detailled",
745
  "Cinematic, High Contrast, highly detailed, taken using a Canon EOS R camera, hyper detailed photo - realistic maximum detail, 32k, Color Grading, ultra HD, extreme meticulous detailing, skin pore detailing, hyper sharpness, perfect without deformations.",
746
  "painting, oil painting, illustration, drawing, art, sketch, anime, cartoon, CG Style, 3D render, unreal engine, blurring, aliasing, pixel, unsharp, weird textures, ugly, dirty, messy, worst quality, low quality, frames, watermark, signature, jpeg artifacts, deformed, lowres, over-smooth",
747
+ 2, # num_samples
748
+ 1024, # min_size
749
+ 1, # downscale
750
+ 8, # upscale
751
+ 100, # edm_steps
752
+ -1, # s_stage1
753
+ 1, # s_stage2
754
+ 7.5, # s_cfg
755
+ False, # randomize_seed
756
+ 42, # seed
757
+ 5, # s_churn
758
+ 1.003, # s_noise
759
+ "AdaIn", # color_fix_type
760
+ "fp16", # diff_dtype
761
+ "bf16", # ae_dtype
762
+ 1.0, # gamma_correction
763
+ True, # linear_CFG
764
+ 4, # spt_linear_CFG
765
+ False, # linear_s_stage2
766
+ 0., # spt_linear_s_stage2
767
+ "v0-Q", # model_select
768
+ "input", # output_format
769
+ 180 # allocation
770
  ],
771
  [
772
  "./Examples/Example2.jpeg",
 
775
  "La cabeza de un gato atigrado, en una casa, fotorrealista, 8k, extremadamente detallada",
776
  "Cinematic, High Contrast, highly detailed, taken using a Canon EOS R camera, hyper detailed photo - realistic maximum detail, 32k, Color Grading, ultra HD, extreme meticulous detailing, skin pore detailing, hyper sharpness, perfect without deformations.",
777
  "painting, oil painting, illustration, drawing, art, sketch, anime, cartoon, CG Style, 3D render, unreal engine, blurring, aliasing, pixel, unsharp, weird textures, ugly, dirty, messy, worst quality, low quality, frames, watermark, signature, jpeg artifacts, deformed, lowres, over-smooth",
778
+ 1, # num_samples
779
+ 1024, # min_size
780
+ 1, # downscale
781
+ 1, # upscale
782
+ 100, # edm_steps
783
+ -1, # s_stage1
784
+ 1, # s_stage2
785
+ 7.5, # s_cfg
786
+ False, # randomize_seed
787
+ 42, # seed
788
+ 5, # s_churn
789
+ 1.003, # s_noise
790
+ "Wavelet", # color_fix_type
791
+ "fp16", # diff_dtype
792
+ "bf16", # ae_dtype
793
+ 1.0, # gamma_correction
794
+ True, # linear_CFG
795
+ 4, # spt_linear_CFG
796
+ False, # linear_s_stage2
797
+ 0., # spt_linear_s_stage2
798
+ "v0-Q", # model_select
799
+ "input", # output_format
800
+ 60 # allocation
801
  ],
802
  [
803
  "./Examples/Example3.webp",
 
806
  "A red apple",
807
  "Cinematic, High Contrast, highly detailed, taken using a Canon EOS R camera, hyper detailed photo - realistic maximum detail, 32k, Color Grading, ultra HD, extreme meticulous detailing, skin pore detailing, hyper sharpness, perfect without deformations.",
808
  "painting, oil painting, illustration, drawing, art, sketch, anime, cartoon, CG Style, 3D render, unreal engine, blurring, aliasing, pixel, unsharp, weird textures, ugly, dirty, messy, worst quality, low quality, frames, watermark, signature, jpeg artifacts, deformed, lowres, over-smooth",
809
+ 1, # num_samples
810
+ 1024, # min_size
811
+ 1, # downscale
812
+ 1, # upscale
813
+ 200, # edm_steps
814
+ -1, # s_stage1
815
+ 1, # s_stage2
816
+ 7.5, # s_cfg
817
+ False, # randomize_seed
818
+ 42, # seed
819
+ 5, # s_churn
820
+ 1.003, # s_noise
821
+ "Wavelet", # color_fix_type
822
+ "fp16", # diff_dtype
823
+ "bf16", # ae_dtype
824
+ 1.0, # gamma_correction
825
+ True, # linear_CFG
826
+ 4, # spt_linear_CFG
827
+ False, # linear_s_stage2
828
+ 0., # spt_linear_s_stage2
829
+ "v0-Q", # model_select
830
+ "input", # output_format
831
+ 180 # allocation
832
  ],
833
  [
834
  "./Examples/Example3.webp",
 
837
  "A red marble",
838
  "Cinematic, High Contrast, highly detailed, taken using a Canon EOS R camera, hyper detailed photo - realistic maximum detail, 32k, Color Grading, ultra HD, extreme meticulous detailing, skin pore detailing, hyper sharpness, perfect without deformations.",
839
  "painting, oil painting, illustration, drawing, art, sketch, anime, cartoon, CG Style, 3D render, unreal engine, blurring, aliasing, pixel, unsharp, weird textures, ugly, dirty, messy, worst quality, low quality, frames, watermark, signature, jpeg artifacts, deformed, lowres, over-smooth",
840
+ 1, # num_samples
841
+ 1024, # min_size
842
+ 1, # downscale
843
+ 1, # upscale
844
+ 200, # edm_steps
845
+ -1, # s_stage1
846
+ 1, # s_stage2
847
+ 7.5, # s_cfg
848
+ False, # randomize_seed
849
+ 42, # seed
850
+ 5, # s_churn
851
+ 1.003, # s_noise
852
+ "Wavelet", # color_fix_type
853
+ "fp16", # diff_dtype
854
+ "bf16", # ae_dtype
855
+ 1.0, # gamma_correction
856
+ True, # linear_CFG
857
+ 4, # spt_linear_CFG
858
+ False, # linear_s_stage2
859
+ 0., # spt_linear_s_stage2
860
+ "v0-Q", # model_select
861
+ "input", # output_format
862
+ 180 # allocation
863
  ],
864
  ],
865
  run_on_click = True,
 
888
  ae_dtype,
889
  gamma_correction,
890
  linear_CFG,
 
891
  spt_linear_CFG,
892
+ linear_s_stage2,
893
  spt_linear_s_stage2,
894
  model_select,
895
  output_format,
 
900
  result_gallery,
901
  restore_information,
902
  reset_btn,
903
+ warning,
904
  dummy_button
905
  ],
906
  cache_examples = False,
 
959
  ae_dtype,
960
  gamma_correction,
961
  linear_CFG,
 
962
  spt_linear_CFG,
963
+ linear_s_stage2,
964
  spt_linear_s_stage2,
965
  model_select,
966
  output_format,
 
978
 
979
  result_gallery.change(on_select_result, [result_slider, result_gallery], result_slider)
980
  result_gallery.select(on_select_result, [result_slider, result_gallery], result_slider)
981
+ result_example.change(on_render_image_example, result_example, result_image_example)
982
 
983
  restart_button.click(fn = load_and_reset, inputs = [
984
  param_setting
 
993
  n_prompt,
994
  color_fix_type,
995
  linear_CFG,
 
996
  spt_linear_CFG,
997
+ linear_s_stage2,
998
  spt_linear_s_stage2,
999
  model_select
1000
  ])
 
1023
  ae_dtype,
1024
  gamma_correction,
1025
  linear_CFG,
 
1026
  spt_linear_CFG,
1027
+ linear_s_stage2,
1028
  spt_linear_s_stage2,
1029
  model_select,
1030
  output_format,
1031
  allocation
1032
  ], queue = False, show_progress = False)
1033
+
1034
+ def handle_field_debug_change(input_image_debug_data, prompt_debug_data, upscale_debug_data):
1035
+ input_image_debug_value[0] = input_image_debug_data
1036
+ prompt_debug_value[0] = prompt_debug_data
1037
+ upscale_debug_value[0] = upscale_debug_data
1038
+ return []
1039
+
1040
+ input_image_debug.upload(
1041
+ fn=handle_field_debug_change,
1042
+ inputs=[input_image_debug, prompt_debug, upscale_debug],
1043
+ outputs=[]
1044
+ )
1045
+
1046
+ prompt_debug.change(
1047
+ fn=handle_field_debug_change,
1048
+ inputs=[input_image_debug, prompt_debug, upscale_debug],
1049
+ outputs=[]
1050
+ )
1051
+
1052
+ upscale_debug.change(
1053
+ fn=handle_field_debug_change,
1054
+ inputs=[input_image_debug, prompt_debug, upscale_debug],
1055
+ outputs=[]
1056
+ )
1057
 
1058
  interface.queue(10).launch(mcp_server=True, ssr_mode=False)