Skip to content

Commit

Permalink
fix: add positive prompt if styles don't have a prompt placeholder (#…
Browse files Browse the repository at this point in the history
…3372)

fixes #3367
  • Loading branch information
mashb1t authored Jul 27, 2024
1 parent c4ce2ce commit 1be3c50
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion modules/async_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion modules/sdxl_styles.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 1be3c50

Please sign in to comment.