fix: correctly extract prompt style when only prompt expansion is selected

This commit is contained in:
Manuel Schmid 2024-01-29 22:27:33 +01:00
parent dcc4874455
commit 6939f7904a
No known key found for this signature in database
GPG Key ID: 32C4F7569B40B84B
1 changed files with 11 additions and 2 deletions

View File

@ -314,8 +314,17 @@ def extract_styles_from_prompt(prompt, negative_prompt):
# add prompt expansion if not all styles could be resolved
# TODO check if it's better to not add fooocus_expansion but just return prompt incl. fooocus_expansion words
# TODO evaluate if adding prompt expansion to metadata is a good idea
if prompt != '' and prompt != real_prompt:
extracted.append(modules.sdxl_styles.fooocus_expansion)
if prompt != '':
if prompt != real_prompt:
extracted.append(modules.sdxl_styles.fooocus_expansion)
# find real_prompt when only prompt expansion is selected
if real_prompt == '':
first_word = prompt.split(', ')[0]
first_word_positions = [i for i in range(len(prompt)) if prompt.startswith(first_word, i)]
real_prompt = prompt[:first_word_positions[-1]]
if real_prompt.endswith(', '):
real_prompt = real_prompt[:-2]
return list(reversed(extracted)), real_prompt, negative_prompt