Skip to content

Commit

Permalink
feat: add advanced parameter for disable_intermediate_results (progre…
Browse files Browse the repository at this point in the history
…ss_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
  • Loading branch information
mashb1t committed Feb 25, 2024
1 parent 965364c commit 6342e17
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
4 changes: 4 additions & 0 deletions language/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion modules/async_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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')
Expand Down
14 changes: 10 additions & 4 deletions webui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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), \
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit 6342e17

Please sign in to comment.