mirror of
https://github.com/lllyasviel/Fooocus.git
synced 2026-08-16 13:13:16 +02:00
prompt expansion v2
This commit is contained in:
+1
-1
@@ -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.sdxl_styles import apply_style_negative, apply_style_positive, aspect_ratios
|
||||||
from modules.private_logger import log
|
from modules.private_logger import log
|
||||||
from modules.expansion import safe_str
|
from modules.expansion import safe_str
|
||||||
|
from modules.util import join_prompts
|
||||||
|
|
||||||
try:
|
try:
|
||||||
async_gradio_app = shared.gradio_root
|
async_gradio_app = shared.gradio_root
|
||||||
@@ -81,12 +82,16 @@ def worker():
|
|||||||
outputs.append(['preview', (5, f'Preparing positive text #{i + 1} ...', None)])
|
outputs.append(['preview', (5, f'Preparing positive text #{i + 1} ...', None)])
|
||||||
current_seed = seed + i
|
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}')
|
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(
|
tasks.append(dict(
|
||||||
prompt=prompt,
|
prompt=prompt,
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ from modules.path import fooocus_expansion_path
|
|||||||
fooocus_magic_split = [
|
fooocus_magic_split = [
|
||||||
', extremely',
|
', extremely',
|
||||||
', trending',
|
', trending',
|
||||||
', intricate',
|
', intricate,',
|
||||||
# '. The',
|
|
||||||
]
|
]
|
||||||
dangrous_patterns = '[]【】()()|::'
|
dangrous_patterns = '[]【】()()|::'
|
||||||
|
|
||||||
@@ -16,7 +15,7 @@ def safe_str(x):
|
|||||||
x = str(x)
|
x = str(x)
|
||||||
for _ in range(16):
|
for _ in range(16):
|
||||||
x = x.replace(' ', ' ')
|
x = x.replace(' ', ' ')
|
||||||
return x.rstrip(",. \r\n")
|
return x.strip(",. \r\n")
|
||||||
|
|
||||||
|
|
||||||
def remove_pattern(x, pattern):
|
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
|
# https://github.com/twri/sdxl_prompt_styler/blob/main/sdxl_styles.json
|
||||||
|
|
||||||
styles = [
|
styles = [
|
||||||
@@ -966,9 +969,4 @@ def apply_style_positive(style, txt):
|
|||||||
|
|
||||||
def apply_style_negative(style, txt):
|
def apply_style_negative(style, txt):
|
||||||
p, n = styles.get(style, default_style)
|
p, n = styles.get(style, default_style)
|
||||||
if n == '':
|
return join_prompts(n, txt)
|
||||||
return txt
|
|
||||||
elif txt == '':
|
|
||||||
return n
|
|
||||||
else:
|
|
||||||
return n + ', ' + txt
|
|
||||||
|
|||||||
@@ -3,6 +3,15 @@ import random
|
|||||||
import os
|
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'):
|
def generate_temp_filename(folder='./outputs/', extension='png'):
|
||||||
current_time = datetime.datetime.now()
|
current_time = datetime.datetime.now()
|
||||||
date_string = current_time.strftime("%Y-%m-%d")
|
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
|
### 1.0.64
|
||||||
|
|
||||||
* Fixed a small OOM problem.
|
* Fixed a small OOM problem.
|
||||||
|
|||||||
Reference in New Issue
Block a user