Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -34,9 +34,6 @@ def search(query: str, ds, images, k):
|
|
34 |
if device != model.device:
|
35 |
model.to(device)
|
36 |
|
37 |
-
print(f"model device: {model.device}")
|
38 |
-
|
39 |
-
|
40 |
qs = []
|
41 |
with torch.no_grad():
|
42 |
batch_query = process_queries(processor, [query], mock_image)
|
@@ -79,14 +76,10 @@ def index(files, ds):
|
|
79 |
if device != model.device:
|
80 |
model.to(device)
|
81 |
|
82 |
-
print(f"model device: {model.device}")
|
83 |
-
|
84 |
|
85 |
for batch_doc in tqdm(dataloader):
|
86 |
with torch.no_grad():
|
87 |
batch_doc = {k: v.to(device) for k, v in batch_doc.items()}
|
88 |
-
print(f"model device: {model.device}")
|
89 |
-
print(f"model device: {batch_doc['input_ids']}")
|
90 |
embeddings_doc = model(**batch_doc)
|
91 |
ds.extend(list(torch.unbind(embeddings_doc.to("cpu"))))
|
92 |
return f"Uploaded and converted {len(images)} pages", ds, images
|
|
|
34 |
if device != model.device:
|
35 |
model.to(device)
|
36 |
|
|
|
|
|
|
|
37 |
qs = []
|
38 |
with torch.no_grad():
|
39 |
batch_query = process_queries(processor, [query], mock_image)
|
|
|
76 |
if device != model.device:
|
77 |
model.to(device)
|
78 |
|
|
|
|
|
79 |
|
80 |
for batch_doc in tqdm(dataloader):
|
81 |
with torch.no_grad():
|
82 |
batch_doc = {k: v.to(device) for k, v in batch_doc.items()}
|
|
|
|
|
83 |
embeddings_doc = model(**batch_doc)
|
84 |
ds.extend(list(torch.unbind(embeddings_doc.to("cpu"))))
|
85 |
return f"Uploaded and converted {len(images)} pages", ds, images
|