From 0d18460fe8e600acfe9139e3c24b21b0974bd55b Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Tue, 4 Apr 2023 09:19:25 -0400 Subject: [PATCH] add clip skip --- config.json | 3 +- extensions-builtin/sd-extension-system-info | 2 +- .../stable-diffusion-webui-images-browser | 2 +- modules/lora | 2 +- modules/lycoris | 2 +- modules/postprocessing.py | 1 - modules/shared.py | 11 +++-- modules/ui.py | 27 ++++++----- ui-config.json | 45 ++++++++++++++++++- user.css | 8 ++-- 10 files changed, 76 insertions(+), 27 deletions(-) diff --git a/config.json b/config.json index 5a63390f1..c83180ade 100644 --- a/config.json +++ b/config.json @@ -230,5 +230,6 @@ "control_net_sync_field_args": false, "image_browser_use_thumbnail": false, "image_browser_thumbnail_size": 200.0, - "disable_all_extensions": "none" + "disable_all_extensions": "none", + "openpose3d_use_online_version": false } \ No newline at end of file diff --git a/extensions-builtin/sd-extension-system-info b/extensions-builtin/sd-extension-system-info index bd94a6ca4..0211c7984 160000 --- a/extensions-builtin/sd-extension-system-info +++ b/extensions-builtin/sd-extension-system-info @@ -1 +1 @@ -Subproject commit bd94a6ca4ddc82d8ddc3497bc4a93ac09d2a0886 +Subproject commit 0211c798462f86e0f78ce4ee1530d25edff22b1f diff --git a/extensions-builtin/stable-diffusion-webui-images-browser b/extensions-builtin/stable-diffusion-webui-images-browser index 07940948b..766b6bd42 160000 --- a/extensions-builtin/stable-diffusion-webui-images-browser +++ b/extensions-builtin/stable-diffusion-webui-images-browser @@ -1 +1 @@ -Subproject commit 07940948bac3f66b5437170437329f07e7e71b04 +Subproject commit 766b6bd4279d3336089a4163731cf01073470d1e diff --git a/modules/lora b/modules/lora index 82c2553f0..8eb60baf3 160000 --- a/modules/lora +++ b/modules/lora @@ -1 +1 @@ -Subproject commit 82c2553f07112aafd3ed6da52531c45949323818 +Subproject commit 8eb60baf3a920fb83a862d95fbfc73d1d19b7b31 diff --git a/modules/lycoris b/modules/lycoris index c3d925421..a7bfc2ab8 160000 --- a/modules/lycoris +++ b/modules/lycoris @@ -1 +1 @@ -Subproject commit c3d925421209a22a60d863ffa3de0b3e7e89f047 +Subproject commit a7bfc2ab83956680ef6c9ced34d08cbc251fce66 diff --git a/modules/postprocessing.py b/modules/postprocessing.py index f58e8bb3d..10c443137 100644 --- a/modules/postprocessing.py +++ b/modules/postprocessing.py @@ -62,7 +62,6 @@ def run_postprocessing(extras_mode, image, image_folder, input_dir, output_dir, if opts.enable_pnginfo: _geninfo, items = images.read_info_from_image(image) - print("I", items) for k, v in items.items(): pp.image.info[k] = v pp.image.info["postprocessing"] = infotext diff --git a/modules/shared.py b/modules/shared.py index 8867304c3..54f3518d5 100644 --- a/modules/shared.py +++ b/modules/shared.py @@ -86,6 +86,11 @@ def reload_hypernetworks(): hypernetworks = hypernetwork.list_hypernetworks(cmd_opts.hypernetwork_dir) +sd_upscalers = [] + +sd_model = None + +clip_model = None class State: skipped = False @@ -600,12 +605,6 @@ latent_upscale_modes = { "Latent (nearest-exact)": {"mode": "nearest-exact", "antialias": False}, } -sd_upscalers = [] - -sd_model = None - -clip_model = None - progress_print_out = sys.stdout diff --git a/modules/ui.py b/modules/ui.py index cecfa633a..d00327636 100644 --- a/modules/ui.py +++ b/modules/ui.py @@ -166,10 +166,12 @@ def interrogate_deepbooru(image): prompt = deepbooru.model.tag(image) return gr.update() if prompt is None else prompt +def change_clip_skip(val): + shared.opts.CLIP_stop_at_last_layers = val def create_seed_inputs(target_interface): with FormRow(elem_id=target_interface + '_seed_row', variant="compact"): - seed = (gr.Textbox if cmd_opts.use_textbox_seed else gr.Number)(label='Seed', value=-1, elem_id=target_interface + '_seed') + seed = gr.Number(label='Seed', value=-1, elem_id=target_interface + '_seed') seed.style(container=False) random_seed = ToolButton(random_symbol, elem_id=target_interface + '_random_seed') reuse_seed = ToolButton(reuse_symbol, elem_id=target_interface + '_reuse_seed') @@ -177,16 +179,16 @@ def create_seed_inputs(target_interface): with FormRow(visible=True, elem_id=target_interface + '_subseed_row') as seed_extra_row_1: subseed = gr.Number(label='Variation seed', value=-1, elem_id=target_interface + '_subseed') subseed.style(container=False) - random_subseed = ToolButton(random_symbol, elem_id=target_interface + '_random_subseed') + # random_subseed = ToolButton(random_symbol, elem_id=target_interface + '_random_subseed') reuse_subseed = ToolButton(reuse_symbol, elem_id=target_interface + '_reuse_subseed') - subseed_strength = gr.Slider(label='Variation strength', value=0.0, minimum=0, maximum=1, step=0.01, elem_id=target_interface + '_subseed_strength') + subseed_strength = gr.Slider(label='Strength', value=0.0, minimum=0, maximum=1, step=0.01, elem_id=target_interface + '_subseed_strength') with FormRow(visible=False) as seed_extra_row_2: seed_resize_from_w = gr.Slider(minimum=0, maximum=2048, step=8, label="Resize seed from width", value=0, elem_id=target_interface + '_seed_resize_from_w') seed_resize_from_h = gr.Slider(minimum=0, maximum=2048, step=8, label="Resize seed from height", value=0, elem_id=target_interface + '_seed_resize_from_h') - random_seed.click(fn=lambda: -1, show_progress=False, inputs=[], outputs=[seed]) - random_subseed.click(fn=lambda: -1, show_progress=False, inputs=[], outputs=[subseed]) + random_seed.click(fn=lambda: [-1, -1], show_progress=False, inputs=[], outputs=[seed, subseed]) + # random_subseed.click(fn=lambda: -1, show_progress=False, inputs=[], outputs=[subseed]) return seed, reuse_seed, subseed, reuse_subseed, subseed_strength, seed_resize_from_h, seed_resize_from_w @@ -466,7 +468,10 @@ def create_ui(): batch_size = gr.Slider(minimum=1, maximum=8, step=1, label='Batch size', value=1, elem_id="txt2img_batch_size") elif category == "cfg": - cfg_scale = gr.Slider(minimum=1.0, maximum=30.0, step=0.5, label='CFG Scale', value=7.0, elem_id="txt2img_cfg_scale") + with FormRow(): + cfg_scale = gr.Slider(minimum=1.0, maximum=30.0, step=0.5, label='CFG Scale', value=7.0, elem_id="txt2img_cfg_scale") + clip_skip = gr.Slider(label='CLIP Skip', value=1, minimum=1, maximum=4, step=1, elem_id='txt2img_clip_skip', interactive=True) + clip_skip.change(fn=change_clip_skip, show_progress=False, inputs=clip_skip) elif category == "seed": seed, reuse_seed, subseed, reuse_subseed, subseed_strength, seed_resize_from_h, seed_resize_from_w = create_seed_inputs('txt2img') @@ -475,7 +480,7 @@ def create_ui(): with FormRow(elem_classes="checkboxes-row", variant="compact"): restore_faces = gr.Checkbox(label='Restore faces', value=False, visible=len(shared.face_restorers) > 1, elem_id="txt2img_restore_faces") tiling = gr.Checkbox(label='Tiling', value=False, elem_id="txt2img_tiling") - enable_hr = gr.Checkbox(label='Hires. fix', value=False, elem_id="txt2img_enable_hr") + enable_hr = gr.Checkbox(label='Hires fix', value=False, elem_id="txt2img_enable_hr") hr_final_resolution = FormHTML(value="", elem_id="txtimg_hr_finalres", label="Upscaled resolution", interactive=False) elif category == "hires_fix": @@ -598,7 +603,7 @@ def create_ui(): (height, "Size-2"), (batch_size, "Batch size"), (subseed, "Variation seed"), - (subseed_strength, "Variation seed strength"), + (subseed_strength, "Variation strength"), (seed_resize_from_w, "Seed resize from-1"), (seed_resize_from_h, "Seed resize from-2"), (denoising_strength, "Denoising strength"), @@ -677,7 +682,7 @@ def create_ui(): with gr.TabItem('Inpaint sketch', id='inpaint_sketch', elem_id="img2img_inpaint_sketch_tab") as tab_inpaint_color: inpaint_color_sketch = gr.Image(label="Color sketch inpainting", show_label=False, elem_id="inpaint_sketch", source="upload", interactive=True, type="pil", tool="color-sketch", image_mode="RGBA").style(height=480) - inpaint_color_sketch_orig = gr.State(None) + inpaint_color_sketch_orig = gr.State(None) # pylint: disable=abstract-class-instantiated add_copy_image_controls('inpaint_sketch', inpaint_color_sketch) def update_orig(image, state): @@ -750,6 +755,8 @@ def create_ui(): cfg_scale = gr.Slider(minimum=1.0, maximum=30.0, step=0.5, label='CFG Scale', value=7.0, elem_id="img2img_cfg_scale") image_cfg_scale = gr.Slider(minimum=0, maximum=3.0, step=0.05, label='Image CFG Scale', value=1.5, elem_id="img2img_image_cfg_scale", visible=shared.sd_model and shared.sd_model.cond_stage_key == "edit") denoising_strength = gr.Slider(minimum=0.0, maximum=1.0, step=0.01, label='Denoising strength', value=0.75, elem_id="img2img_denoising_strength") + clip_skip = gr.Slider(label='CLIP Skip', value=1, minimum=1, maximum=4, step=1, elem_id='img2img_clip_skip', interactive=True) + clip_skip.change(fn=change_clip_skip, show_progress=False, inputs=clip_skip) elif category == "seed": seed, reuse_seed, subseed, reuse_subseed, subseed_strength, seed_resize_from_h, seed_resize_from_w = create_seed_inputs('img2img') @@ -937,7 +944,7 @@ def create_ui(): (height, "Size-2"), (batch_size, "Batch size"), (subseed, "Variation seed"), - (subseed_strength, "Variation seed strength"), + (subseed_strength, "Variation strength"), (seed_resize_from_w, "Seed resize from-1"), (seed_resize_from_h, "Seed resize from-2"), (denoising_strength, "Denoising strength"), diff --git a/ui-config.json b/ui-config.json index 9ef52db71..fdf64d257 100644 --- a/ui-config.json +++ b/ui-config.json @@ -1560,5 +1560,48 @@ "customscript/seed_travel.py/img2img/Curve strength/value": 3, "customscript/seed_travel.py/img2img/Curve strength/minimum": 0.0, "customscript/seed_travel.py/img2img/Curve strength/maximum": 10.0, - "customscript/seed_travel.py/img2img/Curve strength/step": 0.1 + "customscript/seed_travel.py/img2img/Curve strength/step": 0.1, + "txt2img/Strength/visible": true, + "txt2img/Strength/value": 0.0, + "txt2img/Strength/minimum": 0, + "txt2img/Strength/maximum": 1, + "txt2img/Strength/step": 0.01, + "txt2img/CLIP Skip/visible": true, + "txt2img/CLIP Skip/value": 1, + "txt2img/CLIP Skip/minimum": 1, + "txt2img/CLIP Skip/maximum": 4, + "txt2img/CLIP Skip/step": 1, + "img2img/Strength/visible": true, + "img2img/Strength/value": 0.0, + "img2img/Strength/minimum": 0, + "img2img/Strength/maximum": 1, + "img2img/Strength/step": 0.01, + "img2img/CLIP Skip/visible": true, + "img2img/CLIP Skip/value": 1, + "img2img/CLIP Skip/minimum": 1, + "img2img/CLIP Skip/maximum": 4, + "img2img/CLIP Skip/step": 1, + "txt2img/Hires fix/visible": true, + "txt2img/Hires fix/value": false, + "customscript/postprocessing_rembg.py/extras/Remove background/visible": true, + "customscript/postprocessing_rembg.py/extras/Remove background/value": "None", + "customscript/postprocessing_rembg.py/extras/Return mask/visible": true, + "customscript/postprocessing_rembg.py/extras/Return mask/value": false, + "customscript/postprocessing_rembg.py/extras/Alpha matting/visible": true, + "customscript/postprocessing_rembg.py/extras/Alpha matting/value": false, + "customscript/postprocessing_rembg.py/extras/Erode size/visible": true, + "customscript/postprocessing_rembg.py/extras/Erode size/value": 10, + "customscript/postprocessing_rembg.py/extras/Erode size/minimum": 0, + "customscript/postprocessing_rembg.py/extras/Erode size/maximum": 40, + "customscript/postprocessing_rembg.py/extras/Erode size/step": 1, + "customscript/postprocessing_rembg.py/extras/Foreground threshold/visible": true, + "customscript/postprocessing_rembg.py/extras/Foreground threshold/value": 240, + "customscript/postprocessing_rembg.py/extras/Foreground threshold/minimum": 0, + "customscript/postprocessing_rembg.py/extras/Foreground threshold/maximum": 255, + "customscript/postprocessing_rembg.py/extras/Foreground threshold/step": 1, + "customscript/postprocessing_rembg.py/extras/Background threshold/visible": true, + "customscript/postprocessing_rembg.py/extras/Background threshold/value": 10, + "customscript/postprocessing_rembg.py/extras/Background threshold/minimum": 0, + "customscript/postprocessing_rembg.py/extras/Background threshold/maximum": 255, + "customscript/postprocessing_rembg.py/extras/Background threshold/step": 1 } \ No newline at end of file diff --git a/user.css b/user.css index 6f0168899..238068e19 100644 --- a/user.css +++ b/user.css @@ -53,7 +53,7 @@ div.gradio-container.dark > div.w-full.flex.flex-col.min-h-screen > div { backgr .rounded-lg { border-radius: 0; } .tabs { background-color: black; } .gradio-button.tool { border-radius: 0; height: 2em; } -.block.token-counter span { border-radius: 0; } +.block.token-counter span { background-color: #222 !important; box-shadow: 2px 2px 2px #111; border: none !important; border-radius: 0; font-size: 0.8rem; } .tab-nav { zoom: 130%; margin-bottom: 16px; border-bottom: 2px solid #CE6400 !important; padding-bottom: 2px; } .label-wrap { margin: 16px 0px 8px 0px; } .gradio-slider input[type="number"] { width: 4.5em; font-size: 0.8rem; } @@ -76,7 +76,7 @@ div.gradio-container.dark > div.w-full.flex.flex-col.min-h-screen > div { backgr #quicksettings .gr-button-tool { font-size: 1.6rem; box-shadow: none; margin-left: -20px; margin-top: -2px; height: 2.4em; } #quicksettings > div, #quicksettings > fieldset { min-width: 26em; max-width: 26em; line-height: 2em; } #refresh_sd_model_checkpoint { height: 40px; margin-left: -14px; background: #333333; box-shadow: none; } -#refresh_txt2img_styles, #refresh_img2img_styles, #open_folder_txt2img, #open_folder_img2img, #open_folder_extras, #footer, #style_pos_col, #style_neg_col, #roll_col, #save_zip_txt2img, #save_zip_img2img, #extras_upscaler_2, #extras_upscaler_2_visibility, #txt2img_res_switch_btn, #img2img_res_switch_btn, #txt2img_seed_resize_from_w, #txt2img_seed_resize_from_h, #txt2img_subseed_show, #txt2img_reuse_seed, #txt2img_reuse_subseed, #txt2img_tiling, #img2img_subseed_show { display: none; } +#refresh_txt2img_styles, #refresh_img2img_styles, #open_folder_txt2img, #open_folder_img2img, #open_folder_extras, #footer, #style_pos_col, #style_neg_col, #roll_col, #save_zip_txt2img, #save_zip_img2img, #extras_upscaler_2, #extras_upscaler_2_visibility, #txt2img_res_switch_btn, #img2img_res_switch_btn, #txt2img_seed_resize_from_w, #txt2img_seed_resize_from_h, #txt2img_subseed_show, #txt2img_reuse_seed, #txt2img_reuse_subseed, #img2img_reuse_seed, #img2img_reuse_subseed, #txt2img_tiling, #img2img_subseed_show { display: none; } #save-animation { border-radius: 0 !important; margin-bottom: 16px; background-color: #111111; } #script_list { padding: 4px; margin-top: 20px; } #settings > div.flex-wrap { width: 15em; } @@ -178,13 +178,13 @@ div.gradio-container.dark > div.w-full.flex.flex-col.min-h-screen > div { backgr --button-cancel-text-color: white; --button-cancel-text-color-hover: var(--button-cancel-text-color); --button-primary-background-fill: linear-gradient(to bottom right, var(--primary-500), var(--primary-800)); - --button-primary-background-fill-hover: linear-gradient(to bottom right, var(--primary-500), var(--primary-500)); + --button-primary-background-fill-hover: linear-gradient(to bottom right, var(--primary-500), var(--primary-300)); --button-primary-border-color: var(--primary-500); --button-primary-border-color-hover: var(--button-primary-border-color); --button-primary-text-color: white; --button-primary-text-color-hover: var(--button-primary-text-color); --button-secondary-background-fill: linear-gradient(to bottom right, var(--neutral-600), var(--neutral-800)); - --button-secondary-background-fill-hover: linear-gradient(to bottom right, var(--neutral-600), var(--neutral-600)); + --button-secondary-background-fill-hover: linear-gradient(to bottom right, var(--neutral-600), var(--neutral-400)); --button-secondary-border-color: var(--neutral-600); --button-secondary-border-color-hover: var(--button-secondary-border-color); --button-secondary-text-color: white;