Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
CHANGED
@@ -265,7 +265,17 @@ def img_search(image_query, top_k: int = 10):
|
|
265 |
# )
|
266 |
# 获取图像
|
267 |
if text_query != None:
|
268 |
-
image_output = [Image.open(imgs_folder + img.replace('_','/')) for img in info]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
269 |
else:
|
270 |
image_output = []
|
271 |
|
@@ -347,7 +357,17 @@ def txt_search(text_query, top_k: int = 10):
|
|
347 |
# )
|
348 |
# 获取图像
|
349 |
if text_query != None:
|
350 |
-
image_output = [Image.open(imgs_folder + img.replace('_',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
351 |
else:
|
352 |
image_output = []
|
353 |
|
|
|
265 |
# )
|
266 |
# 获取图像
|
267 |
if text_query != None:
|
268 |
+
# image_output = [Image.open(imgs_folder + img.replace('_','/')) for img in info]
|
269 |
+
image_output = []
|
270 |
+
for img in info:
|
271 |
+
sample_name = img.split('_')[0]
|
272 |
+
image_path = imgs_folder + sample_name + '.zip'
|
273 |
+
with zipfile.ZipFile(image_path, 'r') as zip_ref:
|
274 |
+
# 读取图像文件
|
275 |
+
with zip_ref.open(img.replace('_', '/')) as image_file:
|
276 |
+
# 将读取的字节流转换为图像
|
277 |
+
image = Image.open(BytesIO(image_file.read()))
|
278 |
+
image_output.append(image)
|
279 |
else:
|
280 |
image_output = []
|
281 |
|
|
|
357 |
# )
|
358 |
# 获取图像
|
359 |
if text_query != None:
|
360 |
+
# image_output = [Image.open(imgs_folder + img.replace('_','/')) for img in info]
|
361 |
+
image_output = []
|
362 |
+
for img in info:
|
363 |
+
sample_name = img.split('_')[0]
|
364 |
+
image_path = imgs_folder + sample_name + '.zip'
|
365 |
+
with zipfile.ZipFile(image_path, 'r') as zip_ref:
|
366 |
+
# 读取图像文件
|
367 |
+
with zip_ref.open(img.replace('_', '/')) as image_file:
|
368 |
+
# 将读取的字节流转换为图像
|
369 |
+
image = Image.open(BytesIO(image_file.read()))
|
370 |
+
image_output.append(image)
|
371 |
else:
|
372 |
image_output = []
|
373 |
|