zerhero commited on
Commit
7b997f3
1 Parent(s): c3408ce
Files changed (2) hide show
  1. app.py +53 -27
  2. utils/html_utils.py +16 -0
app.py CHANGED
@@ -138,7 +138,7 @@ vae_model_list = get_model_list(directory_vaes)
138
  vae_model_list.insert(0, "None")
139
 
140
 
141
- def get_my_lora(link_url):
142
  for __url in [_url.strip() for _url in link_url.split(',')]:
143
  if not os.path.exists(f"./loras/{__url.split('/')[-1]}"):
144
  download_things(
@@ -148,7 +148,7 @@ def get_my_lora(link_url):
148
  CIVITAI_API_KEY
149
  )
150
 
151
- new_lora_model_list = get_model_list(directory_loras)
152
  new_lora_model_list.insert(0, "None")
153
 
154
  return gr.update(
@@ -204,18 +204,6 @@ warnings.filterwarnings(
204
  logger.setLevel(logging.DEBUG)
205
 
206
 
207
- def info_html(json_data, title, subtitle):
208
- return f"""
209
- <div style='padding: 0; border-radius: 10px;'>
210
- <p style='margin: 0; font-weight: bold;'>{title}</p>
211
- <details>
212
- <summary>Details</summary>
213
- <p style='margin: 0; font-weight: bold;'>{subtitle}</p>
214
- </details>
215
- </div>
216
- """
217
-
218
-
219
  class GuiSD:
220
  def __init__(self, stream=True):
221
  self.model = None
@@ -229,8 +217,18 @@ class GuiSD:
229
  retain_task_model_in_cache=False,
230
  )
231
 
232
- def load_new_model(self, model_name, vae_model, task, progress=gr.Progress(track_tqdm=True)):
233
-
 
 
 
 
 
 
 
 
 
 
234
  yield f"Loading model: {model_name}"
235
 
236
  vae_model = vae_model if vae_model != "None" else None
@@ -406,7 +404,11 @@ class GuiSD:
406
  (image_ip2, mask_ip2, model_ip2, mode_ip2, scale_ip2),
407
  ]
408
 
409
- for imgip, mskip, modelip, modeip, scaleip in all_adapters:
 
 
 
 
410
  if imgip:
411
  params_ip_img.append(imgip)
412
  if mskip:
@@ -748,7 +750,7 @@ with gr.Blocks(css=CSS) as app:
748
  with gr.Row(equal_height=False):
749
 
750
  def run_set_params_gui(base_prompt):
751
- valid_receptors = { # default values
752
  "prompt": gr.update(value=base_prompt),
753
  "neg_prompt": gr.update(value=""),
754
  "Steps": gr.update(value=30),
@@ -848,7 +850,10 @@ with gr.Blocks(css=CSS) as app:
848
  value=vae_model_list[1]
849
  )
850
 
851
- with gr.Accordion("Hires fix", open=False, visible=True):
 
 
 
852
 
853
  upscaler_keys = list(upscaler_dict_gui.keys())
854
 
@@ -965,7 +970,10 @@ with gr.Blocks(css=CSS) as app:
965
  label="Lora Scale 5"
966
  )
967
 
968
- with gr.Accordion("From URL", open=False, visible=True):
 
 
 
969
  text_lora = gr.Textbox(
970
  label="URL",
971
  placeholder="http://...my_lora_url.safetensors",
@@ -1096,7 +1104,6 @@ with gr.Blocks(css=CSS) as app:
1096
  value=choices_task[0]
1097
  )
1098
 
1099
-
1100
  task_gui.change(
1101
  change_preprocessor_choices,
1102
  [task_gui],
@@ -1158,7 +1165,10 @@ with gr.Blocks(css=CSS) as app:
1158
  label="ControlNet Stop Threshold (%)"
1159
  )
1160
 
1161
- with gr.Accordion("T2I adapter", open=False, visible=True):
 
 
 
