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