Spaces:
Sleeping
Sleeping
| FROM python:3.10 | |
| # 1. Install system dependencies | |
| RUN apt-get update && apt-get install -y \ | |
| git \ | |
| libgl1 \ | |
| libglib2.0-0 \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # 2. Create user | |
| RUN useradd -m -u 1000 user | |
| USER user | |
| ENV PATH="/home/user/.local/bin:$PATH" | |
| # 3. Install Torch dependencies FIRST | |
| RUN pip install --no-cache-dir pip --upgrade && \ | |
| pip install --no-cache-dir \ | |
| torch==2.0.1+cpu \ | |
| torchvision==0.15.2+cpu \ | |
| --extra-index-url https://download.pytorch.org/whl/cpu | |
| # 4. Install Detectron2 with --no-build-isolation | |
| # This flag fixes the "No module named torch" error | |
| RUN pip install --no-cache-dir --no-build-isolation git+https://github.com/facebookresearch/detectron2.git | |
| # 5. Install the requirements.txt | |
| WORKDIR /app | |
| COPY --chown=user ./requirements.txt requirements.txt | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # 6. Copy app files and run | |
| COPY --chown=user . /app | |
| CMD ["python", "app.py"] |