1162
  t2i_adapter_preprocessor_gui = gr.Checkbox(
1163
  value=True,
1164
  label="T2i Adapter Preprocessor"
@@ -1221,13 +1231,19 @@ with gr.Blocks(css=CSS) as app:
1221
  [style_prompt_gui]
1222
  )
1223
 
1224
- with gr.Accordion("Textual inversion", open=False, visible=False):
 
 
 
1225
  active_textual_inversion_gui = gr.Checkbox(
1226
  value=False,
1227
  label="Active Textual Inversion in prompt"
1228
  )
1229
 
1230
- with gr.Accordion("Detailfix", open=False, visible=True):
 
 
 
1231
 
1232
  # Adetailer Inpaint Only
1233
  adetailer_inpaint_only_gui = gr.Checkbox(label="Inpaint only", value=True)
@@ -1243,7 +1259,10 @@ with gr.Blocks(css=CSS) as app:
1243
  value="Use same sampler"
1244
  )
1245
 
1246
- with gr.Accordion("Detailfix A", open=False, visible=True):
 
 
 
1247
  # Adetailer A
1248
  adetailer_active_a_gui = gr.Checkbox(
1249
  label="Enable Adetailer A",
@@ -1293,7 +1312,10 @@ with gr.Blocks(css=CSS) as app:
1293
  minimum=1
1294
  )
1295
 
1296
- with gr.Accordion("Detailfix B", open=False, visible=True):
 
 
 
1297
  # Adetailer B
1298
  adetailer_active_b_gui = gr.Checkbox(label="Enable Adetailer B", value=False)
1299
  prompt_ad_b_gui = gr.Textbox(
@@ -1362,7 +1384,10 @@ with gr.Blocks(css=CSS) as app:
1362
  label="Generator in CPU"
1363
  )
1364
 
1365
- with gr.Accordion("More settings", open=False, visible=False):
 
 
 
1366
  loop_generation_gui = gr.Slider(
1367
  minimum=1,
1368
  value=1,
@@ -1544,6 +1569,7 @@ with gr.Blocks(css=CSS) as app:
1544
  label="Invert mask"
1545
  )
1546
  btn = gr.Button("Create mask")
 
1547
  with gr.Column(scale=1):
1548
  img_source = gr.Image(interactive=False)
1549
  img_result = gr.Image(
 
138
  vae_model_list.insert(0, "None")
139
 
140
 
141
+ def get_my_lora(link_url) -> tuple:
142
  for __url in [_url.strip() for _url in link_url.split(',')]:
143
  if not os.path.exists(f"./loras/{__url.split('/')[-1]}"):
144
  download_things(
 
148
  CIVITAI_API_KEY
149
  )
150
 
151
+ new_lora_model_list: list = get_model_list(directory_loras)
152
  new_lora_model_list.insert(0, "None")
153
 
154
  return gr.update(
 
204
  logger.setLevel(logging.DEBUG)
205
 
206
 
 
 
 
 
 
 
 
 
 
 
 
 
207
  class GuiSD:
208
  def __init__(self, stream=True):
209
  self.model = None
 
217
  retain_task_model_in_cache=False,
218
  )
219
 
220
+ def load_new_model(
221
+ self,
222
+ model_name,
223
+ vae_model,
224
+ task,
225
+ progress=gr.Progress(track_tqdm=True)):
226
+ """
227
+ :param model_name:
228
+ :param vae_model:
229
+ :param task:
230
+ :param progress:
231
+ """
232
  yield f"Loading model: {model_name}"
233
 
234
  vae_model = vae_model if vae_model != "None" else None
 
404
  (image_ip2, mask_ip2, model_ip2, mode_ip2, scale_ip2),
405
  ]
406
 
407
+ for (imgip,
408
+ mskip,
409
+ modelip,
410
+ modeip,
411
+ scaleip) in all_adapters:
412
  if imgip:
413
  params_ip_img.append(imgip)
