FROM pytorch/pytorch:2.5.1-cuda12.4-cudnn9-runtime WORKDIR /app # Install system dependencies RUN apt-get update && apt-get install -y \ git \ wget \ curl \ libsm6 \ libxext6 \ libxrender-dev \ libgl1-mesa-glx \ && rm -rf /var/lib/apt/lists/* # Install Python dependencies first COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Clone Segment Anything 2 from Meta RUN git clone https://github.com/facebookresearch/sam2.git segment-anything-2 && \ cd segment-anything-2 && \ pip install -e . && \ cd .. # Download SAM2 model weights RUN cd segment-anything-2/checkpoints && \ bash download_ckpts.sh && \ cd ../.. # Set Hugging Face token for VREyeSAM weights (injected by HF Spaces) ENV HF_TOKEN="" # Copy application files COPY app.py model_server.py ./ # Create .streamlit directory and config RUN mkdir -p .streamlit COPY .streamlit/config.toml .streamlit/ # Note: VREyeSAM fine-tuned weights will be downloaded at runtime by model_server.py # using the HF_TOKEN from HF Spaces Secrets # Expose Streamlit port EXPOSE 7860 # Run Streamlit app CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0"]