Spaces:
Sleeping
Sleeping
Commit ·
5821a9e
1
Parent(s): b47d36f
Add Docker setup for Hugging Face Spaces deployment
Browse files- Dockerfile +16 -0
- requirements.txt +7 -0
- src/inference.py +1 -1
Dockerfile
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.11-slim
|
| 2 |
+
|
| 3 |
+
WORKDIR /app
|
| 4 |
+
|
| 5 |
+
# Install dependencies
|
| 6 |
+
COPY requirements.txt .
|
| 7 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 8 |
+
|
| 9 |
+
# Copy source
|
| 10 |
+
COPY src/ ./src/
|
| 11 |
+
COPY checkpoints/ ./checkpoints/
|
| 12 |
+
|
| 13 |
+
# Expose port Hugging Face expects
|
| 14 |
+
EXPOSE 7860
|
| 15 |
+
|
| 16 |
+
CMD ["python", "-m", "uvicorn", "src.inference:app", "--host", "0.0.0.0", "--port", "7860"]
|
requirements.txt
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fastapi
|
| 2 |
+
uvicorn
|
| 3 |
+
python-multipart
|
| 4 |
+
nibabel
|
| 5 |
+
numpy
|
| 6 |
+
python-dotenv
|
| 7 |
+
torch==2.5.1+cpu --extra-index-url https://download.pytorch.org/whl/cpu
|
src/inference.py
CHANGED
|
@@ -43,7 +43,7 @@ app = FastAPI(
|
|
| 43 |
|
| 44 |
app.add_middleware(
|
| 45 |
CORSMiddleware,
|
| 46 |
-
allow_origins=["
|
| 47 |
allow_methods=["*"],
|
| 48 |
allow_headers=["*"],
|
| 49 |
)
|
|
|
|
| 43 |
|
| 44 |
app.add_middleware(
|
| 45 |
CORSMiddleware,
|
| 46 |
+
allow_origins=["*"],
|
| 47 |
allow_methods=["*"],
|
| 48 |
allow_headers=["*"],
|
| 49 |
)
|