Re: zmevennotification object detection on edge tpu
Posted: Tue Jun 22, 2021 5:56 am
@asker
Good day, followed your advise and took a stab at creating an mlapi docker and looks like it's working correctly. Maybe you can take a look at it and offer some feedback https://github.com/juan11perez/mlapi
I'm not a programmer at all; I've put this together by copying parts here and there from associated work as well as a few days of trial an error, so I'm sure it can be better.
I connected to zm run it and got these logs, confirming it's loading the tpu.
It is indeed much better than running within zmevent server, but I still notice a very rapid momentary spike.
I think the face recognition element is pushing the spike.
I didnt build the image with cuda as Im just trying this out and it all takes ages......
Would running a gpu for the face recognition part help. i.e. does it help with dlib?
Thank you
Ok: installed opencv with cuda and no change. Is there a specific gpu install for face recognition?
more testing........
It's confirmed, the face recognition task is responsible for the entire spike.
If I turn it off with
mlapi hardly moves the cpu at all whilst object detecting.
Good day, followed your advise and took a stab at creating an mlapi docker and looks like it's working correctly. Maybe you can take a look at it and offer some feedback https://github.com/juan11perez/mlapi
I'm not a programmer at all; I've put this together by copying parts here and there from associated work as well as a few days of trial an error, so I'm sure it can be better.
I connected to zm run it and got these logs, confirming it's loading the tpu.
Code: Select all
root@UNRAID:/var/lib/zmeventnotification# python3 ./mlapi.py -c mlapiconfig.ini
Jun 22 2021 05:41:58.190776 [INF] Reading config from: mlapiconfig.ini
Jun 22 2021 05:41:58.190794 [INF] Reading secrets from: /etc/zm/secrets.ini
Jun 22 2021 05:41:58.191020 [DBG 1] Secret token found in config: !ZM_PORTAL
Jun 22 2021 05:41:58.191042 [DBG 1] Secret token found in config: !ZM_USER
Jun 22 2021 05:41:58.191055 [DBG 1] Secret token found in config: !ZM_PASSWORD
Jun 22 2021 05:41:58.191067 [DBG 1] Secret token found in config: !ZM_API_PORTAL
Jun 22 2021 05:41:58.191111 [DBG 1] Secret token found in config: !MLAPI_SECRET_KEY
Jun 22 2021 05:41:58.191236 [DBG 1] Secret token found in config: !PLATEREC_ALPR_KEY
Jun 22 2021 05:41:58.191266 [DBG 2] Found monitor specific section for monitor: 9998
Jun 22 2021 05:41:58.191299 [DBG 2] model_sequence is not a polygon, adding it as unknown string key
Jun 22 2021 05:41:58.191311 [DBG 2] [monitor-9998] overrides key:object_detection_pattern with value:(person|monitor_doorbell)
Jun 22 2021 05:41:58.191327 [DBG 2] adding polygon: valid_face_area [184,235 1475,307 1523,1940 146,1940]
Jun 22 2021 05:41:58.191339 [DBG 2] match_past_detections is not a polygon, adding it as unknown string key
Jun 22 2021 05:41:58.191347 [DBG 2] Found monitor specific section for monitor: 9999
Jun 22 2021 05:41:58.191405 [DBG 2] [monitor-9999] overrides key:object_detection_pattern with value:(person|monitor_deck)
Jun 22 2021 05:41:58.191418 [DBG 2] [monitor-9999] overrides key:stream_sequence with value:{
'frame_strategy': 'most_models',
'frame_set': 'alarm',
'contig_frames_before_error': 5,
'max_attempts': 3,
'sleep_between_attempts': 4,
'resize':800
}
Jun 22 2021 05:41:58.191449 [DBG 2] Doing parameter substitution for globals
Jun 22 2021 05:41:58.191753 [DBG 2] Doing parameter substitution for monitor specific entities
Jun 22 2021 05:41:58.193607 [DBG 1] Opening DB at /config/db/db.json
Jun 22 2021 05:41:58.193712 [DBG 1] DB engine ready
Jun 22 2021 05:41:58.196439 [DBG 2] API SSL certificate check has been disbled
Jun 22 2021 05:41:58.196492 [DBG 1] using username/password for login
Jun 22 2021 05:41:59.292542 [DBG 2] Using new token API
Jun 22 2021 05:41:59.292592 [DBG 1] Access token expires on:2021-06-22 07:41:59.292583 [7200s]
Jun 22 2021 05:41:59.292603 [DBG 1] Refresh token expires on:2021-06-23 05:41:59.292599 [86400s]
Jun 22 2021 05:41:59.292633 [DBG 3] No need to relogin as access token still has 119.99999931666666 minutes remaining
Jun 22 2021 05:41:59.292647 [DBG 3] make_request called with url=https://myzm/zm/api/zones.json payload={} type=get query={'token': 'token'}
Jun 22 2021 05:41:59.625544 [DBG 1] Not importing zone:All for monitor:1 as the global setting says no and there is no local override
Jun 22 2021 05:41:59.625584 [DBG 1] Not importing zone:All for monitor:2 as the global setting says no and there is no local override
Jun 22 2021 05:41:59.625592 [DBG 1] Not importing zone:All for monitor:3 as the global setting says no and there is no local override
Jun 22 2021 05:41:59.625598 [DBG 1] Not importing zone:All for monitor:4 as the global setting says no and there is no local override
Jun 22 2021 05:41:59.625604 [DBG 1] Not importing zone:All for monitor:5 as the global setting says no and there is no local override
Jun 22 2021 05:41:59.625609 [DBG 1] Not importing zone:All for monitor:6 as the global setting says no and there is no local override
Jun 22 2021 05:41:59.625620 [DBG 2] using ml_sequence
Jun 22 2021 05:41:59.646659 [DBG 1] Resetting models, will be loaded on next run
Jun 22 2021 05:41:59.646723 [INF] --------| mlapi version:2.2.20, pyzm version:0.3.50 |--------
Jun 22 2021 05:41:59.646733 [INF] Using bjoern as WSGI server
Jun 22 2021 05:42:12.177665 [DBG 1] Monitor ID not specified, or not found in mlapi config, using zm_detect overrides
Jun 22 2021 05:42:12.177703 [DBG 2] using ml_sequence
Jun 22 2021 05:42:12.178443 [DBG 2] Found stream_sequence in mlapi config, ignoring objectconfig.ini
Jun 22 2021 05:42:12.178492 [DBG 1] Object Recognition requested
Jun 22 2021 05:42:12.178502 [DBG 1] Calling detect streams
Jun 22 2021 05:42:12.178519 [DBG 3] Using automatic locking as we are switching between models
Jun 22 2021 05:42:12.178655 [DBG 2] Media get SSL certificate check has been disbled
Jun 22 2021 05:42:12.178699 [DBG 2] Using URL 15258 for stream
Jun 22 2021 05:42:12.178713 [DBG 2] We will only process frames: ['snapshot', 'alarm']
Jun 22 2021 05:42:12.178722 [DBG 2] No need to start streams, we are picking images from https://myzm/zm/index.php?view=image&eid=15258
Jun 22 2021 05:42:12.178742 [DBG 3] Reading https://myzm/zm/index.php?view=image&eid=15258&fid=snapshot
Jun 22 2021 05:42:12.178765 [DBG 3] No need to relogin as access token still has 119.78523048333334 minutes remaining
Jun 22 2021 05:42:12.178782 [DBG 3] make_request called with url=https://myzm/zm/index.php?view=image&eid=15258&fid=snapshot payload={} type=get query={'token': 'token'}
Jun 22 2021 05:42:13.517691 [DBG 1] perf: Starting for frame:snapshot
Jun 22 2021 05:42:13.517748 [DBG 1] Sequence of detection types to execute: ['object', 'face', 'alpr']
Jun 22 2021 05:42:13.517761 [DBG 1] ============ Frame: snapshot Running object detection type in sequence ==================
Jun 22 2021 05:42:13.518087 [DBG 2] Loading sequence: TPU object detection
Jun 22 2021 05:42:13.518114 [DBG 2] Initializing model type:object with options:{'name': 'TPU object detection', 'enabled': 'yes', 'object_weights': '/var/lib/zmeventnotification/models/coral_edgetpu/ssdlite_mobiledet_coco_qat_postprocess_edgetpu.tflite', 'object_labels': '/var/lib/zmeventnotification/models/coral_edgetpu/coco_indexed.names', 'object_min_confidence': 0.6, 'object_framework': 'coral_edgetpu', 'tpu_max_processes': 1, 'tpu_max_lock_wait': 120, 'max_detection_size': '90%', 'show_models': 'no', 'disable_locks': 'no'}
Jun 22 2021 05:42:13.533870 [DBG 2] portalock: max:1, name:pyzm_uid0_tpu_lock, timeout:120
Jun 22 2021 05:42:13.534108 [DBG 2] Skipping CPU/GPU Yolov4 Object Detection as it is disabled
Jun 22 2021 05:42:13.534125 [DBG 3] object has a same_model_sequence strategy of most_unique
Jun 22 2021 05:42:13.534135 [DBG 3] --------- Frame:snapshot Running variation: #1 -------------
Jun 22 2021 05:42:13.535916 [DBG 2] Waiting for pyzm_uid0_tpu_lock portalock...
Jun 22 2021 05:42:13.536061 [DBG 2] Got pyzm_uid0_tpu_lock portalock
Jun 22 2021 05:42:13.536089 [DBG 1] |--------- Loading "TPU object detection" model from disk -------------|
Jun 22 2021 05:42:13.550617 [DBG 1] perf: processor:tpu TPU initialization (loading /var/lib/zmeventnotification/models/coral_edgetpu/ssdlite_mobiledet_coco_qat_postprocess_edgetpu.tflite from disk) took: 14.47 ms
Jun 22 2021 05:42:13.550694 [DBG 1] |---------- TPU (input image: 800w*450h) ----------|
Jun 22 2021 05:42:13.574776 [DBG 2] Released portalock pyzm_uid0_tpu_lock
Jun 22 2021 05:42:13.574821 [DBG 1] perf: processor:tpu Coral TPU detection took: 24.03 ms
Jun 22 2021 05:42:13.574856 [DBG 3] Coral object returning: [[169, 1, 543, 455]],['person'],[0.76953125]
Jun 22 2021 05:42:13.574886 [DBG 2] core model detection over, got 1 objects. Now filtering
Jun 22 2021 05:42:13.574907 [DBG 2] Max object size found to be: 90%
Jun 22 2021 05:42:13.575170 [DBG 2] Converted 90% to 324000.0
Jun 22 2021 05:42:13.575200 [DBG 2] Returning filtered list of 1 objects.
Jun 22 2021 05:42:13.575220 [DBG 2] This model iteration inside object found: labels: ['person'],conf:[0.76953125]
Jun 22 2021 05:42:13.575243 [DBG 2] Max object size found to be: 90%
Jun 22 2021 05:42:13.575261 [DBG 2] Converted 90% to 324000.0
Jun 22 2021 05:42:13.575283 [DBG 2] No polygons, adding full image polygon: {'name': 'full_image', 'value': [(0, 0), (1920, 0), (1920, 1080), (0, 1080)], 'pattern': None}
Jun 22 2021 05:42:13.575310 [DBG 3] resized polygons x=0.4166666666666667/y=0.4166666666666667: [{'name': 'full_image', 'value': [(0, 0), (800, 0), (800, 450), (0, 450)], 'pattern': None}]
Jun 22 2021 05:42:13.575561 [DBG 2] intersection: comparing object:person,POLYGON ((169 1, 543 1, 543 455, 169 455, 169 1)) to polygon:full_image,POLYGON ((0 0, 800 0, 800 450, 0 450, 0 0))
Jun 22 2021 05:42:13.575602 [DBG 2] Match pattern overridden to (person|car|motorbike|bus|truck|boat) in ml_overrides
Jun 22 2021 05:42:13.575722 [DBG 2] full_image intersects object:person[[(169, 1), (543, 1), (543, 455), (169, 455)]]
Jun 22 2021 05:42:13.575751 [DBG 1] ============ Frame: snapshot Running face detection type in sequence ==================
Jun 22 2021 05:42:13.576125 [DBG 1] Initializing face detection
Jun 22 2021 05:42:13.576145 [DBG 2] portalock: max:1, name:pyzm_uid0_tpu_lock, timeout:120
Jun 22 2021 05:42:14.646178 [DBG 1] perf: processor:cpu Face Recognition library load time took: 0.00 ms
Jun 22 2021 05:42:14.646233 [DBG 1] Initializing face recognition with model:cnn upsample:1, jitters:0
Jun 22 2021 05:42:14.646250 [DBG 2] portalock: max:3, name:pyzm_uid0_cpu_lock, timeout:120
Jun 22 2021 05:42:14.646322 [DBG 1] pre-trained faces found, using that. If you want to add new images, remove: /var/lib/zmeventnotification/known_faces/faces.dat
Jun 22 2021 05:42:14.646908 [DBG 3] face has a same_model_sequence strategy of union
Jun 22 2021 05:42:14.646928 [DBG 3] --------- Frame:snapshot Running variation: #1 -------------
Jun 22 2021 05:42:14.648469 [DBG 2] Waiting for pyzm_uid0_tpu_lock portalock...
Jun 22 2021 05:42:14.648593 [DBG 2] Got pyzm_uid0_tpu_lock lock...
Jun 22 2021 05:42:14.648609 [DBG 1] |--------- Loading "Face Detection (TPU)" model from disk -------------|
Jun 22 2021 05:42:14.652901 [DBG 1] perf: processor:tpu TPU initialization (loading /var/lib/zmeventnotification/models/coral_edgetpu/ssd_mobilenet_v2_face_quant_postprocess_edgetpu.tflite from disk) took: 4.26 ms
Jun 22 2021 05:42:14.652959 [DBG 1] |---------- TPU (input image: 800w*450h) ----------|
Jun 22 2021 05:42:14.677476 [DBG 1] Released pyzm_uid0_tpu_lock portalock
Jun 22 2021 05:42:14.677496 [DBG 1] perf: processor:tpu Coral TPU detection took: 24.47 ms
Jun 22 2021 05:42:14.677509 [DBG 2] Coral face is detection only. Skipping recognition phase
Jun 22 2021 05:42:14.677526 [DBG 2] Coral face returning: [[183, 0, 463, 251]],['face'],[0.99609375]
Jun 22 2021 05:42:14.677543 [DBG 2] This model iteration inside face found: labels: ['face'],conf:[0.99609375]
Jun 22 2021 05:42:14.677557 [DBG 2] Max object size found to be: 90%
Jun 22 2021 05:42:14.677584 [DBG 2] Converted 90% to 324000.0
Jun 22 2021 05:42:14.677765 [DBG 2] intersection: comparing object:face,POLYGON ((183 0, 463 0, 463 251, 183 251, 183 0)) to polygon:full_image,POLYGON ((0 0, 800 0, 800 450, 0 450, 0 0))
Jun 22 2021 05:42:14.677795 [DBG 2] Match pattern overridden to .* in ml_overrides
Jun 22 2021 05:42:14.677813 [DBG 2] full_image intersects object:face[[(183, 0), (463, 0), (463, 251), (183, 251)]]
Jun 22 2021 05:42:14.677835 [DBG 3] --------- Frame:snapshot Running variation: #2 -------------
Jun 22 2021 05:42:14.677848 [DBG 2] Making sure we have matched one of ['face'] in ['face'] before we proceed
Jun 22 2021 05:42:14.677870 [DBG 1] |---------- Dlib Face recognition (input image: 800w*450h) ----------|
Jun 22 2021 05:42:14.677888 [DBG 3] Face options={'name': 'Face Recognition (Dlib)', 'enabled': 'yes', 'pre_existing_labels': ['face'], 'save_unknown_faces': 'yes', 'save_unknown_faces_leeway_pixels': 50, 'face_detection_framework': 'dlib', 'known_images_path': '/var/lib/zmeventnotification/known_faces', 'unknown_images_path': '/var/lib/zmeventnotification/unknown_faces', 'face_model': 'cnn', 'face_train_model': 'cnn', 'face_recog_dist_threshold': 0.6, 'face_num_jitters': 0, 'face_upsample_times': 1, 'gpu_max_processes': 1, 'gpu_max_lock_wait': 120, 'cpu_max_processes': 3, 'cpu_max_lock_wait': 120, 'max_size': 800, 'disable_locks': 'no'}
Jun 22 2021 05:42:14.677902 [DBG 2] Waiting for pyzm_uid0_cpu_lock portalock...
Jun 22 2021 05:42:14.678015 [DBG 2] Got pyzm_uid0_cpu_lock lock...
Jun 22 2021 05:42:16.907750 [DBG 1] perf: processor:cpu Finding faces took 2229.70 ms
Jun 22 2021 05:42:16.964937 [DBG 1] Released pyzm_uid0_cpu_lock portalock
Jun 22 2021 05:42:16.965007 [DBG 1] perf: processor:cpu Computing face recognition distances took 57.18 ms
Jun 22 2021 05:42:16.965020 [DBG 3] Comparing to known faces...
Jun 22 2021 05:42:16.967683 [DBG 3] Closest knn match indexes (lesser is better): (array([[0.58467917]]), array([[16]]))
Jun 22 2021 05:42:16.968716 [DBG 1] perf: processor:cpu Matching recognized faces to known faces took 3.68 ms
Jun 22 2021 05:42:16.968749 [DBG 2] Face Dlib:Returning: [[202, 0, 406, 189]], ['Juan'], [1]
Jun 22 2021 05:42:16.968767 [DBG 2] This model iteration inside face found: labels: ['Juan'],conf:[1]
Jun 22 2021 05:42:16.968796 [DBG 2] Max object size found to be: 90%
Jun 22 2021 05:42:16.968823 [DBG 2] Converted 90% to 324000.0
Jun 22 2021 05:42:16.969247 [DBG 2] intersection: comparing object:Juan,POLYGON ((202 0, 406 0, 406 189, 202 189, 202 0)) to polygon:full_image,POLYGON ((0 0, 800 0, 800 450, 0 450, 0 0))
Jun 22 2021 05:42:16.969375 [DBG 2] Match pattern overridden to .* in ml_overrides
Jun 22 2021 05:42:16.969593 [DBG 2] full_image intersects object:Juan[[(202, 0), (406, 0), (406, 189), (202, 189)]]
Jun 22 2021 05:42:16.970010 [DBG 1] ============ Frame: snapshot Running alpr detection type in sequence ==================
Jun 22 2021 05:42:16.970034 [DBG 2] Making sure we have matched one of ['car', 'motorbike', 'bus', 'truck', 'boat'] in ['person', 'face', 'Juan'] before we proceed
Jun 22 2021 05:42:16.970048 [DBG 1] Did not find pre existing labels, not running detection type
Jun 22 2021 05:42:16.970217 [DBG 3] Reading https://myzm/zm/index.php?view=image&eid=15258&fid=alarm
Jun 22 2021 05:42:16.970300 [DBG 3] No need to relogin as access token still has 119.70537231666667 minutes remaining
Jun 22 2021 05:42:16.970338 [DBG 3] make_request called with url=https://myzm/zm/index.php?view=image&eid=15258&fid=alarm payload={} type=get query={'token': 'token'}
Jun 22 2021 05:42:17.941947 [DBG 1] perf: Starting for frame:alarm
Jun 22 2021 05:42:17.942013 [DBG 1] Sequence of detection types to execute: ['object', 'face', 'alpr']
Jun 22 2021 05:42:17.942026 [DBG 1] ============ Frame: alarm Running object detection type in sequence ==================
Jun 22 2021 05:42:17.942039 [DBG 3] object has a same_model_sequence strategy of most_unique
Jun 22 2021 05:42:17.942050 [DBG 3] --------- Frame:alarm Running variation: #1 -------------
Jun 22 2021 05:42:17.942687 [DBG 2] Waiting for pyzm_uid0_tpu_lock portalock...
Jun 22 2021 05:42:17.942849 [DBG 2] Got pyzm_uid0_tpu_lock portalock
Jun 22 2021 05:42:17.942869 [DBG 1] |---------- TPU (input image: 800w*450h) ----------|
Jun 22 2021 05:42:17.964806 [DBG 2] Released portalock pyzm_uid0_tpu_lock
Jun 22 2021 05:42:17.964828 [DBG 1] perf: processor:tpu Coral TPU detection took: 21.89 ms
Jun 22 2021 05:42:17.964839 [DBG 3] Coral object returning: [],[],[]
Jun 22 2021 05:42:17.964852 [DBG 2] core model detection over, got 0 objects. Now filtering
Jun 22 2021 05:42:17.964871 [DBG 2] Max object size found to be: 90%
Jun 22 2021 05:42:17.964897 [DBG 2] Converted 90% to 324000.0
Jun 22 2021 05:42:17.964906 [DBG 2] Returning filtered list of 0 objects.
Jun 22 2021 05:42:17.964915 [DBG 2] This model iteration inside object found: labels: [],conf:[]
Jun 22 2021 05:42:17.964927 [DBG 2] Max object size found to be: 90%
Jun 22 2021 05:42:17.964937 [DBG 2] Converted 90% to 324000.0
Jun 22 2021 05:42:17.964946 [DBG 2] We did not find any object matches in frame: alarm
Jun 22 2021 05:42:17.964953 [DBG 1] ============ Frame: alarm Running face detection type in sequence ==================
Jun 22 2021 05:42:17.964961 [DBG 3] face has a same_model_sequence strategy of union
Jun 22 2021 05:42:17.964970 [DBG 3] --------- Frame:alarm Running variation: #1 -------------
Jun 22 2021 05:42:17.965524 [DBG 2] Waiting for pyzm_uid0_tpu_lock portalock...
Jun 22 2021 05:42:17.965628 [DBG 2] Got pyzm_uid0_tpu_lock lock...
Jun 22 2021 05:42:17.965642 [DBG 1] |---------- TPU (input image: 800w*450h) ----------|
Jun 22 2021 05:42:17.989082 [DBG 1] Released pyzm_uid0_tpu_lock portalock
Jun 22 2021 05:42:17.989118 [DBG 1] perf: processor:tpu Coral TPU detection took: 23.39 ms
Jun 22 2021 05:42:17.989128 [DBG 2] Coral face is detection only. Skipping recognition phase
Jun 22 2021 05:42:17.989136 [DBG 2] Coral face returning: [],[],[]
Jun 22 2021 05:42:17.989148 [DBG 2] This model iteration inside face found: labels: [],conf:[]
Jun 22 2021 05:42:17.989160 [DBG 2] Max object size found to be: 90%
Jun 22 2021 05:42:17.989185 [DBG 2] Converted 90% to 324000.0
Jun 22 2021 05:42:17.989197 [DBG 3] --------- Frame:alarm Running variation: #2 -------------
Jun 22 2021 05:42:17.989210 [DBG 2] Making sure we have matched one of ['face'] in [] before we proceed
Jun 22 2021 05:42:17.989219 [DBG 1] Did not find pre existing labels, not running sequence in model
Jun 22 2021 05:42:17.989226 [DBG 2] We did not find any face matches in frame: alarm
Jun 22 2021 05:42:17.989238 [DBG 1] ============ Frame: alarm Running alpr detection type in sequence ==================
Jun 22 2021 05:42:17.989246 [DBG 2] Making sure we have matched one of ['car', 'motorbike', 'bus', 'truck', 'boat'] in [] before we proceed
Jun 22 2021 05:42:17.989254 [DBG 1] Did not find pre existing labels, not running detection type
Jun 22 2021 05:42:17.989269 [DBG 1] perf: TOTAL detection sequence (with image loads) took: 5810.73 ms to process 15258
Jun 22 2021 05:42:17.989315 [DBG 1] Returning {'matched_data': {'boxes': [[169, 1, 543, 455], [183, 0, 463, 251], [202, 0, 406, 189]], 'error_boxes': [], 'labels': ['person', 'face', 'Juan'], 'confidences': [0.76953125, 0.99609375, 1], 'frame_id': 'snapshot', 'model_names': ['coral', 'face_tpu', 'face_dlib'], 'image_dimensions': {'original': (1080, 1920), 'resized': (450, 800)}, 'image': None, 'polygons': [{'name': 'full_image', 'value': [(0, 0), (800, 0), (800, 450), (0, 450)], 'pattern': None}]}, 'all_matches': [{'frame_id': 'snapshot', 'boxes': [[169, 1, 543, 455], [183, 0, 463, 251], [202, 0, 406, 189]], 'error_boxes': [], 'labels': ['person', 'face', 'Juan'], 'confidences': [0.76953125, 0.99609375, 1], 'detection_types': ['object', 'face', 'face'], 'model_names': ['coral', 'face_tpu', 'face_dlib']}]}
Jun 22 2021 05:42:24.234572 [DBG 1] Monitor ID not specified, or not found in mlapi config, using zm_detect overrides
Jun 22 2021 05:42:24.234602 [DBG 2] using ml_sequence
Jun 22 2021 05:42:24.235223 [DBG 2] Found stream_sequence in mlapi config, ignoring objectconfig.ini
Jun 22 2021 05:42:24.235262 [DBG 1] Object Recognition requested
Jun 22 2021 05:42:24.235272 [DBG 1] Calling detect streams
Jun 22 2021 05:42:24.235287 [DBG 3] Using automatic locking as we are switching between models
Jun 22 2021 05:42:24.235373 [DBG 2] Media get SSL certificate check has been disbled
Jun 22 2021 05:42:24.235405 [DBG 2] Using URL 15259 for stream
Jun 22 2021 05:42:24.235419 [DBG 2] We will only process frames: ['snapshot', 'alarm']
Jun 22 2021 05:42:24.235426 [DBG 2] No need to start streams, we are picking images from https://myzm/zm/index.php?view=image&eid=15259
Jun 22 2021 05:42:24.235447 [DBG 3] Reading https://myzm/zm/index.php?view=image&eid=15259&fid=snapshot
Jun 22 2021 05:42:24.235466 [DBG 3] No need to relogin as access token still has 119.58428545 minutes remaining
Jun 22 2021 05:42:24.235479 [DBG 3] make_request called with url=https://myzm/zm/index.php?view=image&eid=15259&fid=snapshot payload={} type=get query={'token': 'token'}
Jun 22 2021 05:42:25.172912 [DBG 1] perf: Starting for frame:snapshot
Jun 22 2021 05:42:25.172973 [DBG 1] Sequence of detection types to execute: ['object', 'face', 'alpr']
Jun 22 2021 05:42:25.172986 [DBG 1] ============ Frame: snapshot Running object detection type in sequence ==================
Jun 22 2021 05:42:25.172998 [DBG 3] object has a same_model_sequence strategy of most_unique
Jun 22 2021 05:42:25.173008 [DBG 3] --------- Frame:snapshot Running variation: #1 -------------
Jun 22 2021 05:42:25.173640 [DBG 2] Waiting for pyzm_uid0_tpu_lock portalock...
Jun 22 2021 05:42:25.173794 [DBG 2] Got pyzm_uid0_tpu_lock portalock
Jun 22 2021 05:42:25.173809 [DBG 1] |---------- TPU (input image: 800w*450h) ----------|
Jun 22 2021 05:42:25.195898 [DBG 2] Released portalock pyzm_uid0_tpu_lock
Jun 22 2021 05:42:25.195946 [DBG 1] perf: processor:tpu Coral TPU detection took: 22.01 ms
Jun 22 2021 05:42:25.195958 [DBG 3] Coral object returning: [],[],[]
Jun 22 2021 05:42:25.195971 [DBG 2] core model detection over, got 0 objects. Now filtering
Jun 22 2021 05:42:25.195978 [DBG 2] Max object size found to be: 90%
Jun 22 2021 05:42:25.196002 [DBG 2] Converted 90% to 324000.0
Jun 22 2021 05:42:25.196011 [DBG 2] Returning filtered list of 0 objects.
Jun 22 2021 05:42:25.196019 [DBG 2] This model iteration inside object found: labels: [],conf:[]
Jun 22 2021 05:42:25.196030 [DBG 2] Max object size found to be: 90%
Jun 22 2021 05:42:25.196040 [DBG 2] Converted 90% to 324000.0
Jun 22 2021 05:42:25.196055 [DBG 2] No polygons, adding full image polygon: {'name': 'full_image', 'value': [(0, 0), (1920, 0), (1920, 1080), (0, 1080)], 'pattern': None}
Jun 22 2021 05:42:25.196075 [DBG 3] resized polygons x=0.4166666666666667/y=0.4166666666666667: [{'name': 'full_image', 'value': [(0, 0), (800, 0), (800, 450), (0, 450)], 'pattern': None}]
Jun 22 2021 05:42:25.196088 [DBG 2] We did not find any object matches in frame: snapshot
Jun 22 2021 05:42:25.196097 [DBG 1] ============ Frame: snapshot Running face detection type in sequence ==================
Jun 22 2021 05:42:25.196106 [DBG 3] face has a same_model_sequence strategy of union
Jun 22 2021 05:42:25.196114 [DBG 3] --------- Frame:snapshot Running variation: #1 -------------
Jun 22 2021 05:42:25.196795 [DBG 2] Waiting for pyzm_uid0_tpu_lock portalock...
Jun 22 2021 05:42:25.196939 [DBG 2] Got pyzm_uid0_tpu_lock lock...
Jun 22 2021 05:42:25.196953 [DBG 1] |---------- TPU (input image: 800w*450h) ----------|
Jun 22 2021 05:42:25.220181 [DBG 1] Released pyzm_uid0_tpu_lock portalock
Jun 22 2021 05:42:25.220200 [DBG 1] perf: processor:tpu Coral TPU detection took: 23.20 ms
Jun 22 2021 05:42:25.220207 [DBG 2] Coral face is detection only. Skipping recognition phase
Jun 22 2021 05:42:25.220214 [DBG 2] Coral face returning: [],[],[]
Jun 22 2021 05:42:25.220224 [DBG 2] This model iteration inside face found: labels: [],conf:[]
Jun 22 2021 05:42:25.220233 [DBG 2] Max object size found to be: 90%
Jun 22 2021 05:42:25.220251 [DBG 2] Converted 90% to 324000.0
Jun 22 2021 05:42:25.220261 [DBG 3] --------- Frame:snapshot Running variation: #2 -------------
Jun 22 2021 05:42:25.220273 [DBG 2] Making sure we have matched one of ['face'] in [] before we proceed
Jun 22 2021 05:42:25.220282 [DBG 1] Did not find pre existing labels, not running sequence in model
Jun 22 2021 05:42:25.220290 [DBG 2] We did not find any face matches in frame: snapshot
Jun 22 2021 05:42:25.220298 [DBG 1] ============ Frame: snapshot Running alpr detection type in sequence ==================
Jun 22 2021 05:42:25.220307 [DBG 2] Making sure we have matched one of ['car', 'motorbike', 'bus', 'truck', 'boat'] in [] before we proceed
Jun 22 2021 05:42:25.220314 [DBG 1] Did not find pre existing labels, not running detection type
Jun 22 2021 05:42:25.220327 [DBG 3] Reading https://myzm/zm/index.php?view=image&eid=15259&fid=alarm
Jun 22 2021 05:42:25.220345 [DBG 3] No need to relogin as access token still has 119.56787071666666 minutes remaining
Jun 22 2021 05:42:25.220365 [DBG 3] make_request called with url=https://myzm/zm/index.php?view=image&eid=15259&fid=alarm payload={} type=get query={'token': 'token'}
Jun 22 2021 05:42:25.790255 [DBG 1] perf: Starting for frame:alarm
Jun 22 2021 05:42:25.790316 [DBG 1] Sequence of detection types to execute: ['object', 'face', 'alpr']
Jun 22 2021 05:42:25.790328 [DBG 1] ============ Frame: alarm Running object detection type in sequence ==================
Jun 22 2021 05:42:25.790338 [DBG 3] object has a same_model_sequence strategy of most_unique
Jun 22 2021 05:42:25.790347 [DBG 3] --------- Frame:alarm Running variation: #1 -------------
Jun 22 2021 05:42:25.790974 [DBG 2] Waiting for pyzm_uid0_tpu_lock portalock...
Jun 22 2021 05:42:25.791121 [DBG 2] Got pyzm_uid0_tpu_lock portalock
Jun 22 2021 05:42:25.791134 [DBG 1] |---------- TPU (input image: 800w*450h) ----------|
Jun 22 2021 05:42:25.812939 [DBG 2] Released portalock pyzm_uid0_tpu_lock
Jun 22 2021 05:42:25.812960 [DBG 1] perf: processor:tpu Coral TPU detection took: 21.77 ms
Jun 22 2021 05:42:25.812978 [DBG 3] Coral object returning: [[300, 144, 656, 452]],['person'],[0.8125]
Jun 22 2021 05:42:25.812991 [DBG 2] core model detection over, got 1 objects. Now filtering
Jun 22 2021 05:42:25.812999 [DBG 2] Max object size found to be: 90%
Jun 22 2021 05:42:25.813022 [DBG 2] Converted 90% to 324000.0
Jun 22 2021 05:42:25.813034 [DBG 2] Returning filtered list of 1 objects.
Jun 22 2021 05:42:25.813044 [DBG 2] This model iteration inside object found: labels: ['person'],conf:[0.8125]
Jun 22 2021 05:42:25.813055 [DBG 2] Max object size found to be: 90%
Jun 22 2021 05:42:25.813065 [DBG 2] Converted 90% to 324000.0
Jun 22 2021 05:42:25.813237 [DBG 2] intersection: comparing object:person,POLYGON ((300 144, 656 144, 656 452, 300 452, 300 144)) to polygon:full_image,POLYGON ((0 0, 800 0, 800 450, 0 450, 0 0))
Jun 22 2021 05:42:25.813265 [DBG 2] Match pattern overridden to (person|car|motorbike|bus|truck|boat) in ml_overrides
Jun 22 2021 05:42:25.813280 [DBG 2] full_image intersects object:person[[(300, 144), (656, 144), (656, 452), (300, 452)]]
Jun 22 2021 05:42:25.813301 [DBG 1] ============ Frame: alarm Running face detection type in sequence ==================
Jun 22 2021 05:42:25.813310 [DBG 3] face has a same_model_sequence strategy of union
Jun 22 2021 05:42:25.813317 [DBG 3] --------- Frame:alarm Running variation: #1 -------------
Jun 22 2021 05:42:25.813771 [DBG 2] Waiting for pyzm_uid0_tpu_lock portalock...
Jun 22 2021 05:42:25.813886 [DBG 2] Got pyzm_uid0_tpu_lock lock...
Jun 22 2021 05:42:25.813900 [DBG 1] |---------- TPU (input image: 800w*450h) ----------|
Jun 22 2021 05:42:25.837289 [DBG 1] Released pyzm_uid0_tpu_lock portalock
Jun 22 2021 05:42:25.837340 [DBG 1] perf: processor:tpu Coral TPU detection took: 23.32 ms
Jun 22 2021 05:42:25.837354 [DBG 2] Coral face is detection only. Skipping recognition phase
Jun 22 2021 05:42:25.837368 [DBG 2] Coral face returning: [[372, 141, 550, 349]],['face'],[0.9921875]
Jun 22 2021 05:42:25.837385 [DBG 2] This model iteration inside face found: labels: ['face'],conf:[0.9921875]
Jun 22 2021 05:42:25.837397 [DBG 2] Max object size found to be: 90%
Jun 22 2021 05:42:25.837423 [DBG 2] Converted 90% to 324000.0
Jun 22 2021 05:42:25.837601 [DBG 2] intersection: comparing object:face,POLYGON ((372 141, 550 141, 550 349, 372 349, 372 141)) to polygon:full_image,POLYGON ((0 0, 800 0, 800 450, 0 450, 0 0))
Jun 22 2021 05:42:25.837631 [DBG 2] Match pattern overridden to .* in ml_overrides
Jun 22 2021 05:42:25.837647 [DBG 2] full_image intersects object:face[[(372, 141), (550, 141), (550, 349), (372, 349)]]
Jun 22 2021 05:42:25.837667 [DBG 3] --------- Frame:alarm Running variation: #2 -------------
Jun 22 2021 05:42:25.837679 [DBG 2] Making sure we have matched one of ['face'] in ['face'] before we proceed
Jun 22 2021 05:42:25.837692 [DBG 1] |---------- Dlib Face recognition (input image: 800w*450h) ----------|
Jun 22 2021 05:42:25.837708 [DBG 3] Face options={'name': 'Face Recognition (Dlib)', 'enabled': 'yes', 'pre_existing_labels': ['face'], 'save_unknown_faces': 'yes', 'save_unknown_faces_leeway_pixels': 50, 'face_detection_framework': 'dlib', 'known_images_path': '/var/lib/zmeventnotification/known_faces', 'unknown_images_path': '/var/lib/zmeventnotification/unknown_faces', 'face_model': 'cnn', 'face_train_model': 'cnn', 'face_recog_dist_threshold': 0.6, 'face_num_jitters': 0, 'face_upsample_times': 1, 'gpu_max_processes': 1, 'gpu_max_lock_wait': 120, 'cpu_max_processes': 3, 'cpu_max_lock_wait': 120, 'max_size': 800, 'disable_locks': 'no'}
Jun 22 2021 05:42:25.837721 [DBG 2] Waiting for pyzm_uid0_cpu_lock portalock...
Jun 22 2021 05:42:25.837852 [DBG 2] Got pyzm_uid0_cpu_lock lock...
Jun 22 2021 05:42:28.329840 [DBG 1] perf: processor:cpu Finding faces took 2491.94 ms
Jun 22 2021 05:42:28.542914 [DBG 1] Released pyzm_uid0_cpu_lock portalock
Jun 22 2021 05:42:28.542986 [DBG 1] perf: processor:cpu Computing face recognition distances took 213.07 ms
Jun 22 2021 05:42:28.542999 [DBG 3] Comparing to known faces...
Jun 22 2021 05:42:28.543945 [DBG 3] Closest knn match indexes (lesser is better): (array([[0.48731977]]), array([[9]]))
Jun 22 2021 05:42:28.544484 [DBG 1] perf: processor:cpu Matching recognized faces to known faces took 1.47 ms
Jun 22 2021 05:42:28.544518 [DBG 2] Face Dlib:Returning: [[383, 187, 501, 305]], ['Juan'], [1]
Jun 22 2021 05:42:28.544540 [DBG 2] This model iteration inside face found: labels: ['Juan'],conf:[1]
Jun 22 2021 05:42:28.544559 [DBG 2] Max object size found to be: 90%
Jun 22 2021 05:42:28.544589 [DBG 2] Converted 90% to 324000.0
Jun 22 2021 05:42:28.544809 [DBG 2] intersection: comparing object:Juan,POLYGON ((383 187, 501 187, 501 305, 383 305, 383 187)) to polygon:full_image,POLYGON ((0 0, 800 0, 800 450, 0 450, 0 0))
Jun 22 2021 05:42:28.544850 [DBG 2] Match pattern overridden to .* in ml_overrides
Jun 22 2021 05:42:28.544883 [DBG 2] full_image intersects object:Juan[[(383, 187), (501, 187), (501, 305), (383, 305)]]
Jun 22 2021 05:42:28.544917 [DBG 1] ============ Frame: alarm Running alpr detection type in sequence ==================
Jun 22 2021 05:42:28.544935 [DBG 2] Making sure we have matched one of ['car', 'motorbike', 'bus', 'truck', 'boat'] in ['person', 'face', 'Juan'] before we proceed
Jun 22 2021 05:42:28.544950 [DBG 1] Did not find pre existing labels, not running detection type
Jun 22 2021 05:42:28.545130 [DBG 1] perf: TOTAL detection sequence (with image loads) took: 4309.83 ms to process 15259
Jun 22 2021 05:42:28.545191 [DBG 1] Returning {'matched_data': {'boxes': [[300, 144, 656, 452], [372, 141, 550, 349], [383, 187, 501, 305]], 'error_boxes': [], 'labels': ['person', 'face', 'Juan'], 'confidences': [0.8125, 0.9921875, 1], 'frame_id': 'alarm', 'model_names': ['coral', 'face_tpu', 'face_dlib'], 'image_dimensions': {'original': (1080, 1920), 'resized': (450, 800)}, 'image': None, 'polygons': [{'name': 'full_image', 'value': [(0, 0), (800, 0), (800, 450), (0, 450)], 'pattern': None}]}, 'all_matches': [{'frame_id': 'alarm', 'boxes': [[300, 144, 656, 452], [372, 141, 550, 349], [383, 187, 501, 305]], 'error_boxes': [], 'labels': ['person', 'face', 'Juan'], 'confidences': [0.8125, 0.9921875, 1], 'detection_types': ['object', 'face', 'face'], 'model_names': ['coral', 'face_tpu', 'face_dlib']}]}
I think the face recognition element is pushing the spike.
I didnt build the image with cuda as Im just trying this out and it all takes ages......
Would running a gpu for the face recognition part help. i.e. does it help with dlib?
Thank you
Ok: installed opencv with cuda and no change. Is there a specific gpu install for face recognition?
more testing........
It's confirmed, the face recognition task is responsible for the entire spike.
If I turn it off with
Code: Select all
'name':'Face Recognition (Dlib)', # optional
'enabled': 'no'