Spaces:
Building
Building
File size: 2,589 Bytes
2acc806 205385f 706df25 4e6448d a3044ee 2acc806 0194c93 3be0778 cb8fce9 2acc806 91eada4 2acc806 7a33ead f5cb3be a3044ee 2acc806 a3044ee 2acc806 0194c93 32ac535 c580257 da5cd2e 91eada4 32ac535 27be29b 32ac535 25eb4da 3ff7d27 b4bc4c7 0194c93 b4bc4c7 c580257 b4bc4c7 a3044ee 91eada4 a3044ee 91eada4 |
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 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# syntax = docker/dockerfile:1.2
FROM continuumio/miniconda3:24.1.2-0
# install os dependencies including xauth for xvfb
RUN mkdir -p /usr/share/man/man1
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
ca-certificates \
curl \
vim \
sudo \
default-jre \
git \
gcc \
build-essential \
wget \
xvfb \
xauth \
&& rm -rf /var/lib/apt/lists/*
RUN conda install python=3.8.13 -y
# Install Python and model dependencies
RUN pip install openmim
RUN pip install torch==2.0.0
RUN mim install mmcv-full==1.7.0
RUN pip install mmdet==2.27.0
RUN pip install torchserve
RUN pip install mmpose==0.29.0
RUN pip install torchvision==0.15.1
RUN pip install numpy==1.24.4 scikit-image scipy opencv-python requests pyyaml flask glfw PyOpenGL Pillow shapely tqdm langid
RUN pip install fastapi==0.100.0
RUN pip install uvicorn==0.22.0
RUN pip install requests==2.31.0
# bugfix for xtcocoapi, a dependency of mmpose
RUN git clone https://github.com/jin-s13/xtcocoapi.git
WORKDIR xtcocoapi
RUN pip install -r requirements.txt
RUN python setup.py install
WORKDIR /
# prep torchserve
RUN mkdir -p /home/torchserve/model-store
RUN wget https://github.com/facebookresearch/AnimatedDrawings/releases/download/v0.0.1/drawn_humanoid_detector.mar -P /home/torchserve/model-store/
RUN wget https://github.com/facebookresearch/AnimatedDrawings/releases/download/v0.0.1/drawn_humanoid_pose_estimator.mar -P /home/torchserve/model-store/
COPY config.properties /home/torchserve/config.properties
# Create a non-root user with UID 1000
RUN adduser --disabled-password --gecos '' --uid 1000 appuser
WORKDIR /app
COPY setup.py /app/setup.py
COPY animated_drawings /app/animated_drawings
COPY app.py /app/app.py
COPY examples /app/examples
# COPY requirements.txt /app/requirements.txt
RUN pip install -e .
# RUN pip install -r requirements.txt
# Pre-create directories and set permissions
RUN mkdir -p uploads_gradio outputs_gradio flagged && \
chown -R appuser:appuser /app
USER appuser
EXPOSE 7860
# Start TorchServe, warm-up models, then run the app.
CMD sh -c "\
torchserve --start --ncs --ts-config /home/torchserve/config.properties && \
sleep 15 && \
# Warm-up requests with a small test image to load models into memory.
curl -X POST http://localhost:8080/predictions/drawn_humanoid_detector -F image=@/app/examples/test.png && \
curl -X POST http://localhost:8080/predictions/drawn_humanoid_pose_estimator -F image=@/app/examples/test.png && \
xvfb-run -a python app.py \
" |