From 99cbf4a6e1ce6ccbac3d06a5e60c521aac2676ff Mon Sep 17 00:00:00 2001 From: kkrampa Date: Wed, 13 May 2020 00:19:04 +0200 Subject: [PATCH 01/16] Tweaks --- Dockerfile-x86-openvino | 4 +--- download_openvino_model.sh | 4 ++++ {data => libs/detectors/x86/data}/.keep | 0 libs/detectors/x86/openvino.py | 4 ++-- 4 files changed, 7 insertions(+), 5 deletions(-) create mode 100755 download_openvino_model.sh rename {data => libs/detectors/x86/data}/.keep (100%) diff --git a/Dockerfile-x86-openvino b/Dockerfile-x86-openvino index bf033597..607cc01e 100644 --- a/Dockerfile-x86-openvino +++ b/Dockerfile-x86-openvino @@ -1,4 +1,4 @@ -FROM openvino/ubuntu18_dev +FROM openvino/ubuntu18_runtime USER root VOLUME /repo @@ -8,7 +8,5 @@ RUN apt-get update && apt-get install -y pkg-config libsm6 libxext6 libxrender-d RUN pip3 install --upgrade pip setuptools==41.0.0 && pip3 install opencv-python wget flask scipy image -RUN /opt/intel/openvino/deployment_tools/tools/model_downloader/downloader.py --name pedestrian-detection-adas-0002 --precisions FP32 - EXPOSE 8000 diff --git a/download_openvino_model.sh b/download_openvino_model.sh new file mode 100755 index 00000000..71e8b992 --- /dev/null +++ b/download_openvino_model.sh @@ -0,0 +1,4 @@ +wget https://download.01.org/opencv/2020/openvinotoolkit/2020.2/open_model_zoo/models_bin/3/person-detection-retail-0013/FP32/person-detection-retail-0013.xml \ + -O libs/detectors/x86/data/person-detection-retail-0013.xml +wget https://download.01.org/opencv/2020/openvinotoolkit/2020.2/open_model_zoo/models_bin/3/person-detection-retail-0013/FP32/person-detection-retail-0013.bin \ + -O libs/detectors/x86/data/person-detection-retail-0013.bin diff --git a/data/.keep b/libs/detectors/x86/data/.keep similarity index 100% rename from data/.keep rename to libs/detectors/x86/data/.keep diff --git a/libs/detectors/x86/openvino.py b/libs/detectors/x86/openvino.py index fc8f9e69..3b6f49c6 100644 --- a/libs/detectors/x86/openvino.py +++ b/libs/detectors/x86/openvino.py @@ -6,7 +6,7 @@ from libs.detectors.utils.fps_calculator import convert_infr_time_to_fps -from openvino.inference_engine import IENetwork, IECore +from openvino.inference_engine import IECore class Detector: """ @@ -24,7 +24,7 @@ def __init__(self, config): # Frames Per Second self.fps = None - model_path = '/opt/intel/openvino_2020.2.120/deployment_tools/open_model_zoo/tools/downloader/intel/pedestrian-detection-adas-0002/FP32' + model_path = 'libs/detectors/x86/data' core = IECore() network = core.read_network( From 81f5e5ecab93c15f22c8e2792df69a5014486b1e Mon Sep 17 00:00:00 2001 From: kkrampa Date: Wed, 13 May 2020 00:30:29 +0200 Subject: [PATCH 02/16] Tweaks --- Dockerfile-x86-openvino | 2 ++ README.md | 14 ++++++++++++++ config-x86-openvino.ini | 2 +- config-x86.ini | 2 +- 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Dockerfile-x86-openvino b/Dockerfile-x86-openvino index 607cc01e..aaaad6a4 100644 --- a/Dockerfile-x86-openvino +++ b/Dockerfile-x86-openvino @@ -10,3 +10,5 @@ RUN pip3 install --upgrade pip setuptools==41.0.0 && pip3 install opencv-python EXPOSE 8000 +CMD source /opt/intel/openvino/bin/setupvars.sh && python3 neuralet-distancing.py --config=config-x86-openvino.ini + diff --git a/README.md b/README.md index 08155920..b7f4031b 100644 --- a/README.md +++ b/README.md @@ -99,6 +99,20 @@ docker build -f Dockerfile-x86 -t "neuralet/x86_64:applications-smart-distancing docker run -it -p HOST_PORT:8000 -v /PATH_TO_CLONED_REPO_ROOT/:/repo neuralet/x86_64:applications-smart-distancing ``` +**Run on x86 using OpenVino** + + +``` +cd neuralet/applications/smart-distancing/ +# download model first +./download_openvino_model.sh + +# 1) Build Docker image (This step is optional, you can skip it if you want to pull the container from neuralet dockerhub) +docker build -f Dockerfile-x86-openvino -t "neuralet/x86_64-openvino:applications-smart-distancing" . +# 2) Run Docker container: +docker run -it -p HOST_PORT:8000 -v /PATH_TO_CLONED_REPO_ROOT/:/repo neuralet/x86_64-openvino:applications-smart-distancing +``` + ### Configurations You can read and modify the configurations in `config-jetson.ini` file for Jetson Nano and `config-skeleton.ini` file for Coral. diff --git a/config-x86-openvino.ini b/config-x86-openvino.ini index 770792f7..cf93e967 100644 --- a/config-x86-openvino.ini +++ b/config-x86-openvino.ini @@ -1,5 +1,5 @@ [App] -VideoPath: data/TownCentreXVID.avi +VideoPath: /repo/applications/smart-distancing/data/TownCentreXVID.avi Host: 0.0.0.0 Port: 8000 Resolution: 640,480 diff --git a/config-x86.ini b/config-x86.ini index 92171c58..6d11ba3d 100644 --- a/config-x86.ini +++ b/config-x86.ini @@ -1,5 +1,5 @@ [App] -VideoPath: data/TownCentreXVID.avi +VideoPath: /repo/applications/smart-distancing/data/TownCentreXVID.avi Host: 0.0.0.0 Port: 8000 Resolution: 640,480 From 36f5b6f619fbef1f2d27b42075c22eadb0dfc597 Mon Sep 17 00:00:00 2001 From: Mohammad H Sekhavat Date: Wed, 13 May 2020 13:21:33 -0400 Subject: [PATCH 03/16] Implement Dummy Detector Detects random bounding boxes on each frame. Also fixes: #84 --- libs/core.py | 5 ++--- libs/detectors/dummy/__init__.py | 0 libs/detectors/dummy/detector.py | 29 +++++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 libs/detectors/dummy/__init__.py create mode 100644 libs/detectors/dummy/detector.py diff --git a/libs/core.py b/libs/core.py index d2421c2d..ea175df8 100755 --- a/libs/core.py +++ b/libs/core.py @@ -25,7 +25,8 @@ def __init__(self, config): from libs.detectors.edgetpu.detector import Detector self.detector = Detector(self.config) elif self.device == 'Dummy': - self.detector = None + from libs.detectors.dummy.detector import Detector + self.detector = Detector(self.config) elif self.device == 'x86': from libs.detectors.x86.detector import Detector self.detector = Detector(self.config) @@ -48,8 +49,6 @@ def __process(self, cv_image): return object_list list of dict for each obj, obj["bbox"] is normalized coordinations for [x0, y0, x1, y1] of box """ - if self.device == 'Dummy': - return cv_image, [], None # Resize input image to resolution resolution = [int(i) for i in self.config.get_section_dict('App')['Resolution'].split(',')] diff --git a/libs/detectors/dummy/__init__.py b/libs/detectors/dummy/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/libs/detectors/dummy/detector.py b/libs/detectors/dummy/detector.py new file mode 100644 index 00000000..0fa6165a --- /dev/null +++ b/libs/detectors/dummy/detector.py @@ -0,0 +1,29 @@ +import numpy as np +import time + +class Detector: + """ + Detects Random bounding boxes + + Detector class is a high level class for detecting object using edgetpu devices. + When an instance of the Detector is created you can call inference method and feed your + input image in order to get the detection results. + + :param config: Is a ConfigEngine instance which provides necessary parameters. + """ + + def __init__(self, config): + self.config = config + self.name = self.config.get_section_dict('Detector')['Name'] + self.class_id = self.config.get_section_dict('Detector')['ClassID'] + + def inference(self, resized_rgb_image): + self.fps = int(np.random.rand() * 10 + 10) + time.sleep(1.0 / self.fps) + bbox_transform = np.array([[1, 0, 0, 0], [0, 1, 0, 0], [1, 0, 1, 0], [0, 1, 0, 1]]) * 0.5 + class_id = self.class_id + return [{ + 'id': str(class_id)+"-"+str(i), + 'bbox': (bbox_transform @ np.random.rand(4)).tolist(), + 'cls': class_id + } for i in range(np.random.randint(5))] From 839b8e98082c020c996adf3e844c52a966654611 Mon Sep 17 00:00:00 2001 From: Mohammad H Sekhavat Date: Wed, 13 May 2020 13:44:59 -0400 Subject: [PATCH 04/16] Reduce fps for dummy detector --- libs/detectors/dummy/detector.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/detectors/dummy/detector.py b/libs/detectors/dummy/detector.py index 0fa6165a..04a32003 100644 --- a/libs/detectors/dummy/detector.py +++ b/libs/detectors/dummy/detector.py @@ -18,7 +18,7 @@ def __init__(self, config): self.class_id = self.config.get_section_dict('Detector')['ClassID'] def inference(self, resized_rgb_image): - self.fps = int(np.random.rand() * 10 + 10) + self.fps = np.random.choice([0.5, 1, 2]) time.sleep(1.0 / self.fps) bbox_transform = np.array([[1, 0, 0, 0], [0, 1, 0, 0], [1, 0, 1, 0], [0, 1, 0, 1]]) * 0.5 class_id = self.class_id From 40d4bf25f95516c4b129479b4abc1dab452b3778 Mon Sep 17 00:00:00 2001 From: Mohsen Hejrati Date: Thu, 14 May 2020 21:30:30 -0700 Subject: [PATCH 05/16] add slack channel. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b7f4031b..fa56ab07 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ You can run this application on edge devices such as NVIDIA's Jetson Nano or Goo We encourage the community to join us in building a practical solution to keep people safe while allowing them to get back to their jobs. You can read more about the project motivation and roadmap here: https://docs.google.com/presentation/d/13EEt4JfdkYSqpPLpotx9taBHpNW6WtfXo2SfwFU_aQ0/edit?usp=sharing -Please reach out to covid19project@neuralet.com if you have any questions. +Please join [our slack channel](https://neuralet.slack.com/join/shared_invite/zt-envn1kqo-PE5qB~yE~Y_t0kkUSI~HWw) or reach out to covid19project@neuralet.com if you have any questions. ## Getting Started From 0bfea43f352dd044b44aece5c2b0f220ae7e31a3 Mon Sep 17 00:00:00 2001 From: mrn-mln Date: Sun, 17 May 2020 17:21:00 +0430 Subject: [PATCH 06/16] fix #100 --- ui/utils/visualization_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/utils/visualization_utils.py b/ui/utils/visualization_utils.py index 5e8f8c52..b1944c07 100644 --- a/ui/utils/visualization_utils.py +++ b/ui/utils/visualization_utils.py @@ -409,8 +409,8 @@ def visualization_preparation(nn_out, distances, dist_threshold): detection_boxes = [] is_violating = [] colors = [] - - distance = np.amin(distances + np.identity(len(distances)) * dist_threshold * 2, 0) if distances !=[] else [0] + + distance = np.amin(distances + np.identity(len(distances)) * dist_threshold * 2, 0) if distances != [] else [dist_threshold] for i, obj in enumerate(nn_out): # Colorizing bounding box based on the distances between them # R = 255 when dist=0 and R = 0 when dist > dist_threshold From 932a580cd266a0c2e886cb62cd1c5ee7c25b9be6 Mon Sep 17 00:00:00 2001 From: Michael de Gans <47511965+mdegans@users.noreply.github.com> Date: Mon, 18 May 2020 16:45:39 -0700 Subject: [PATCH 07/16] rename dockerfiles (#92) * rename dockerfiles - some IDEs like this better (eg. vscode) --- README.md | 10 +++++----- Dockerfile-amd64-usbtpu => amd64-usbtpu.Dockerfile | 0 ...rfile-coral-dev-board => coral-dev-board.Dockerfile | 0 Dockerfile-jetson-nano => jetson-nano.Dockerfile | 0 Dockerfile-x86-openvino => x86-openvino.Dockerfile | 0 Dockerfile-x86 => x86.Dockerfile | 0 6 files changed, 5 insertions(+), 5 deletions(-) rename Dockerfile-amd64-usbtpu => amd64-usbtpu.Dockerfile (100%) rename Dockerfile-coral-dev-board => coral-dev-board.Dockerfile (100%) rename Dockerfile-jetson-nano => jetson-nano.Dockerfile (100%) rename Dockerfile-x86-openvino => x86-openvino.Dockerfile (100%) rename Dockerfile-x86 => x86.Dockerfile (100%) diff --git a/README.md b/README.md index fa56ab07..1b1bcea5 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ cd neuralet/applications/smart-distancing/ ./download_jetson_trt.sh # 2) Build Docker image (This step is optional, you can skip it if you want to pull the container from neuralet dockerhub) -docker build -f Dockerfile-jetson-nano -t "neuralet/jetson-nano:applications-smart-distancing" . +docker build -f jetson-nano.Dockerfile -t "neuralet/jetson-nano:applications-smart-distancing" . # 3) Run Docker container: docker run -it --runtime nvidia --privileged -p HOST_PORT:8000 -v /PATH_TO_CLONED_REPO_ROOT/:/repo neuralet/jetson-nano:applications-smart-distancing @@ -74,7 +74,7 @@ docker run -it --runtime nvidia --privileged -p HOST_PORT:8000 -v /PATH_TO_CLONE cd neuralet/applications/smart-distancing/ # 1) Build Docker image (This step is optional, you can skip it if you want to pull the container from neuralet dockerhub) -docker build -f Dockerfile-coral-dev-board -t "neuralet/coral-dev-board:applications-smart-distancing" . +docker build -f coral-dev-board.Dockerfile -t "neuralet/coral-dev-board:applications-smart-distancing" . # 2) Run Docker container: docker run -it --privileged -p HOST_PORT:8000 -v /PATH_TO_CLONED_REPO_ROOT/:/repo neuralet/coral-dev-board:applications-smart-distancing ``` @@ -84,7 +84,7 @@ docker run -it --privileged -p HOST_PORT:8000 -v /PATH_TO_CLONED_REPO_ROOT/:/rep cd neuralet/applications/smart-distancing/ # 1) Build Docker image (This step is optional, you can skip it if you want to pull the container from neuralet dockerhub) -docker build -f Dockerfile-amd64-usbtpu -t "neuralet/amd64:applications-smart-distancing" . +docker build -f amd64-usbtpu.Dockerfile -t "neuralet/amd64:applications-smart-distancing" . # 2) Run Docker container: docker run -it --privileged -p HOST_PORT:8000 -v /PATH_TO_CLONED_REPO_ROOT/:/repo neuralet/amd64:applications-smart-distancing ``` @@ -94,7 +94,7 @@ docker run -it --privileged -p HOST_PORT:8000 -v /PATH_TO_CLONED_REPO_ROOT/:/rep cd neuralet/applications/smart-distancing/ # 1) Build Docker image (This step is optional, you can skip it if you want to pull the container from neuralet dockerhub) -docker build -f Dockerfile-x86 -t "neuralet/x86_64:applications-smart-distancing" . +docker build -f x86.Dockerfile -t "neuralet/x86_64:applications-smart-distancing" . # 2) Run Docker container: docker run -it -p HOST_PORT:8000 -v /PATH_TO_CLONED_REPO_ROOT/:/repo neuralet/x86_64:applications-smart-distancing ``` @@ -108,7 +108,7 @@ cd neuralet/applications/smart-distancing/ ./download_openvino_model.sh # 1) Build Docker image (This step is optional, you can skip it if you want to pull the container from neuralet dockerhub) -docker build -f Dockerfile-x86-openvino -t "neuralet/x86_64-openvino:applications-smart-distancing" . +docker build -f x86-openvino.Dockerfile -t "neuralet/x86_64-openvino:applications-smart-distancing" . # 2) Run Docker container: docker run -it -p HOST_PORT:8000 -v /PATH_TO_CLONED_REPO_ROOT/:/repo neuralet/x86_64-openvino:applications-smart-distancing ``` diff --git a/Dockerfile-amd64-usbtpu b/amd64-usbtpu.Dockerfile similarity index 100% rename from Dockerfile-amd64-usbtpu rename to amd64-usbtpu.Dockerfile diff --git a/Dockerfile-coral-dev-board b/coral-dev-board.Dockerfile similarity index 100% rename from Dockerfile-coral-dev-board rename to coral-dev-board.Dockerfile diff --git a/Dockerfile-jetson-nano b/jetson-nano.Dockerfile similarity index 100% rename from Dockerfile-jetson-nano rename to jetson-nano.Dockerfile diff --git a/Dockerfile-x86-openvino b/x86-openvino.Dockerfile similarity index 100% rename from Dockerfile-x86-openvino rename to x86-openvino.Dockerfile diff --git a/Dockerfile-x86 b/x86.Dockerfile similarity index 100% rename from Dockerfile-x86 rename to x86.Dockerfile From c3e550ca40472afc1acc748e0b4f1f597458286d Mon Sep 17 00:00:00 2001 From: alpha-carinae29 Date: Mon, 25 May 2020 13:46:44 -0700 Subject: [PATCH 08/16] change load_model function in libs/detectors/x86/mobilenet_ssd.py --- libs/detectors/x86/mobilenet_ssd.py | 34 ++++++++++++++++------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/libs/detectors/x86/mobilenet_ssd.py b/libs/detectors/x86/mobilenet_ssd.py index c68bd2fe..529e9c11 100644 --- a/libs/detectors/x86/mobilenet_ssd.py +++ b/libs/detectors/x86/mobilenet_ssd.py @@ -1,27 +1,31 @@ import pathlib import time - +import os import numpy as np - +import tarfile +import wget import tensorflow as tf from libs.detectors.utils.fps_calculator import convert_infr_time_to_fps def load_model(model_name): - base_url = 'http://download.tensorflow.org/models/object_detection/' - model_file = model_name + '.tar.gz' - model_dir = tf.keras.utils.get_file( - fname=model_name, - origin=base_url + model_file, - untar=True) - - model_dir = pathlib.Path(model_dir) / "saved_model" - - model = tf.saved_model.load(str(model_dir)) - model = model.signatures['serving_default'] - - return model + base_url = 'http://download.tensorflow.org/models/object_detection/' + model_file = model_name + '.tar.gz' + base_dir = "libs/detectors/x86/data/" + model_dir = os.path.join(base_dir, model_name) + if not os.path.isdir(model_dir): + print('model does not exist under: ', model_dir, 'downloading from ', base_url + model_file) + wget.download(base_url + model_file, base_dir) + with tarfile.open(base_dir + model_file, "r") as tar: + tar.extractall(path=base_dir) + + model_dir = pathlib.Path(model_dir) / "saved_model" + + model = tf.saved_model.load(str(model_dir)) + model = model.signatures['serving_default'] + + return model class Detector: From 4d493bbec1911933f9c96dfbd00bfa5afd1fce06 Mon Sep 17 00:00:00 2001 From: alpha-carinae29 Date: Mon, 25 May 2020 14:46:47 -0700 Subject: [PATCH 09/16] add pedestrian mobilenet v2 detector to the smart distancing --- config-x86.ini | 2 +- libs/detectors/x86/detector.py | 3 + .../x86/pedestrian_ssd_mobilenet_v2.py | 78 +++++++++++++++++++ 3 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 libs/detectors/x86/pedestrian_ssd_mobilenet_v2.py diff --git a/config-x86.ini b/config-x86.ini index 6d11ba3d..062a9c54 100644 --- a/config-x86.ini +++ b/config-x86.ini @@ -7,7 +7,7 @@ Resolution: 640,480 [Detector] ; Supported devices: Jetson , EdgeTPU, Dummy Device: x86 -Name: mobilenet_ssd_v2 +Name: pedestrian_ssd_mobilenet_v2 ;ImageSize should be 3 numbers seperated by commas, no spaces: 300,300,3 ImageSize: 300,300,3 ModelPath: diff --git a/libs/detectors/x86/detector.py b/libs/detectors/x86/detector.py index 389c00f5..c5801c58 100644 --- a/libs/detectors/x86/detector.py +++ b/libs/detectors/x86/detector.py @@ -19,6 +19,9 @@ def __init__(self, config): elif self.name == "openvino": from libs.detectors.x86 import openvino self.net = openvino.Detector(self.config) + elif self.name == "pedestrian_ssd_mobilenet_v2": + from libs.detectors.x86 import pedestrian_ssd_mobilenet_v2 + self.net = pedestrian_ssd_mobilenet_v2.Detector(self.config) else: raise ValueError('Not supported network named: ', self.name) diff --git a/libs/detectors/x86/pedestrian_ssd_mobilenet_v2.py b/libs/detectors/x86/pedestrian_ssd_mobilenet_v2.py new file mode 100644 index 00000000..1be51f90 --- /dev/null +++ b/libs/detectors/x86/pedestrian_ssd_mobilenet_v2.py @@ -0,0 +1,78 @@ +import pathlib +import time +import os +import numpy as np +import tarfile +import wget +import tensorflow as tf + +from libs.detectors.utils.fps_calculator import convert_infr_time_to_fps + + +def load_model(model_name): + base_url = 'https://raw.githubusercontent.com/neuralet/neuralet-models/master/amd64/' + model_file = model_name + "/saved_model/saved_model.pb" + base_dir = "libs/detectors/x86/data/" + model_dir = os.path.join(base_dir, model_name) + if not os.path.isdir(model_dir): + os.makedirs(os.path.join(model_dir, "saved_model"), exist_ok=True) + print('model does not exist under: ', model_dir, 'downloading from ', base_url + model_file) + wget.download(base_url + model_file, os.path.join(model_dir, "saved_model")) + + model_dir = pathlib.Path(model_dir) / "saved_model" + + model = tf.saved_model.load(str(model_dir)) + model = model.signatures['serving_default'] + + return model + + +class Detector: + """ + Perform object detection with the given model. The model is a quantized tflite + file which if the detector can not find it at the path it will download it + from neuralet repository automatically. + + :param config: Is a ConfigEngine instance which provides necessary parameters. + """ + + def __init__(self, config): + self.config = config + # Get the model name from the config + self.model_name = self.config.get_section_dict('Detector')['Name'] + # Frames Per Second + self.fps = None + + self.detection_model = load_model('ped_ssd_mobilenet_v2') + + def inference(self, resized_rgb_image): + """ + inference function sets input tensor to input image and gets the output. + The interpreter instance provides corresponding detection output which is used for creating result + Args: + resized_rgb_image: uint8 numpy array with shape (img_height, img_width, channels) + + Returns: + result: a dictionary contains of [{"id": 0, "bbox": [x1, y1, x2, y2], "score":s%}, {...}, {...}, ...] + """ + input_image = np.expand_dims(resized_rgb_image, axis=0) + input_tensor = tf.convert_to_tensor(input_image) + t_begin = time.perf_counter() + output_dict = self.detection_model(input_tensor) + inference_time = time.perf_counter() - t_begin # Seconds + + # Calculate Frames rate (fps) + self.fps = convert_infr_time_to_fps(inference_time) + + boxes = output_dict['detection_boxes'] + labels = output_dict['detection_classes'] + scores = output_dict['detection_scores'] + + class_id = int(self.config.get_section_dict('Detector')['ClassID']) + score_threshold = float(self.config.get_section_dict('Detector')['MinScore']) + result = [] + for i in range(boxes.shape[1]): # number of boxes + if labels[0, i] == class_id and scores[0, i] > score_threshold: + result.append({"id": str(class_id) + '-' + str(i), "bbox": boxes[0, i, :], "score": scores[0, i]}) + + return result From ea417510875118f5d12aa50e4c70c86c5f5aeae0 Mon Sep 17 00:00:00 2001 From: alpha-carinae29 Date: Mon, 25 May 2020 14:55:36 -0700 Subject: [PATCH 10/16] add pedestrian ssdlite mobilenet v2 detector to the smart distancing --- libs/detectors/x86/detector.py | 3 + .../x86/pedestrian_ssdlite_mobilenet_v2.py | 78 +++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 libs/detectors/x86/pedestrian_ssdlite_mobilenet_v2.py diff --git a/libs/detectors/x86/detector.py b/libs/detectors/x86/detector.py index c5801c58..71bd9175 100644 --- a/libs/detectors/x86/detector.py +++ b/libs/detectors/x86/detector.py @@ -22,6 +22,9 @@ def __init__(self, config): elif self.name == "pedestrian_ssd_mobilenet_v2": from libs.detectors.x86 import pedestrian_ssd_mobilenet_v2 self.net = pedestrian_ssd_mobilenet_v2.Detector(self.config) + elif self.name == "pedestrian_ssdlite_mobilenet_v2": + from libs.detectors.x86 import pedestrian_ssdlite_mobilenet_v2 + self.net = pedestrian_ssdlite_mobilenet_v2.Detector(self.config) else: raise ValueError('Not supported network named: ', self.name) diff --git a/libs/detectors/x86/pedestrian_ssdlite_mobilenet_v2.py b/libs/detectors/x86/pedestrian_ssdlite_mobilenet_v2.py new file mode 100644 index 00000000..55b87995 --- /dev/null +++ b/libs/detectors/x86/pedestrian_ssdlite_mobilenet_v2.py @@ -0,0 +1,78 @@ +import pathlib +import time +import os +import numpy as np +import tarfile +import wget +import tensorflow as tf + +from libs.detectors.utils.fps_calculator import convert_infr_time_to_fps + + +def load_model(model_name): + base_url = 'https://raw.githubusercontent.com/neuralet/neuralet-models/master/amd64/' + model_file = model_name + "/saved_model/saved_model.pb" + base_dir = "libs/detectors/x86/data/" + model_dir = os.path.join(base_dir, model_name) + if not os.path.isdir(model_dir): + os.makedirs(os.path.join(model_dir, "saved_model"), exist_ok=True) + print('model does not exist under: ', model_dir, 'downloading from ', base_url + model_file) + wget.download(base_url + model_file, os.path.join(model_dir, "saved_model")) + + model_dir = pathlib.Path(model_dir) / "saved_model" + + model = tf.saved_model.load(str(model_dir)) + model = model.signatures['serving_default'] + + return model + + +class Detector: + """ + Perform object detection with the given model. The model is a quantized tflite + file which if the detector can not find it at the path it will download it + from neuralet repository automatically. + + :param config: Is a ConfigEngine instance which provides necessary parameters. + """ + + def __init__(self, config): + self.config = config + # Get the model name from the config + self.model_name = self.config.get_section_dict('Detector')['Name'] + # Frames Per Second + self.fps = None + + self.detection_model = load_model('ped_ssdlite_mobilenet_v2') + + def inference(self, resized_rgb_image): + """ + inference function sets input tensor to input image and gets the output. + The interpreter instance provides corresponding detection output which is used for creating result + Args: + resized_rgb_image: uint8 numpy array with shape (img_height, img_width, channels) + + Returns: + result: a dictionary contains of [{"id": 0, "bbox": [x1, y1, x2, y2], "score":s%}, {...}, {...}, ...] + """ + input_image = np.expand_dims(resized_rgb_image, axis=0) + input_tensor = tf.convert_to_tensor(input_image) + t_begin = time.perf_counter() + output_dict = self.detection_model(input_tensor) + inference_time = time.perf_counter() - t_begin # Seconds + + # Calculate Frames rate (fps) + self.fps = convert_infr_time_to_fps(inference_time) + + boxes = output_dict['detection_boxes'] + labels = output_dict['detection_classes'] + scores = output_dict['detection_scores'] + + class_id = int(self.config.get_section_dict('Detector')['ClassID']) + score_threshold = float(self.config.get_section_dict('Detector')['MinScore']) + result = [] + for i in range(boxes.shape[1]): # number of boxes + if labels[0, i] == class_id and scores[0, i] > score_threshold: + result.append({"id": str(class_id) + '-' + str(i), "bbox": boxes[0, i, :], "score": scores[0, i]}) + + return result From 408f2971ef9252a5e5e15de0ea9afe5540933241 Mon Sep 17 00:00:00 2001 From: alpha-carinae29 Date: Mon, 25 May 2020 15:03:37 -0700 Subject: [PATCH 11/16] add pedestrian ssdlite mobilenet v3 detector to the smart distancing --- libs/detectors/x86/detector.py | 3 + .../x86/pedestrian_ssdlite_mobilenet_v3.py | 78 +++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 libs/detectors/x86/pedestrian_ssdlite_mobilenet_v3.py diff --git a/libs/detectors/x86/detector.py b/libs/detectors/x86/detector.py index 71bd9175..7f6bfab2 100644 --- a/libs/detectors/x86/detector.py +++ b/libs/detectors/x86/detector.py @@ -25,6 +25,9 @@ def __init__(self, config): elif self.name == "pedestrian_ssdlite_mobilenet_v2": from libs.detectors.x86 import pedestrian_ssdlite_mobilenet_v2 self.net = pedestrian_ssdlite_mobilenet_v2.Detector(self.config) + elif self.name == "pedestrian_ssdlite_mobilenet_v3": + from libs.detectors.x86 import pedestrian_ssdlite_mobilenet_v3 + self.net = pedestrian_ssdlite_mobilenet_v3.Detector(self.config) else: raise ValueError('Not supported network named: ', self.name) diff --git a/libs/detectors/x86/pedestrian_ssdlite_mobilenet_v3.py b/libs/detectors/x86/pedestrian_ssdlite_mobilenet_v3.py new file mode 100644 index 00000000..3b838cb7 --- /dev/null +++ b/libs/detectors/x86/pedestrian_ssdlite_mobilenet_v3.py @@ -0,0 +1,78 @@ +import pathlib +import time +import os +import numpy as np +import tarfile +import wget +import tensorflow as tf + +from libs.detectors.utils.fps_calculator import convert_infr_time_to_fps + + +def load_model(model_name): + base_url = 'https://raw.githubusercontent.com/neuralet/neuralet-models/master/amd64/' + model_file = model_name + "/saved_model/saved_model.pb" + base_dir = "libs/detectors/x86/data/" + model_dir = os.path.join(base_dir, model_name) + if not os.path.isdir(model_dir): + os.makedirs(os.path.join(model_dir, "saved_model"), exist_ok=True) + print('model does not exist under: ', model_dir, 'downloading from ', base_url + model_file) + wget.download(base_url + model_file, os.path.join(model_dir, "saved_model")) + + model_dir = pathlib.Path(model_dir) / "saved_model" + + model = tf.saved_model.load(str(model_dir)) + model = model.signatures['serving_default'] + + return model + + +class Detector: + """ + Perform object detection with the given model. The model is a quantized tflite + file which if the detector can not find it at the path it will download it + from neuralet repository automatically. + + :param config: Is a ConfigEngine instance which provides necessary parameters. + """ + + def __init__(self, config): + self.config = config + # Get the model name from the config + self.model_name = self.config.get_section_dict('Detector')['Name'] + # Frames Per Second + self.fps = None + + self.detection_model = load_model('ped_ssdlite_mobilenet_v3') + + def inference(self, resized_rgb_image): + """ + inference function sets input tensor to input image and gets the output. + The interpreter instance provides corresponding detection output which is used for creating result + Args: + resized_rgb_image: uint8 numpy array with shape (img_height, img_width, channels) + + Returns: + result: a dictionary contains of [{"id": 0, "bbox": [x1, y1, x2, y2], "score":s%}, {...}, {...}, ...] + """ + input_image = np.expand_dims(resized_rgb_image, axis=0) + input_tensor = tf.convert_to_tensor(input_image) + t_begin = time.perf_counter() + output_dict = self.detection_model(input_tensor) + inference_time = time.perf_counter() - t_begin # Seconds + + # Calculate Frames rate (fps) + self.fps = convert_infr_time_to_fps(inference_time) + + boxes = output_dict['detection_boxes'] + labels = output_dict['detection_classes'] + scores = output_dict['detection_scores'] + + class_id = int(self.config.get_section_dict('Detector')['ClassID']) + score_threshold = float(self.config.get_section_dict('Detector')['MinScore']) + result = [] + for i in range(boxes.shape[1]): # number of boxes + if labels[0, i] == class_id and scores[0, i] > score_threshold: + result.append({"id": str(class_id) + '-' + str(i), "bbox": boxes[0, i, :], "score": scores[0, i]}) + + return result From 606729a57f7780c3588d8411051b6793da0c2063 Mon Sep 17 00:00:00 2001 From: alpha-carinae29 Date: Mon, 25 May 2020 15:12:42 -0700 Subject: [PATCH 12/16] change COCO model from mobilenet_ssd to ssd_mobilenet_v2 --- libs/detectors/x86/detector.py | 6 +++--- libs/detectors/x86/{mobilenet_ssd.py => ssd_mobilenet_v2} | 0 2 files changed, 3 insertions(+), 3 deletions(-) rename libs/detectors/x86/{mobilenet_ssd.py => ssd_mobilenet_v2} (100%) diff --git a/libs/detectors/x86/detector.py b/libs/detectors/x86/detector.py index 7f6bfab2..9b71e11f 100644 --- a/libs/detectors/x86/detector.py +++ b/libs/detectors/x86/detector.py @@ -13,9 +13,9 @@ def __init__(self, config): self.config = config self.name = self.config.get_section_dict('Detector')['Name'] - if self.name == 'mobilenet_ssd_v2': - from libs.detectors.x86 import mobilenet_ssd - self.net = mobilenet_ssd.Detector(self.config) + if self.name == 'ssd_mobilenet_v2': + from libs.detectors.x86 import ssd_mobilenet_v2 + self.net = ssd_mobilenet_v2.Detector(self.config) elif self.name == "openvino": from libs.detectors.x86 import openvino self.net = openvino.Detector(self.config) diff --git a/libs/detectors/x86/mobilenet_ssd.py b/libs/detectors/x86/ssd_mobilenet_v2 similarity index 100% rename from libs/detectors/x86/mobilenet_ssd.py rename to libs/detectors/x86/ssd_mobilenet_v2 From 991749d56b7fc0b27042f9517261d47977fee0b8 Mon Sep 17 00:00:00 2001 From: alpha-carinae29 Date: Mon, 25 May 2020 15:13:24 -0700 Subject: [PATCH 13/16] modify config files --- config-skeleton.ini | 2 +- config-x86.ini | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/config-skeleton.ini b/config-skeleton.ini index 371b008a..d7770080 100644 --- a/config-skeleton.ini +++ b/config-skeleton.ini @@ -7,7 +7,7 @@ Resolution: 640,480 [Detector] ; Supported devices: Jetson , EdgeTPU, Dummy Device: EdgeTPU -; Detector's Name can be either "mobilenet_ssd_v2", "pedestrian_ssdlite_mobilenet_v2" or "pedestrian_ssdlite_mobilenet_v2" +; Detector's Name can be either "mobilenet_ssd_v2", "pedestrian_ssd_mobilenet_v2" or "pedestrian_ssdlite_mobilenet_v2" ; the first one is trained on COCO dataset and next two are trained on Oxford Town Center dataset to detect pedestrians Name: pedestrian_ssdlite_mobilenet_v2 ;ImageSize should be 3 numbers seperated by commas, no spaces: 300,300,3 diff --git a/config-x86.ini b/config-x86.ini index 062a9c54..bfb9adad 100644 --- a/config-x86.ini +++ b/config-x86.ini @@ -7,8 +7,11 @@ Resolution: 640,480 [Detector] ; Supported devices: Jetson , EdgeTPU, Dummy Device: x86 +;Name can be either ssd_mobilenet_v2 or pedestrian_ssd_mobilenet_v2 or pedestrian_ssdlite_mobilenet_v2 or pedestrian_ssdlite_mobilenet_v2 +;The first one is trained on COCO dataset and next three are trained on Oxford Town Center dataset to detect pedestrians Name: pedestrian_ssd_mobilenet_v2 ;ImageSize should be 3 numbers seperated by commas, no spaces: 300,300,3 +;For the pedestrian_ssdlite_mobilenet_v3: 320,320,3 ImageSize: 300,300,3 ModelPath: ClassID: 1 From d1bdca1c2ca41f7ada8c48ded8dc5c73ea58e732 Mon Sep 17 00:00:00 2001 From: alpha-carinae29 Date: Mon, 25 May 2020 15:18:08 -0700 Subject: [PATCH 14/16] delete tarfile import --- libs/detectors/x86/pedestrian_ssd_mobilenet_v2.py | 1 - libs/detectors/x86/pedestrian_ssdlite_mobilenet_v2.py | 1 - libs/detectors/x86/pedestrian_ssdlite_mobilenet_v3.py | 1 - 3 files changed, 3 deletions(-) diff --git a/libs/detectors/x86/pedestrian_ssd_mobilenet_v2.py b/libs/detectors/x86/pedestrian_ssd_mobilenet_v2.py index 1be51f90..7c12aaef 100644 --- a/libs/detectors/x86/pedestrian_ssd_mobilenet_v2.py +++ b/libs/detectors/x86/pedestrian_ssd_mobilenet_v2.py @@ -2,7 +2,6 @@ import time import os import numpy as np -import tarfile import wget import tensorflow as tf diff --git a/libs/detectors/x86/pedestrian_ssdlite_mobilenet_v2.py b/libs/detectors/x86/pedestrian_ssdlite_mobilenet_v2.py index 55b87995..dc2b53e4 100644 --- a/libs/detectors/x86/pedestrian_ssdlite_mobilenet_v2.py +++ b/libs/detectors/x86/pedestrian_ssdlite_mobilenet_v2.py @@ -2,7 +2,6 @@ import time import os import numpy as np -import tarfile import wget import tensorflow as tf diff --git a/libs/detectors/x86/pedestrian_ssdlite_mobilenet_v3.py b/libs/detectors/x86/pedestrian_ssdlite_mobilenet_v3.py index 3b838cb7..30be361e 100644 --- a/libs/detectors/x86/pedestrian_ssdlite_mobilenet_v3.py +++ b/libs/detectors/x86/pedestrian_ssdlite_mobilenet_v3.py @@ -2,7 +2,6 @@ import time import os import numpy as np -import tarfile import wget import tensorflow as tf From 99ac7857bfa2e3dbf0ed09183a1087b43f574468 Mon Sep 17 00:00:00 2001 From: alpha-carinae29 Date: Wed, 3 Jun 2020 08:11:33 -0700 Subject: [PATCH 15/16] add pedestrian faster rcnn model for x86 --- config-x86.ini | 4 +- libs/detectors/x86/detector.py | 3 + .../x86/pedestrian_faster_rcnn_resnet50.py | 77 +++++++++++++++++++ 3 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 libs/detectors/x86/pedestrian_faster_rcnn_resnet50.py diff --git a/config-x86.ini b/config-x86.ini index c1655d32..f0d22fb7 100644 --- a/config-x86.ini +++ b/config-x86.ini @@ -8,8 +8,8 @@ Resolution: 640,480 [Detector] ; Supported devices: Jetson , EdgeTPU, Dummy Device: x86 -;Name can be either ssd_mobilenet_v2 or pedestrian_ssd_mobilenet_v2 or pedestrian_ssdlite_mobilenet_v2 or pedestrian_ssdlite_mobilenet_v2 -;The first one is trained on COCO dataset and next three are trained on Oxford Town Center dataset to detect pedestrians +;Name can be either ssd_mobilenet_v2 or pedestrian_ssd_mobilenet_v2 or pedestrian_ssdlite_mobilenet_v2 or pedestrian_ssdlite_mobilenet_v2 or pedestrian_faster_rcnn_resnet50 +;The first one is trained on COCO dataset and next four are trained on Oxford Town Center dataset to detect pedestrians Name: pedestrian_ssd_mobilenet_v2 ;ImageSize should be 3 numbers seperated by commas, no spaces: 300,300,3 ;For the pedestrian_ssdlite_mobilenet_v3: 320,320,3 diff --git a/libs/detectors/x86/detector.py b/libs/detectors/x86/detector.py index 9b71e11f..f4e9933c 100644 --- a/libs/detectors/x86/detector.py +++ b/libs/detectors/x86/detector.py @@ -28,6 +28,9 @@ def __init__(self, config): elif self.name == "pedestrian_ssdlite_mobilenet_v3": from libs.detectors.x86 import pedestrian_ssdlite_mobilenet_v3 self.net = pedestrian_ssdlite_mobilenet_v3.Detector(self.config) + elif self.name == "pedestrian_faster_rcnn_resnet50": + from libs.detectors.x86 import pedestrian_faster_rcnn_resnet50 + self.net = pedestrian_faster_rcnn_resnet50.Detector(self.config) else: raise ValueError('Not supported network named: ', self.name) diff --git a/libs/detectors/x86/pedestrian_faster_rcnn_resnet50.py b/libs/detectors/x86/pedestrian_faster_rcnn_resnet50.py new file mode 100644 index 00000000..49bcb75b --- /dev/null +++ b/libs/detectors/x86/pedestrian_faster_rcnn_resnet50.py @@ -0,0 +1,77 @@ +import pathlib +import time +import os +import numpy as np +import wget +import tensorflow as tf + +from libs.detectors.utils.fps_calculator import convert_infr_time_to_fps + + +def load_model(model_name): + base_url = 'https://raw.githubusercontent.com/neuralet/neuralet-models/master/amd64/' + model_file = model_name + "/saved_model/saved_model.pb" + base_dir = "libs/detectors/x86/data/" + model_dir = os.path.join(base_dir, model_name) + if not os.path.isdir(model_dir): + os.makedirs(os.path.join(model_dir, "saved_model"), exist_ok=True) + print('model does not exist under: ', model_dir, 'downloading from ', base_url + model_file) + wget.download(base_url + model_file, os.path.join(model_dir, "saved_model")) + + model_dir = pathlib.Path(model_dir) / "saved_model" + + model = tf.saved_model.load(str(model_dir)) + model = model.signatures['serving_default'] + + return model + + +class Detector: + """ + Perform object detection with the given model. The model is a quantized tflite + file which if the detector can not find it at the path it will download it + from neuralet repository automatically. + + :param config: Is a ConfigEngine instance which provides necessary parameters. + """ + + def __init__(self, config): + self.config = config + # Get the model name from the config + self.model_name = self.config.get_section_dict('Detector')['Name'] + # Frames Per Second + self.fps = None + + self.detection_model = load_model('ped_faster_rcnn_resnet50') + + def inference(self, resized_rgb_image): + """ + inference function sets input tensor to input image and gets the output. + The interpreter instance provides corresponding detection output which is used for creating result + Args: + resized_rgb_image: uint8 numpy array with shape (img_height, img_width, channels) + + Returns: + result: a dictionary contains of [{"id": 0, "bbox": [x1, y1, x2, y2], "score":s%}, {...}, {...}, ...] + """ + input_image = np.expand_dims(resized_rgb_image, axis=0) + input_tensor = tf.convert_to_tensor(input_image) + t_begin = time.perf_counter() + output_dict = self.detection_model(input_tensor) + inference_time = time.perf_counter() - t_begin # Seconds + + # Calculate Frames rate (fps) + self.fps = convert_infr_time_to_fps(inference_time) + + boxes = output_dict['detection_boxes'] + labels = output_dict['detection_classes'] + scores = output_dict['detection_scores'] + + class_id = int(self.config.get_section_dict('Detector')['ClassID']) + score_threshold = float(self.config.get_section_dict('Detector')['MinScore']) + result = [] + for i in range(boxes.shape[1]): # number of boxes + if labels[0, i] == class_id and scores[0, i] > score_threshold: + result.append({"id": str(class_id) + '-' + str(i), "bbox": boxes[0, i, :], "score": scores[0, i]}) + + return result From b542a9718d6cbfe62897902ab586028b7485d1d9 Mon Sep 17 00:00:00 2001 From: alpha-carinae29 Date: Wed, 3 Jun 2020 08:18:15 -0700 Subject: [PATCH 16/16] change model path --- libs/detectors/x86/pedestrian_faster_rcnn_resnet50.py | 2 +- libs/detectors/x86/pedestrian_ssd_mobilenet_v2.py | 2 +- libs/detectors/x86/pedestrian_ssdlite_mobilenet_v2.py | 2 +- libs/detectors/x86/pedestrian_ssdlite_mobilenet_v3.py | 2 +- libs/detectors/x86/{ssd_mobilenet_v2 => ssd_mobilenet_v2.py} | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) rename libs/detectors/x86/{ssd_mobilenet_v2 => ssd_mobilenet_v2.py} (98%) diff --git a/libs/detectors/x86/pedestrian_faster_rcnn_resnet50.py b/libs/detectors/x86/pedestrian_faster_rcnn_resnet50.py index 49bcb75b..1d4d8922 100644 --- a/libs/detectors/x86/pedestrian_faster_rcnn_resnet50.py +++ b/libs/detectors/x86/pedestrian_faster_rcnn_resnet50.py @@ -11,7 +11,7 @@ def load_model(model_name): base_url = 'https://raw.githubusercontent.com/neuralet/neuralet-models/master/amd64/' model_file = model_name + "/saved_model/saved_model.pb" - base_dir = "libs/detectors/x86/data/" + base_dir = "/repo/data/x86/" model_dir = os.path.join(base_dir, model_name) if not os.path.isdir(model_dir): os.makedirs(os.path.join(model_dir, "saved_model"), exist_ok=True) diff --git a/libs/detectors/x86/pedestrian_ssd_mobilenet_v2.py b/libs/detectors/x86/pedestrian_ssd_mobilenet_v2.py index 7c12aaef..772280d4 100644 --- a/libs/detectors/x86/pedestrian_ssd_mobilenet_v2.py +++ b/libs/detectors/x86/pedestrian_ssd_mobilenet_v2.py @@ -11,7 +11,7 @@ def load_model(model_name): base_url = 'https://raw.githubusercontent.com/neuralet/neuralet-models/master/amd64/' model_file = model_name + "/saved_model/saved_model.pb" - base_dir = "libs/detectors/x86/data/" + base_dir = "/repo/data/x86/" model_dir = os.path.join(base_dir, model_name) if not os.path.isdir(model_dir): os.makedirs(os.path.join(model_dir, "saved_model"), exist_ok=True) diff --git a/libs/detectors/x86/pedestrian_ssdlite_mobilenet_v2.py b/libs/detectors/x86/pedestrian_ssdlite_mobilenet_v2.py index dc2b53e4..84dd7977 100644 --- a/libs/detectors/x86/pedestrian_ssdlite_mobilenet_v2.py +++ b/libs/detectors/x86/pedestrian_ssdlite_mobilenet_v2.py @@ -11,7 +11,7 @@ def load_model(model_name): base_url = 'https://raw.githubusercontent.com/neuralet/neuralet-models/master/amd64/' model_file = model_name + "/saved_model/saved_model.pb" - base_dir = "libs/detectors/x86/data/" + base_dir = "/repo/data/x86/" model_dir = os.path.join(base_dir, model_name) if not os.path.isdir(model_dir): os.makedirs(os.path.join(model_dir, "saved_model"), exist_ok=True) diff --git a/libs/detectors/x86/pedestrian_ssdlite_mobilenet_v3.py b/libs/detectors/x86/pedestrian_ssdlite_mobilenet_v3.py index 30be361e..7eaffcb8 100644 --- a/libs/detectors/x86/pedestrian_ssdlite_mobilenet_v3.py +++ b/libs/detectors/x86/pedestrian_ssdlite_mobilenet_v3.py @@ -11,7 +11,7 @@ def load_model(model_name): base_url = 'https://raw.githubusercontent.com/neuralet/neuralet-models/master/amd64/' model_file = model_name + "/saved_model/saved_model.pb" - base_dir = "libs/detectors/x86/data/" + base_dir = "/repo/data/x86/" model_dir = os.path.join(base_dir, model_name) if not os.path.isdir(model_dir): os.makedirs(os.path.join(model_dir, "saved_model"), exist_ok=True) diff --git a/libs/detectors/x86/ssd_mobilenet_v2 b/libs/detectors/x86/ssd_mobilenet_v2.py similarity index 98% rename from libs/detectors/x86/ssd_mobilenet_v2 rename to libs/detectors/x86/ssd_mobilenet_v2.py index 529e9c11..f1fe9e6c 100644 --- a/libs/detectors/x86/ssd_mobilenet_v2 +++ b/libs/detectors/x86/ssd_mobilenet_v2.py @@ -12,7 +12,7 @@ def load_model(model_name): base_url = 'http://download.tensorflow.org/models/object_detection/' model_file = model_name + '.tar.gz' - base_dir = "libs/detectors/x86/data/" + base_dir = "/repo/data/x86/" model_dir = os.path.join(base_dir, model_name) if not os.path.isdir(model_dir): print('model does not exist under: ', model_dir, 'downloading from ', base_url + model_file)