Spaces:
Runtime error
Runtime error
| # Use official Python image | |
| FROM python:3.10-slim | |
| # Disable interactive prompts | |
| ENV DEBIAN_FRONTEND=noninteractive | |
| # Set working directory | |
| WORKDIR /app | |
| # Install system dependencies | |
| RUN apt-get update && apt-get install -y \ | |
| ffmpeg \ | |
| libsm6 \ | |
| libxext6 \ | |
| git \ | |
| curl \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Copy requirements and install Python packages | |
| COPY requirements.txt . | |
| # Upgrade pip first and set timeout + retries | |
| RUN pip install --upgrade pip \ | |
| && pip config set global.timeout 100 \ | |
| && pip config set global.retries 10 \ | |
| && pip install --no-cache-dir -r requirements.txt | |
| # Set environment variables for cache directories with proper permissions | |
| ENV HF_HOME=/tmp/hf_cache | |
| ENV TRANSFORMERS_CACHE=/tmp/transformers | |
| ENV HF_DATASETS_CACHE=/tmp/datasets | |
| ENV HF_METRICS_CACHE=/tmp/metrics | |
| ENV MPLCONFIGDIR=/tmp/matplotlib | |
| # Create cache directories with proper permissions | |
| RUN mkdir -p /tmp/hf_cache /tmp/transformers /tmp/datasets /tmp/metrics /tmp/matplotlib \ | |
| && chmod -R 777 /tmp/hf_cache /tmp/transformers /tmp/datasets /tmp/metrics /tmp/matplotlib | |
| # Pre-download the SAM model from Hugging Face | |
| RUN python -c "\ | |
| from transformers import SamModel, SamProcessor; \ | |
| SamModel.from_pretrained('Zigeng/SlimSAM-uniform-50'); \ | |
| SamProcessor.from_pretrained('Zigeng/SlimSAM-uniform-50')" | |
| # Copy all project files | |
| COPY . . | |
| # Create necessary directories for the app with proper permissions | |
| RUN mkdir -p static/uploads static/outputs \ | |
| && chmod -R 777 static | |
| # Expose port for Flask | |
| EXPOSE 6000 | |
| # Run using gunicorn | |
| CMD ["gunicorn", "--bind", "0.0.0.0:6000", "app:app"] |