From 4e721897730e1127b4668cad1caa464defd8969b Mon Sep 17 00:00:00 2001 From: thomasht86 Date: Tue, 29 Oct 2024 11:18:00 +0100 Subject: [PATCH] update colpali version --- ...retrieval-with-colpali-vlm_Vespa-cloud.ipynb | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/docs/sphinx/source/examples/simplified-retrieval-with-colpali-vlm_Vespa-cloud.ipynb b/docs/sphinx/source/examples/simplified-retrieval-with-colpali-vlm_Vespa-cloud.ipynb index 2bdb4f6b..fa6b9753 100644 --- a/docs/sphinx/source/examples/simplified-retrieval-with-colpali-vlm_Vespa-cloud.ipynb +++ b/docs/sphinx/source/examples/simplified-retrieval-with-colpali-vlm_Vespa-cloud.ipynb @@ -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" ] }, { @@ -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" ] }, @@ -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)" ] }, { @@ -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", @@ -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",