Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -48,7 +48,7 @@ def process_queries(processor, queries, mock_image, max_length: int = 50):
|
|
48 |
return batch_query
|
49 |
|
50 |
|
51 |
-
def search(query: str, ds, images)
|
52 |
qs = []
|
53 |
with torch.no_grad():
|
54 |
batch_query = process_queries(processor, [query], mock_image)
|
@@ -59,9 +59,8 @@ def search(query: str, ds, images) -> str:
|
|
59 |
# run evaluation
|
60 |
retriever_evaluator = CustomEvaluator(is_multi_vector=True)
|
61 |
scores = retriever_evaluator.evaluate(qs, ds)
|
62 |
-
|
63 |
-
return f"The most relevant page is {
|
64 |
-
# return f"Query: {query}, most relevant page: 1, {len(ds)}", images[1]
|
65 |
|
66 |
|
67 |
def index(file, ds):
|
|
|
48 |
return batch_query
|
49 |
|
50 |
|
51 |
+
def search(query: str, ds, images):
|
52 |
qs = []
|
53 |
with torch.no_grad():
|
54 |
batch_query = process_queries(processor, [query], mock_image)
|
|
|
59 |
# run evaluation
|
60 |
retriever_evaluator = CustomEvaluator(is_multi_vector=True)
|
61 |
scores = retriever_evaluator.evaluate(qs, ds)
|
62 |
+
best_page = int(scores.argmax(axis=1).item())
|
63 |
+
return f"The most relevant page is {best_page}", images[best_page]
|
|
|
64 |
|
65 |
|
66 |
def index(file, ds):
|