Spaces:
Running
on
Zero
Running
on
Zero
init commit
Browse files
app.py
CHANGED
|
@@ -228,7 +228,7 @@ def _launch_demo(args, model, processor):
|
|
| 228 |
# 使用 URL 的哈希值作为文件名,避免重复下载
|
| 229 |
url_hash = hashlib.md5(url.encode()).hexdigest()
|
| 230 |
temp_dir = tempfile.gettempdir()
|
| 231 |
-
temp_path = os.path.join(temp_dir, f"hyocr_demo_{url_hash}.
|
| 232 |
|
| 233 |
# 如果文件已存在,直接返回
|
| 234 |
if os.path.exists(temp_path):
|
|
@@ -237,7 +237,7 @@ def _launch_demo(args, model, processor):
|
|
| 237 |
# 下载图片
|
| 238 |
response = requests.get(url, timeout=10)
|
| 239 |
response.raise_for_status()
|
| 240 |
-
img = Image.open(BytesIO(response.content))
|
| 241 |
img.save(temp_path)
|
| 242 |
return temp_path
|
| 243 |
except Exception as e:
|
|
|
|
| 228 |
# 使用 URL 的哈希值作为文件名,避免重复下载
|
| 229 |
url_hash = hashlib.md5(url.encode()).hexdigest()
|
| 230 |
temp_dir = tempfile.gettempdir()
|
| 231 |
+
temp_path = os.path.join(temp_dir, f"hyocr_demo_{url_hash}.png")
|
| 232 |
|
| 233 |
# 如果文件已存在,直接返回
|
| 234 |
if os.path.exists(temp_path):
|
|
|
|
| 237 |
# 下载图片
|
| 238 |
response = requests.get(url, timeout=10)
|
| 239 |
response.raise_for_status()
|
| 240 |
+
img = Image.open(BytesIO(response.content))
|
| 241 |
img.save(temp_path)
|
| 242 |
return temp_path
|
| 243 |
except Exception as e:
|