/
tpu.Dockerfile.full
82 lines (67 loc) · 2.52 KB
/
tpu.Dockerfile.full
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
80
81
82
FROM debian:buster-slim
RUN apt-get update
RUN apt-get install --no-install-recommends -y \
gnupg \
ca-certificates \
curl \
apt-utils \
apt-transport-https
# Python package management and basic dependencies
RUN apt-get install -y curl python3.7 python3.7-dev python3.7-distutils
# Set python 3 as the default python
RUN update-alternatives --set python /usr/bin/python3.7
# Upgrade pip to latest version
RUN curl -s https://bootstrap.pypa.io/get-pip.py -o get-pip.py && \
python get-pip.py --force-reinstall && \
rm get-pip.py
RUN apt-get update && apt-get install -y build-essential cmake git wget unzip \
curl yasm pkg-config libswscale-dev libtbb2 libtbb-dev libjpeg-dev \
libpng-dev libtiff-dev libavformat-dev libpq-dev libfreeimage3 \
&& rm -rf /var/lib/apt/lists/*
# install drivers for coral tpu
RUN echo "deb https://packages.cloud.google.com/apt coral-edgetpu-stable main" | tee /etc/apt/sources.list.d/coral-edgetpu.list
RUN curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
RUN apt-get update && apt-get install -y libedgetpu1-std
# install common python packages
SHELL ["/bin/bash", "-c"]
WORKDIR /app/ml
COPY requirements.txt .
RUN pip --no-cache-dir install -r requirements.txt
ARG BE_VERSION
ARG APP_VERSION_STRING
ENV BE_VERSION=$BE_VERSION
ENV APP_VERSION_STRING=$APP_VERSION_STRING
ENV HOME=/app/ml
ENV LC_ALL=C.UTF-8
ENV LANG=C.UTF-8
ENV PYTHONUNBUFFERED=0
ENV JOBLIB_MULTIPROCESSING=0
# download ML models
ARG INTEL_OPTIMIZATION=false
ARG GPU_IDX=-1
ENV GPU_IDX=$GPU_IDX INTEL_OPTIMIZATION=$INTEL_OPTIMIZATION
ARG FACE_DETECTION_PLUGIN="facenet.coralmtcnn.FaceDetector"
ARG CALCULATION_PLUGIN="facenet.coralmtcnn.Calculator"
ARG EXTRA_PLUGINS="facenet.LandmarksDetector,agegender.AgeDetector,agegender.GenderDetector,facenet.facemask.MaskDetector"
ENV FACE_DETECTION_PLUGIN=$FACE_DETECTION_PLUGIN CALCULATION_PLUGIN=$CALCULATION_PLUGIN \
EXTRA_PLUGINS=$EXTRA_PLUGINS
COPY src src
COPY srcext srcext
RUN pip --no-cache-dir install srcext/mtcnn_tflite/
RUN python -m src.services.facescan.plugins.setup
# copy rest of the code
COPY tools tools
COPY sample_images sample_images
# run tests
ARG SKIP_TESTS
COPY pytest.ini .
RUN if [ -z $SKIP_TESTS ]; then pytest -m "not performance" /app/ml/src; fi
# create folder for tflite model
RUN mkdir -p /app/ml/.cache/mtcnn-tflite-models
RUN chmod a+rwx -R /app/ml/.cache/mtcnn-tflite-models
USER root
EXPOSE 3000
COPY uwsgi.ini .
ENV UWSGI_PROCESSES=${UWSGI_PROCESSES:-2}
ENV UWSGI_THREADS=1
CMD ["uwsgi", "--ini", "uwsgi.ini"]