Update webui.py
Browse files
webui.py
CHANGED
@@ -73,7 +73,7 @@ def generate_clicked(task):
|
|
73 |
gr.update(visible=True, value=product)
|
74 |
finished = True
|
75 |
|
76 |
-
# delete
|
77 |
if args_manager.args.disable_image_log:
|
78 |
for filepath in product:
|
79 |
if isinstance(filepath, str) and os.path.exists(filepath):
|
@@ -142,7 +142,7 @@ with shared.gradio_root:
|
|
142 |
skip_button.click(skip_clicked, inputs=currentTask, outputs=currentTask, queue=False, show_progress=False)
|
143 |
with gr.Row(elem_classes='advanced_check_row'):
|
144 |
input_image_checkbox = gr.Checkbox(label='Input Image', value=True, container=True, elem_classes='min_check')
|
145 |
-
advanced_checkbox = gr.Checkbox(label='Advanced', value=False, container=True, elem_classes=
|
146 |
with gr.Row(visible=True) as image_input_panel:
|
147 |
with gr.Tabs():
|
148 |
with gr.TabItem(label='Upscale or Variation') as uov_tab:
|
@@ -261,7 +261,7 @@ with shared.gradio_root:
|
|
261 |
aspect_ratios_selection = gr.Radio(label='Aspect Ratios', choices=modules.config.available_aspect_ratios,
|
262 |
value=modules.config.default_aspect_ratio, info='width × height',
|
263 |
elem_classes='aspect_ratios')
|
264 |
-
image_number = gr.Slider(label='Image Number', minimum=1, maximum=modules.config.default_max_image_number, step=1, value=
|
265 |
|
266 |
output_format = gr.Radio(label='Output Format',
|
267 |
choices=modules.flags.output_formats,
|
@@ -273,7 +273,7 @@ with shared.gradio_root:
|
|
273 |
value=modules.config.default_prompt_negative,
|
274 |
show_copy_button=True)
|
275 |
seed_random = gr.Checkbox(label='Random', value=True)
|
276 |
-
image_seed = gr.Textbox(label='Seed', value=0, max_lines=1, visible=
|
277 |
|
278 |
def random_checked(r):
|
279 |
return gr.update(visible=not r)
|
@@ -370,165 +370,167 @@ with shared.gradio_root:
|
|
370 |
|
371 |
with gr.Row():
|
372 |
model_refresh = gr.Button(label='Refresh', value='\U0001f504 Refresh All Files', variant='secondary', elem_classes='refresh_button')
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
def model_refresh_clicked():
|
522 |
-
modules.config.update_all_model_names()
|
523 |
-
results = [gr.update(choices=modules.config.model_filenames)]
|
524 |
-
results += [gr.update(choices=['None'] + modules.config.model_filenames)]
|
525 |
-
for i in range(modules.config.default_max_lora_number):
|
526 |
-
results += [gr.update(interactive=True), gr.update(choices=['None'] + modules.config.lora_filenames), gr.update()]
|
527 |
-
return results
|
528 |
-
|
529 |
-
model_refresh.click(model_refresh_clicked, [], [base_model, refiner_model] + lora_ctrls,
|
530 |
queue=False, show_progress=False)
|
531 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
532 |
performance_selection.change(lambda x: [gr.update(interactive=x != 'Extreme Speed')] * 11 +
|
533 |
[gr.update(visible=x != 'Extreme Speed')] * 1 +
|
534 |
[gr.update(interactive=x != 'Extreme Speed', value=x == 'Extreme Speed', )] * 1,
|
@@ -662,11 +664,11 @@ with shared.gradio_root:
|
|
662 |
def trigger_describe(mode, img):
|
663 |
if mode == flags.desc_type_photo:
|
664 |
from extras.interrogate import default_interrogator as default_interrogator_photo
|
665 |
-
return default_interrogator_photo(img), ["
|
666 |
if mode == flags.desc_type_anime:
|
667 |
from extras.wd14tagger import default_interrogator as default_interrogator_anime
|
668 |
-
return default_interrogator_anime(img), ["
|
669 |
-
return mode, ["
|
670 |
|
671 |
desc_btn.click(trigger_describe, inputs=[desc_method, desc_input_image],
|
672 |
outputs=[prompt, style_selections], show_progress=True, queue=False)
|
|
|
73 |
gr.update(visible=True, value=product)
|
74 |
finished = True
|
75 |
|
76 |
+
# delete Image temp images, only keep gradio temp images
|
77 |
if args_manager.args.disable_image_log:
|
78 |
for filepath in product:
|
79 |
if isinstance(filepath, str) and os.path.exists(filepath):
|
|
|
142 |
skip_button.click(skip_clicked, inputs=currentTask, outputs=currentTask, queue=False, show_progress=False)
|
143 |
with gr.Row(elem_classes='advanced_check_row'):
|
144 |
input_image_checkbox = gr.Checkbox(label='Input Image', value=True, container=True, elem_classes='min_check')
|
145 |
+
advanced_checkbox = gr.Checkbox(label='Advanced', value=False, container=True, elem_classes='min_check')
|
146 |
with gr.Row(visible=True) as image_input_panel:
|
147 |
with gr.Tabs():
|
148 |
with gr.TabItem(label='Upscale or Variation') as uov_tab:
|
|
|
261 |
aspect_ratios_selection = gr.Radio(label='Aspect Ratios', choices=modules.config.available_aspect_ratios,
|
262 |
value=modules.config.default_aspect_ratio, info='width × height',
|
263 |
elem_classes='aspect_ratios')
|
264 |
+
image_number = gr.Slider(label='Image Number', minimum=1, maximum=modules.config.default_max_image_number, step=1, value=1)
|
265 |
|
266 |
output_format = gr.Radio(label='Output Format',
|
267 |
choices=modules.flags.output_formats,
|
|
|
273 |
value=modules.config.default_prompt_negative,
|
274 |
show_copy_button=True)
|
275 |
seed_random = gr.Checkbox(label='Random', value=True)
|
276 |
+
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
|
277 |
|
278 |
def random_checked(r):
|
279 |
return gr.update(visible=not r)
|
|
|
370 |
|
371 |
with gr.Row():
|
372 |
model_refresh = gr.Button(label='Refresh', value='\U0001f504 Refresh All Files', variant='secondary', elem_classes='refresh_button')
|
373 |
+
|
374 |
+
with gr.Column(visible=False):
|
375 |
+
with gr.Tab(label='Advanced', elem_id="advancedAdvancedSettings"):
|
376 |
+
guidance_scale = gr.Slider(label='Guidance Scale', minimum=1.0, maximum=30.0, step=0.01,
|
377 |
+
value=modules.config.default_cfg_scale,
|
378 |
+
info='Higher value means style is cleaner, vivider, and more artistic.')
|
379 |
+
sharpness = gr.Slider(label='Image Sharpness', minimum=0.0, maximum=30.0, step=0.001,
|
380 |
+
value=modules.config.default_sample_sharpness,
|
381 |
+
info='Higher value means image and texture are sharper.')
|
382 |
+
dev_mode = gr.Checkbox(label='Developer Debug Mode', value=True, container=True)
|
383 |
+
|
384 |
+
with gr.Column(visible=True) as dev_tools:
|
385 |
+
with gr.Tab(label='Debug Tools'):
|
386 |
+
adm_scaler_positive = gr.Slider(label='Positive ADM Guidance Scaler', minimum=0.1, maximum=3.0,
|
387 |
+
step=0.001, value=1.5, info='The scaler multiplied to positive ADM (use 1.0 to disable). ')
|
388 |
+
adm_scaler_negative = gr.Slider(label='Negative ADM Guidance Scaler', minimum=0.1, maximum=3.0,
|
389 |
+
step=0.001, value=0.8, info='The scaler multiplied to negative ADM (use 1.0 to disable). ')
|
390 |
+
adm_scaler_end = gr.Slider(label='ADM Guidance End At Step', minimum=0.0, maximum=1.0,
|
391 |
+
step=0.001, value=0.3,
|
392 |
+
info='When to end the guidance from positive/negative ADM. ')
|
393 |
+
|
394 |
+
refiner_swap_method = gr.Dropdown(label='Refiner swap method', value=flags.refiner_swap_method,
|
395 |
+
choices=['joint', 'separate', 'vae'])
|
396 |
+
|
397 |
+
adaptive_cfg = gr.Slider(label='CFG Mimicking from TSNR', minimum=1.0, maximum=30.0, step=0.01,
|
398 |
+
value=modules.config.default_cfg_tsnr,
|
399 |
+
info='Enabling Image\'s implementation of CFG mimicking for TSNR '
|
400 |
+
'(effective when real CFG > mimicked CFG).')
|
401 |
+
sampler_name = gr.Dropdown(label='Sampler', choices=flags.sampler_list,
|
402 |
+
value=modules.config.default_sampler)
|
403 |
+
scheduler_name = gr.Dropdown(label='Scheduler', choices=flags.scheduler_list,
|
404 |
+
value=modules.config.default_scheduler)
|
405 |
+
|
406 |
+
generate_image_grid = gr.Checkbox(label='Generate Image Grid for Each Batch',
|
407 |
+
info='(Experimental) This may cause performance problems on some computers and certain internet conditions.',
|
408 |
+
value=False)
|
409 |
+
|
410 |
+
overwrite_step = gr.Slider(label='Forced Overwrite of Sampling Step',
|
411 |
+
minimum=-1, maximum=200, step=1,
|
412 |
+
value=modules.config.default_overwrite_step,
|
413 |
+
info='Set as -1 to disable. For developer debugging.')
|
414 |
+
overwrite_switch = gr.Slider(label='Forced Overwrite of Refiner Switch Step',
|
415 |
+
minimum=-1, maximum=200, step=1,
|
416 |
+
value=modules.config.default_overwrite_switch,
|
417 |
+
info='Set as -1 to disable. For developer debugging.')
|
418 |
+
overwrite_width = gr.Slider(label='Forced Overwrite of Generating Width',
|
419 |
+
minimum=-1, maximum=2048, step=1, value=-1,
|
420 |
+
info='Set as -1 to disable. For developer debugging. '
|
421 |
+
'Results will be worse for non-standard numbers that SDXL is not trained on.')
|
422 |
+
overwrite_height = gr.Slider(label='Forced Overwrite of Generating Height',
|
423 |
+
minimum=-1, maximum=2048, step=1, value=-1,
|
424 |
+
info='Set as -1 to disable. For developer debugging. '
|
425 |
+
'Results will be worse for non-standard numbers that SDXL is not trained on.')
|
426 |
+
overwrite_vary_strength = gr.Slider(label='Forced Overwrite of Denoising Strength of "Vary"',
|
427 |
+
minimum=-1, maximum=1.0, step=0.001, value=-1,
|
428 |
+
info='Set as negative number to disable. For developer debugging.')
|
429 |
+
overwrite_upscale_strength = gr.Slider(label='Forced Overwrite of Denoising Strength of "Upscale"',
|
430 |
+
minimum=-1, maximum=1.0, step=0.001, value=-1,
|
431 |
+
info='Set as negative number to disable. For developer debugging.')
|
432 |
+
disable_preview = gr.Checkbox(label='Disable Preview', value=False,
|
433 |
+
info='Disable preview during generation.')
|
434 |
+
disable_intermediate_results = gr.Checkbox(label='Disable Intermediate Results',
|
435 |
+
value=modules.config.default_performance == 'Extreme Speed',
|
436 |
+
interactive=modules.config.default_performance != 'Extreme Speed',
|
437 |
+
info='Disable intermediate results during generation, only show final gallery.')
|
438 |
+
disable_seed_increment = gr.Checkbox(label='Disable seed increment',
|
439 |
+
info='Disable automatic seed increment when image number is > 1.',
|
440 |
+
value=False)
|
441 |
+
|
442 |
+
if not args_manager.args.disable_metadata:
|
443 |
+
save_metadata_to_images = gr.Checkbox(label='Save Metadata to Images', value=True,
|
444 |
+
info='Adds parameters to generated images allowing manual regeneration.')
|
445 |
+
metadata_scheme = gr.Radio(label='Metadata Scheme', choices=flags.metadata_scheme, value=modules.config.default_metadata_scheme,
|
446 |
+
info='Image Prompt parameters are not included. Use png and a1111 for compatibility with Civitai.',
|
447 |
+
visible=True)
|
448 |
+
|
449 |
+
save_metadata_to_images.change(lambda x: gr.update(visible=x), inputs=[save_metadata_to_images], outputs=[metadata_scheme],
|
450 |
+
queue=False, show_progress=False)
|
451 |
+
|
452 |
+
with gr.Tab(label='Control'):
|
453 |
+
debugging_cn_preprocessor = gr.Checkbox(label='Debug Preprocessors', value=True,
|
454 |
+
info='See the results from preprocessors.')
|
455 |
+
skipping_cn_preprocessor = gr.Checkbox(label='Skip Preprocessors', value=True,
|
456 |
+
info='Do not preprocess images. (Inputs are already canny/depth/cropped-face/etc.)')
|
457 |
+
|
458 |
+
mixing_image_prompt_and_vary_upscale = gr.Checkbox(label='Mixing Image Prompt and Vary/Upscale',
|
459 |
+
value=True)
|
460 |
+
mixing_image_prompt_and_inpaint = gr.Checkbox(label='Mixing Image Prompt and Inpaint',
|
461 |
+
value=True)
|
462 |
+
|
463 |
+
controlnet_softness = gr.Slider(label='Softness of ControlNet', minimum=0.0, maximum=1.0,
|
464 |
+
step=0.001, value=0.25,
|
465 |
+
info='Similar to the Control Mode in A1111 (use 0.0 to disable). ')
|
466 |
+
|
467 |
+
with gr.Tab(label='Canny'):
|
468 |
+
canny_low_threshold = gr.Slider(label='Canny Low Threshold', minimum=1, maximum=255,
|
469 |
+
step=1, value=64)
|
470 |
+
canny_high_threshold = gr.Slider(label='Canny High Threshold', minimum=1, maximum=255,
|
471 |
+
step=1, value=128)
|
472 |
+
|
473 |
+
with gr.Tab(label='Inpaint'):
|
474 |
+
debugging_inpaint_preprocessor = gr.Checkbox(label='Debug Inpaint Preprocessing', value=True)
|
475 |
+
inpaint_disable_initial_latent = gr.Checkbox(label='Disable initial latent in inpaint', value=False)
|
476 |
+
inpaint_engine = gr.Dropdown(label='Inpaint Engine',
|
477 |
+
value=modules.config.default_inpaint_engine_version,
|
478 |
+
choices=flags.inpaint_engine_versions,
|
479 |
+
info='Version of inpaint model')
|
480 |
+
inpaint_strength = gr.Slider(label='Inpaint Denoising Strength',
|
481 |
+
minimum=0.0, maximum=1.0, step=0.001, value=1.0,
|
482 |
+
info='Same as the denoising strength in A1111 inpaint. '
|
483 |
+
'Only used in inpaint, not used in outpaint. '
|
484 |
+
'(Outpaint always use 1.0)')
|
485 |
+
inpaint_respective_field = gr.Slider(label='Inpaint Respective Field',
|
486 |
+
minimum=0.0, maximum=1.0, step=0.001, value=0.618,
|
487 |
+
info='The area to inpaint. '
|
488 |
+
'Value 0 is same as "Only Masked" in A1111. '
|
489 |
+
'Value 1 is same as "Whole Image" in A1111. '
|
490 |
+
'Only used in inpaint, not used in outpaint. '
|
491 |
+
'(Outpaint always use 1.0)')
|
492 |
+
inpaint_erode_or_dilate = gr.Slider(label='Mask Erode or Dilate',
|
493 |
+
minimum=-64, maximum=64, step=1, value=0,
|
494 |
+
info='Positive value will make white area in the mask larger, '
|
495 |
+
'negative value will make white area smaller.'
|
496 |
+
'(default is 0, always process before any mask invert)')
|
497 |
+
# inpaint_mask_upload_checkbox = gr.Checkbox(label='Enable Mask Upload', value=True)
|
498 |
+
# invert_mask_checkbox = gr.Checkbox(label='Invert Mask', value=False)
|
499 |
+
|
500 |
+
inpaint_ctrls = [debugging_inpaint_preprocessor, inpaint_disable_initial_latent, inpaint_engine,
|
501 |
+
inpaint_strength, inpaint_respective_field,
|
502 |
+
inpaint_mask_upload_checkbox, invert_mask_checkbox, inpaint_erode_or_dilate]
|
503 |
+
|
504 |
+
inpaint_mask_upload_checkbox.change(lambda x: gr.update(visible=x),
|
505 |
+
inputs=inpaint_mask_upload_checkbox,
|
506 |
+
outputs=inpaint_mask_image, queue=False, show_progress=False)
|
507 |
+
|
508 |
+
with gr.Tab(label='FreeU'):
|
509 |
+
freeu_enabled = gr.Checkbox(label='Enabled', value=False)
|
510 |
+
freeu_b1 = gr.Slider(label='B1', minimum=0, maximum=2, step=0.01, value=1.01)
|
511 |
+
freeu_b2 = gr.Slider(label='B2', minimum=0, maximum=2, step=0.01, value=1.02)
|
512 |
+
freeu_s1 = gr.Slider(label='S1', minimum=0, maximum=4, step=0.01, value=0.99)
|
513 |
+
freeu_s2 = gr.Slider(label='S2', minimum=0, maximum=4, step=0.01, value=0.95)
|
514 |
+
freeu_ctrls = [freeu_enabled, freeu_b1, freeu_b2, freeu_s1, freeu_s2]
|
515 |
+
|
516 |
+
def dev_mode_checked(r):
|
517 |
+
return gr.update(visible=r)
|
518 |
+
|
519 |
+
|
520 |
+
dev_mode.change(dev_mode_checked, inputs=[dev_mode], outputs=[dev_tools],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
521 |
queue=False, show_progress=False)
|
522 |
|
523 |
+
def model_refresh_clicked():
|
524 |
+
modules.config.update_all_model_names()
|
525 |
+
results = [gr.update(choices=modules.config.model_filenames)]
|
526 |
+
results += [gr.update(choices=['None'] + modules.config.model_filenames)]
|
527 |
+
for i in range(modules.config.default_max_lora_number):
|
528 |
+
results += [gr.update(interactive=True), gr.update(choices=['None'] + modules.config.lora_filenames), gr.update()]
|
529 |
+
return results
|
530 |
+
|
531 |
+
model_refresh.click(model_refresh_clicked, [], [base_model, refiner_model] + lora_ctrls,
|
532 |
+
queue=False, show_progress=False)
|
533 |
+
|
534 |
performance_selection.change(lambda x: [gr.update(interactive=x != 'Extreme Speed')] * 11 +
|
535 |
[gr.update(visible=x != 'Extreme Speed')] * 1 +
|
536 |
[gr.update(interactive=x != 'Extreme Speed', value=x == 'Extreme Speed', )] * 1,
|
|
|
664 |
def trigger_describe(mode, img):
|
665 |
if mode == flags.desc_type_photo:
|
666 |
from extras.interrogate import default_interrogator as default_interrogator_photo
|
667 |
+
return default_interrogator_photo(img), ["Image V2", "Image Enhance", "Image Sharp"]
|
668 |
if mode == flags.desc_type_anime:
|
669 |
from extras.wd14tagger import default_interrogator as default_interrogator_anime
|
670 |
+
return default_interrogator_anime(img), ["Image V2", "Image Masterpiece"]
|
671 |
+
return mode, ["Image V2"]
|
672 |
|
673 |
desc_btn.click(trigger_describe, inputs=[desc_method, desc_input_image],
|
674 |
outputs=[prompt, style_selections], show_progress=True, queue=False)
|