Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
CHANGED
@@ -169,22 +169,17 @@ def search(text_query, image_query, top_k: int = 10):
|
|
169 |
# {"Score": [torch.round(torch.tensor(value)*100)/100 for value in top_k_scores], "Title": top_k_titles, "Text": top_k_texts}
|
170 |
# )
|
171 |
# 获取图像
|
172 |
-
|
173 |
-
for img in info:
|
174 |
-
with zipfile.ZipFile('./image.zip', 'r') as zip_ref:
|
175 |
-
# 读取图像文件
|
176 |
-
with zip_ref.open(imgs_folder + img.replace('_','/')) as image_file:
|
177 |
-
# 将读取的字节流转换为图像
|
178 |
-
image = Image.open(BytesIO(image_file.read()))
|
179 |
-
image_output.append(image)
|
180 |
|
181 |
if text_query != None:
|
182 |
# image_output = [Image.open(imgs_folder + img.replace('_','/')) for img in info]
|
183 |
image_output = []
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
|
|
|
|
188 |
# 将读取的字节流转换为图像
|
189 |
image = Image.open(BytesIO(image_file.read()))
|
190 |
image_output.append(image)
|
|
|
169 |
# {"Score": [torch.round(torch.tensor(value)*100)/100 for value in top_k_scores], "Title": top_k_titles, "Text": top_k_texts}
|
170 |
# )
|
171 |
# 获取图像
|
172 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
173 |
|
174 |
if text_query != None:
|
175 |
# image_output = [Image.open(imgs_folder + img.replace('_','/')) for img in info]
|
176 |
image_output = []
|
177 |
+
for img in info:
|
178 |
+
sample_name = img.split('_')[0]
|
179 |
+
image_path = imgs_folder + sample_name + '.zip'
|
180 |
+
with zipfile.ZipFile(image_path, 'r') as zip_ref:
|
181 |
+
# 读取图像文件
|
182 |
+
with zip_ref.open(img.replace('_', '/')) as image_file:
|
183 |
# 将读取的字节流转换为图像
|
184 |
image = Image.open(BytesIO(image_file.read()))
|
185 |
image_output.append(image)
|