Spaces:
Sleeping
Sleeping
| FROM python:3.10-slim | |
| # Set working directory | |
| WORKDIR /app | |
| # Install system dependencies required for OpenCV and building python packages | |
| RUN apt-get update && apt-get install -y \ | |
| ffmpeg \ | |
| libsm6 \ | |
| libxext6 \ | |
| git \ | |
| g++ \ | |
| build-essential \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Install PyTorch first because GroundingDINO compilation requires it to be already installed | |
| RUN pip install --no-cache-dir --upgrade pip && \ | |
| pip install --no-cache-dir torch torchvision torchaudio setuptools wheel cython | |
| # Install GroundingDINO without build isolation so it can see the installed torch | |
| RUN pip install --no-cache-dir --no-build-isolation git+https://github.com/IDEA-Research/GroundingDINO.git | |
| # Install SAM 2 | |
| RUN pip install --no-cache-dir git+https://github.com/facebookresearch/segment-anything-2.git | |
| # Copy requirements and install them | |
| COPY requirements.txt . | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Hugging Face Spaces requires apps to run as a non-root user | |
| RUN useradd -m -u 1000 user | |
| USER user | |
| ENV HOME=/home/user \ | |
| PATH=/home/user/.local/bin:$PATH | |
| # Switch to the user's home directory | |
| WORKDIR $HOME/app | |
| # Copy the rest of the application files and assign ownership to the new user | |
| COPY --chown=user . $HOME/app | |
| # Expose the Gradio default port | |
| EXPOSE 7860 | |
| # Command to run the application | |
| CMD ["python", "app.py"] | |