AdrienB134 commited on
Commit
6c26916
1 Parent(s): 9373b86
Files changed (1) hide show
  1. app.py +5 -0
app.py CHANGED
@@ -84,6 +84,9 @@ def model_inference(
84
  output_text = processor.batch_decode(
85
  generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
86
  )
 
 
 
87
  return output_text[0]
88
 
89
 
@@ -124,6 +127,7 @@ def search(query: str, ds, images, k):
124
  results.append((images[idx])) #, f"Page {idx}"
125
  del model
126
  del processor
 
127
  print("done")
128
  return results
129
 
@@ -181,6 +185,7 @@ def index_gpu(images, ds):
181
  ds.extend(list(torch.unbind(embeddings_doc.to("cpu"))))
182
  del model
183
  del processor
 
184
  print("done")
185
  return f"Uploaded and converted {len(images)} pages", ds, images
186
 
 
84
  output_text = processor.batch_decode(
85
  generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
86
  )
87
+ del model
88
+ del processor
89
+ torch.cuda.empty_cache()
90
  return output_text[0]
91
 
92
 
 
127
  results.append((images[idx])) #, f"Page {idx}"
128
  del model
129
  del processor
130
+ torch.cuda.empty_cache()
131
  print("done")
132
  return results
133
 
 
185
  ds.extend(list(torch.unbind(embeddings_doc.to("cpu"))))
186
  del model
187
  del processor
188
+ torch.cuda.empty_cache()
189
  print("done")
190
  return f"Uploaded and converted {len(images)} pages", ds, images
191