mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-21 19:07:46 +01:00
revamp dockerfile
This commit is contained in:
parent
cc2abe93a6
commit
10dc56f6ea
124
Dockerfile
124
Dockerfile
@ -1,108 +1,48 @@
|
|||||||
FROM ubuntu:18.04
|
FROM debian:buster-slim
|
||||||
|
LABEL maintainer "blakeb@blakeshome.com"
|
||||||
ARG DEVICE
|
|
||||||
|
|
||||||
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
# Install packages for apt repo
|
# Install packages for apt repo
|
||||||
RUN apt-get -qq update && apt-get -qq install --no-install-recommends -y \
|
RUN apt -qq update && apt -qq install --no-install-recommends -y \
|
||||||
apt-transport-https \
|
gnupg wget \
|
||||||
ca-certificates \
|
|
||||||
curl \
|
|
||||||
wget \
|
|
||||||
gnupg-agent \
|
|
||||||
dirmngr \
|
|
||||||
software-properties-common \
|
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
COPY scripts/install_odroid_repo.sh .
|
|
||||||
|
|
||||||
RUN if [ "$DEVICE" = "odroid" ]; then \
|
|
||||||
sh /install_odroid_repo.sh; \
|
|
||||||
fi
|
|
||||||
|
|
||||||
RUN apt-get -qq update && apt-get -qq install --no-install-recommends -y \
|
|
||||||
python3 \
|
|
||||||
# OpenCV dependencies
|
|
||||||
ffmpeg \
|
ffmpeg \
|
||||||
build-essential \
|
python3 \
|
||||||
cmake \
|
|
||||||
unzip \
|
|
||||||
pkg-config \
|
|
||||||
libjpeg-dev \
|
|
||||||
libpng-dev \
|
|
||||||
libtiff-dev \
|
|
||||||
libavcodec-dev \
|
|
||||||
libavformat-dev \
|
|
||||||
libswscale-dev \
|
|
||||||
libv4l-dev \
|
|
||||||
libxvidcore-dev \
|
|
||||||
libx264-dev \
|
|
||||||
libgtk-3-dev \
|
|
||||||
libatlas-base-dev \
|
|
||||||
gfortran \
|
|
||||||
python3-dev \
|
|
||||||
# Coral USB Python API Dependencies
|
|
||||||
libusb-1.0-0 \
|
|
||||||
python3-pip \
|
python3-pip \
|
||||||
python3-pil \
|
# python-prctl
|
||||||
python3-numpy \
|
build-essential libcap-dev \
|
||||||
python3-prctl \
|
# pillow-simd
|
||||||
libc++1 \
|
zlib1g-dev libjpeg-dev python3-dev\
|
||||||
libc++abi1 \
|
|
||||||
libunwind8 \
|
|
||||||
libgcc1 \
|
|
||||||
# VAAPI drivers for Intel hardware accel
|
# VAAPI drivers for Intel hardware accel
|
||||||
libva-drm2 libva2 i965-va-driver vainfo \
|
libva-drm2 libva2 i965-va-driver vainfo \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& echo "deb https://packages.cloud.google.com/apt coral-edgetpu-stable main" > /etc/apt/sources.list.d/coral-edgetpu.list \
|
||||||
|
&& wget -q -O - https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - \
|
||||||
|
&& apt -qq update \
|
||||||
|
&& echo "libedgetpu1-max libedgetpu/accepted-eula boolean true" | debconf-set-selections \
|
||||||
|
&& apt -qq install --no-install-recommends -y \
|
||||||
|
libedgetpu1-max \
|
||||||
|
python3-edgetpu \
|
||||||
|
&& rm -rf /var/lib/apt/lists/* \
|
||||||
|
&& (apt-get autoremove -y; apt-get autoclean -y)
|
||||||
|
|
||||||
# Download & build OpenCV
|
# needs to be installed before others
|
||||||
# TODO: use multistage build to reduce image size:
|
RUN pip3 install -U wheel setuptools
|
||||||
# https://medium.com/@denismakogon/pain-and-gain-running-opencv-application-with-golang-and-docker-on-alpine-3-7-435aa11c7aec
|
|
||||||
# https://www.merixstudio.com/blog/docker-multi-stage-builds-python-development/
|
|
||||||
RUN wget -q -P /usr/local/src/ --no-check-certificate https://github.com/opencv/opencv/archive/4.0.1.zip
|
|
||||||
RUN cd /usr/local/src/ \
|
|
||||||
&& unzip 4.0.1.zip \
|
|
||||||
&& rm 4.0.1.zip \
|
|
||||||
&& cd /usr/local/src/opencv-4.0.1/ \
|
|
||||||
&& mkdir build \
|
|
||||||
&& cd /usr/local/src/opencv-4.0.1/build \
|
|
||||||
&& cmake -D CMAKE_INSTALL_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local/ .. \
|
|
||||||
&& make -j4 \
|
|
||||||
&& make install \
|
|
||||||
&& ldconfig \
|
|
||||||
&& rm -rf /usr/local/src/opencv-4.0.1
|
|
||||||
|
|
||||||
# Download and install EdgeTPU libraries for Coral
|
RUN pip3 install -U \
|
||||||
RUN wget https://dl.google.com/coral/edgetpu_api/edgetpu_api_latest.tar.gz -O edgetpu_api.tar.gz --trust-server-names \
|
opencv-python \
|
||||||
&& tar xzf edgetpu_api.tar.gz
|
python-prctl \
|
||||||
|
|
||||||
COPY scripts/install_edgetpu_api.sh edgetpu_api/install.sh
|
|
||||||
|
|
||||||
RUN cd edgetpu_api \
|
|
||||||
&& /bin/bash install.sh
|
|
||||||
|
|
||||||
# Copy a python 3.6 version
|
|
||||||
RUN cd /usr/local/lib/python3.6/dist-packages/edgetpu/swig/ \
|
|
||||||
&& ln -s _edgetpu_cpp_wrapper.cpython-35m-arm-linux-gnueabihf.so _edgetpu_cpp_wrapper.cpython-36m-arm-linux-gnueabihf.so
|
|
||||||
|
|
||||||
# symlink the model and labels
|
|
||||||
RUN wget https://dl.google.com/coral/canned_models/mobilenet_ssd_v2_coco_quant_postprocess_edgetpu.tflite -O mobilenet_ssd_v2_coco_quant_postprocess_edgetpu.tflite --trust-server-names
|
|
||||||
RUN wget https://dl.google.com/coral/canned_models/coco_labels.txt -O coco_labels.txt --trust-server-names
|
|
||||||
RUN ln -s mobilenet_ssd_v2_coco_quant_postprocess_edgetpu.tflite /frozen_inference_graph.pb
|
|
||||||
RUN ln -s /coco_labels.txt /label_map.pbtext
|
|
||||||
|
|
||||||
# Minimize image size
|
|
||||||
RUN (apt-get autoremove -y; \
|
|
||||||
apt-get autoclean -y)
|
|
||||||
|
|
||||||
# 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 \
|
numpy \
|
||||||
Flask \
|
Flask \
|
||||||
paho-mqtt \
|
paho-mqtt \
|
||||||
PyYAML \
|
PyYAML \
|
||||||
matplotlib \
|
matplotlib \
|
||||||
scipy
|
scipy \
|
||||||
|
pillow-simd
|
||||||
|
|
||||||
|
# symlink the model and labels
|
||||||
|
RUN wget -q https://github.com/google-coral/edgetpu/raw/master/test_data/mobilenet_ssd_v2_coco_quant_postprocess_edgetpu.tflite -O mobilenet_ssd_v2_coco_quant_postprocess_edgetpu.tflite --trust-server-names
|
||||||
|
RUN wget -q https://dl.google.com/coral/canned_models/coco_labels.txt -O coco_labels.txt --trust-server-names
|
||||||
|
RUN ln -s mobilenet_ssd_v2_coco_quant_postprocess_edgetpu.tflite /frozen_inference_graph.pb
|
||||||
|
RUN ln -s /coco_labels.txt /label_map.pbtext
|
||||||
|
|
||||||
WORKDIR /opt/frigate/
|
WORKDIR /opt/frigate/
|
||||||
ADD frigate frigate/
|
ADD frigate frigate/
|
||||||
|
@ -14,7 +14,7 @@ flattened_frame = np.expand_dims(frame, axis=0).flatten()
|
|||||||
detection_times = []
|
detection_times = []
|
||||||
|
|
||||||
for x in range(0, 1000):
|
for x in range(0, 1000):
|
||||||
objects = engine.DetectWithInputTensor(flattened_frame, threshold=0.1, top_k=3)
|
objects = engine.detect_with_input_tensor(flattened_frame, threshold=0.1, top_k=3)
|
||||||
detection_times.append(engine.get_inference_time())
|
detection_times.append(engine.get_inference_time())
|
||||||
|
|
||||||
print("Average inference time: " + str(statistics.mean(detection_times)))
|
print("Average inference time: " + str(statistics.mean(detection_times)))
|
@ -32,7 +32,7 @@ class PreppedQueueProcessor(threading.Thread):
|
|||||||
frame = self.prepped_frame_queue.get()
|
frame = self.prepped_frame_queue.get()
|
||||||
|
|
||||||
# Actual detection.
|
# Actual detection.
|
||||||
frame['detected_objects'] = self.engine.DetectWithInputTensor(frame['frame'], threshold=0.2, top_k=5)
|
frame['detected_objects'] = self.engine.detect_with_input_tensor(frame['frame'], threshold=0.2, top_k=5)
|
||||||
self.fps.update()
|
self.fps.update()
|
||||||
self.avg_inference_speed = (self.avg_inference_speed*9 + self.engine.get_inference_time())/10
|
self.avg_inference_speed = (self.avg_inference_speed*9 + self.engine.get_inference_time())/10
|
||||||
|
|
||||||
|
@ -152,8 +152,6 @@ class RegionRefiner(threading.Thread):
|
|||||||
})
|
})
|
||||||
self.camera.dynamic_region_fps.update()
|
self.camera.dynamic_region_fps.update()
|
||||||
look_again = True
|
look_again = True
|
||||||
# TODO: zoom in on unclipped low confidence objects
|
|
||||||
# else: ...
|
|
||||||
|
|
||||||
# if we are looking again, then this frame is not ready for processing
|
# if we are looking again, then this frame is not ready for processing
|
||||||
if look_again:
|
if look_again:
|
||||||
|
Loading…
Reference in New Issue
Block a user