Spaces:
Sleeping
Sleeping
File size: 1,437 Bytes
976fe0f 9d5d881 976fe0f 9d5d881 976fe0f 3b2afc4 976fe0f 3b2afc4 976fe0f 3b2afc4 976fe0f 3b2afc4 976fe0f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | FROM python:3.11-slim
# Install system dependencies
# libgl1-mesa-glx is obsolete in newer Debian (Trixie), replaced by libgl1 and libglx-mesa0
RUN apt-get update && apt-get install -y \
git \
wget \
libgl1 \
libglx-mesa0 \
libglib2.0-0 \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /app
# Copy the GroundingDINO code first
RUN git clone https://github.com/IDEA-Research/GroundingDINO.git .
# Install dependencies and the package
RUN pip install --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
RUN pip install --no-cache-dir transformers==4.35.2
RUN pip install --no-cache-dir fastapi uvicorn python-multipart supervision opencv-python-headless huggingface_hub
# Install GroundingDINO package without CUDA extensions for CPU mode
ENV CUDA_HOME=""
RUN pip install --no-cache-dir -e .
# Create weights directory and download Swin-B weights
RUN mkdir -p weights && \
wget -q -O weights/groundingdino_swinb_cogcoor.pth https://github.com/IDEA-Research/GroundingDINO/releases/download/v0.1.0-alpha2/groundingdino_swinb_cogcoor.pth && \
cp groundingdino/config/GroundingDINO_SwinB_cfg.py weights/GroundingDINO_SwinB_cfg.py
# Copy the application code
COPY main.py .
# Expose port 7860 (Hugging Face Spaces default)
EXPOSE 7860
# Run the application
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|