Skip to content

Commit 6498b44

Browse files
authored
Merge pull request #1805 from vespa-engine/thomasht86/fix-colpali-deps
Thomasht86/fix colpali deps
2 parents c6ab6f1 + 980d783 commit 6498b44

File tree

7 files changed

+1532
-1468
lines changed

7 files changed

+1532
-1468
lines changed

visual-retrieval-colpali/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,15 +128,15 @@ See [Custom python spaces](https://huggingface.co/docs/hub/en/spaces-sdks-python
128128

129129
#### Upload the files
130130

131-
To deploy, run
131+
To deploy, run from the project root directory:
132132

133133
(Replace `vespa-engine/colpali-vespa-visual-retrieval` with your own huggingface user/repo name, does not need to exist beforehand)
134134

135135
```bash
136-
huggingface-cli upload vespa-engine/colpali-vespa-visual-retrieval src . --repo-type=space
136+
hf upload vespa-engine/colpali-vespa-visual-retrieval src . --repo-type=space --delete "*" --commit-message "Deploy to HF Space"
137137
```
138138

139-
Note that we upload only the `src` directory.
139+
Note that we upload only the `src` directory. The `--delete "*"` flag ensures that any files that exist in the space but not in your local `src` directory will be removed, keeping everything in sync.
140140

141141
## Development
142142

visual-retrieval-colpali/pyproject.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,22 @@ readme = "README.md"
66
requires-python = ">=3.10, <3.12"
77
license = { text = "Apache-2.0" }
88
dependencies = [
9-
"python-fasthtml",
9+
"python-fasthtml==0.12.33",
10+
"uvicorn[standard]==0.38.0",
1011
"huggingface-hub",
1112
"pyvespa>=0.50.0",
1213
"vespacli",
1314
"torch",
1415
"vidore-benchmark[interpretability]>=4.0.0,<5.0.0",
15-
"colpali-engine",
16+
"colpali-engine==0.3.1",
1617
"einops",
1718
"pypdf",
1819
"setuptools",
1920
"python-dotenv",
2021
"shad4fast>=1.2.1",
2122
"google-generativeai>=0.7.2",
2223
"spacy",
24+
"transformers==4.45",
2325
"pip",
2426
]
2527

visual-retrieval-colpali/src/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ app_file: main.py
1010
pinned: false
1111
license: apache-2.0
1212
suggested_hardware: t4-small
13+
header: mini
1314
models:
1415
- vidore/colpaligemma-3b-pt-448-base
1516
- vidore/colpali-v1.2

visual-retrieval-colpali/src/frontend/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ def ChatResult(query_id: str, query: str, doc_ids: Optional[list] = None):
755755
)
756756

