Dockerfile 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. FROM ubuntu:18.04
  2. ARG DEVICE
  3. # Install packages for apt repo
  4. RUN apt-get -qq update && apt-get -qq install --no-install-recommends -y \
  5. apt-transport-https \
  6. ca-certificates \
  7. curl \
  8. wget \
  9. gnupg-agent \
  10. dirmngr \
  11. software-properties-common \
  12. && rm -rf /var/lib/apt/lists/*
  13. COPY scripts/install_odroid_repo.sh .
  14. RUN if [ "$DEVICE" = "odroid" ]; then \
  15. sh /install_odroid_repo.sh; \
  16. fi
  17. RUN apt-get -qq update && apt-get -qq install --no-install-recommends -y \
  18. python3 \
  19. # OpenCV dependencies
  20. ffmpeg \
  21. build-essential \
  22. cmake \
  23. unzip \
  24. pkg-config \
  25. libjpeg-dev \
  26. libpng-dev \
  27. libtiff-dev \
  28. libavcodec-dev \
  29. libavformat-dev \
  30. libswscale-dev \
  31. libv4l-dev \
  32. libxvidcore-dev \
  33. libx264-dev \
  34. libgtk-3-dev \
  35. libatlas-base-dev \
  36. gfortran \
  37. python3-dev \
  38. # Coral USB Python API Dependencies
  39. libusb-1.0-0 \
  40. python3-pip \
  41. python3-pil \
  42. python3-numpy \
  43. python3-prctl \
  44. libc++1 \
  45. libc++abi1 \
  46. libunwind8 \
  47. libgcc1 \
  48. # VAAPI drivers for Intel hardware accel
  49. libva-drm2 libva2 i965-va-driver vainfo \
  50. && rm -rf /var/lib/apt/lists/*
  51. # Download & build OpenCV
  52. # TODO: use multistage build to reduce image size:
  53. # https://medium.com/@denismakogon/pain-and-gain-running-opencv-application-with-golang-and-docker-on-alpine-3-7-435aa11c7aec
  54. # https://www.merixstudio.com/blog/docker-multi-stage-builds-python-development/
  55. RUN wget -q -P /usr/local/src/ --no-check-certificate https://github.com/opencv/opencv/archive/4.0.1.zip
  56. RUN cd /usr/local/src/ \
  57. && unzip 4.0.1.zip \
  58. && rm 4.0.1.zip \
  59. && cd /usr/local/src/opencv-4.0.1/ \
  60. && mkdir build \
  61. && cd /usr/local/src/opencv-4.0.1/build \
  62. && cmake -D CMAKE_INSTALL_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local/ .. \
  63. && make -j4 \
  64. && make install \
  65. && ldconfig \
  66. && rm -rf /usr/local/src/opencv-4.0.1
  67. # Download and install EdgeTPU libraries for Coral
  68. RUN wget https://dl.google.com/coral/edgetpu_api/edgetpu_api_latest.tar.gz -O edgetpu_api.tar.gz --trust-server-names \
  69. && tar xzf edgetpu_api.tar.gz
  70. COPY scripts/install_edgetpu_api.sh edgetpu_api/install.sh
  71. RUN cd edgetpu_api \
  72. && /bin/bash install.sh
  73. # Copy a python 3.6 version
  74. RUN cd /usr/local/lib/python3.6/dist-packages/edgetpu/swig/ \
  75. && ln -s _edgetpu_cpp_wrapper.cpython-35m-arm-linux-gnueabihf.so _edgetpu_cpp_wrapper.cpython-36m-arm-linux-gnueabihf.so
  76. # symlink the model and labels
  77. 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
  78. RUN wget https://dl.google.com/coral/canned_models/coco_labels.txt -O coco_labels.txt --trust-server-names
  79. RUN ln -s mobilenet_ssd_v2_coco_quant_postprocess_edgetpu.tflite /frozen_inference_graph.pb
  80. RUN ln -s /coco_labels.txt /label_map.pbtext
  81. # Minimize image size
  82. RUN (apt-get autoremove -y; \
  83. apt-get autoclean -y)
  84. # Install core packages
  85. RUN wget -q -O /tmp/get-pip.py --no-check-certificate https://bootstrap.pypa.io/get-pip.py && python3 /tmp/get-pip.py
  86. RUN pip install -U pip \
  87. numpy \
  88. Flask \
  89. paho-mqtt \
  90. PyYAML \
  91. matplotlib \
  92. scipy
  93. WORKDIR /opt/frigate/
  94. ADD frigate frigate/
  95. COPY detect_objects.py .
  96. COPY benchmark.py .
  97. CMD ["python3", "-u", "detect_objects.py"]