From 6342e179dd0ed28c50ff963cf04a82f13cd2fb5b Mon Sep 17 00:00:00 2001 From: Manuel Schmid <9307310+mashb1t@users.noreply.github.com> Date: Sat, 24 Feb 2024 20:07:36 +0100 Subject: [PATCH] feat: add advanced parameter for disable_intermediate_results (progress_gallery) (#1013) * add advanced parameter for disable_intermediate_results prevents gradio frontend process from clogging image output and updates in high throughput scenarios such as LCM with image number >= 4 * update disable_intermediate_results correctly based on default and selected performance * chore: add missing translations --- language/en.json | 4 ++++ modules/async_worker.py | 3 ++- webui.py | 14 ++++++++++---- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/language/en.json b/language/en.json index fd40ca2f8c..8a782e3fd4 100644 --- a/language/en.json +++ b/language/en.json @@ -342,6 +342,10 @@ "Forced Overwrite of Denoising Strength of \"Vary\"": "Forced Overwrite of Denoising Strength of \"Vary\"", "Set as negative number to disable. For developer debugging.": "Set as negative number to disable. For developer debugging.", "Forced Overwrite of Denoising Strength of \"Upscale\"": "Forced Overwrite of Denoising Strength of \"Upscale\"", + "Disable Preview": "Disable Preview", + "Disable preview during generation.": "Disable preview during generation.", + "Disable Intermediate Results": "Disable Intermediate Results", + "Disable intermediate results during generation, only show final gallery.": "Disable intermediate results during generation, only show final gallery.", "Inpaint Engine": "Inpaint Engine", "v1": "v1", "Version of Fooocus inpaint model": "Version of Fooocus inpaint model", diff --git a/modules/async_worker.py b/modules/async_worker.py index d0ce4ba918..a304e69747 100644 --- a/modules/async_worker.py +++ b/modules/async_worker.py @@ -147,6 +147,7 @@ def handler(async_task): inpaint_additional_prompt = args.pop() inpaint_mask_image_upload = args.pop() disable_preview = args.pop() + disable_intermediate_results = args.pop() adm_scaler_positive = args.pop() adm_scaler_negative = args.pop() adm_scaler_end = args.pop() @@ -842,7 +843,7 @@ def callback(step, x0, x, total_steps, y): d.append(('Version', 'v' + fooocus_version.version)) log(x, d) - yield_result(async_task, imgs, do_not_show_finished_images=len(tasks) == 1) + yield_result(async_task, imgs, do_not_show_finished_images=len(tasks) == 1 or disable_intermediate_results) except ldm_patched.modules.model_management.InterruptProcessingException as e: if async_task.last_stop == 'skip': print('User skipped') diff --git a/webui.py b/webui.py index 05b7d20ef9..c0a98863e3 100644 --- a/webui.py +++ b/webui.py @@ -63,7 +63,7 @@ def generate_clicked(task): if flag == 'results': yield gr.update(visible=True), \ gr.update(visible=True), \ - gr.update(visible=True, value=product), \ + gr.update(visible=True, value=product) if not advanced_parameters.disable_intermediate_results else gr.update(), \ gr.update(visible=False) if flag == 'finish': yield gr.update(visible=False), \ @@ -390,6 +390,10 @@ def update_history_link(): info='Set as negative number to disable. For developer debugging.') disable_preview = gr.Checkbox(label='Disable Preview', value=False, info='Disable preview during generation.') + disable_intermediate_results = gr.Checkbox(label='Disable Intermediate Results', + value=modules.config.default_performance == 'Extreme Speed', + interactive=modules.config.default_performance != 'Extreme Speed', + info='Disable intermediate results during generation, only show final gallery.') with gr.Tab(label='Control'): debugging_cn_preprocessor = gr.Checkbox(label='Debug Preprocessors', value=False, @@ -474,12 +478,13 @@ def model_refresh_clicked(): queue=False, show_progress=False) performance_selection.change(lambda x: [gr.update(interactive=x != 'Extreme Speed')] * 11 + - [gr.update(visible=x != 'Extreme Speed')] * 1, + [gr.update(visible=x != 'Extreme Speed')] * 1 + + [gr.update(interactive=x != 'Extreme Speed', value=x == 'Extreme Speed', )] * 1, inputs=performance_selection, outputs=[ guidance_scale, sharpness, adm_scaler_end, adm_scaler_positive, adm_scaler_negative, refiner_switch, refiner_model, sampler_name, - scheduler_name, adaptive_cfg, refiner_swap_method, negative_prompt + scheduler_name, adaptive_cfg, refiner_swap_method, negative_prompt, disable_intermediate_results ], queue=False, show_progress=False) advanced_checkbox.change(lambda x: gr.update(visible=x), advanced_checkbox, advanced_column, @@ -529,7 +534,8 @@ def inpaint_mode_change(mode): ctrls += [input_image_checkbox, current_tab] ctrls += [uov_method, uov_input_image] ctrls += [outpaint_selections, inpaint_input_image, inpaint_additional_prompt, inpaint_mask_image] - ctrls += [disable_preview, adm_scaler_positive, adm_scaler_negative, adm_scaler_end, adaptive_cfg] + ctrls += [disable_preview, disable_intermediate_results] + ctrls += [adm_scaler_positive, adm_scaler_negative, adm_scaler_end, adaptive_cfg] ctrls += [sampler_name, scheduler_name] ctrls += [overwrite_step, overwrite_switch, overwrite_width, overwrite_height, overwrite_vary_strength] ctrls += [overwrite_upscale_strength, mixing_image_prompt_and_vary_upscale, mixing_image_prompt_and_inpaint]