Spaces:
Sleeping
Sleeping
Commit ·
95ddc8a
1
Parent(s): 1947612
feat: download ONNX model from HF Hub at build time, add django-cors-headers
Browse files- Dockerfile +15 -1
- backend/requirements.txt +1 -0
Dockerfile
CHANGED
|
@@ -6,6 +6,9 @@ ENV PYTHONDONTWRITEBYTECODE=1
|
|
| 6 |
ENV PYTHONUNBUFFERED=1
|
| 7 |
ENV PORT=7860
|
| 8 |
|
|
|
|
|
|
|
|
|
|
| 9 |
WORKDIR /app
|
| 10 |
|
| 11 |
# Install system dependencies, curl, OpenCV support, Node.js 20,
|
|
@@ -26,10 +29,21 @@ COPY backend/requirements.txt ./backend/requirements.txt
|
|
| 26 |
# Upgrade pip and install requirements + gunicorn directly in container
|
| 27 |
RUN pip install --no-cache-dir --upgrade pip setuptools wheel \
|
| 28 |
&& pip install --no-cache-dir -r ./backend/requirements.txt \
|
| 29 |
-
&& pip install --no-cache-dir gunicorn
|
| 30 |
|
| 31 |
COPY backend/ ./backend/
|
| 32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
# ---- Prepare Node.js & React Frontend ----
|
| 34 |
COPY package*.json ./
|
| 35 |
# Force installation of devDependencies (Vite, esbuild, typescript) for building, even if NODE_ENV=production
|
|
|
|
| 6 |
ENV PYTHONUNBUFFERED=1
|
| 7 |
ENV PORT=7860
|
| 8 |
|
| 9 |
+
# HF model repo where dermavision.onnx is stored (override with --build-arg)
|
| 10 |
+
ARG HF_MODEL_REPO=WilfredAyine/dermavision-onnx
|
| 11 |
+
|
| 12 |
WORKDIR /app
|
| 13 |
|
| 14 |
# Install system dependencies, curl, OpenCV support, Node.js 20,
|
|
|
|
| 29 |
# Upgrade pip and install requirements + gunicorn directly in container
|
| 30 |
RUN pip install --no-cache-dir --upgrade pip setuptools wheel \
|
| 31 |
&& pip install --no-cache-dir -r ./backend/requirements.txt \
|
| 32 |
+
&& pip install --no-cache-dir gunicorn huggingface_hub
|
| 33 |
|
| 34 |
COPY backend/ ./backend/
|
| 35 |
|
| 36 |
+
# ---- Download ONNX model from Hugging Face Hub ----
|
| 37 |
+
# The model is too large for git — it lives in a dedicated HF model repo.
|
| 38 |
+
RUN python3 -c "
|
| 39 |
+
from huggingface_hub import hf_hub_download
|
| 40 |
+
import shutil, pathlib
|
| 41 |
+
dst = pathlib.Path('/app/backend/model')
|
| 42 |
+
dst.mkdir(parents=True, exist_ok=True)
|
| 43 |
+
path = hf_hub_download(repo_id='${HF_MODEL_REPO}', filename='dermavision.onnx', local_dir=str(dst))
|
| 44 |
+
print(f'Model downloaded to {path}')
|
| 45 |
+
"
|
| 46 |
+
|
| 47 |
# ---- Prepare Node.js & React Frontend ----
|
| 48 |
COPY package*.json ./
|
| 49 |
# Force installation of devDependencies (Vite, esbuild, typescript) for building, even if NODE_ENV=production
|
backend/requirements.txt
CHANGED
|
@@ -17,3 +17,4 @@ httpx>=0.27
|
|
| 17 |
python-dotenv>=1.0
|
| 18 |
reportlab
|
| 19 |
qrcode[pil]
|
|
|
|
|
|
| 17 |
python-dotenv>=1.0
|
| 18 |
reportlab
|
| 19 |
qrcode[pil]
|
| 20 |
+
django-cors-headers>=4.0
|