mirror of
https://github.com/lllyasviel/Fooocus.git
synced 2026-08-16 13:13:16 +02:00
fix oom
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user