Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
change file directories
Browse files- RAG/colpali.py +3 -3
RAG/colpali.py
CHANGED
@@ -159,7 +159,7 @@ def img_highlight(img,batch_queries,query_tokens):
|
|
159 |
img_name = os.path.basename(img) # e.g., "my_image.png"
|
160 |
|
161 |
# Construct the search pattern
|
162 |
-
search_pattern = f"/
|
163 |
|
164 |
# Search for matching files
|
165 |
matching_files = glob.glob(search_pattern)
|
@@ -251,7 +251,7 @@ def img_highlight(img,batch_queries,query_tokens):
|
|
251 |
for idx, (fig, ax) in enumerate(plots):
|
252 |
if(idx<3):
|
253 |
continue
|
254 |
-
savepath = "/
|
255 |
fig.savefig(savepath, bbox_inches="tight")
|
256 |
map_images.append({'file':savepath})
|
257 |
print(f"Similarity map for token `{query_tokens_from_model[idx]}` saved at `{savepath}`")
|
@@ -344,7 +344,7 @@ def colpali_search_rerank(query):
|
|
344 |
final_docs.append(doc)
|
345 |
final_docs_sorted = sorted(final_docs, key=lambda d: d['total_score'], reverse=True)
|
346 |
final_docs_sorted_20.append(final_docs_sorted[:20])
|
347 |
-
img = "/
|
348 |
ans = generate_ans(img,query)
|
349 |
|
350 |
images_highlighted = [{'file':img}]
|
|
|
159 |
img_name = os.path.basename(img) # e.g., "my_image.png"
|
160 |
|
161 |
# Construct the search pattern
|
162 |
+
search_pattern = f"/data/app_bkp/similarity_maps/similarity_map_{img_name}_token_*"
|
163 |
|
164 |
# Search for matching files
|
165 |
matching_files = glob.glob(search_pattern)
|
|
|
251 |
for idx, (fig, ax) in enumerate(plots):
|
252 |
if(idx<3):
|
253 |
continue
|
254 |
+
savepath = "/data/app_bkp/similarity_maps/similarity_map_"+(img.split("/"))[-1]+"_token_"+str(idx)+"_"+query_tokens_from_model[idx]+".png"
|
255 |
fig.savefig(savepath, bbox_inches="tight")
|
256 |
map_images.append({'file':savepath})
|
257 |
print(f"Similarity map for token `{query_tokens_from_model[idx]}` saved at `{savepath}`")
|
|
|
344 |
final_docs.append(doc)
|
345 |
final_docs_sorted = sorted(final_docs, key=lambda d: d['total_score'], reverse=True)
|
346 |
final_docs_sorted_20.append(final_docs_sorted[:20])
|
347 |
+
img = "/data/app_bkp/vs/"+final_docs_sorted_20[0][0]['image']
|
348 |
ans = generate_ans(img,query)
|
349 |
|
350 |
images_highlighted = [{'file':img}]
|