使用本地图像
This commit is contained in:
1
start.sh
1
start.sh
@@ -1,7 +1,6 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# 创建虚拟环境 Python 3.10.12
|
# 创建虚拟环境 Python 3.10.12
|
||||||
cd ~/reverse_image_search_gpu
|
|
||||||
python3.10 -m venv venv
|
python3.10 -m venv venv
|
||||||
source venv/bin/activate
|
source venv/bin/activate
|
||||||
|
|
||||||
|
@@ -13,6 +13,13 @@ def download_image(url:str) -> Image:
|
|||||||
if url.startswith('http://image.gameuiux.cn/') or url.startswith('https://image.gameuiux.cn/'):
|
if url.startswith('http://image.gameuiux.cn/') or url.startswith('https://image.gameuiux.cn/'):
|
||||||
try:
|
try:
|
||||||
url = url.replace('http://image.gameuiux.cn/', '').replace('https://image.gameuiux.cn/', '')
|
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()
|
obj = bucket_image2.get_object(url).read()
|
||||||
return Image.open(io.BytesIO(obj))
|
return Image.open(io.BytesIO(obj))
|
||||||
except Exception:
|
except Exception:
|
||||||
|
Reference in New Issue
Block a user