Skip to content

Commit

Permalink
update colpali version
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasht86 committed Oct 29, 2024
1 parent b4bac41 commit 4e72189
Showing 1 changed file with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
},
"outputs": [],
"source": [
"!pip3 install colpali-engine==0.2.2 pdf2image pypdf==5.0.1 pyvespa vespacli requests numpy"
"!pip3 install colpali-engine==0.3.2 pdf2image pypdf==5.0.1 pyvespa vespacli requests numpy"
]
},
{
Expand All @@ -93,15 +93,11 @@
"import torch\n",
"from torch.utils.data import DataLoader\n",
"from tqdm import tqdm\n",
"from transformers import AutoProcessor\n",
"from PIL import Image\n",
"from io import BytesIO\n",
"\n",
"from colpali_engine.models.paligemma_colbert_architecture import ColPali\n",
"from colpali_engine.utils.colpali_processing_utils import (\n",
" process_images,\n",
" process_queries,\n",
")\n",
"from colpali_engine.models import ColPali, ColPaliProcessor\n",
"\n",
"from colpali_engine.utils.image_utils import scale_image, get_base64_image"
]
},
Expand Down Expand Up @@ -330,10 +326,9 @@
"source": [
"model_name = \"vidore/colpali-v1.2\"\n",
"model = ColPali.from_pretrained(model_name, torch_dtype=type).eval()\n",
"model.load_adapter(model_name)\n",
"model = model.eval()\n",
"model.to(device)\n",
"processor = AutoProcessor.from_pretrained(model_name)"
"processor = ColPaliProcessor.from_pretrained(model_name)"
]
},
{
Expand Down Expand Up @@ -583,7 +578,7 @@
" pdf[\"images\"],\n",
" batch_size=2,\n",
" shuffle=False,\n",
" collate_fn=lambda x: process_images(processor, x),\n",
" collate_fn=lambda x: processor.process_images(x),\n",
" )\n",
" for batch_doc in tqdm(dataloader):\n",
" with torch.no_grad():\n",
Expand Down Expand Up @@ -966,7 +961,7 @@
" queries,\n",
" batch_size=1,\n",
" shuffle=False,\n",
" collate_fn=lambda x: process_queries(processor, x, dummy_image),\n",
" collate_fn=lambda x: processor.process_queries(x),\n",
")\n",
"qs = []\n",
"for batch_query in dataloader:\n",
Expand Down

0 comments on commit 4e72189

Please sign in to comment.