manu commited on
Commit
83816c5
β€’
1 Parent(s): a2d6d06

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -4
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