Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -24,10 +24,11 @@ def save_image(image_file, upload_dir: str) -> str:
|
|
24 |
Path(upload_dir).mkdir(parents=True, exist_ok=True)
|
25 |
filename = secrets.token_hex(10) + Path(image_file.name).suffix
|
26 |
file_path = Path(upload_dir) / filename
|
27 |
-
with open(
|
28 |
-
f_output.write(
|
29 |
return str(file_path)
|
30 |
|
|
|
31 |
def clean_response(response: str) -> str:
|
32 |
response = re.sub(r'<ref>(.*?)</ref>(?:<box>.*?</box>)*(?:<quad>.*?</quad>)*', r'\1', response).strip()
|
33 |
return response
|
|
|
24 |
Path(upload_dir).mkdir(parents=True, exist_ok=True)
|
25 |
filename = secrets.token_hex(10) + Path(image_file.name).suffix
|
26 |
file_path = Path(upload_dir) / filename
|
27 |
+
with open(file_path, "wb") as f_output:
|
28 |
+
f_output.write(image_file.read())
|
29 |
return str(file_path)
|
30 |
|
31 |
+
|
32 |
def clean_response(response: str) -> str:
|
33 |
response = re.sub(r'<ref>(.*?)</ref>(?:<box>.*?</box>)*(?:<quad>.*?</quad>)*', r'\1', response).strip()
|
34 |
return response
|