From a85f252010a907bd547b74c221c31a20882e9c3a Mon Sep 17 00:00:00 2001 From: satori Date: Sun, 10 Nov 2024 17:37:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8=E6=9C=AC=E5=9C=B0=E5=9B=BE?= =?UTF-8?q?=E5=83=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- start.sh | 1 - utilities/download.py | 7 +++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/start.sh b/start.sh index e21e03e..52e674b 100755 --- a/start.sh +++ b/start.sh @@ -1,7 +1,6 @@ #!/bin/sh # 创建虚拟环境 Python 3.10.12 -cd ~/reverse_image_search_gpu python3.10 -m venv venv source venv/bin/activate diff --git a/utilities/download.py b/utilities/download.py index 13bfb82..de4cfa3 100644 --- a/utilities/download.py +++ b/utilities/download.py @@ -13,6 +13,13 @@ def download_image(url:str) -> Image: if url.startswith('http://image.gameuiux.cn/') or url.startswith('https://image.gameuiux.cn/'): try: url = url.replace('http://image.gameuiux.cn/', '').replace('https://image.gameuiux.cn/', '') + # 先尝试本地图像 + if os.path.exists(f"oss/{url}"): + print('使用本地图像:', url) + return Image.open(f"{IMAGES_PATH}/{url}") + + # 使用 OSS 下载 + print('使用 OSS 下载:', url) obj = bucket_image2.get_object(url).read() return Image.open(io.BytesIO(obj)) except Exception: