diff --git a/Dockerfile b/Dockerfile index 80093e41d..19de5dde8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -82,20 +82,21 @@ RUN cd /usr/local/src/ \ 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 \ + && rm -rf edgetpu_api.tar.gz \ && cd python-tflite-source \ && 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 \ && cp edgetpu/swig/compiled_so/edgetpu_cpp_wrapper.py edgetpu/swig/ \ && python3 setup.py develop --user -# Minimize image size +# symlink the model and labels +RUN ln -s /python-tflite-source/edgetpu/test_data/mobilenet_ssd_v2_coco_quant_postprocess_edgetpu.tflite /mobilenet_ssd_v2_coco.tflite +RUN ln -s /python-tflite-source/edgetpu/test_data/coco_labels.txt /coco_labels.txt + +# Minimize image size RUN (apt-get autoremove -y; \ apt-get autoclean -y) -# 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 - # 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=. diff --git a/frigate/object_detection.py b/frigate/object_detection.py index 3a1d11c42..4dc7e62ac 100644 --- a/frigate/object_detection.py +++ b/frigate/object_detection.py @@ -6,11 +6,6 @@ import numpy as np from edgetpu.detection.engine import DetectionEngine from . util import tonumpyarray -# Path to frozen detection graph. This is the actual model that is used for the object detection. -PATH_TO_CKPT = '/frozen_inference_graph.pb' -# List of the strings that is used to add correct label for each box. -PATH_TO_LABELS = '/label_map.pbtext' - # Function to read labels from text files. def ReadLabelFile(file_path): with open(file_path, 'r') as f: @@ -27,10 +22,11 @@ class PreppedQueueProcessor(threading.Thread): threading.Thread.__init__(self) self.cameras = cameras self.prepped_frame_queue = prepped_frame_queue - - # Load the edgetpu engine and labels - self.engine = DetectionEngine(PATH_TO_CKPT) - self.labels = ReadLabelFile(PATH_TO_LABELS) + + # Load the edgetpu engine with the model used for object detection. + self.engine = DetectionEngine('/mobilenet_ssd_v2_coco.tflite') + # Load the strings used to add the correct label for each box. + self.labels = ReadLabelFile('/coco_labels.txt') def run(self): # process queue...