Update webui.py
Browse files
webui.py
CHANGED
@@ -254,284 +254,283 @@ with shared.gradio_root:
|
|
254 |
ip_tab.select(lambda: 'ip', outputs=current_tab, queue=False, _js=down_js, show_progress=False)
|
255 |
desc_tab.select(lambda: 'desc', outputs=current_tab, queue=False, _js=down_js, show_progress=False)
|
256 |
|
257 |
-
with gr.
|
258 |
-
with gr.
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
297 |
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
shared.gradio_root.load(update_history_link, outputs=history_link, queue=False, show_progress=False)
|
306 |
-
|
307 |
-
with gr.TabItem(label='Style'):
|
308 |
-
style_sorter.try_load_sorted_styles(
|
309 |
-
style_names=legal_style_names,
|
310 |
-
default_selected=modules.config.default_styles)
|
311 |
-
|
312 |
-
style_search_bar = gr.Textbox(show_label=False, container=False,
|
313 |
-
placeholder="\U0001F50E Type here to search styles ...",
|
314 |
-
value="",
|
315 |
-
label='Search Styles',
|
316 |
-
show_copy_button=True)
|
317 |
-
style_selections = gr.CheckboxGroup(show_label=False, container=False,
|
318 |
-
choices=copy.deepcopy(style_sorter.all_styles),
|
319 |
-
value=copy.deepcopy(modules.config.default_styles),
|
320 |
-
label='Selected Styles',
|
321 |
-
elem_classes=['style_selections'])
|
322 |
-
gradio_receiver_style_selections = gr.Textbox(elem_id='gradio_receiver_style_selections', visible=False, show_copy_button=True)
|
323 |
-
|
324 |
-
shared.gradio_root.load(lambda: gr.update(choices=copy.deepcopy(style_sorter.all_styles)),
|
325 |
-
outputs=style_selections)
|
326 |
-
|
327 |
-
style_search_bar.change(style_sorter.search_styles,
|
328 |
-
inputs=[style_selections, style_search_bar],
|
329 |
-
outputs=style_selections,
|
330 |
-
queue=False,
|
331 |
-
show_progress=False).then(
|
332 |
-
lambda: None, _js='()=>{refresh_style_localization();}')
|
333 |
-
|
334 |
-
gradio_receiver_style_selections.input(style_sorter.sort_styles,
|
335 |
-
inputs=style_selections,
|
336 |
-
outputs=style_selections,
|
337 |
-
queue=False,
|
338 |
-
show_progress=False).then(
|
339 |
-
lambda: None, _js='()=>{refresh_style_localization();}')
|
340 |
-
|
341 |
-
with gr.TabItem(label='Model'):
|
342 |
-
with gr.Group():
|
343 |
-
with gr.Row():
|
344 |
-
base_model = gr.Dropdown(label='Base Model (SDXL only)', choices=modules.config.model_filenames, value=modules.config.default_base_model_name, show_label=True)
|
345 |
-
refiner_model = gr.Dropdown(label='Refiner (SDXL or SD 1.5)', choices=['None'] + modules.config.model_filenames, value=modules.config.default_refiner_model_name, show_label=True)
|
346 |
-
|
347 |
-
refiner_switch = gr.Slider(label='Refiner Switch At', minimum=0.1, maximum=1.0, step=0.0001,
|
348 |
-
info='Use 0.4 for SD1.5 realistic models; '
|
349 |
-
'or 0.667 for SD1.5 anime models; '
|
350 |
-
'or 0.8 for XL-refiners; '
|
351 |
-
'or any value for switching two SDXL models.',
|
352 |
-
value=modules.config.default_refiner_switch,
|
353 |
-
visible=modules.config.default_refiner_model_name != 'None')
|
354 |
-
|
355 |
-
refiner_model.change(lambda x: gr.update(visible=x != 'None'),
|
356 |
-
inputs=refiner_model, outputs=refiner_switch, show_progress=False, queue=False)
|
357 |
-
|
358 |
-
with gr.Group():
|
359 |
-
lora_ctrls = []
|
360 |
-
|
361 |
-
for i, (n, v) in enumerate(modules.config.default_loras):
|
362 |
-
with gr.Row():
|
363 |
-
lora_enabled = gr.Checkbox(label='Enable', value=True,
|
364 |
-
elem_classes=['lora_enable', 'min_check'], scale=1)
|
365 |
-
lora_model = gr.Dropdown(label=f'LoRA {i + 1}',
|
366 |
-
choices=['None'] + modules.config.lora_filenames, value=n,
|
367 |
-
elem_classes='lora_model', scale=5)
|
368 |
-
lora_weight = gr.Slider(label='Weight', minimum=modules.config.default_loras_min_weight,
|
369 |
-
maximum=modules.config.default_loras_max_weight, step=0.01, value=v,
|
370 |
-
elem_classes='lora_weight', scale=5)
|
371 |
-
lora_ctrls += [lora_enabled, lora_model, lora_weight]
|
372 |
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
with gr.Column(visible=False):
|
377 |
-
with gr.Tab(label='Advanced', elem_id="advancedAdvancedSettings"):
|
378 |
-
guidance_scale = gr.Slider(label='Guidance Scale', minimum=1.0, maximum=30.0, step=0.01,
|
379 |
-
value=modules.config.default_cfg_scale,
|
380 |
-
info='Higher value means style is cleaner, vivider, and more artistic.')
|
381 |
-
sharpness = gr.Slider(label='Image Sharpness', minimum=0.0, maximum=30.0, step=0.001,
|
382 |
-
value=modules.config.default_sample_sharpness,
|
383 |
-
info='Higher value means image and texture are sharper.')
|
384 |
-
dev_mode = gr.Checkbox(label='Developer Debug Mode', value=True, container=True)
|
385 |
-
|
386 |
-
with gr.Column(visible=True) as dev_tools:
|
387 |
-
with gr.Tab(label='Debug Tools'):
|
388 |
-
adm_scaler_positive = gr.Slider(label='Positive ADM Guidance Scaler', minimum=0.1, maximum=3.0,
|
389 |
-
step=0.001, value=1.5, info='The scaler multiplied to positive ADM (use 1.0 to disable). ')
|
390 |
-
adm_scaler_negative = gr.Slider(label='Negative ADM Guidance Scaler', minimum=0.1, maximum=3.0,
|
391 |
-
step=0.001, value=0.8, info='The scaler multiplied to negative ADM (use 1.0 to disable). ')
|
392 |
-
adm_scaler_end = gr.Slider(label='ADM Guidance End At Step', minimum=0.0, maximum=1.0,
|
393 |
-
step=0.001, value=0.3,
|
394 |
-
info='When to end the guidance from positive/negative ADM. ')
|
395 |
-
|
396 |
-
refiner_swap_method = gr.Dropdown(label='Refiner swap method', value=flags.refiner_swap_method,
|
397 |
-
choices=['joint', 'separate', 'vae'])
|
398 |
-
|
399 |
-
adaptive_cfg = gr.Slider(label='CFG Mimicking from TSNR', minimum=1.0, maximum=30.0, step=0.01,
|
400 |
-
value=modules.config.default_cfg_tsnr,
|
401 |
-
info='Enabling Image\'s implementation of CFG mimicking for TSNR '
|
402 |
-
'(effective when real CFG > mimicked CFG).')
|
403 |
-
sampler_name = gr.Dropdown(label='Sampler', choices=flags.sampler_list,
|
404 |
-
value=modules.config.default_sampler)
|
405 |
-
scheduler_name = gr.Dropdown(label='Scheduler', choices=flags.scheduler_list,
|
406 |
-
value=modules.config.default_scheduler)
|
407 |
-
|
408 |
-
generate_image_grid = gr.Checkbox(label='Generate Image Grid for Each Batch',
|
409 |
-
info='(Experimental) This may cause performance problems on some computers and certain internet conditions.',
|
410 |
-
value=False)
|
411 |
|
412 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
413 |
minimum=-1, maximum=200, step=1,
|
414 |
-
value=modules.config.
|
415 |
info='Set as -1 to disable. For developer debugging.')
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
info='Disable intermediate results during generation, only show final gallery.')
|
440 |
-
disable_seed_increment = gr.Checkbox(label='Disable seed increment',
|
441 |
-
info='Disable automatic seed increment when image number is > 1.',
|
442 |
-
value=False)
|
443 |
-
|
444 |
-
if not args_manager.args.disable_metadata:
|
445 |
-
save_metadata_to_images = gr.Checkbox(label='Save Metadata to Images', value=True,
|
446 |
-
info='Adds parameters to generated images allowing manual regeneration.')
|
447 |
-
metadata_scheme = gr.Radio(label='Metadata Scheme', choices=flags.metadata_scheme, value=modules.config.default_metadata_scheme,
|
448 |
-
info='Image Prompt parameters are not included. Use png and a1111 for compatibility with Civitai.',
|
449 |
-
visible=True)
|
450 |
-
|
451 |
-
save_metadata_to_images.change(lambda x: gr.update(visible=x), inputs=[save_metadata_to_images], outputs=[metadata_scheme],
|
452 |
-
queue=False, show_progress=False)
|
453 |
-
|
454 |
-
with gr.Tab(label='Control'):
|
455 |
-
debugging_cn_preprocessor = gr.Checkbox(label='Debug Preprocessors', value=True,
|
456 |
-
info='See the results from preprocessors.')
|
457 |
-
skipping_cn_preprocessor = gr.Checkbox(label='Skip Preprocessors', value=True,
|
458 |
-
info='Do not preprocess images. (Inputs are already canny/depth/cropped-face/etc.)')
|
459 |
-
|
460 |
-
mixing_image_prompt_and_vary_upscale = gr.Checkbox(label='Mixing Image Prompt and Vary/Upscale',
|
461 |
-
value=True)
|
462 |
-
mixing_image_prompt_and_inpaint = gr.Checkbox(label='Mixing Image Prompt and Inpaint',
|
463 |
-
value=True)
|
464 |
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
step=1, value=64)
|
472 |
-
canny_high_threshold = gr.Slider(label='Canny High Threshold', minimum=1, maximum=255,
|
473 |
-
step=1, value=128)
|
474 |
-
|
475 |
-
with gr.Tab(label='Inpaint'):
|
476 |
-
debugging_inpaint_preprocessor = gr.Checkbox(label='Debug Inpaint Preprocessing', value=False)
|
477 |
-
inpaint_disable_initial_latent = gr.Checkbox(label='Disable initial latent in inpaint', value=False)
|
478 |
-
inpaint_engine = gr.Dropdown(label='Inpaint Engine',
|
479 |
-
value=modules.config.default_inpaint_engine_version,
|
480 |
-
choices=flags.inpaint_engine_versions,
|
481 |
-
info='Version of inpaint model')
|
482 |
-
inpaint_strength = gr.Slider(label='Inpaint Denoising Strength',
|
483 |
-
minimum=0.0, maximum=1.0, step=0.001, value=1.0,
|
484 |
-
info='Same as the denoising strength in A1111 inpaint. '
|
485 |
-
'Only used in inpaint, not used in outpaint. '
|
486 |
-
'(Outpaint always use 1.0)')
|
487 |
-
inpaint_respective_field = gr.Slider(label='Inpaint Respective Field',
|
488 |
-
minimum=0.0, maximum=1.0, step=0.001, value=0.618,
|
489 |
-
info='The area to inpaint. '
|
490 |
-
'Value 0 is same as "Only Masked" in A1111. '
|
491 |
-
'Value 1 is same as "Whole Image" in A1111. '
|
492 |
-
'Only used in inpaint, not used in outpaint. '
|
493 |
-
'(Outpaint always use 1.0)')
|
494 |
-
inpaint_erode_or_dilate = gr.Slider(label='Mask Erode or Dilate',
|
495 |
-
minimum=-64, maximum=64, step=1, value=0,
|
496 |
-
info='Positive value will make white area in the mask larger, '
|
497 |
-
'negative value will make white area smaller.'
|
498 |
-
'(default is 0, always process before any mask invert)')
|
499 |
-
# inpaint_mask_upload_checkbox = gr.Checkbox(label='Enable Mask Upload', value=False)
|
500 |
-
# invert_mask_checkbox = gr.Checkbox(label='Invert Mask', value=False)
|
501 |
-
|
502 |
-
inpaint_ctrls = [debugging_inpaint_preprocessor, inpaint_disable_initial_latent, inpaint_engine,
|
503 |
-
inpaint_strength, inpaint_respective_field,
|
504 |
-
inpaint_mask_upload_checkbox, invert_mask_checkbox, inpaint_erode_or_dilate]
|
505 |
-
|
506 |
-
inpaint_mask_upload_checkbox.change(lambda x: gr.update(visible=x),
|
507 |
-
inputs=inpaint_mask_upload_checkbox,
|
508 |
-
outputs=inpaint_mask_image, queue=False, show_progress=False)
|
509 |
-
|
510 |
-
with gr.Tab(label='FreeU'):
|
511 |
-
freeu_enabled = gr.Checkbox(label='Enabled', value=False)
|
512 |
-
freeu_b1 = gr.Slider(label='B1', minimum=0, maximum=2, step=0.01, value=1.01)
|
513 |
-
freeu_b2 = gr.Slider(label='B2', minimum=0, maximum=2, step=0.01, value=1.02)
|
514 |
-
freeu_s1 = gr.Slider(label='S1', minimum=0, maximum=4, step=0.01, value=0.99)
|
515 |
-
freeu_s2 = gr.Slider(label='S2', minimum=0, maximum=4, step=0.01, value=0.95)
|
516 |
-
freeu_ctrls = [freeu_enabled, freeu_b1, freeu_b2, freeu_s1, freeu_s2]
|
517 |
-
|
518 |
-
def dev_mode_checked(r):
|
519 |
-
return gr.update(visible=r)
|
520 |
-
|
521 |
-
|
522 |
-
dev_mode.change(dev_mode_checked, inputs=[dev_mode], outputs=[dev_tools],
|
523 |
-
queue=False, show_progress=False)
|
524 |
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
532 |
|
533 |
-
|
534 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
535 |
|
536 |
performance_selection.change(lambda x: [gr.update(interactive=x != 'Extreme Speed')] * 11 +
|
537 |
[gr.update(visible=x != 'Extreme Speed')] * 1 +
|
|
|
254 |
ip_tab.select(lambda: 'ip', outputs=current_tab, queue=False, _js=down_js, show_progress=False)
|
255 |
desc_tab.select(lambda: 'desc', outputs=current_tab, queue=False, _js=down_js, show_progress=False)
|
256 |
|
257 |
+
with gr.Column(visible=False) as advanced_column:
|
258 |
+
with gr.TabItem(label='Setting'):
|
259 |
+
performance_selection = gr.Radio(label='Performance',
|
260 |
+
choices=modules.flags.performance_selections,
|
261 |
+
value=modules.config.default_performance)
|
262 |
+
aspect_ratios_selection = gr.Radio(label='Aspect Ratios', choices=modules.config.available_aspect_ratios,
|
263 |
+
value=modules.config.default_aspect_ratio, info='width × height',
|
264 |
+
elem_classes='aspect_ratios')
|
265 |
+
image_number = gr.Slider(label='Image Number', minimum=1, maximum=modules.config.default_max_image_number, step=1, value=1)
|
266 |
+
|
267 |
+
output_format = gr.Radio(label='Output Format',
|
268 |
+
choices=modules.flags.output_formats,
|
269 |
+
value=modules.config.default_output_format)
|
270 |
+
|
271 |
+
negative_prompt = gr.Textbox(label='Negative Prompt', show_label=True, placeholder="Type prompt here.",
|
272 |
+
info='Describing what you do not want to see.', lines=2,
|
273 |
+
elem_id='negative_prompt',
|
274 |
+
value=modules.config.default_prompt_negative,
|
275 |
+
show_copy_button=True)
|
276 |
+
seed_random = gr.Checkbox(label='Random', value=True)
|
277 |
+
image_seed = gr.Textbox(label='Seed', value=0, max_lines=1, visible=False, show_copy_button=True) # workaround for https://github.com/gradio-app/gradio/issues/5354
|
278 |
+
|
279 |
+
def random_checked(r):
|
280 |
+
return gr.update(visible=not r)
|
281 |
+
|
282 |
+
def refresh_seed(r, seed_string):
|
283 |
+
if r:
|
284 |
+
return random.randint(constants.MIN_SEED, constants.MAX_SEED)
|
285 |
+
else:
|
286 |
+
try:
|
287 |
+
seed_value = int(seed_string)
|
288 |
+
if constants.MIN_SEED <= seed_value <= constants.MAX_SEED:
|
289 |
+
return seed_value
|
290 |
+
except ValueError:
|
291 |
+
pass
|
292 |
+
return random.randint(constants.MIN_SEED, constants.MAX_SEED)
|
293 |
+
|
294 |
+
seed_random.change(random_checked, inputs=[seed_random], outputs=[image_seed],
|
295 |
+
queue=False, show_progress=False)
|
296 |
+
|
297 |
+
def update_history_link():
|
298 |
+
if args_manager.args.disable_image_log:
|
299 |
+
return gr.update(value='')
|
300 |
+
|
301 |
+
return gr.update(value=f'<a href="file={get_current_html_path(output_format)}" target="_blank">\U0001F4DA History Log</a>')
|
302 |
+
|
303 |
+
history_link = gr.HTML()
|
304 |
+
shared.gradio_root.load(update_history_link, outputs=history_link, queue=False, show_progress=False)
|
305 |
+
|
306 |
+
with gr.TabItem(label='Style'):
|
307 |
+
style_sorter.try_load_sorted_styles(
|
308 |
+
style_names=legal_style_names,
|
309 |
+
default_selected=modules.config.default_styles)
|
310 |
+
|
311 |
+
style_search_bar = gr.Textbox(show_label=False, container=False,
|
312 |
+
placeholder="\U0001F50E Type here to search styles ...",
|
313 |
+
value="",
|
314 |
+
label='Search Styles',
|
315 |
+
show_copy_button=True)
|
316 |
+
style_selections = gr.CheckboxGroup(show_label=False, container=False,
|
317 |
+
choices=copy.deepcopy(style_sorter.all_styles),
|
318 |
+
value=copy.deepcopy(modules.config.default_styles),
|
319 |
+
label='Selected Styles',
|
320 |
+
elem_classes=['style_selections'])
|
321 |
+
gradio_receiver_style_selections = gr.Textbox(elem_id='gradio_receiver_style_selections', visible=False, show_copy_button=True)
|
322 |
+
|
323 |
+
shared.gradio_root.load(lambda: gr.update(choices=copy.deepcopy(style_sorter.all_styles)),
|
324 |
+
outputs=style_selections)
|
325 |
+
|
326 |
+
style_search_bar.change(style_sorter.search_styles,
|
327 |
+
inputs=[style_selections, style_search_bar],
|
328 |
+
outputs=style_selections,
|
329 |
+
queue=False,
|
330 |
+
show_progress=False).then(
|
331 |
+
lambda: None, _js='()=>{refresh_style_localization();}')
|
332 |
+
|
333 |
+
gradio_receiver_style_selections.input(style_sorter.sort_styles,
|
334 |
+
inputs=style_selections,
|
335 |
+
outputs=style_selections,
|
336 |
+
queue=False,
|
337 |
+
show_progress=False).then(
|
338 |
+
lambda: None, _js='()=>{refresh_style_localization();}')
|
339 |
+
|
340 |
+
with gr.TabItem(label='Model'):
|
341 |
+
with gr.Group():
|
342 |
+
with gr.Row():
|
343 |
+
base_model = gr.Dropdown(label='Base Model (SDXL only)', choices=modules.config.model_filenames, value=modules.config.default_base_model_name, show_label=True)
|
344 |
+
refiner_model = gr.Dropdown(label='Refiner (SDXL or SD 1.5)', choices=['None'] + modules.config.model_filenames, value=modules.config.default_refiner_model_name, show_label=True)
|
345 |
|
346 |
+
refiner_switch = gr.Slider(label='Refiner Switch At', minimum=0.1, maximum=1.0, step=0.0001,
|
347 |
+
info='Use 0.4 for SD1.5 realistic models; '
|
348 |
+
'or 0.667 for SD1.5 anime models; '
|
349 |
+
'or 0.8 for XL-refiners; '
|
350 |
+
'or any value for switching two SDXL models.',
|
351 |
+
value=modules.config.default_refiner_switch,
|
352 |
+
visible=modules.config.default_refiner_model_name != 'None')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
353 |
|
354 |
+
refiner_model.change(lambda x: gr.update(visible=x != 'None'),
|
355 |
+
inputs=refiner_model, outputs=refiner_switch, show_progress=False, queue=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
356 |
|
357 |
+
with gr.Group():
|
358 |
+
lora_ctrls = []
|
359 |
+
|
360 |
+
for i, (n, v) in enumerate(modules.config.default_loras):
|
361 |
+
with gr.Row():
|
362 |
+
lora_enabled = gr.Checkbox(label='Enable', value=True,
|
363 |
+
elem_classes=['lora_enable', 'min_check'], scale=1)
|
364 |
+
lora_model = gr.Dropdown(label=f'LoRA {i + 1}',
|
365 |
+
choices=['None'] + modules.config.lora_filenames, value=n,
|
366 |
+
elem_classes='lora_model', scale=5)
|
367 |
+
lora_weight = gr.Slider(label='Weight', minimum=modules.config.default_loras_min_weight,
|
368 |
+
maximum=modules.config.default_loras_max_weight, step=0.01, value=v,
|
369 |
+
elem_classes='lora_weight', scale=5)
|
370 |
+
lora_ctrls += [lora_enabled, lora_model, lora_weight]
|
371 |
+
|
372 |
+
with gr.Row():
|
373 |
+
model_refresh = gr.Button(label='Refresh', value='\U0001f504 Refresh All Files', variant='secondary', elem_classes='refresh_button')
|
374 |
+
|
375 |
+
with gr.Column(visible=False):
|
376 |
+
with gr.Tab(label='Advanced', elem_id="advancedAdvancedSettings"):
|
377 |
+
guidance_scale = gr.Slider(label='Guidance Scale', minimum=1.0, maximum=30.0, step=0.01,
|
378 |
+
value=modules.config.default_cfg_scale,
|
379 |
+
info='Higher value means style is cleaner, vivider, and more artistic.')
|
380 |
+
sharpness = gr.Slider(label='Image Sharpness', minimum=0.0, maximum=30.0, step=0.001,
|
381 |
+
value=modules.config.default_sample_sharpness,
|
382 |
+
info='Higher value means image and texture are sharper.')
|
383 |
+
dev_mode = gr.Checkbox(label='Developer Debug Mode', value=True, container=True)
|
384 |
+
|
385 |
+
with gr.Column(visible=True) as dev_tools:
|
386 |
+
with gr.Tab(label='Debug Tools'):
|
387 |
+
adm_scaler_positive = gr.Slider(label='Positive ADM Guidance Scaler', minimum=0.1, maximum=3.0,
|
388 |
+
step=0.001, value=1.5, info='The scaler multiplied to positive ADM (use 1.0 to disable). ')
|
389 |
+
adm_scaler_negative = gr.Slider(label='Negative ADM Guidance Scaler', minimum=0.1, maximum=3.0,
|
390 |
+
step=0.001, value=0.8, info='The scaler multiplied to negative ADM (use 1.0 to disable). ')
|
391 |
+
adm_scaler_end = gr.Slider(label='ADM Guidance End At Step', minimum=0.0, maximum=1.0,
|
392 |
+
step=0.001, value=0.3,
|
393 |
+
info='When to end the guidance from positive/negative ADM. ')
|
394 |
+
|
395 |
+
refiner_swap_method = gr.Dropdown(label='Refiner swap method', value=flags.refiner_swap_method,
|
396 |
+
choices=['joint', 'separate', 'vae'])
|
397 |
+
|
398 |
+
adaptive_cfg = gr.Slider(label='CFG Mimicking from TSNR', minimum=1.0, maximum=30.0, step=0.01,
|
399 |
+
value=modules.config.default_cfg_tsnr,
|
400 |
+
info='Enabling Image\'s implementation of CFG mimicking for TSNR '
|
401 |
+
'(effective when real CFG > mimicked CFG).')
|
402 |
+
sampler_name = gr.Dropdown(label='Sampler', choices=flags.sampler_list,
|
403 |
+
value=modules.config.default_sampler)
|
404 |
+
scheduler_name = gr.Dropdown(label='Scheduler', choices=flags.scheduler_list,
|
405 |
+
value=modules.config.default_scheduler)
|
406 |
+
|
407 |
+
generate_image_grid = gr.Checkbox(label='Generate Image Grid for Each Batch',
|
408 |
+
info='(Experimental) This may cause performance problems on some computers and certain internet conditions.',
|
409 |
+
value=False)
|
410 |
+
|
411 |
+
overwrite_step = gr.Slider(label='Forced Overwrite of Sampling Step',
|
412 |
+
minimum=-1, maximum=200, step=1,
|
413 |
+
value=modules.config.default_overwrite_step,
|
414 |
+
info='Set as -1 to disable. For developer debugging.')
|
415 |
+
overwrite_switch = gr.Slider(label='Forced Overwrite of Refiner Switch Step',
|
416 |
minimum=-1, maximum=200, step=1,
|
417 |
+
value=modules.config.default_overwrite_switch,
|
418 |
info='Set as -1 to disable. For developer debugging.')
|
419 |
+
overwrite_width = gr.Slider(label='Forced Overwrite of Generating Width',
|
420 |
+
minimum=-1, maximum=2048, step=1, value=-1,
|
421 |
+
info='Set as -1 to disable. For developer debugging. '
|
422 |
+
'Results will be worse for non-standard numbers that SDXL is not trained on.')
|
423 |
+
overwrite_height = gr.Slider(label='Forced Overwrite of Generating Height',
|
424 |
+
minimum=-1, maximum=2048, step=1, value=-1,
|
425 |
+
info='Set as -1 to disable. For developer debugging. '
|
426 |
+
'Results will be worse for non-standard numbers that SDXL is not trained on.')
|
427 |
+
overwrite_vary_strength = gr.Slider(label='Forced Overwrite of Denoising Strength of "Vary"',
|
428 |
+
minimum=-1, maximum=1.0, step=0.001, value=-1,
|
429 |
+
info='Set as negative number to disable. For developer debugging.')
|
430 |
+
overwrite_upscale_strength = gr.Slider(label='Forced Overwrite of Denoising Strength of "Upscale"',
|
431 |
+
minimum=-1, maximum=1.0, step=0.001, value=-1,
|
432 |
+
info='Set as negative number to disable. For developer debugging.')
|
433 |
+
disable_preview = gr.Checkbox(label='Disable Preview', value=False,
|
434 |
+
info='Disable preview during generation.')
|
435 |
+
disable_intermediate_results = gr.Checkbox(label='Disable Intermediate Results',
|
436 |
+
value=modules.config.default_performance == 'Extreme Speed',
|
437 |
+
interactive=modules.config.default_performance != 'Extreme Speed',
|
438 |
+
info='Disable intermediate results during generation, only show final gallery.')
|
439 |
+
disable_seed_increment = gr.Checkbox(label='Disable seed increment',
|
440 |
+
info='Disable automatic seed increment when image number is > 1.',
|
441 |
+
value=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
442 |
|
443 |
+
if not args_manager.args.disable_metadata:
|
444 |
+
save_metadata_to_images = gr.Checkbox(label='Save Metadata to Images', value=True,
|
445 |
+
info='Adds parameters to generated images allowing manual regeneration.')
|
446 |
+
metadata_scheme = gr.Radio(label='Metadata Scheme', choices=flags.metadata_scheme, value=modules.config.default_metadata_scheme,
|
447 |
+
info='Image Prompt parameters are not included. Use png and a1111 for compatibility with Civitai.',
|
448 |
+
visible=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
449 |
|
450 |
+
save_metadata_to_images.change(lambda x: gr.update(visible=x), inputs=[save_metadata_to_images], outputs=[metadata_scheme],
|
451 |
+
queue=False, show_progress=False)
|
452 |
+
|
453 |
+
with gr.Tab(label='Control'):
|
454 |
+
debugging_cn_preprocessor = gr.Checkbox(label='Debug Preprocessors', value=True,
|
455 |
+
info='See the results from preprocessors.')
|
456 |
+
skipping_cn_preprocessor = gr.Checkbox(label='Skip Preprocessors', value=True,
|
457 |
+
info='Do not preprocess images. (Inputs are already canny/depth/cropped-face/etc.)')
|
458 |
+
|
459 |
+
mixing_image_prompt_and_vary_upscale = gr.Checkbox(label='Mixing Image Prompt and Vary/Upscale',
|
460 |
+
value=True)
|
461 |
+
mixing_image_prompt_and_inpaint = gr.Checkbox(label='Mixing Image Prompt and Inpaint',
|
462 |
+
value=True)
|
463 |
+
|
464 |
+
controlnet_softness = gr.Slider(label='Softness of ControlNet', minimum=0.0, maximum=1.0,
|
465 |
+
step=0.001, value=0.25,
|
466 |
+
info='Similar to the Control Mode in A1111 (use 0.0 to disable). ')
|
467 |
+
|
468 |
+
with gr.Tab(label='Canny'):
|
469 |
+
canny_low_threshold = gr.Slider(label='Canny Low Threshold', minimum=1, maximum=255,
|
470 |
+
step=1, value=64)
|
471 |
+
canny_high_threshold = gr.Slider(label='Canny High Threshold', minimum=1, maximum=255,
|
472 |
+
step=1, value=128)
|
473 |
+
|
474 |
+
with gr.Tab(label='Inpaint'):
|
475 |
+
debugging_inpaint_preprocessor = gr.Checkbox(label='Debug Inpaint Preprocessing', value=False)
|
476 |
+
inpaint_disable_initial_latent = gr.Checkbox(label='Disable initial latent in inpaint', value=False)
|
477 |
+
inpaint_engine = gr.Dropdown(label='Inpaint Engine',
|
478 |
+
value=modules.config.default_inpaint_engine_version,
|
479 |
+
choices=flags.inpaint_engine_versions,
|
480 |
+
info='Version of inpaint model')
|
481 |
+
inpaint_strength = gr.Slider(label='Inpaint Denoising Strength',
|
482 |
+
minimum=0.0, maximum=1.0, step=0.001, value=1.0,
|
483 |
+
info='Same as the denoising strength in A1111 inpaint. '
|
484 |
+
'Only used in inpaint, not used in outpaint. '
|
485 |
+
'(Outpaint always use 1.0)')
|
486 |
+
inpaint_respective_field = gr.Slider(label='Inpaint Respective Field',
|
487 |
+
minimum=0.0, maximum=1.0, step=0.001, value=0.618,
|
488 |
+
info='The area to inpaint. '
|
489 |
+
'Value 0 is same as "Only Masked" in A1111. '
|
490 |
+
'Value 1 is same as "Whole Image" in A1111. '
|
491 |
+
'Only used in inpaint, not used in outpaint. '
|
492 |
+
'(Outpaint always use 1.0)')
|
493 |
+
inpaint_erode_or_dilate = gr.Slider(label='Mask Erode or Dilate',
|
494 |
+
minimum=-64, maximum=64, step=1, value=0,
|
495 |
+
info='Positive value will make white area in the mask larger, '
|
496 |
+
'negative value will make white area smaller.'
|
497 |
+
'(default is 0, always process before any mask invert)')
|
498 |
+
# inpaint_mask_upload_checkbox = gr.Checkbox(label='Enable Mask Upload', value=False)
|
499 |
+
# invert_mask_checkbox = gr.Checkbox(label='Invert Mask', value=False)
|
500 |
+
|
501 |
+
inpaint_ctrls = [debugging_inpaint_preprocessor, inpaint_disable_initial_latent, inpaint_engine,
|
502 |
+
inpaint_strength, inpaint_respective_field,
|
503 |
+
inpaint_mask_upload_checkbox, invert_mask_checkbox, inpaint_erode_or_dilate]
|
504 |
+
|
505 |
+
inpaint_mask_upload_checkbox.change(lambda x: gr.update(visible=x),
|
506 |
+
inputs=inpaint_mask_upload_checkbox,
|
507 |
+
outputs=inpaint_mask_image, queue=False, show_progress=False)
|
508 |
+
|
509 |
+
with gr.Tab(label='FreeU'):
|
510 |
+
freeu_enabled = gr.Checkbox(label='Enabled', value=False)
|
511 |
+
freeu_b1 = gr.Slider(label='B1', minimum=0, maximum=2, step=0.01, value=1.01)
|
512 |
+
freeu_b2 = gr.Slider(label='B2', minimum=0, maximum=2, step=0.01, value=1.02)
|
513 |
+
freeu_s1 = gr.Slider(label='S1', minimum=0, maximum=4, step=0.01, value=0.99)
|
514 |
+
freeu_s2 = gr.Slider(label='S2', minimum=0, maximum=4, step=0.01, value=0.95)
|
515 |
+
freeu_ctrls = [freeu_enabled, freeu_b1, freeu_b2, freeu_s1, freeu_s2]
|
516 |
+
|
517 |
+
def dev_mode_checked(r):
|
518 |
+
return gr.update(visible=r)
|
519 |
+
|
520 |
+
|
521 |
+
dev_mode.change(dev_mode_checked, inputs=[dev_mode], outputs=[dev_tools],
|
522 |
+
queue=False, show_progress=False)
|
523 |
|
524 |
+
def model_refresh_clicked():
|
525 |
+
modules.config.update_all_model_names()
|
526 |
+
results = [gr.update(choices=modules.config.model_filenames)]
|
527 |
+
results += [gr.update(choices=['None'] + modules.config.model_filenames)]
|
528 |
+
for i in range(modules.config.default_max_lora_number):
|
529 |
+
results += [gr.update(interactive=True), gr.update(choices=['None'] + modules.config.lora_filenames), gr.update()]
|
530 |
+
return results
|
531 |
+
|
532 |
+
model_refresh.click(model_refresh_clicked, [], [base_model, refiner_model] + lora_ctrls,
|
533 |
+
queue=False, show_progress=False)
|
534 |
|
535 |
performance_selection.change(lambda x: [gr.update(interactive=x != 'Extreme Speed')] * 11 +
|
536 |
[gr.update(visible=x != 'Extreme Speed')] * 1 +
|