aleo1 commited on
Commit
4ce0c66
1 Parent(s): 595a02a

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -12
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
- image_output = []
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
- with zipfile.ZipFile('./image.zip', 'r') as zip_ref:
185
- # 读取图像文件
186
- for img in info:
187
- with zip_ref.open(imgs_folder + img.replace('_', '/')) as image_file:
 
 
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)