From 8bfc90202dcde1dec634479aaaa9a949a195d531 Mon Sep 17 00:00:00 2001 From: lllyasviel Date: Wed, 4 Oct 2023 15:15:41 -0700 Subject: [PATCH] making debug easier (#542) * making debug easier * making debug easier --- fooocus_version.py | 2 +- modules/async_worker.py | 23 +++++++++++++++++++++++ webui.py | 22 ++++++++++++++++++++++ 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/fooocus_version.py b/fooocus_version.py index 4de40ce6..30796d26 100644 --- a/fooocus_version.py +++ b/fooocus_version.py @@ -1 +1 @@ -version = '2.0.88' +version = '2.0.89' diff --git a/modules/async_worker.py b/modules/async_worker.py index b9f0d5e6..83550e3b 100644 --- a/modules/async_worker.py +++ b/modules/async_worker.py @@ -48,6 +48,7 @@ def worker(): prompt, negative_prompt, style_selections, performance_selction, \ aspect_ratios_selction, image_number, image_seed, sharpness, adm_scaler_positive, adm_scaler_negative, guidance_scale, adaptive_cfg, sampler_name, scheduler_name, \ + overwrite_step, overwrite_switch, overwrite_width, overwrite_height, overwrite_vary_strength, overwrite_upscale_strength, \ base_model_name, refiner_model_name, \ l1, w1, l2, w2, l3, w3, l4, w4, l5, w5, \ input_image_checkbox, current_tab, \ @@ -95,10 +96,22 @@ def worker(): steps = 60 switch = 40 + if overwrite_step > 0: + steps = overwrite_step + + if overwrite_switch > 0: + switch = overwrite_switch + pipeline.clear_all_caches() # save memory width, height = aspect_ratios[aspect_ratios_selction] + if overwrite_width > 0: + width = overwrite_width + + if overwrite_height > 0: + height = overwrite_height + if input_image_checkbox: progressbar(0, 'Image processing ...') if current_tab == 'uov' and uov_method != flags.disabled and uov_input_image is not None: @@ -113,6 +126,8 @@ def worker(): denoising_strength = 0.5 if 'strong' in uov_method: denoising_strength = 0.85 + if overwrite_vary_strength > 0: + denoising_strength = overwrite_vary_strength initial_pixels = core.numpy_to_pytorch(uov_input_image) progressbar(0, 'VAE encoding ...') initial_latent = core.encode_vae(vae=pipeline.xl_base_patched.vae, pixels=initial_pixels) @@ -169,6 +184,14 @@ def worker(): denoising_strength = 1.0 - 0.618 steps = int(steps * 0.618) switch = int(steps * 0.67) + + if overwrite_upscale_strength > 0: + denoising_strength = overwrite_upscale_strength + if overwrite_step > 0: + steps = overwrite_step + if overwrite_switch > 0: + switch = overwrite_switch + initial_pixels = core.numpy_to_pytorch(uov_input_image) progressbar(0, 'VAE encoding ...') diff --git a/webui.py b/webui.py index 2fbfb45b..57f36dfb 100644 --- a/webui.py +++ b/webui.py @@ -171,6 +171,27 @@ with shared.gradio_root: sampler_name = gr.Dropdown(label='Sampler', choices=flags.sampler_list, value=flags.default_sampler, info='Only effective in non-inpaint mode.') scheduler_name = gr.Dropdown(label='Scheduler', choices=flags.scheduler_list, value=flags.default_scheduler, info='Scheduler of Sampler.') + overwrite_step = gr.Slider(label='Forced Overwrite of Sampling Step', + minimum=-1, maximum=200, step=1, value=-1, + info='Set as -1 to disable. For developer debugging.') + overwrite_switch = gr.Slider(label='Forced Overwrite of Refiner Switch Step', + minimum=-1, maximum=200, step=1, value=-1, + info='Set as -1 to disable. For developer debugging.') + overwrite_width = gr.Slider(label='Forced Overwrite of Generating Width', + minimum=-1, maximum=2048, step=1, value=-1, + info='Set as -1 to disable. For developer debugging.') + overwrite_height = gr.Slider(label='Forced Overwrite of Generating Height', + minimum=-1, maximum=2048, step=1, value=-1, + info='Set as -1 to disable. For developer debugging.') + overwrite_vary_strength = gr.Slider(label='Forced Overwrite of Denoising Strength of "Vary"', + minimum=-1, maximum=1.0, step=0.001, value=-1, + info='Set as negative number to disable. For developer debugging.') + overwrite_upscale_strength = gr.Slider(label='Forced Overwrite of Denoising Strength of "Upscale"', + minimum=-1, maximum=1.0, step=0.001, value=-1, + info='Set as negative number to disable. For developer debugging.') + + overwrite_ctrls = [overwrite_step, overwrite_switch, overwrite_width, overwrite_height, overwrite_vary_strength, overwrite_upscale_strength] + def dev_mode_checked(r): return gr.update(visible=r) @@ -192,6 +213,7 @@ with shared.gradio_root: prompt, negative_prompt, style_selections, performance_selction, aspect_ratios_selction, image_number, image_seed, sharpness, adm_scaler_positive, adm_scaler_negative, guidance_scale, adaptive_cfg, sampler_name, scheduler_name ] + ctrls += overwrite_ctrls ctrls += [base_model, refiner_model] + lora_ctrls ctrls += [input_image_checkbox, current_tab] ctrls += [uov_method, uov_input_image]