Spaces:
Runtime error
Runtime error
deploy
Browse files- Dockerfile +7 -3
- main.py +2 -0
- requirements.txt +2 -1
Dockerfile
CHANGED
|
@@ -4,11 +4,15 @@ FROM python:3.10-slim
|
|
| 4 |
# Set the working directory inside the container
|
| 5 |
WORKDIR /app
|
| 6 |
|
|
|
|
|
|
|
|
|
|
| 7 |
# Copy the requirements file
|
| 8 |
COPY requirements.txt .
|
| 9 |
|
| 10 |
-
# Install dependencies
|
| 11 |
-
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
| 12 |
|
| 13 |
# Copy the entire app to the container
|
| 14 |
COPY . .
|
|
@@ -17,4 +21,4 @@ COPY . .
|
|
| 17 |
EXPOSE 7860
|
| 18 |
|
| 19 |
# Run FastAPI with Uvicorn
|
| 20 |
-
CMD ["uvicorn", "
|
|
|
|
| 4 |
# Set the working directory inside the container
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
+
# Set environment variable for Hugging Face cache directory
|
| 8 |
+
ENV TRANSFORMERS_CACHE="/app/cache"
|
| 9 |
+
|
| 10 |
# Copy the requirements file
|
| 11 |
COPY requirements.txt .
|
| 12 |
|
| 13 |
+
# Install dependencies and update huggingface_hub
|
| 14 |
+
RUN pip install --no-cache-dir -r requirements.txt \
|
| 15 |
+
&& pip install --upgrade huggingface_hub
|
| 16 |
|
| 17 |
# Copy the entire app to the container
|
| 18 |
COPY . .
|
|
|
|
| 21 |
EXPOSE 7860
|
| 22 |
|
| 23 |
# Run FastAPI with Uvicorn
|
| 24 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
main.py
CHANGED
|
@@ -3,6 +3,8 @@ from pydantic import BaseModel
|
|
| 3 |
from sentence_transformers import SentenceTransformer
|
| 4 |
import numpy as np
|
| 5 |
|
|
|
|
|
|
|
| 6 |
# Initialize FastAPI app
|
| 7 |
app = FastAPI()
|
| 8 |
|
|
|
|
| 3 |
from sentence_transformers import SentenceTransformer
|
| 4 |
import numpy as np
|
| 5 |
|
| 6 |
+
import os
|
| 7 |
+
os.environ["TRANSFORMERS_CACHE"] = "/app/cache"
|
| 8 |
# Initialize FastAPI app
|
| 9 |
app = FastAPI()
|
| 10 |
|
requirements.txt
CHANGED
|
@@ -6,4 +6,5 @@ scikit-learn==1.2.2
|
|
| 6 |
sentence-transformers==2.2.2
|
| 7 |
numpy==1.23.5
|
| 8 |
pydantic==1.10.8
|
| 9 |
-
torch==2.0.1 # Required for sentence-transformers
|
|
|
|
|
|
| 6 |
sentence-transformers==2.2.2
|
| 7 |
numpy==1.23.5
|
| 8 |
pydantic==1.10.8
|
| 9 |
+
torch==2.0.1 # Required for sentence-transformers
|
| 10 |
+
huggingface_hub>=0.16.4
|