This commit is contained in:
lvmin
2023-09-10 22:08:55 -07:00
parent afdf47ea79
commit 14713eb95e
3 changed files with 13 additions and 1 deletions
+8
View File
@@ -9,6 +9,7 @@ fooocus_magic_split = [
', intricate',
'. The',
]
dangrous_patterns = '[]【】()()|:'
def safe_str(x):
@@ -18,6 +19,12 @@ def safe_str(x):
return x.rstrip(",. \r\n")
def remove_pattern(x, pattern):
for p in pattern:
x = x.replace(p, '')
return x
class FooocusExpansion:
def __init__(self):
self.tokenizer = AutoTokenizer.from_pretrained(fooocus_expansion_path)
@@ -37,4 +44,5 @@ class FooocusExpansion:
response = self.pipe(prompt, max_length=len(prompt) + 256)
result = response[0]['generated_text'][len(origin):]
result = safe_str(result)
result = remove_pattern(result, dangrous_patterns)
return result