Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -83,12 +83,16 @@ model = AutoModelForCausalLM.from_pretrained(checkpoint, device_map='balanced')
|
|
83 |
|
84 |
def filter_text(text):
|
85 |
"""Filters out the text up to and including 'Rewritten Prompt:'."""
|
86 |
-
phrase = "
|
87 |
pattern = f"(.*?){re.escape(phrase)}(.*)"
|
88 |
match = re.search(pattern, text)
|
89 |
# match = re.search(pattern, text,flags=re.DOTALL)
|
90 |
-
|
91 |
-
|
|
|
|
|
|
|
|
|
92 |
|
93 |
MAX_SEED = np.iinfo(np.int32).max
|
94 |
MAX_IMAGE_SIZE = 4096
|
|
|
83 |
|
84 |
def filter_text(text):
|
85 |
"""Filters out the text up to and including 'Rewritten Prompt:'."""
|
86 |
+
phrase = "rewritten prompt : "
|
87 |
pattern = f"(.*?){re.escape(phrase)}(.*)"
|
88 |
match = re.search(pattern, text)
|
89 |
# match = re.search(pattern, text,flags=re.DOTALL)
|
90 |
+
if match:
|
91 |
+
filtered_text = match.group(2)
|
92 |
+
return filtered_text
|
93 |
+
else:
|
94 |
+
# Handle the case where no match is found
|
95 |
+
return text
|
96 |
|
97 |
MAX_SEED = np.iinfo(np.int32).max
|
98 |
MAX_IMAGE_SIZE = 4096
|