414
  if mskip:
 
750
  with gr.Row(equal_height=False):
751
 
752
  def run_set_params_gui(base_prompt):
753
+ valid_receptors: dict = { # default values
754
  "prompt": gr.update(value=base_prompt),
755
  "neg_prompt": gr.update(value=""),
756
  "Steps": gr.update(value=30),
 
850
  value=vae_model_list[1]
851
  )
852
 
853
+ with gr.Accordion(
854
+ "Hires fix",
855
+ open=False,
856
+ visible=True):
857
 
858
  upscaler_keys = list(upscaler_dict_gui.keys())
859
 
 
970
  label="Lora Scale 5"
971
  )
972
 
973
+ with gr.Accordion(
974
+ "From URL",
975
+ open=False,
976
+ visible=True):
977
  text_lora = gr.Textbox(
978
  label="URL",
979
  placeholder="http://...my_lora_url.safetensors",
 
1104
  value=choices_task[0]
1105
  )
1106
 
 
1107
  task_gui.change(
1108
  change_preprocessor_choices,
1109
  [task_gui],
 
1165
  label="ControlNet Stop Threshold (%)"
1166
  )
1167
 
1168
+ with gr.Accordion(
1169
+ "T2I adapter",
1170
+ open=False,
1171
+ visible=True):
1172
  t2i_adapter_preprocessor_gui = gr.Checkbox(
1173
  value=True,
1174
  label="T2i Adapter Preprocessor"
 
1231
  [style_prompt_gui]
1232
  )
1233
 
1234
+ with gr.Accordion(
1235
+ "Textual inversion",
1236
+ open=False,
1237
+ visible=False):
1238
  active_textual_inversion_gui = gr.Checkbox(
1239
  value=False,
1240
  label="Active Textual Inversion in prompt"
1241
  )
1242
 
1243
+ with gr.Accordion(
1244
+ "Detailfix",
1245
+ open=False,
1246
+ visible=True):
1247
 
1248
  # Adetailer Inpaint Only
1249
  adetailer_inpaint_only_gui = gr.Checkbox(label="Inpaint only", value=True)
 
1259
  value="Use same sampler"
1260
  )
1261
 
1262
+ with gr.Accordion(
1263
+ "Detailfix A",
1264
+ open=False,
1265
+ visible=True):
1266
  # Adetailer A
1267
  adetailer_active_a_gui = gr.Checkbox(
1268
  label="Enable Adetailer A",
 
1312
  minimum=1
1313
  )
1314
 
1315
+ with gr.Accordion(
1316
+ "Detailfix B",
1317
+ open=False,
1318
+ visible=True):
1319
  # Adetailer B
1320
  adetailer_active_b_gui = gr.Checkbox(label="Enable Adetailer B", value=False)
1321
  prompt_ad_b_gui = gr.Textbox(
 
1384
  label="Generator in CPU"
1385
  )
1386
 
1387
+ with gr.Accordion(
1388
+ "More settings",
1389
+ open=False,
1390
+ visible=False):
1391
  loop_generation_gui = gr.Slider(
1392
  minimum=1,
1393
  value=1,
 
1569
  label="Invert mask"
1570
  )
1571
  btn = gr.Button("Create mask")
1572
+
1573
  with gr.Column(scale=1):
1574
  img_source = gr.Image(interactive=False)
1575
  img_result = gr.Image(
utils/html_utils.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ def info_html(json_data, title, subtitle):
2
+ """
3
+ :param json_data:
4
+ :param title:
5
+ :param subtitle:
6
+ :return:
7
+ """
8
+ return f"""
9
+ <div style='padding: 0; border-radius: 10px;'>
10
+ <p style='margin: 0; font-weight: bold;'>{title}</p>
11
+ <details>
12
+ <summary>Details</summary>
13
+ <p style='margin: 0; font-weight: bold;'>{subtitle}</p>
14
+ </details>
15
+ </div>
16
+ """