r3gm commited on
Commit
27fa464
1 Parent(s): 481fe70

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -17
app.py CHANGED
@@ -61,6 +61,9 @@ load_diffusers_format_model = [
61
  'GraydientPlatformAPI/realcartoon-pony-diffusion',
62
  'John6666/nova-anime-xl-pony-v5-sdxl',
63
  'John6666/autismmix-sdxl-autismmix-pony-sdxl',
 
 
 
64
  'yodayo-ai/kivotos-xl-2.0',
65
  'yodayo-ai/holodayo-xl-2.1',
66
  'yodayo-ai/clandestine-xl-1.0',
@@ -104,14 +107,14 @@ PREPROCESSOR_CONTROLNET = {
104
  ],
105
  "scribble": [
106
  "HED",
107
- "Pidinet",
108
  "None",
109
  ],
110
  "softedge": [
111
- "Pidinet",
112
  "HED",
113
  "HED safe",
114
- "Pidinet safe",
115
  "None",
116
  ],
117
  "segmentation": [
@@ -464,6 +467,7 @@ class GuiSD:
464
  retain_task_model_in_cache=False,
465
  device="cpu",
466
  )
 
467
 
468
  def load_new_model(self, model_name, vae_model, task, progress=gr.Progress(track_tqdm=True)):
469
 
@@ -777,7 +781,7 @@ class GuiSD:
777
  if msg_lora:
778
  info_state += msg_lora
779
 
780
- info_state = info_state + "<br>" + "GENERATION DATA:<br>" + "<br>-------<br>".join(metadata).replace("\n", "<br>")
781
 
782
  download_links = "<br>".join(
783
  [
@@ -899,10 +903,10 @@ with gr.Blocks(theme="NoCrypt/miku", css=CSS) as app:
899
  prompt_gui = gr.Textbox(lines=5, placeholder="Enter prompt", label="Prompt")
900
  neg_prompt_gui = gr.Textbox(lines=3, placeholder="Enter Neg prompt", label="Negative prompt")
901
  with gr.Row(equal_height=False):
902
- set_params_gui = gr.Button(value="↙️")
903
- clear_prompt_gui = gr.Button(value="🗑️")
904
- set_random_seed = gr.Button(value="🎲")
905
- generate_button = gr.Button(value="GENERATE", variant="primary")
906
 
907
  model_name_gui.change(
908
  update_task_options,
@@ -935,7 +939,7 @@ with gr.Blocks(theme="NoCrypt/miku", css=CSS) as app:
935
 
936
  with gr.Column(scale=1):
937
  steps_gui = gr.Slider(minimum=1, maximum=100, step=1, value=30, label="Steps")
938
- cfg_gui = gr.Slider(minimum=0, maximum=30, step=0.5, value=7.5, label="CFG")
939
  sampler_gui = gr.Dropdown(label="Sampler", choices=scheduler_names, value="Euler a")
940
  img_width_gui = gr.Slider(minimum=64, maximum=4096, step=8, value=1024, label="Img Width")
941
  img_height_gui = gr.Slider(minimum=64, maximum=4096, step=8, value=1024, label="Img Height")
@@ -943,11 +947,11 @@ with gr.Blocks(theme="NoCrypt/miku", css=CSS) as app:
943
  pag_scale_gui = gr.Slider(minimum=0.0, maximum=10.0, step=0.1, value=0.0, label="PAG Scale")
944
  with gr.Row():
945
  clip_skip_gui = gr.Checkbox(value=True, label="Layer 2 Clip Skip")
946
- free_u_gui = gr.Checkbox(value=True, label="FreeU")
947
 
948
  with gr.Row(equal_height=False):
949
 
950
- def run_set_params_gui(base_prompt):
951
  valid_receptors = { # default values
952
  "prompt": gr.update(value=base_prompt),
953
  "neg_prompt": gr.update(value=""),
@@ -956,12 +960,14 @@ with gr.Blocks(theme="NoCrypt/miku", css=CSS) as app:
956
  "height": gr.update(value=1024),
957
  "Seed": gr.update(value=-1),
958
  "Sampler": gr.update(value="Euler a"),
959
- "scale": gr.update(value=7.5), # cfg
960
  "skip": gr.update(value=True),
 
961
  }
962
  valid_keys = list(valid_receptors.keys())
963
 
964
  parameters = extract_parameters(base_prompt)
 
965
  for key, val in parameters.items():
966
  # print(val)
967
  if key in valid_keys:
@@ -969,6 +975,8 @@ with gr.Blocks(theme="NoCrypt/miku", css=CSS) as app:
969
  if val not in scheduler_names:
970
  continue
971
  elif key == "skip":
 
 
972
  if int(val) >= 2:
973
  val = True
974
  if key == "prompt":
@@ -981,6 +989,12 @@ with gr.Blocks(theme="NoCrypt/miku", css=CSS) as app:
981
  val = int(val)
982
  if key == "scale":
983
  val = float(val)
 
 
 
 
 
 
984
  if key == "Seed":
985
  continue
986
  valid_receptors[key] = gr.update(value=val)
@@ -989,7 +1003,7 @@ with gr.Blocks(theme="NoCrypt/miku", css=CSS) as app:
989
  return [value for value in valid_receptors.values()]
990
 
991
  set_params_gui.click(
992
- run_set_params_gui, [prompt_gui], [
993
  prompt_gui,
994
  neg_prompt_gui,
995
  steps_gui,
@@ -999,6 +1013,7 @@ with gr.Blocks(theme="NoCrypt/miku", css=CSS) as app:
999
  sampler_gui,
1000
  cfg_gui,
1001
  clip_skip_gui,
 
1002
  ],
1003
  )
1004
 
@@ -1014,7 +1029,7 @@ with gr.Blocks(theme="NoCrypt/miku", css=CSS) as app:
1014
  run_set_random_seed, [], seed_gui
1015
  )
1016
 
1017
- num_images_gui = gr.Slider(minimum=1, maximum=4, step=1, value=1, label="Images")
1018
  prompt_s_options = [
1019
  ("Compel format: (word)weight", "Compel"),
1020
  ("Classic format: (word:weight)", "Classic"),
@@ -1024,7 +1039,7 @@ with gr.Blocks(theme="NoCrypt/miku", css=CSS) as app:
1024
  ("None", "None"),
1025
  ]
1026
  prompt_syntax_gui = gr.Dropdown(label="Prompt Syntax", choices=prompt_s_options, value=prompt_s_options[1][1])
1027
- vae_model_gui = gr.Dropdown(label="VAE Model", choices=vae_model_list)
1028
 
1029
  with gr.Accordion("Hires fix", open=False, visible=True):
1030
 
@@ -1116,7 +1131,7 @@ with gr.Blocks(theme="NoCrypt/miku", css=CSS) as app:
1116
  control_net_start_threshold_gui = gr.Slider(minimum=0, maximum=1, step=0.01, value=0, label="ControlNet Start Threshold (%)")
1117
  control_net_stop_threshold_gui = gr.Slider(minimum=0, maximum=1, step=0.01, value=1, label="ControlNet Stop Threshold (%)")
1118
 
1119
- with gr.Accordion("T2I adapter", open=False, visible=True):
1120
  t2i_adapter_preprocessor_gui = gr.Checkbox(value=True, label="T2i Adapter Preprocessor")
1121
  adapter_conditioning_scale_gui = gr.Slider(minimum=0, maximum=5., step=0.1, value=1, label="Adapter Conditioning Scale")
1122
  adapter_conditioning_factor_gui = gr.Slider(minimum=0, maximum=1., step=0.01, value=0.55, label="Adapter Conditioning Factor (%)")
@@ -1403,6 +1418,12 @@ with gr.Blocks(theme="NoCrypt/miku", css=CSS) as app:
1403
  outputs=[result_images, actual_task_info],
1404
  cache_examples=False,
1405
  )
 
 
 
 
 
 
1406
 
1407
  with gr.Tab("Inpaint mask maker", render=True):
1408
 
@@ -1597,4 +1618,4 @@ app.launch(
1597
  show_error=True,
1598
  debug=True,
1599
  allowed_paths=["./images/"],
1600
- )
 
61
  'GraydientPlatformAPI/realcartoon-pony-diffusion',
62
  'John6666/nova-anime-xl-pony-v5-sdxl',
63
  'John6666/autismmix-sdxl-autismmix-pony-sdxl',
64
+ 'John6666/aimz-dream-real-pony-mix-v3-sdxl',
65
+ 'John6666/duchaiten-pony-real-v11fix-sdxl',
66
+ 'John6666/duchaiten-pony-real-v20-sdxl',
67
  'yodayo-ai/kivotos-xl-2.0',
68
  'yodayo-ai/holodayo-xl-2.1',
69
  'yodayo-ai/clandestine-xl-1.0',
 
107
  ],
108
  "scribble": [
109
  "HED",
110
+ "PidiNet",
111
  "None",
112
  ],
113
  "softedge": [
114
+ "PidiNet",
115
  "HED",
116
  "HED safe",
117
+ "PidiNet safe",
118
  "None",
119
  ],
120
  "segmentation": [
 
467
  retain_task_model_in_cache=False,
468
  device="cpu",
469
  )
470
+ self.model.load_beta_styles()
471
 
472
  def load_new_model(self, model_name, vae_model, task, progress=gr.Progress(track_tqdm=True)):
473
 
 
781
  if msg_lora:
782
  info_state += msg_lora
783
 
784
+ info_state = info_state + "<br>" + "GENERATION DATA:<br>" + metadata[0].replace("\n", "<br>") + "<br>-------<br>"
785
 
786
  download_links = "<br>".join(
787
  [
 
903
  prompt_gui = gr.Textbox(lines=5, placeholder="Enter prompt", label="Prompt")
904
  neg_prompt_gui = gr.Textbox(lines=3, placeholder="Enter Neg prompt", label="Negative prompt")
905
  with gr.Row(equal_height=False):
906
+ set_params_gui = gr.Button(value="↙️", variant="secondary", size="sm")
907
+ clear_prompt_gui = gr.Button(value="🗑️", variant="secondary", size="sm")
908
+ set_random_seed = gr.Button(value="🎲", variant="secondary", size="sm")
909
+ generate_button = gr.Button(value="GENERATE IMAGE", variant="primary")
910
 
911
  model_name_gui.change(
912
  update_task_options,
 
939
 
940
  with gr.Column(scale=1):
941
  steps_gui = gr.Slider(minimum=1, maximum=100, step=1, value=30, label="Steps")
942
+ cfg_gui = gr.Slider(minimum=0, maximum=30, step=0.5, value=7., label="CFG")
943
  sampler_gui = gr.Dropdown(label="Sampler", choices=scheduler_names, value="Euler a")
944
  img_width_gui = gr.Slider(minimum=64, maximum=4096, step=8, value=1024, label="Img Width")
945
  img_height_gui = gr.Slider(minimum=64, maximum=4096, step=8, value=1024, label="Img Height")
 
947
  pag_scale_gui = gr.Slider(minimum=0.0, maximum=10.0, step=0.1, value=0.0, label="PAG Scale")
948
  with gr.Row():
949
  clip_skip_gui = gr.Checkbox(value=True, label="Layer 2 Clip Skip")
950
+ free_u_gui = gr.Checkbox(value=False, label="FreeU")
951
 
952
  with gr.Row(equal_height=False):
953
 
954
+ def run_set_params_gui(base_prompt, name_model):
955
  valid_receptors = { # default values
956
  "prompt": gr.update(value=base_prompt),
957
  "neg_prompt": gr.update(value=""),
 
960
  "height": gr.update(value=1024),
961
  "Seed": gr.update(value=-1),
962
  "Sampler": gr.update(value="Euler a"),
963
+ "scale": gr.update(value=7.), # cfg
964
  "skip": gr.update(value=True),
965
+ "Model": gr.update(value=name_model),
966
  }
967
  valid_keys = list(valid_receptors.keys())
968
 
969
  parameters = extract_parameters(base_prompt)
970
+
971
  for key, val in parameters.items():
972
  # print(val)
973
  if key in valid_keys:
 
975
  if val not in scheduler_names:
976
  continue
977
  elif key == "skip":
978
+ if "," in str(val):
979
+ val = val.replace(",", "")
980
  if int(val) >= 2:
981
  val = True
982
  if key == "prompt":
 
989
  val = int(val)
990
  if key == "scale":
991
  val = float(val)
992
+ if key == "Model":
993
+ filtered_models = [m for m in model_list if val in m]
994
+ if filtered_models:
995
+ val = filtered_models[0]
996
+ else:
997
+ val = name_model
998
  if key == "Seed":
999
  continue
1000
  valid_receptors[key] = gr.update(value=val)
 
1003
  return [value for value in valid_receptors.values()]
1004
 
1005
  set_params_gui.click(
1006
+ run_set_params_gui, [prompt_gui, model_name_gui], [
1007
  prompt_gui,
1008
  neg_prompt_gui,
1009
  steps_gui,
 
1013
  sampler_gui,
1014
  cfg_gui,
1015
  clip_skip_gui,
1016
+ model_name_gui,
1017
  ],
1018
  )
1019
 
 
1029
  run_set_random_seed, [], seed_gui
1030
  )
1031
 
1032
+ num_images_gui = gr.Slider(minimum=1, maximum=5, step=1, value=1, label="Images")
1033
  prompt_s_options = [
1034
  ("Compel format: (word)weight", "Compel"),
1035
  ("Classic format: (word:weight)", "Classic"),
 
1039
  ("None", "None"),
1040
  ]
1041
  prompt_syntax_gui = gr.Dropdown(label="Prompt Syntax", choices=prompt_s_options, value=prompt_s_options[1][1])
1042
+ vae_model_gui = gr.Dropdown(label="VAE Model", choices=vae_model_list, value=vae_model_list[0])
1043
 
1044
  with gr.Accordion("Hires fix", open=False, visible=True):
1045
 
 
1131
  control_net_start_threshold_gui = gr.Slider(minimum=0, maximum=1, step=0.01, value=0, label="ControlNet Start Threshold (%)")
1132
  control_net_stop_threshold_gui = gr.Slider(minimum=0, maximum=1, step=0.01, value=1, label="ControlNet Stop Threshold (%)")
1133
 
1134
+ with gr.Accordion("T2I adapter", open=False, visible=False):
1135
  t2i_adapter_preprocessor_gui = gr.Checkbox(value=True, label="T2i Adapter Preprocessor")
1136
  adapter_conditioning_scale_gui = gr.Slider(minimum=0, maximum=5., step=0.1, value=1, label="Adapter Conditioning Scale")
1137
  adapter_conditioning_factor_gui = gr.Slider(minimum=0, maximum=1., step=0.01, value=0.55, label="Adapter Conditioning Factor (%)")
 
1418
  outputs=[result_images, actual_task_info],
1419
  cache_examples=False,
1420
  )
1421
+ gr.Markdown(
1422
+ """### Resources
1423
+ - John6666's space has some great features you might find helpful [link](https://huggingface.co/spaces/John6666/DiffuseCraftMod).
1424
+ - You can also try the image generator in Colab’s free tier, which provides free GPU [link](https://github.com/R3gm/SD_diffusers_interactive).
1425
+ """
1426
+ )
1427
 
1428
  with gr.Tab("Inpaint mask maker", render=True):
1429
 
 
1618
  show_error=True,
1619
  debug=True,
1620
  allowed_paths=["./images/"],
1621
+ )