From 6c812b68db33f50a4e0fb5e0d14fae6bc63b1b7e Mon Sep 17 00:00:00 2001 From: lllyasviel Date: Mon, 13 Nov 2023 14:35:23 -0800 Subject: [PATCH] add preprocessor skip --- fooocus_version.py | 2 +- modules/advanced_parameters.py | 8 ++++---- modules/async_worker.py | 15 ++++++++++++--- webui.py | 7 +++++-- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/fooocus_version.py b/fooocus_version.py index 246d9d9..de300a0 100644 --- a/fooocus_version.py +++ b/fooocus_version.py @@ -1 +1 @@ -version = '2.1.804' +version = '2.1.805' diff --git a/modules/advanced_parameters.py b/modules/advanced_parameters.py index 035d43b..46d074a 100644 --- a/modules/advanced_parameters.py +++ b/modules/advanced_parameters.py @@ -2,9 +2,9 @@ adm_scaler_positive, adm_scaler_negative, adm_scaler_end, adaptive_cfg, sampler_ scheduler_name, generate_image_grid, overwrite_step, overwrite_switch, overwrite_width, overwrite_height, \ overwrite_vary_strength, overwrite_upscale_strength, \ mixing_image_prompt_and_vary_upscale, mixing_image_prompt_and_inpaint, \ - debugging_cn_preprocessor, controlnet_softness, canny_low_threshold, canny_high_threshold, inpaint_engine, \ + debugging_cn_preprocessor, skipping_cn_preprocessor, controlnet_softness, canny_low_threshold, canny_high_threshold, inpaint_engine, \ refiner_swap_method, \ - freeu_enabled, freeu_b1, freeu_b2, freeu_s1, freeu_s2 = [None] * 26 + freeu_enabled, freeu_b1, freeu_b2, freeu_s1, freeu_s2 = [None] * 27 def set_all_advanced_parameters(*args): @@ -12,7 +12,7 @@ def set_all_advanced_parameters(*args): scheduler_name, generate_image_grid, overwrite_step, overwrite_switch, overwrite_width, overwrite_height, \ overwrite_vary_strength, overwrite_upscale_strength, \ mixing_image_prompt_and_vary_upscale, mixing_image_prompt_and_inpaint, \ - debugging_cn_preprocessor, controlnet_softness, canny_low_threshold, canny_high_threshold, inpaint_engine, \ + debugging_cn_preprocessor, skipping_cn_preprocessor, controlnet_softness, canny_low_threshold, canny_high_threshold, inpaint_engine, \ refiner_swap_method, \ freeu_enabled, freeu_b1, freeu_b2, freeu_s1, freeu_s2 @@ -20,7 +20,7 @@ def set_all_advanced_parameters(*args): scheduler_name, generate_image_grid, overwrite_step, overwrite_switch, overwrite_width, overwrite_height, \ overwrite_vary_strength, overwrite_upscale_strength, \ mixing_image_prompt_and_vary_upscale, mixing_image_prompt_and_inpaint, \ - debugging_cn_preprocessor, controlnet_softness, canny_low_threshold, canny_high_threshold, inpaint_engine, \ + debugging_cn_preprocessor, skipping_cn_preprocessor, controlnet_softness, canny_low_threshold, canny_high_threshold, inpaint_engine, \ refiner_swap_method, \ freeu_enabled, freeu_b1, freeu_b2, freeu_s1, freeu_s2 = args diff --git a/modules/async_worker.py b/modules/async_worker.py index 00d40d6..aa5ea83 100644 --- a/modules/async_worker.py +++ b/modules/async_worker.py @@ -553,7 +553,10 @@ def worker(): for task in cn_tasks[flags.cn_canny]: cn_img, cn_stop, cn_weight = task cn_img = resize_image(HWC3(cn_img), width=width, height=height) - cn_img = preprocessors.canny_pyramid(cn_img) + + if not advanced_parameters.skipping_cn_preprocessor: + cn_img = preprocessors.canny_pyramid(cn_img) + cn_img = HWC3(cn_img) task[0] = core.numpy_to_pytorch(cn_img) if advanced_parameters.debugging_cn_preprocessor: @@ -562,7 +565,10 @@ def worker(): for task in cn_tasks[flags.cn_cpds]: cn_img, cn_stop, cn_weight = task cn_img = resize_image(HWC3(cn_img), width=width, height=height) - cn_img = preprocessors.cpds(cn_img) + + if not advanced_parameters.skipping_cn_preprocessor: + cn_img = preprocessors.cpds(cn_img) + cn_img = HWC3(cn_img) task[0] = core.numpy_to_pytorch(cn_img) if advanced_parameters.debugging_cn_preprocessor: @@ -581,7 +587,10 @@ def worker(): return for task in cn_tasks[flags.cn_ip_face]: cn_img, cn_stop, cn_weight = task - cn_img = fooocus_extras.face_crop.crop_image(HWC3(cn_img)) + cn_img = HWC3(cn_img) + + if not advanced_parameters.skipping_cn_preprocessor: + cn_img = fooocus_extras.face_crop.crop_image(cn_img) # https://github.com/tencent-ailab/IP-Adapter/blob/d580c50a291566bbf9fc7ac0f760506607297e6d/README.md?plain=1#L75 cn_img = resize_image(cn_img, width=224, height=224, resize_mode=0) diff --git a/webui.py b/webui.py index ccc741b..a918c19 100644 --- a/webui.py +++ b/webui.py @@ -311,7 +311,10 @@ with shared.gradio_root: info='Version of Fooocus inpaint model') with gr.Tab(label='Control Debug'): - debugging_cn_preprocessor = gr.Checkbox(label='Debug Preprocessors', value=False) + debugging_cn_preprocessor = gr.Checkbox(label='Debug Preprocessors', value=False, + info='See the results from preprocessors.') + skipping_cn_preprocessor = gr.Checkbox(label='Skip Preprocessors', value=False, + info='Do not preprocess images. (Inputs are already canny/depth/cropped-face/etc.)') mixing_image_prompt_and_vary_upscale = gr.Checkbox(label='Mixing Image Prompt and Vary/Upscale', value=False) @@ -340,7 +343,7 @@ with shared.gradio_root: scheduler_name, generate_image_grid, overwrite_step, overwrite_switch, overwrite_width, overwrite_height, overwrite_vary_strength, overwrite_upscale_strength, mixing_image_prompt_and_vary_upscale, mixing_image_prompt_and_inpaint, - debugging_cn_preprocessor, controlnet_softness, canny_low_threshold, canny_high_threshold, + debugging_cn_preprocessor, skipping_cn_preprocessor, controlnet_softness, canny_low_threshold, canny_high_threshold, inpaint_engine, refiner_swap_method] adps += freeu_ctrls