Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -142,14 +142,14 @@ def retrieve_gradio(knowledge_base: str, query: str, topk: int):
|
|
142 |
|
143 |
similarities_np = similarities.cpu().numpy()
|
144 |
print(f"topk_doc_ids_np: {topk_doc_ids_np}, topk_values_np: {topk_values_np}")
|
145 |
-
images_topk = [Image.open(os.path.join(target_cache_dir, f"{index2img_filename[idx]}
|
146 |
|
147 |
with open(os.path.join(target_cache_dir, f"q-{query_md5}.json"), 'w') as f:
|
148 |
f.write(json.dumps(
|
149 |
{
|
150 |
"knowledge_base": knowledge_base,
|
151 |
"query": query,
|
152 |
-
"retrived_docs": [os.path.join(target_cache_dir, f"{index2img_filename[idx]}
|
153 |
}, indent=4, ensure_ascii=False
|
154 |
))
|
155 |
|
|
|
142 |
|
143 |
similarities_np = similarities.cpu().numpy()
|
144 |
print(f"topk_doc_ids_np: {topk_doc_ids_np}, topk_values_np: {topk_values_np}")
|
145 |
+
images_topk = [Image.open(os.path.join(target_cache_dir, f"{index2img_filename[idx]}")) for idx in topk_doc_ids_np]
|
146 |
|
147 |
with open(os.path.join(target_cache_dir, f"q-{query_md5}.json"), 'w') as f:
|
148 |
f.write(json.dumps(
|
149 |
{
|
150 |
"knowledge_base": knowledge_base,
|
151 |
"query": query,
|
152 |
+
"retrived_docs": [os.path.join(target_cache_dir, f"{index2img_filename[idx]}") for idx in topk_doc_ids_np]
|
153 |
}, indent=4, ensure_ascii=False
|
154 |
))
|
155 |
|