Spaces:
Running
on
L4
Running
on
L4
Upload backend/colpali.py with huggingface_hub
Browse files- backend/colpali.py +9 -9
backend/colpali.py
CHANGED
|
@@ -27,8 +27,8 @@ from vespa.io import VespaQueryResponse
|
|
| 27 |
matplotlib.use("Agg")
|
| 28 |
|
| 29 |
MAX_QUERY_TERMS = 64
|
| 30 |
-
OUTPUT_DIR = Path(__file__).parent.parent / "output" / "sim_maps"
|
| 31 |
-
OUTPUT_DIR.mkdir(exist_ok=True)
|
| 32 |
|
| 33 |
COLPALI_GEMMA_MODEL_ID = "vidore--colpaligemma-3b-pt-448-base"
|
| 34 |
COLPALI_GEMMA_MODEL_SNAPSHOT = "12c59eb7e23bc4c26876f7be7c17760d5d3a1ffa"
|
|
@@ -156,12 +156,12 @@ def gen_similarity_map(
|
|
| 156 |
return fig, ax
|
| 157 |
|
| 158 |
|
| 159 |
-
def save_figure(fig, filename: str = "similarity_map.png"):
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
|
| 166 |
|
| 167 |
def annotate_plot(ax, query, selected_token):
|
|
@@ -256,7 +256,7 @@ def gen_similarity_map_new(
|
|
| 256 |
)
|
| 257 |
ax = annotate_plot(ax, query, token_to_show)
|
| 258 |
# save the figure
|
| 259 |
-
save_figure(fig, f"similarity_map_{token_to_show}.png")
|
| 260 |
return fig, ax
|
| 261 |
|
| 262 |
|
|
|
|
| 27 |
matplotlib.use("Agg")
|
| 28 |
|
| 29 |
MAX_QUERY_TERMS = 64
|
| 30 |
+
# OUTPUT_DIR = Path(__file__).parent.parent / "output" / "sim_maps"
|
| 31 |
+
# OUTPUT_DIR.mkdir(exist_ok=True)
|
| 32 |
|
| 33 |
COLPALI_GEMMA_MODEL_ID = "vidore--colpaligemma-3b-pt-448-base"
|
| 34 |
COLPALI_GEMMA_MODEL_SNAPSHOT = "12c59eb7e23bc4c26876f7be7c17760d5d3a1ffa"
|
|
|
|
| 156 |
return fig, ax
|
| 157 |
|
| 158 |
|
| 159 |
+
# def save_figure(fig, filename: str = "similarity_map.png"):
|
| 160 |
+
# fig.savefig(
|
| 161 |
+
# OUTPUT_DIR / filename,
|
| 162 |
+
# bbox_inches="tight",
|
| 163 |
+
# pad_inches=0,
|
| 164 |
+
# )
|
| 165 |
|
| 166 |
|
| 167 |
def annotate_plot(ax, query, selected_token):
|
|
|
|
| 256 |
)
|
| 257 |
ax = annotate_plot(ax, query, token_to_show)
|
| 258 |
# save the figure
|
| 259 |
+
# save_figure(fig, f"similarity_map_{token_to_show}.png")
|
| 260 |
return fig, ax
|
| 261 |
|
| 262 |
|