FROM python:3.10-slim # Set working directory WORKDIR /app # Install system dependencies RUN apt-get update && apt-get install -y \ curl \ && rm -rf /var/lib/apt/lists/* # Copy requirements first for better layer caching COPY requirements.txt . # Install Python dependencies # Install CPU-only PyTorch to reduce image size for HuggingFace Spaces RUN pip install --no-cache-dir torch torchvision --index-url https://download.pytorch.org/whl/cpu RUN pip install --no-cache-dir fastapi uvicorn safetensors Pillow numpy python-multipart packaging # Copy application files COPY app.py . COPY ResNet50_S1_best.safetensors . COPY ResNet50_S2_best.safetensors . COPY ResNet50_S3_best.safetensors . # Expose port EXPOSE 7860 # Health check HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \ CMD curl -f http://localhost:7860/ || exit 1 # Run the application CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]