From 1be3c504ed0b15662131a9e16573e5e2995620bd Mon Sep 17 00:00:00 2001 From: Manuel Schmid <9307310+mashb1t@users.noreply.github.com> Date: Sat, 27 Jul 2024 12:35:55 +0200 Subject: [PATCH] fix: add positive prompt if styles don't have a prompt placeholder (#3372) fixes https://github.com/lllyasviel/Fooocus/issues/3367 --- modules/async_worker.py | 9 ++++++++- modules/sdxl_styles.py | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/modules/async_worker.py b/modules/async_worker.py index 489834b21..b2939d2be 100644 --- a/modules/async_worker.py +++ b/modules/async_worker.py @@ -689,13 +689,20 @@ def process_prompt(async_task, prompt, negative_prompt, base_model_additional_lo task_styles = async_task.style_selections.copy() if use_style: + placeholder_replaced = False + for j, s in enumerate(task_styles): if s == random_style_name: s = get_random_style(task_rng) task_styles[j] = s - p, n = apply_style(s, positive=task_prompt) + p, n, style_has_placeholder = apply_style(s, positive=task_prompt) + if style_has_placeholder: + placeholder_replaced = True positive_basic_workloads = positive_basic_workloads + p negative_basic_workloads = negative_basic_workloads + n + + if not placeholder_replaced: + positive_basic_workloads = [task_prompt] + positive_basic_workloads else: positive_basic_workloads.append(task_prompt) diff --git a/modules/sdxl_styles.py b/modules/sdxl_styles.py index 12ab6c5ca..3feb886af 100644 --- a/modules/sdxl_styles.py +++ b/modules/sdxl_styles.py @@ -59,7 +59,7 @@ def get_random_style(rng: Random) -> str: def apply_style(style, positive): p, n = styles[style] - return p.replace('{prompt}', positive).splitlines(), n.splitlines() + return p.replace('{prompt}', positive).splitlines(), n.splitlines(), '{prompt}' in p def get_words(arrays, total_mult, index):