Spaces:
Running
on
Zero
Running
on
Zero
update helper
Browse files
helper.py
CHANGED
@@ -208,7 +208,7 @@ def add_comma_after_pattern_ti(text):
|
|
208 |
modified_text = pattern.sub(lambda x: x.group() + ',', text)
|
209 |
return modified_text
|
210 |
|
211 |
-
def save_image(img):
|
212 |
path = "./tmp/"
|
213 |
|
214 |
# Check if the input is a string (file path) and load the image if it is
|
@@ -218,9 +218,10 @@ def save_image(img):
|
|
218 |
# Ensure the Hugging Face path exists locally
|
219 |
if not os.path.exists(path):
|
220 |
os.makedirs(path)
|
221 |
-
|
|
|
222 |
# Generate a unique filename
|
223 |
-
unique_name = str(uuid.uuid4()) + ".webp"
|
224 |
unique_name = os.path.join(path, unique_name)
|
225 |
|
226 |
# Convert the image to WebP format
|
|
|
208 |
modified_text = pattern.sub(lambda x: x.group() + ',', text)
|
209 |
return modified_text
|
210 |
|
211 |
+
def save_image(img, flag):
|
212 |
path = "./tmp/"
|
213 |
|
214 |
# Check if the input is a string (file path) and load the image if it is
|
|
|
218 |
# Ensure the Hugging Face path exists locally
|
219 |
if not os.path.exists(path):
|
220 |
os.makedirs(path)
|
221 |
+
if flag:
|
222 |
+
flag = "_" + flag
|
223 |
# Generate a unique filename
|
224 |
+
unique_name = str(uuid.uuid4()) + flag + ".webp"
|
225 |
unique_name = os.path.join(path, unique_name)
|
226 |
|
227 |
# Convert the image to WebP format
|