Spaces:
Sleeping
Sleeping
Sushwetabm
commited on
Commit
Β·
1f8e84b
1
Parent(s):
6d5a8ce
updated requirements.txt and dockerfile
Browse files- Dockerfile +2 -10
- requirements.txt +10 -17
Dockerfile
CHANGED
|
@@ -1,32 +1,24 @@
|
|
| 1 |
-
# β
Use official slim image
|
| 2 |
FROM python:3.10-slim
|
| 3 |
|
| 4 |
-
# β
Set working directory
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
-
# β
Set environment variables early to ensure cache use in setup.py
|
| 8 |
ENV TRANSFORMERS_CACHE=/app/model_cache \
|
| 9 |
HF_HOME=/app/model_cache \
|
| 10 |
TORCH_HOME=/app/model_cache \
|
| 11 |
TOKENIZERS_PARALLELISM=false \
|
| 12 |
OMP_NUM_THREADS=4
|
| 13 |
|
| 14 |
-
# β
Install only necessary OS packages and clean cache
|
| 15 |
RUN apt-get update && apt-get install -y git \
|
| 16 |
&& rm -rf /var/lib/apt/lists/*
|
| 17 |
|
| 18 |
-
# β
Copy files (excluding model_cache, logs, etc. via .dockerignore)
|
| 19 |
COPY . .
|
| 20 |
|
| 21 |
-
# β
Upgrade pip + install deps without cache
|
| 22 |
RUN pip install --upgrade pip \
|
| 23 |
&& pip install --no-cache-dir -r requirements.txt
|
| 24 |
|
| 25 |
-
#
|
| 26 |
-
RUN python
|
| 27 |
|
| 28 |
-
# β
Expose Hugging Face Space-required port
|
| 29 |
EXPOSE 7860
|
| 30 |
|
| 31 |
-
# β
Launch FastAPI on port 7860 for HF Space
|
| 32 |
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860", "--timeout-keep-alive", "120", "--log-level", "info"]
|
|
|
|
|
|
|
| 1 |
FROM python:3.10-slim
|
| 2 |
|
|
|
|
| 3 |
WORKDIR /app
|
| 4 |
|
|
|
|
| 5 |
ENV TRANSFORMERS_CACHE=/app/model_cache \
|
| 6 |
HF_HOME=/app/model_cache \
|
| 7 |
TORCH_HOME=/app/model_cache \
|
| 8 |
TOKENIZERS_PARALLELISM=false \
|
| 9 |
OMP_NUM_THREADS=4
|
| 10 |
|
|
|
|
| 11 |
RUN apt-get update && apt-get install -y git \
|
| 12 |
&& rm -rf /var/lib/apt/lists/*
|
| 13 |
|
|
|
|
| 14 |
COPY . .
|
| 15 |
|
|
|
|
| 16 |
RUN pip install --upgrade pip \
|
| 17 |
&& pip install --no-cache-dir -r requirements.txt
|
| 18 |
|
| 19 |
+
# Optional: preload model
|
| 20 |
+
RUN python download_model.py
|
| 21 |
|
|
|
|
| 22 |
EXPOSE 7860
|
| 23 |
|
|
|
|
| 24 |
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860", "--timeout-keep-alive", "120", "--log-level", "info"]
|
requirements.txt
CHANGED
|
@@ -1,24 +1,17 @@
|
|
| 1 |
-
#
|
| 2 |
-
# transformers>=4.40.0
|
| 3 |
-
# accelerate>=0.25.0
|
| 4 |
-
# bitsandbytes
|
| 5 |
-
# fastapi
|
| 6 |
-
# uvicorn
|
| 7 |
-
#Your original dependencies (optimized versions)
|
| 8 |
torch>=2.1.0
|
| 9 |
transformers==4.41.1
|
| 10 |
accelerate==0.30.1
|
| 11 |
bitsandbytes
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
fastapi
|
| 13 |
uvicorn[standard]
|
|
|
|
|
|
|
| 14 |
|
| 15 |
-
#
|
| 16 |
-
|
| 17 |
-
safetensors>=0.4.0 # Faster model loading format
|
| 18 |
-
huggingface-hub>=0.19.0 # Better caching and download management
|
| 19 |
-
|
| 20 |
-
# Optional performance improvements
|
| 21 |
-
psutil>=5.9.0 # For system monitoring
|
| 22 |
-
python-multipart # For FastAPI file uploads if needed
|
| 23 |
-
|
| 24 |
-
python-dotenv
|
|
|
|
| 1 |
+
# Core dependencies
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
torch>=2.1.0
|
| 3 |
transformers==4.41.1
|
| 4 |
accelerate==0.30.1
|
| 5 |
bitsandbytes
|
| 6 |
+
tokenizers>=0.15.0
|
| 7 |
+
safetensors>=0.4.0
|
| 8 |
+
huggingface-hub>=0.19.0
|
| 9 |
+
|
| 10 |
+
# FastAPI web backend
|
| 11 |
fastapi
|
| 12 |
uvicorn[standard]
|
| 13 |
+
python-multipart # For handling file uploads in FastAPI
|
| 14 |
+
python-dotenv # For loading environment variables
|
| 15 |
|
| 16 |
+
# Optional: System monitoring / logging (optional but useful)
|
| 17 |
+
psutil>=5.9.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|