openscopelabs commited on
Commit
f1803be
·
1 Parent(s): 8653aff

fix(deploy): unblock Dockerfile build + slim image for HF CPU spaces

Browse files

- Add `git` to apt deps so pip can install `clip` from its git URL.
YOLO-World's `model.set_classes(...)` lazy-imports CLIP at runtime
and Ultralytics' auto-installer relies on git+pip; without git in
the image the build crashed inside `scripts.setup_yolo_world` with
ModuleNotFoundError: No module named 'clip'.
- Pin clip in requirements.txt so the dependency is explicit + the
resolver doesn't try the auto-install path at runtime.
- Install CPU-only torch/torchvision wheels from
https://download.pytorch.org/whl/cpu before the rest of pip
requirements. The default PyPI torch bundles CUDA (~700 MB) which a
CPU Hugging Face space can't use; this cuts ~700 MB off the final
image. Subsequent `pip install -r requirements.txt` sees torch>=2.2
already satisfied and skips reinstall.
- Drop unused deps: aiortc (WebRTC was removed), ffmpeg-python (we
spawn ffmpeg via subprocess), pandas (never imported), httpx
(removed with the HLS proxy).

Files changed (2) hide show
  1. Dockerfile +8 -0
  2. requirements.txt +6 -4
Dockerfile CHANGED
@@ -21,6 +21,7 @@ RUN apt-get update \
21
  libglib2.0-0 \
22
  curl \
23
  ca-certificates \
 
24
  && rm -rf /var/lib/apt/lists/*
25
 
26
  WORKDIR /app
@@ -28,7 +29,14 @@ WORKDIR /app
28
  # --- python deps -----------------------------------------------------
29
  # Copy requirements first to maximise layer caching on code-only edits.
30
  COPY requirements.txt ./
 
 
 
 
31
  RUN pip install --no-cache-dir --upgrade pip \
 
 
 
32
  && pip install --no-cache-dir -r requirements.txt
33
 
34
  # --- app source ------------------------------------------------------
 
21
  libglib2.0-0 \
22
  curl \
23
  ca-certificates \
24
+ git \
25
  && rm -rf /var/lib/apt/lists/*
26
 
27
  WORKDIR /app
 
29
  # --- python deps -----------------------------------------------------
30
  # Copy requirements first to maximise layer caching on code-only edits.
31
  COPY requirements.txt ./
32
+ # Install CPU-only torch/torchvision first — the default PyPI wheels
33
+ # bundle CUDA (~700 MB extra) which a Hugging Face CPU space can't use
34
+ # anyway. Subsequent `pip install -r requirements.txt` sees torch>=2.2
35
+ # is already satisfied and skips the redownload.
36
  RUN pip install --no-cache-dir --upgrade pip \
37
+ && pip install --no-cache-dir \
38
+ --index-url https://download.pytorch.org/whl/cpu \
39
+ torch torchvision \
40
  && pip install --no-cache-dir -r requirements.txt
41
 
42
  # --- app source ------------------------------------------------------
requirements.txt CHANGED
@@ -2,12 +2,14 @@ fastapi==0.115.5
2
  uvicorn[standard]==0.32.1
3
  pydantic==2.10.3
4
  ultralytics==8.3.40
 
 
 
 
 
 
5
  supervision==0.25.1
6
  opencv-python-headless==4.10.0.84
7
  numpy>=1.26
8
- pandas>=2.2
9
  torch>=2.2
10
- ffmpeg-python==0.2.0
11
  psycopg[binary]>=3.2
12
- httpx>=0.27
13
- aiortc>=1.9
 
2
  uvicorn[standard]==0.32.1
3
  pydantic==2.10.3
4
  ultralytics==8.3.40
5
+ # YOLO-World's text-prompt classifier loads OpenAI CLIP at runtime via
6
+ # `model.set_classes(...)`. Ultralytics auto-pip-installs it on demand,
7
+ # but that path needs `git` in the image AND a network reach at first
8
+ # request. Bake it into requirements so the dependency is explicit,
9
+ # version-pinned-ish, and resolved at image build time.
10
+ clip @ git+https://github.com/ultralytics/CLIP.git
11
  supervision==0.25.1
12
  opencv-python-headless==4.10.0.84
13
  numpy>=1.26
 
14
  torch>=2.2
 
15
  psycopg[binary]>=3.2