Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
Stable Diffusion Webui
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
novelai-storage
Stable Diffusion Webui
Commits
120a84bd
Commit
120a84bd
authored
Dec 05, 2023
by
AUTOMATIC1111
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge pull request #14203 from AUTOMATIC1111/remove-clean_text()
remove clean_text()
parent
368d66c9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
20 deletions
+3
-20
modules/styles.py
modules/styles.py
+3
-20
No files found.
modules/styles.py
View file @
120a84bd
...
@@ -2,7 +2,6 @@ import csv
...
@@ -2,7 +2,6 @@ import csv
import
fnmatch
import
fnmatch
import
os
import
os
import
os.path
import
os.path
import
re
import
typing
import
typing
import
shutil
import
shutil
...
@@ -14,22 +13,6 @@ class PromptStyle(typing.NamedTuple):
...
@@ -14,22 +13,6 @@ class PromptStyle(typing.NamedTuple):
path
:
str
=
None
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
:
def
merge_prompts
(
style_prompt
:
str
,
prompt
:
str
)
->
str
:
if
"{prompt}"
in
style_prompt
:
if
"{prompt}"
in
style_prompt
:
res
=
style_prompt
.
replace
(
"{prompt}"
,
prompt
)
res
=
style_prompt
.
replace
(
"{prompt}"
,
prompt
)
...
@@ -44,7 +27,7 @@ def apply_styles_to_prompt(prompt, styles):
...
@@ -44,7 +27,7 @@ def apply_styles_to_prompt(prompt, styles):
for
style
in
styles
:
for
style
in
styles
:
prompt
=
merge_prompts
(
style
,
prompt
)
prompt
=
merge_prompts
(
style
,
prompt
)
return
clean_text
(
prompt
)
return
prompt
def
unwrap_style_text_from_prompt
(
style_text
,
prompt
):
def
unwrap_style_text_from_prompt
(
style_text
,
prompt
):
...
@@ -56,8 +39,8 @@ 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
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.
purposes here. It isn't returned; the original style text is not modified.
"""
"""
stripped_prompt
=
clean_text
(
prompt
)
stripped_prompt
=
prompt
stripped_style_text
=
clean_text
(
style_text
)
stripped_style_text
=
style_text
if
"{prompt}"
in
stripped_style_text
:
if
"{prompt}"
in
stripped_style_text
:
# Work out whether the prompt is wrapped in the style text. If so, we
# 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.
# return True and the "inner" prompt text that isn't part of the style.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment