Spaces:
Sleeping
Sleeping
Fix model loading
Browse files- Dockerfile +9 -10
- app.py +3 -0
Dockerfile
CHANGED
|
@@ -7,19 +7,18 @@ WORKDIR /app
|
|
| 7 |
# Copy everything including smoldocling
|
| 8 |
COPY . .
|
| 9 |
|
| 10 |
-
#
|
| 11 |
-
|
|
|
|
| 12 |
|
| 13 |
-
#
|
| 14 |
-
ENV TRANSFORMERS_CACHE=/tmp/huggingface/transformers
|
| 15 |
-
ENV HF_HUB_CACHE=/tmp/huggingface/hub
|
| 16 |
-
|
| 17 |
-
# Install requirements (editable install of local package)
|
| 18 |
RUN pip install --no-cache-dir -r requirements.txt && \
|
| 19 |
-
pip install -e ./smoldocling
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
-
# 🟩 Pre-download model to avoid runtime issues
|
| 22 |
-
RUN python -c "from transformers import AutoModel, AutoTokenizer; AutoTokenizer.from_pretrained('ds4sd/SmolDocling-256M-preview'); AutoModel.from_pretrained('ds4sd/SmolDocling-256M-preview')"
|
| 23 |
|
| 24 |
EXPOSE 7860
|
| 25 |
|
|
|
|
| 7 |
# Copy everything including smoldocling
|
| 8 |
COPY . .
|
| 9 |
|
| 10 |
+
# Set cache environment so model is stored in /app/.cache
|
| 11 |
+
ENV TRANSFORMERS_CACHE=/app/.cache/transformers
|
| 12 |
+
ENV HF_HUB_CACHE=/app/.cache/hub
|
| 13 |
|
| 14 |
+
# Pre-download the model
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
RUN pip install --no-cache-dir -r requirements.txt && \
|
| 16 |
+
pip install -e ./smoldocling && \
|
| 17 |
+
python -c "from transformers import AutoTokenizer, AutoModel; \
|
| 18 |
+
AutoTokenizer.from_pretrained('ds4sd/SmolDocling-256M-preview'); \
|
| 19 |
+
AutoModel.from_pretrained('ds4sd/SmolDocling-256M-preview')"
|
| 20 |
+
|
| 21 |
|
|
|
|
|
|
|
| 22 |
|
| 23 |
EXPOSE 7860
|
| 24 |
|
app.py
CHANGED
|
@@ -7,6 +7,9 @@ from smoldocling import cli
|
|
| 7 |
import shutil
|
| 8 |
import dotenv
|
| 9 |
|
|
|
|
|
|
|
|
|
|
| 10 |
# Load environment variables
|
| 11 |
dotenv.load_dotenv()
|
| 12 |
|
|
|
|
| 7 |
import shutil
|
| 8 |
import dotenv
|
| 9 |
|
| 10 |
+
os.environ["TRANSFORMERS_CACHE"] = "/app/.cache/transformers"
|
| 11 |
+
os.environ["HF_HUB_CACHE"] = "/app/.cache/hub"
|
| 12 |
+
|
| 13 |
# Load environment variables
|
| 14 |
dotenv.load_dotenv()
|
| 15 |
|