2019-01-26 15:02:59 +01:00
|
|
|
FROM ubuntu:16.04
|
|
|
|
|
|
|
|
# Install system packages
|
|
|
|
RUN apt-get -qq update && apt-get -qq install --no-install-recommends -y python3 \
|
|
|
|
python3-dev \
|
|
|
|
python-pil \
|
|
|
|
python-lxml \
|
|
|
|
python-tk \
|
|
|
|
build-essential \
|
|
|
|
cmake \
|
|
|
|
git \
|
|
|
|
libgtk2.0-dev \
|
|
|
|
pkg-config \
|
|
|
|
libavcodec-dev \
|
|
|
|
libavformat-dev \
|
|
|
|
libswscale-dev \
|
|
|
|
libtbb2 \
|
|
|
|
libtbb-dev \
|
|
|
|
libjpeg-dev \
|
|
|
|
libpng-dev \
|
|
|
|
libtiff-dev \
|
|
|
|
libjasper-dev \
|
|
|
|
libdc1394-22-dev \
|
|
|
|
x11-apps \
|
|
|
|
wget \
|
|
|
|
vim \
|
|
|
|
ffmpeg \
|
|
|
|
unzip \
|
2019-03-17 15:03:52 +01:00
|
|
|
libusb-1.0-0-dev \
|
|
|
|
python3-setuptools \
|
|
|
|
python3-numpy \
|
|
|
|
zlib1g-dev \
|
|
|
|
libgoogle-glog-dev \
|
|
|
|
swig \
|
|
|
|
libunwind-dev \
|
|
|
|
libc++-dev \
|
|
|
|
libc++abi-dev \
|
|
|
|
build-essential \
|
2019-01-26 15:02:59 +01:00
|
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
|
|
# Install core packages
|
|
|
|
RUN wget -q -O /tmp/get-pip.py --no-check-certificate https://bootstrap.pypa.io/get-pip.py && python3 /tmp/get-pip.py
|
|
|
|
RUN pip install -U pip \
|
|
|
|
numpy \
|
2019-03-17 15:03:52 +01:00
|
|
|
pillow \
|
2019-01-26 15:02:59 +01:00
|
|
|
matplotlib \
|
|
|
|
notebook \
|
2019-02-10 03:37:46 +01:00
|
|
|
Flask \
|
2019-02-10 15:03:12 +01:00
|
|
|
imutils \
|
2019-03-28 13:30:58 +01:00
|
|
|
paho-mqtt \
|
|
|
|
PyYAML
|
2019-01-26 15:02:59 +01:00
|
|
|
|
|
|
|
# Install tensorflow models object detection
|
|
|
|
RUN GIT_SSL_NO_VERIFY=true git clone -q https://github.com/tensorflow/models /usr/local/lib/python3.5/dist-packages/tensorflow/models
|
|
|
|
RUN wget -q -P /usr/local/src/ --no-check-certificate https://github.com/google/protobuf/releases/download/v3.5.1/protobuf-python-3.5.1.tar.gz
|
|
|
|
|
|
|
|
# Download & build protobuf-python
|
|
|
|
RUN cd /usr/local/src/ \
|
|
|
|
&& tar xf protobuf-python-3.5.1.tar.gz \
|
|
|
|
&& rm protobuf-python-3.5.1.tar.gz \
|
|
|
|
&& cd /usr/local/src/protobuf-3.5.1/ \
|
|
|
|
&& ./configure \
|
|
|
|
&& make \
|
|
|
|
&& make install \
|
|
|
|
&& ldconfig \
|
|
|
|
&& rm -rf /usr/local/src/protobuf-3.5.1/
|
|
|
|
|
|
|
|
# Download & build OpenCV
|
2019-02-09 14:23:18 +01:00
|
|
|
RUN wget -q -P /usr/local/src/ --no-check-certificate https://github.com/opencv/opencv/archive/4.0.1.zip
|
2019-01-26 15:02:59 +01:00
|
|
|
RUN cd /usr/local/src/ \
|
2019-02-09 14:23:18 +01:00
|
|
|
&& unzip 4.0.1.zip \
|
|
|
|
&& rm 4.0.1.zip \
|
|
|
|
&& cd /usr/local/src/opencv-4.0.1/ \
|
2019-01-26 15:02:59 +01:00
|
|
|
&& mkdir build \
|
2019-02-09 14:23:18 +01:00
|
|
|
&& cd /usr/local/src/opencv-4.0.1/build \
|
2019-01-26 15:02:59 +01:00
|
|
|
&& cmake -D CMAKE_INSTALL_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local/ .. \
|
|
|
|
&& make -j4 \
|
|
|
|
&& make install \
|
2019-02-09 14:23:18 +01:00
|
|
|
&& rm -rf /usr/local/src/opencv-4.0.1
|
2019-01-26 15:02:59 +01:00
|
|
|
|
2019-03-17 15:03:52 +01:00
|
|
|
# Download and install EdgeTPU libraries
|
|
|
|
RUN wget -q -O edgetpu_api.tar.gz --no-check-certificate http://storage.googleapis.com/cloud-iot-edge-pretrained-models/edgetpu_api.tar.gz
|
|
|
|
|
|
|
|
RUN tar xzf edgetpu_api.tar.gz \
|
|
|
|
&& cd python-tflite-source \
|
2019-03-26 11:44:33 +01:00
|
|
|
&& cp -p libedgetpu/libedgetpu_x86_64.so /lib/x86_64-linux-gnu/libedgetpu.so \
|
|
|
|
&& cp edgetpu/swig/compiled_so/_edgetpu_cpp_wrapper_x86_64.so edgetpu/swig/_edgetpu_cpp_wrapper.so \
|
2019-03-17 15:03:52 +01:00
|
|
|
&& cp edgetpu/swig/compiled_so/edgetpu_cpp_wrapper.py edgetpu/swig/ \
|
|
|
|
&& python3 setup.py develop --user
|
|
|
|
|
2019-01-26 15:02:59 +01:00
|
|
|
# Minimize image size
|
|
|
|
RUN (apt-get autoremove -y; \
|
|
|
|
apt-get autoclean -y)
|
|
|
|
|
2019-03-30 13:58:31 +01:00
|
|
|
# symlink the model and labels
|
|
|
|
RUN ln -s /python-tflite-source/edgetpu/test_data/mobilenet_ssd_v2_coco_quant_postprocess_edgetpu.tflite /frozen_inference_graph.pb
|
|
|
|
RUN ln -s /python-tflite-source/edgetpu/test_data/coco_labels.txt /label_map.pbtext
|
|
|
|
|
2019-01-26 15:02:59 +01:00
|
|
|
# Set TF object detection available
|
|
|
|
ENV PYTHONPATH "$PYTHONPATH:/usr/local/lib/python3.5/dist-packages/tensorflow/models/research:/usr/local/lib/python3.5/dist-packages/tensorflow/models/research/slim"
|
|
|
|
RUN cd /usr/local/lib/python3.5/dist-packages/tensorflow/models/research && protoc object_detection/protos/*.proto --python_out=.
|
|
|
|
|
2019-02-28 13:49:27 +01:00
|
|
|
WORKDIR /opt/frigate/
|
|
|
|
ADD frigate frigate/
|
2019-01-26 15:02:59 +01:00
|
|
|
COPY detect_objects.py .
|
|
|
|
|
2019-03-17 15:03:52 +01:00
|
|
|
CMD ["python3", "-u", "detect_objects.py"]
|