Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -21,7 +21,7 @@ def search(query: str, ds, images, k):
|
|
21 |
qs = []
|
22 |
with torch.no_grad():
|
23 |
batch_query = process_queries(processor, [query], mock_image)
|
24 |
-
batch_query = {k: v.to(device) for k, v in batch_query.items()}
|
25 |
embeddings_query = model(**batch_query)
|
26 |
qs.extend(list(torch.unbind(embeddings_query.to("cpu"))))
|
27 |
|
@@ -55,11 +55,9 @@ def index(files, ds):
|
|
55 |
collate_fn=lambda x: process_images(processor, x),
|
56 |
)
|
57 |
|
58 |
-
print(f"model device: {model.device}")
|
59 |
-
print(f"device: {device}")
|
60 |
for batch_doc in tqdm(dataloader):
|
61 |
with torch.no_grad():
|
62 |
-
batch_doc = {k: v.to(device) for k, v in batch_doc.items()}
|
63 |
embeddings_doc = model(**batch_doc)
|
64 |
ds.extend(list(torch.unbind(embeddings_doc.to("cpu"))))
|
65 |
return f"Uploaded and converted {len(images)} pages", ds, images
|
|
|
21 |
qs = []
|
22 |
with torch.no_grad():
|
23 |
batch_query = process_queries(processor, [query], mock_image)
|
24 |
+
batch_query = {k: v.to(model.device) for k, v in batch_query.items()}
|
25 |
embeddings_query = model(**batch_query)
|
26 |
qs.extend(list(torch.unbind(embeddings_query.to("cpu"))))
|
27 |
|
|
|
55 |
collate_fn=lambda x: process_images(processor, x),
|
56 |
)
|
57 |
|
|
|
|
|
58 |
for batch_doc in tqdm(dataloader):
|
59 |
with torch.no_grad():
|
60 |
+
batch_doc = {k: v.to(model.device) for k, v in batch_doc.items()}
|
61 |
embeddings_doc = model(**batch_doc)
|
62 |
ds.extend(list(torch.unbind(embeddings_doc.to("cpu"))))
|
63 |
return f"Uploaded and converted {len(images)} pages", ds, images
|