Update app.py
Browse files
app.py
CHANGED
@@ -4,7 +4,7 @@ import os
|
|
4 |
import zipfile
|
5 |
import uuid
|
6 |
import gradio as gr
|
7 |
-
|
8 |
|
9 |
|
10 |
def remove_watermark_area(original_image, text_mask_path):
|
@@ -60,17 +60,24 @@ def make_zip(image_list):
|
|
60 |
zipf.write(image, os.path.basename(image))
|
61 |
return zip_path
|
62 |
|
|
|
|
|
|
|
|
|
|
|
63 |
def process_files(image_files):
|
64 |
image_list = []
|
65 |
if len(image_files) == 1:
|
66 |
-
saved_path = os.path.basename(image_files[0])
|
67 |
-
saved_path = f"./temp/{saved_path}"
|
|
|
68 |
remove_watermark(image_files[0], saved_path)
|
69 |
return saved_path, saved_path
|
70 |
else:
|
71 |
for image_path in image_files:
|
72 |
-
saved_path = os.path.basename(image_path)
|
73 |
-
saved_path = f"./temp/{saved_path}"
|
|
|
74 |
remove_watermark(image_path, saved_path)
|
75 |
image_list.append(saved_path)
|
76 |
zip_path = make_zip(image_list)
|
|
|
4 |
import zipfile
|
5 |
import uuid
|
6 |
import gradio as gr
|
7 |
+
import uuid
|
8 |
|
9 |
|
10 |
def remove_watermark_area(original_image, text_mask_path):
|
|
|
60 |
zipf.write(image, os.path.basename(image))
|
61 |
return zip_path
|
62 |
|
63 |
+
def random_image_name():
|
64 |
+
"""Generate a random image name."""
|
65 |
+
return str(uuid.uuid4())[:8]
|
66 |
+
|
67 |
+
|
68 |
def process_files(image_files):
|
69 |
image_list = []
|
70 |
if len(image_files) == 1:
|
71 |
+
# saved_path = os.path.basename(image_files[0])
|
72 |
+
# saved_path = f"./temp/{saved_path}"
|
73 |
+
saved_path = f"./temp/{random_image_name()}.jpg"
|
74 |
remove_watermark(image_files[0], saved_path)
|
75 |
return saved_path, saved_path
|
76 |
else:
|
77 |
for image_path in image_files:
|
78 |
+
# saved_path = os.path.basename(image_path)
|
79 |
+
# saved_path = f"./temp/{saved_path}"
|
80 |
+
saved_path = f"./temp/{random_image_name()}.jpg"
|
81 |
remove_watermark(image_path, saved_path)
|
82 |
image_list.append(saved_path)
|
83 |
zip_path = make_zip(image_list)
|