Chest-xray / Dockerfile
AIcoder35235's picture
Update Dockerfile
c4bd273 verified
raw
history blame contribute delete
885 Bytes
# 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"]