manu commited on
Commit
94b55f0
1 Parent(s): ef183b3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -1,3 +1,5 @@
 
 
1
  import gradio as gr
2
  from pdf2image import convert_from_path
3
 
@@ -6,6 +8,7 @@ from PIL import Image
6
  from torch.utils.data import DataLoader
7
  from tqdm import tqdm
8
  from transformers import AutoProcessor
 
9
 
10
  from custom_colbert.models.paligemma_colbert_architecture import ColPali
11
  from custom_colbert.trainer.retrieval_evaluator import CustomEvaluator
@@ -87,9 +90,10 @@ def index(file):
87
  COLORS = ['#4285f4', '#db4437', '#f4b400', '#0f9d58', '#e48ef1']
88
  # Load model
89
  model_name = "coldoc/colpali-3b-mix-448"
90
- model = ColPali.from_pretrained("google/paligemma-3b-mix-448", torch_dtype=torch.bfloat16, device_map="cuda").eval()
 
91
  model.load_adapter(model_name)
92
- processor = AutoProcessor.from_pretrained(model_name)
93
  device = model.device
94
  mock_image = Image.new("RGB", (448, 448), (255, 255, 255))
95
 
 
1
+ import os
2
+
3
  import gradio as gr
4
  from pdf2image import convert_from_path
5
 
 
8
  from torch.utils.data import DataLoader
9
  from tqdm import tqdm
10
  from transformers import AutoProcessor
11
+ imoort os
12
 
13
  from custom_colbert.models.paligemma_colbert_architecture import ColPali
14
  from custom_colbert.trainer.retrieval_evaluator import CustomEvaluator
 
90
  COLORS = ['#4285f4', '#db4437', '#f4b400', '#0f9d58', '#e48ef1']
91
  # Load model
92
  model_name = "coldoc/colpali-3b-mix-448"
93
+ token = os.environ.get("HF_TOKEN")
94
+ model = ColPali.from_pretrained("google/paligemma-3b-mix-448", torch_dtype=torch.bfloat16, device_map="cuda", token=token).eval()
95
  model.load_adapter(model_name)
96
+ processor = AutoProcessor.from_pretrained(model_name, token=token)
97
  device = model.device
98
  mock_image = Image.new("RGB", (448, 448), (255, 255, 255))
99