757757
return Div(
758-
Div("AI-response (Gemini-2.0)", cls="text-xl font-semibold p-5"),
758+
Div("AI-response (Gemini-2.5)", cls="text-xl font-semibold p-5"),
759759
Div(
760760
Div(
761761
messages,

visual-retrieval-colpali/src/main.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
Script,
2525
StreamingResponse,
2626
fast_app,
27-
serve,
2827
)
2928
from PIL import Image
3029
from shad4fast import ShadHead
@@ -43,6 +42,7 @@
4342
SimMapButtonReady,
4443
)
4544
from frontend.layout import Layout
45+
import uvicorn
4646

4747
highlight_js_theme_link = Link(id="highlight-theme", rel="stylesheet", href="")
4848
highlight_js_theme = Script(src="/static/js/highlightjs-theme.js")
@@ -68,7 +68,11 @@
6868
awesomplete_js = Script(
6969
src="https://cdnjs.cloudflare.com/ajax/libs/awesomplete/1.1.7/awesomplete.min.js"
7070
)
71-
sselink = Script(src="https://unpkg.com/[email protected]/sse.js")
71+
sselink = Script(
72+
src="https://cdn.jsdelivr.net/npm/[email protected]",
73+
integrity="sha384-A986SAtodyH8eg8x8irJnYUk7i9inVQqYigD6qZ9evobksGNIXfeFvDwLSHcp31N",
74+
crossorigin="anonymous",
75+
)
7276

7377
# Get log level from environment variable, default to INFO
7478
LOG_LEVEL = os.getenv("LOG_LEVEL", "INFO").upper()
@@ -112,7 +116,7 @@
112116
Do NOT include backticks (`) in your response. Only simple HTML tags and text.
113117
"""
114118
gemini_model = genai.GenerativeModel(
115-
"gemini-2.0-flash", system_instruction=GEMINI_SYSTEM_PROMPT
119+
"gemini-2.5-flash", system_instruction=GEMINI_SYSTEM_PROMPT
116120
)
117121
STATIC_DIR = Path("static")
118122
IMG_DIR = STATIC_DIR / "full_images"
@@ -381,7 +385,7 @@ async def message_generator(query_id: str, query: str, doc_ids: list):
381385
# yield message with number of images ready
382386
yield f"event: message\ndata: Generating response based on {len(images)} images...\n\n"
383387
if not images:
384-
yield "event: message\ndata: Failed to send images to Gemini 2.0!\n\n"
388+
yield "event: message\ndata: Failed to send images to Gemini 2.5!\n\n"
385389
yield "event: close\ndata: \n\n"
386390
return
387391

@@ -417,4 +421,5 @@ def get():
417421
if __name__ == "__main__":
418422
HOT_RELOAD = os.getenv("HOT_RELOAD", "False").lower() == "true"
419423
logger.info(f"Starting app with hot reload: {HOT_RELOAD}")
420-
serve(port=7860, reload=HOT_RELOAD)
424+
uvicorn.run("main:app", host="0.0.0.0", timeout_worker_healthcheck=30, port=7860)
425+
# serve(port=7860, reload=HOT_RELOAD)

visual-retrieval-colpali/src/requirements.txt

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
# uv pip compile pyproject.toml -o src/requirements.txt
33
accelerate==0.34.2
44
# via peft
5-
aiohappyeyeballs==2.4.3
5+
aiohappyeyeballs==2.6.1
66
# via aiohttp
77
aiohttp==3.12.14
88
# via
99
# datasets
1010
# fsspec
1111
# pyvespa
12-
aiosignal==1.3.1
12+
aiosignal==1.4.0
1313
# via aiohttp
1414
annotated-types==0.7.0
1515
# via pydantic
@@ -18,6 +18,10 @@ anyio==4.6.0
1818
# httpx
1919
# starlette
2020
# watchfiles
21+
apsw==3.50.4.0
22+
# via apswutils
23+
apswutils==0.1.0
24+
# via fastlite
2125
async-timeout==4.0.3
2226
# via aiohttp
2327
attrs==24.2.0
@@ -85,13 +89,13 @@ eval-type-backport==0.2.0
8589
# via mteb
8690
exceptiongroup==1.2.2
8791
# via anyio
88-
fastcore==1.7.11
92+
fastcore==1.8.15
8993
# via
94+
# apswutils
9095
# fastlite
9196
# python-fasthtml
9297
# pyvespa
93-
# sqlite-minutils
94-
fastlite==0.0.11
98+
fastlite==0.2.1
9599
# via python-fasthtml
96100
filelock==3.16.1
97101
# via
@@ -150,21 +154,23 @@ h11==0.16.0
150154
# uvicorn
151155
h2==4.3.0
152156
# via httpx
153-
hpack==4.0.0
157+
hf-xet==1.2.0
158+
# via huggingface-hub
159+
hpack==4.1.0
154160
# via h2
155-
httpcore==1.0.6
161+
httpcore==1.0.9
156162
# via httpx
157163
httplib2==0.22.0
158164
# via
159165
# google-api-python-client
160166
# google-auth-httplib2
161-
httptools==0.6.1
167+
httptools==0.7.1
162168
# via uvicorn
163169
httpx==0.27.2
164170
# via
165171
# python-fasthtml
166172
# pyvespa
167-
huggingface-hub==0.25.1
173+
huggingface-hub==0.36.0
168174
# via
169175
# visual-retrieval-colpali (pyproject.toml)
170176
# accelerate
@@ -173,7 +179,7 @@ huggingface-hub==0.25.1
173179
# sentence-transformers
174180
# tokenizers
175181
# transformers
176-
hyperframe==6.0.1
182+
hyperframe==6.1.0
177183
# via h2
178184
idna==3.10
179185
# via
@@ -291,6 +297,10 @@ preshed==3.0.9
291297
# via
292298
# spacy
293299
# thinc
300+
propcache==0.4.1
301+
# via
302+
# aiohttp
303+
# yarl
294304
proto-plus==1.24.0
295305
# via
296306
# google-ai-generativelanguage
@@ -346,7 +356,7 @@ python-dotenv==1.0.1
346356
# visual-retrieval-colpali (pyproject.toml)
347357
# uvicorn
348358
# vidore-benchmark
349-
python-fasthtml==0.6.9
359+
python-fasthtml==0.12.33
350360
# via
351361
# visual-retrieval-colpali (pyproject.toml)
352362
# lucide-fasthtml
@@ -439,8 +449,6 @@ spacy-legacy==3.0.12
439449
# via spacy
440450
spacy-loggers==1.0.5
441451
# via spacy
442-
sqlite-minutils==3.37.0.post3
443-
# via fastlite
444452
srsly==2.4.8
445453
# via
446454
# confection
@@ -457,7 +465,7 @@ thinc==8.2.5
457465
# via spacy
458466
threadpoolctl==3.5.0
459467
# via scikit-learn
460-
tokenizers==0.20.0
468+
tokenizers==0.20.3
461469
# via transformers
462470
torch==2.8.0
463471
# via
@@ -478,8 +486,9 @@ tqdm==4.66.5
478486
# sentence-transformers
479487
# spacy
480488
# transformers
481-
transformers==4.53.0
489+
transformers==4.45.0
482490
# via
491+
# visual-retrieval-colpali (pyproject.toml)
483492
# colpali-engine
484493
# peft
485494
# sentence-transformers
@@ -491,6 +500,7 @@ typer==0.12.5
491500
# weasel
492501
typing-extensions==4.12.2
493502
# via
503+
# aiosignal
494504
# anyio
495505
# cloudpathlib
496506
# google-generativeai
@@ -502,6 +512,7 @@ typing-extensions==4.12.2
502512
# pypdf
503513
# pyvespa
504514
# rich
515+
# starlette
505516
# torch
506517
# typer
507518
# uvicorn
@@ -513,8 +524,10 @@ urllib3==2.5.0
513524
# via
514525
# docker
515526
# requests
516-
uvicorn==0.31.0
517-
# via python-fasthtml
527+
uvicorn==0.38.0
528+
# via
529+
# visual-retrieval-colpali (pyproject.toml)
530+
# python-fasthtml
518531
uvloop==0.20.0
519532
# via uvicorn
520533
vespacli==8.391.23
@@ -536,5 +549,5 @@ wrapt==1.16.0
536549
# via smart-open
537550
xxhash==3.5.0
538551
# via datasets
539-
yarl==1.13.1
552+
yarl==1.22.0
540553
# via aiohttp

0 commit comments

Comments
 (0)