mirror of
https://github.com/lllyasviel/Fooocus.git
synced 2026-08-16 13:13:16 +02:00
feat: improve performance, do not reload the pipeline when prompts are the same as in the original task
This commit is contained in:
+20
-16
@@ -897,12 +897,12 @@ def worker():
|
|||||||
'face')
|
'face')
|
||||||
return base_model_additional_loras, clip_vision_path, controlnet_canny_path, controlnet_cpds_path, inpaint_head_model_path, inpaint_image, inpaint_mask, ip_adapter_face_path, ip_adapter_path, ip_negative_path, skip_prompt_processing, use_synthetic_refiner
|
return base_model_additional_loras, clip_vision_path, controlnet_canny_path, controlnet_cpds_path, inpaint_head_model_path, inpaint_image, inpaint_mask, ip_adapter_face_path, ip_adapter_path, ip_negative_path, skip_prompt_processing, use_synthetic_refiner
|
||||||
|
|
||||||
def prepare_enhance_prompt(prompt: str, fallback_prompt: str, translate: bool, type: str):
|
def prepare_enhance_prompt(prompt: str, fallback_prompt: str, translate: bool, prompt_type: str):
|
||||||
if len(remove_empty_str([safe_str(p) for p in prompt.splitlines()], default='')) == 0:
|
if safe_str(prompt) == '' or len(remove_empty_str([safe_str(p) for p in prompt.splitlines()], default='')) == 0:
|
||||||
prompt = fallback_prompt
|
prompt = fallback_prompt
|
||||||
else:
|
else:
|
||||||
if translate:
|
if translate:
|
||||||
prompt = translate2en(prompt, type)
|
prompt = translate2en(prompt, prompt_type)
|
||||||
prompt = prompt + '\n' + fallback_prompt
|
prompt = prompt + '\n' + fallback_prompt
|
||||||
return prompt
|
return prompt
|
||||||
|
|
||||||
@@ -1134,20 +1134,24 @@ def worker():
|
|||||||
enhance_prompt = prepare_enhance_prompt(enhance_prompt, async_task.prompt, async_task.translate_prompts, 'prompt')
|
enhance_prompt = prepare_enhance_prompt(enhance_prompt, async_task.prompt, async_task.translate_prompts, 'prompt')
|
||||||
enhance_negative_prompt = prepare_enhance_prompt(enhance_negative_prompt, async_task.negative_prompt, async_task.translate_prompts, 'negative prompt')
|
enhance_negative_prompt = prepare_enhance_prompt(enhance_negative_prompt, async_task.negative_prompt, async_task.translate_prompts, 'negative prompt')
|
||||||
|
|
||||||
tasks_enhance, use_expansion, loras = process_prompt(async_task, enhance_prompt,
|
if not inpaint_parameterized_enhance and enhance_prompt == async_task.prompt and enhance_negative_prompt == async_task.negative_prompt:
|
||||||
enhance_negative_prompt,
|
task_enhance = task.copy()
|
||||||
base_model_additional_loras_enhance,
|
tasks_enhance = tasks.copy()
|
||||||
1, True,
|
else:
|
||||||
use_expansion, use_style,
|
tasks_enhance, use_expansion, loras = process_prompt(async_task, enhance_prompt,
|
||||||
use_synthetic_refiner)
|
enhance_negative_prompt,
|
||||||
task_enhance = tasks_enhance[0]
|
base_model_additional_loras_enhance,
|
||||||
|
1, True,
|
||||||
|
use_expansion, use_style,
|
||||||
|
use_synthetic_refiner)
|
||||||
|
task_enhance = tasks_enhance[0]
|
||||||
|
|
||||||
# TODO could support vary, upscale and CN in the future
|
# TODO could support vary, upscale and CN in the future
|
||||||
# if 'cn' in goals:
|
# if 'cn' in goals:
|
||||||
# apply_control_nets(async_task, height, ip_adapter_face_path, ip_adapter_path, width)
|
# apply_control_nets(async_task, height, ip_adapter_face_path, ip_adapter_path, width)
|
||||||
if async_task.freeu_enabled:
|
if async_task.freeu_enabled:
|
||||||
apply_freeu(async_task)
|
apply_freeu(async_task)
|
||||||
patch_samplers(async_task)
|
patch_samplers(async_task)
|
||||||
|
|
||||||
goals_enhance = ['inpaint']
|
goals_enhance = ['inpaint']
|
||||||
enhance_inpaint_strength, initial_latent_enhance, width_enhance, height_enhance = apply_inpaint(
|
enhance_inpaint_strength, initial_latent_enhance, width_enhance, height_enhance = apply_inpaint(
|
||||||
|
|||||||
Reference in New Issue
Block a user