prompt expansion v2
This commit is contained in:
parent
e6557a4ded
commit
0f658a97f7
|
|
@ -1 +1 @@
|
|||
version = '1.0.66'
|
||||
version = '1.0.67'
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ def worker():
|
|||
from modules.sdxl_styles import apply_style_negative, apply_style_positive, aspect_ratios
|
||||
from modules.private_logger import log
|
||||
from modules.expansion import safe_str
|
||||
from modules.util import join_prompts
|
||||
|
||||
try:
|
||||
async_gradio_app = shared.gradio_root
|
||||
|
|
@ -81,12 +82,16 @@ def worker():
|
|||
outputs.append(['preview', (5, f'Preparing positive text #{i + 1} ...', None)])
|
||||
current_seed = seed + i
|
||||
|
||||
p_txt = apply_style_positive(style_selction, prompt)
|
||||
expansion_weight = 0.35
|
||||
|
||||
suffix = pipeline.expansion(p_txt, current_seed)
|
||||
suffix = pipeline.expansion(prompt, current_seed)
|
||||
suffix = f'({suffix}:{expansion_weight})'
|
||||
print(f'[Prompt Expansion] New suffix: {suffix}')
|
||||
|
||||
p_txt = safe_str(p_txt) + suffix
|
||||
p_txt = apply_style_positive(style_selction, prompt)
|
||||
p_txt = safe_str(p_txt)
|
||||
|
||||
p_txt = join_prompts(p_txt, suffix)
|
||||
|
||||
tasks.append(dict(
|
||||
prompt=prompt,
|
||||
|
|
|
|||
|
|
@ -6,8 +6,7 @@ from modules.path import fooocus_expansion_path
|
|||
fooocus_magic_split = [
|
||||
', extremely',
|
||||
', trending',
|
||||
', intricate',
|
||||
# '. The',
|
||||
', intricate,',
|
||||
]
|
||||
dangrous_patterns = '[]【】()()|::'
|
||||
|
||||
|
|
@ -16,7 +15,7 @@ def safe_str(x):
|
|||
x = str(x)
|
||||
for _ in range(16):
|
||||
x = x.replace(' ', ' ')
|
||||
return x.rstrip(",. \r\n")
|
||||
return x.strip(",. \r\n")
|
||||
|
||||
|
||||
def remove_pattern(x, pattern):
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
from modules.util import join_prompts
|
||||
|
||||
|
||||
# https://github.com/twri/sdxl_prompt_styler/blob/main/sdxl_styles.json
|
||||
|
||||
styles = [
|
||||
|
|
@ -966,9 +969,4 @@ def apply_style_positive(style, txt):
|
|||
|
||||
def apply_style_negative(style, txt):
|
||||
p, n = styles.get(style, default_style)
|
||||
if n == '':
|
||||
return txt
|
||||
elif txt == '':
|
||||
return n
|
||||
else:
|
||||
return n + ', ' + txt
|
||||
return join_prompts(n, txt)
|
||||
|
|
|
|||
|
|
@ -3,6 +3,15 @@ import random
|
|||
import os
|
||||
|
||||
|
||||
def join_prompts(*args, **kwargs):
|
||||
prompts = [str(x) for x in args if str(x) != ""]
|
||||
if len(prompts) == 0:
|
||||
return ""
|
||||
if len(prompts) == 1:
|
||||
return prompts[0]
|
||||
return ', '.join(prompts)
|
||||
|
||||
|
||||
def generate_temp_filename(folder='./outputs/', extension='png'):
|
||||
current_time = datetime.datetime.now()
|
||||
date_string = current_time.strftime("%Y-%m-%d")
|
||||
|
|
|
|||
|
|
@ -1,3 +1,7 @@
|
|||
### 1.0.67
|
||||
|
||||
* Use dynamic weighting and lower weights for prompt expansion.
|
||||
|
||||
### 1.0.64
|
||||
|
||||
* Fixed a small OOM problem.
|
||||
|
|
|
|||
Loading…
Reference in New Issue