diff options
author | w-e-w <40751091+w-e-w@users.noreply.github.com> | 2023-12-04 19:40:12 +0000 |
---|---|---|
committer | w-e-w <40751091+w-e-w@users.noreply.github.com> | 2023-12-04 19:41:09 +0000 |
commit | 854f8c318c2610c76259056ab02739176aa849e8 (patch) | |
tree | a5444fd165fcbaf86410f7aa1bb5c80c0a3b2bdc | |
parent | 22e23dbf29b0bbc807daa57318c31145f8dd0774 (diff) | |
download | stable-diffusion-webui-gfx803-854f8c318c2610c76259056ab02739176aa849e8.tar.gz stable-diffusion-webui-gfx803-854f8c318c2610c76259056ab02739176aa849e8.tar.bz2 stable-diffusion-webui-gfx803-854f8c318c2610c76259056ab02739176aa849e8.zip |
remove clean_text()
-rw-r--r-- | modules/styles.py | 23 |
1 files changed, 3 insertions, 20 deletions
diff --git a/modules/styles.py b/modules/styles.py index 4d218cd7..7fb6c2e1 100644 --- a/modules/styles.py +++ b/modules/styles.py @@ -2,7 +2,6 @@ import csv import fnmatch
import os
import os.path
-import re
import typing
import shutil
@@ -14,22 +13,6 @@ class PromptStyle(typing.NamedTuple): path: str = None
-def clean_text(text: str) -> str:
- """
- Iterating through a list of regular expressions and replacement strings, we
- clean up the prompt and style text to make it easier to match against each
- other.
- """
- re_list = [
- ("multiple commas", re.compile("(,+\s+)+,?"), ", "),
- ("multiple spaces", re.compile("\s{2,}"), " "),
- ]
- for _, regex, replace in re_list:
- text = regex.sub(replace, text)
-
- return text.strip(", ")
-
-
def merge_prompts(style_prompt: str, prompt: str) -> str:
if "{prompt}" in style_prompt:
res = style_prompt.replace("{prompt}", prompt)
@@ -44,7 +27,7 @@ def apply_styles_to_prompt(prompt, styles): for style in styles:
prompt = merge_prompts(style, prompt)
- return clean_text(prompt)
+ return prompt
def unwrap_style_text_from_prompt(style_text, prompt):
@@ -56,8 +39,8 @@ def unwrap_style_text_from_prompt(style_text, prompt): Note that the "cleaned" version of the style text is only used for matching
purposes here. It isn't returned; the original style text is not modified.
"""
- stripped_prompt = clean_text(prompt)
- stripped_style_text = clean_text(style_text)
+ stripped_prompt = prompt
+ stripped_style_text = style_text
if "{prompt}" in stripped_style_text:
# Work out whether the prompt is wrapped in the style text. If so, we
# return True and the "inner" prompt text that isn't part of the style.
|