Spaces:
Sleeping
Sleeping
Create Dockerfile
Browse files- Dockerfile +21 -0
Dockerfile
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 1. Use a lightweight Python base
|
| 2 |
+
FROM python:3.11-slim
|
| 3 |
+
|
| 4 |
+
# 2. Set the working directory
|
| 5 |
+
WORKDIR /app
|
| 6 |
+
|
| 7 |
+
# 3. Install PyTorch (CPU version to save massive space/RAM) and required libraries
|
| 8 |
+
RUN pip install --no-cache-dir torch torchvision --index-url https://download.pytorch.org/whl/cpu
|
| 9 |
+
RUN pip install --no-cache-dir fastapi uvicorn transformers pillow pydantic
|
| 10 |
+
|
| 11 |
+
# 4. THE CHEAT CODE: Pre-download the heavy model weights during the build phase
|
| 12 |
+
RUN python -c "from transformers import pipeline; pipeline('image-classification', model='dima806/chest_xray_pneumonia_detection')"
|
| 13 |
+
|
| 14 |
+
# 5. Copy your FastAPI code into the container
|
| 15 |
+
COPY app.py .
|
| 16 |
+
|
| 17 |
+
# 6. Expose the exact port Hugging Face Spaces requires
|
| 18 |
+
EXPOSE 7860
|
| 19 |
+
|
| 20 |
+
# 7. Start the node
|
| 21 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|