Spaces:
Running
Running
optimizations 1
Browse files- .dockerignore +18 -0
- Dockerfile +8 -8
- requirements.txt +4 -3
.dockerignore
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.git
|
| 2 |
+
.gitignore
|
| 3 |
+
.gitattributes
|
| 4 |
+
__pycache__
|
| 5 |
+
*.pyc
|
| 6 |
+
*.pyo
|
| 7 |
+
*.egg-info
|
| 8 |
+
.pytest_cache
|
| 9 |
+
.venv
|
| 10 |
+
venv
|
| 11 |
+
.DS_Store
|
| 12 |
+
*.md
|
| 13 |
+
.vscode
|
| 14 |
+
.idea
|
| 15 |
+
node_modules
|
| 16 |
+
.next
|
| 17 |
+
build
|
| 18 |
+
dist
|
Dockerfile
CHANGED
|
@@ -1,26 +1,26 @@
|
|
| 1 |
FROM python:3.10-slim
|
| 2 |
|
| 3 |
-
# Install system deps needed by OpenCV
|
| 4 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 5 |
libglib2.0-0 \
|
| 6 |
libsm6 \
|
| 7 |
libxext6 \
|
| 8 |
libxrender-dev \
|
| 9 |
libgl1 \
|
| 10 |
-
&& rm -rf /var/lib/apt/lists/*
|
| 11 |
|
| 12 |
WORKDIR /app
|
| 13 |
|
| 14 |
-
# ββ
|
| 15 |
COPY requirements.txt .
|
| 16 |
-
|
| 17 |
-
# Install with --no-cache-dir to reduce build time
|
| 18 |
-
# PyTorch CPU will still take time but this reduces disk I/O
|
| 19 |
RUN pip install --no-cache-dir --upgrade pip setuptools wheel && \
|
| 20 |
pip install --no-cache-dir --default-timeout=1000 -r requirements.txt
|
| 21 |
|
| 22 |
-
# ββ Copy
|
| 23 |
-
COPY
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
# HuggingFace Spaces requires port 7860
|
| 26 |
EXPOSE 7860
|
|
|
|
| 1 |
FROM python:3.10-slim
|
| 2 |
|
| 3 |
+
# Install system deps needed by OpenCV (minimal set)
|
| 4 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 5 |
libglib2.0-0 \
|
| 6 |
libsm6 \
|
| 7 |
libxext6 \
|
| 8 |
libxrender-dev \
|
| 9 |
libgl1 \
|
| 10 |
+
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
| 11 |
|
| 12 |
WORKDIR /app
|
| 13 |
|
| 14 |
+
# ββ Install dependencies FIRST (most stable layer) ββ
|
| 15 |
COPY requirements.txt .
|
|
|
|
|
|
|
|
|
|
| 16 |
RUN pip install --no-cache-dir --upgrade pip setuptools wheel && \
|
| 17 |
pip install --no-cache-dir --default-timeout=1000 -r requirements.txt
|
| 18 |
|
| 19 |
+
# ββ Copy model files SECOND (slower to change than code) ββ
|
| 20 |
+
COPY trainedmodels/ ./trainedmodels/
|
| 21 |
+
|
| 22 |
+
# ββ Copy app code LAST (fastest layer, changes most often) ββ
|
| 23 |
+
COPY app.py inference.py README.md ./
|
| 24 |
|
| 25 |
# HuggingFace Spaces requires port 7860
|
| 26 |
EXPOSE 7860
|
requirements.txt
CHANGED
|
@@ -1,5 +1,4 @@
|
|
| 1 |
--extra-index-url https://download.pytorch.org/whl/cpu
|
| 2 |
-
--extra-index-url https://pypi.org/simple
|
| 3 |
|
| 4 |
torch==2.0.1+cpu
|
| 5 |
torchvision==0.15.2+cpu
|
|
@@ -8,7 +7,9 @@ fastapi==0.111.0
|
|
| 8 |
uvicorn[standard]==0.29.0
|
| 9 |
python-multipart==0.0.9
|
| 10 |
opencv-python-headless==4.9.0.80
|
| 11 |
-
albumentations==1.4.2
|
| 12 |
numpy==1.26.4
|
| 13 |
-
matplotlib==3.8.4
|
| 14 |
Pillow==10.3.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
--extra-index-url https://download.pytorch.org/whl/cpu
|
|
|
|
| 2 |
|
| 3 |
torch==2.0.1+cpu
|
| 4 |
torchvision==0.15.2+cpu
|
|
|
|
| 7 |
uvicorn[standard]==0.29.0
|
| 8 |
python-multipart==0.0.9
|
| 9 |
opencv-python-headless==4.9.0.80
|
|
|
|
| 10 |
numpy==1.26.4
|
|
|
|
| 11 |
Pillow==10.3.0
|
| 12 |
+
|
| 13 |
+
# Optional: Remove these if not used in inference
|
| 14 |
+
# albumentations==1.4.2
|
| 15 |
+
# matplotlib==3.8.4
|