From 547b0e8ed39c25c39de809f28332bde8c643425d Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Fri, 2 Apr 2021 16:41:38 -0400 Subject: [PATCH] add face recognition --- docs/guides/breaking.rst | 8 ++++++++ hook/objectconfig.ini | 20 ++++++++++++++++++-- hook/setup.py | 2 +- install.sh | 4 +++- 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/docs/guides/breaking.rst b/docs/guides/breaking.rst index 33093f83..36e1f3d8 100644 --- a/docs/guides/breaking.rst +++ b/docs/guides/breaking.rst @@ -1,6 +1,14 @@ Breaking Changes ---------------- +Version 6.1.18 onwards +~~~~~~~~~~~~~~~~~~~~~~~ +- I now support face detection using TPU (NOT recognition). See objectconfig.ini for an example +- You can now add descriptive names for each model sequence to better differentiate in logs +- Each model sequence now has an ``enabled`` flag (default is ``yes``). If ``no`` that means the model won't be loaded. This is a good way + to temporarily remove models while keeping config files intact +- We now also have a ``same_model_strategy`` value of ``union`` - when set to ``union`` it will combine detection from all models for that type + Version 6.1.17 onwards ~~~~~~~~~~~~~~~~~~~~~~~ - You can now localize ``past_det_max_diff_area``, ``max_detection_size`` to specific objects diff --git a/hook/objectconfig.ini b/hook/objectconfig.ini index b8a7d400..20c10b8c 100644 --- a/hook/objectconfig.ini +++ b/hook/objectconfig.ini @@ -411,6 +411,8 @@ ml_sequence= { }, 'sequence': [{ #First run on TPU with higher confidence + 'name': 'TPU object detection', + 'enabled': 'no', 'object_weights':'{{tpu_object_weights_mobiledet}}', 'object_labels': '{{tpu_object_labels}}', 'object_min_confidence': {{tpu_min_confidence}}, @@ -423,6 +425,8 @@ ml_sequence= { }, { # YoloV4 on GPU if TPU fails (because sequence strategy is 'first') + 'name': 'YoloV4 GPU/CPU', + 'enabled': 'yes', # don't really need to say this explictly 'object_config':'{{yolo4_object_config}}', 'object_weights':'{{yolo4_object_weights}}', 'object_labels': '{{yolo4_object_labels}}', @@ -440,9 +444,11 @@ ml_sequence= { 'face': { 'general':{ 'pattern': '{{face_detection_pattern}}', - 'same_model_sequence_strategy': 'first' + 'same_model_sequence_strategy': 'union' }, 'sequence': [{ + 'name': 'DLIB based face recognition', + 'enabled': 'yes', 'save_unknown_faces':'{{save_unknown_faces}}', 'save_unknown_faces_leeway_pixels':{{save_unknown_faces_leeway_pixels}}, 'face_detection_framework': '{{face_detection_framework}}', @@ -458,7 +464,15 @@ ml_sequence= { 'cpu_max_processes': {{cpu_max_processes}}, 'cpu_max_lock_wait': {{cpu_max_lock_wait}}, 'max_size':800 - }] + }, + { + 'name': 'TPU face detection', + 'enabled': 'no', + 'face_detection_framework': 'tpu', + 'face_weights':'/var/lib/zmeventnotification/models/coral_edgetpu/ssd_mobilenet_v2_face_quant_postprocess_edgetpu.tflite', + 'face_min_confidence': 0.3, + + }] }, 'alpr': { @@ -469,6 +483,8 @@ ml_sequence= { }, 'sequence': [{ + 'name': 'Platerecognizer cloud', + 'enabled': 'yes', 'alpr_api_type': '{{alpr_api_type}}', 'alpr_service': '{{alpr_service}}', 'alpr_key': '{{alpr_key}}', diff --git a/hook/setup.py b/hook/setup.py index 248122d1..b9645080 100644 --- a/hook/setup.py +++ b/hook/setup.py @@ -16,7 +16,7 @@ LICENSE = 'GPL' INSTALL_REQUIRES = [ 'numpy', 'requests', 'Shapely', 'imutils', - 'pyzm>=0.3.41', 'scikit-learn', 'future', 'imageio', + 'pyzm>=0.3.42', 'scikit-learn', 'future', 'imageio', 'imageio-ffmpeg','pygifsicle', 'Pillow' ] diff --git a/install.sh b/install.sh index ea214e29..b46136f4 100755 --- a/install.sh +++ b/install.sh @@ -229,10 +229,12 @@ install_hook() { echo 'Checking for Google Coral Edge TPU data files...' - targets=( 'coco_indexed.names' 'ssd_mobilenet_v2_coco_quant_postprocess_edgetpu.tflite' 'ssdlite_mobiledet_coco_qat_postprocess_edgetpu.tflite') + targets=( 'coco_indexed.names' 'ssd_mobilenet_v2_coco_quant_postprocess_edgetpu.tflite' 'ssdlite_mobiledet_coco_qat_postprocess_edgetpu.tflite' 'ssd_mobilenet_v2_face_quant_postprocess_edgetpu.tflite') sources=('https://dl.google.com/coral/canned_models/coco_labels.txt' 'https://github.com/google-coral/edgetpu/raw/master/test_data/ssd_mobilenet_v2_coco_quant_postprocess_edgetpu.tflite' 'https://github.com/google-coral/test_data/raw/master/ssdlite_mobiledet_coco_qat_postprocess_edgetpu.tflite' + 'https://github.com/google-coral/test_data/raw/master/ssd_mobilenet_v2_face_quant_postprocess_edgetpu.tflite' + ) for ((i=0;i<${#targets[@]};++i))