Spaces:
Sleeping
Sleeping
File size: 1,587 Bytes
ddb819d 57867ea ddb819d aeb75e3 ddb819d c43199d a05657a ddb819d 4f5d5bb ddb819d 275b542 |
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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# Use Python 3.9 slim as the base image
FROM python:3.9-slim
# Set environment variables
ENV PYTHONUNBUFFERED=1 \
DEBIAN_FRONTEND=noninteractive \
MPLCONFIGDIR=/tmp/.matplotlib \
XDG_CACHE_HOME=/tmp/.cache
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
git \
wget \
build-essential \
python3-dev \
cmake \
libopencv-dev \
libglib2.0-0 \
libsm6 \
libxext6 \
libxrender1 \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
# Set the working directory
WORKDIR /app
# Install PyTorch CPU version
RUN pip3 install --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
# Install Python dependencies
RUN pip3 install --no-cache-dir \
numpy \
pyyaml \
fastapi \
uvicorn \
python-multipart \
opencv-python-headless \
scipy \
pillow \
matplotlib==3.9.0
RUN pip3 install --no-cache-dir "omegaconf>=2.4.0.dev2"
Run pip3 install --no-cache-dir "hydra-core==1.1.0"
# Clone and install Detectron2
RUN git clone https://github.com/facebookresearch/detectron2.git && \
cd detectron2 && \
python setup.py build develop && \
cd .. && rm -rf detectron2/.git
# Copy application files
COPY ./app.py /app
COPY ./mask_rcnn_config.yaml /app/
COPY ./model_final.pth /app/
# Create directory for uploads
RUN mkdir -p /app/uploads && chmod -R 777 /app/uploads
# Expose the application port
EXPOSE 8000
# Set the command to run the FastAPI server
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|