zmevennotification object detection on edge tpu

Discussion topics related to mobile applications and ZoneMinder Event Server (including machine learning)
juan11perez
Posts: 64
Joined: Tue Apr 27, 2021 3:41 am

Re: zmevennotification object detection on edge tpu

Post by juan11perez »

@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.

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']}]}
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

Code: Select all

				'name':'Face Recognition (Dlib)', # optional
				'enabled': 'no'
mlapi hardly moves the cpu at all whilst object detecting.
VicThor
Posts: 39
Joined: Tue Oct 13, 2020 8:47 pm

Re: zmevennotification object detection on edge tpu

Post by VicThor »

Hey, how did you pull the image?

I am getting :

docker: Error response from daemon: pull access denied for ghcr.io/juan11perez/mlapi, repository does not exist or may require 'docker login': denied: permission_denied: read_package.

I am logged in ghcr.io
juan11perez
Posts: 64
Joined: Tue Apr 27, 2021 3:41 am

Re: zmevennotification object detection on edge tpu

Post by juan11perez »

Good day.
sorry. it was private. I've made it public now
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: zmevennotification object detection on edge tpu

Post by asker »

juan11perez wrote: Tue Jun 22, 2021 5:56 am 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'
mlapi hardly moves the cpu at all whilst object detecting.
Yes, it will help. Your face detection is running on TPU but recognition is on CPU (dlib). Face recognition doesn't use OpenCV, so you'll need Dlib to be re-compiled with GPU support. I made notes here - take a look at the Dlib section
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
juan11perez
Posts: 64
Joined: Tue Apr 27, 2021 3:41 am

Re: zmevennotification object detection on edge tpu

Post by juan11perez »

@asker thank you for your advise. So I finally got it all running satisfactorily!
I'll share my mistakes, hopefully to help others.
As mentioned earlier I'm running zm in docker. Initially it was running on cpu only; I subsequently compiled opencv with cuda and didn't notice any significant improvement.

After a lot of trial and error and googling; I understood my problem. The culprit was indeed dlib due to my lack of knowledge.
When I applied the below setting, the cpu spikes stopped immediately and object recognition started working with the coral and gpu with negligible impact to cpu. Happy.....

Code: Select all

				'name':'Face Recognition (Dlib)', # optional
				'enabled': 'yes',
The problem was that when the event server is first installed, if Cuda is not available dlib setup.py will install dlib without gpu support (as it should).
Adding gpu/cuda later on doesn't fix the problem automatically. You need to uninstall dlib and reinstall as follows:

Code: Select all

pip3 uninstall -y dlib
cd ~/ ; git clone https://github.com/davisking/dlib.git ; cd dlib ; python3 setup.py install
if it finds the cuda libraries in /usr/local/cuda it will compile with gpu support and all is good.

Once I fixed that problem, the docker performed as it should utilising the tpu and gpu with barely any impact to cpu. (5 to 10% as you mentioned)

I then made the same corrections to the mlapi docker I created (compiled opencv with cuda for yolov and reinstalled dlib with gpu support).

Tested inference time using the eventserver in docker directly and mlapi. The difference is significant.
As intimated in the documentation mlapi will be slower the first time as it loads the models; all subsequent runs were 1/5 the initial time in my case.

So face/object detection in the eventsever was around 4.5 seconds consistently. In mlapi after the first run around 0.7 of a second. Six times faster !!

One more thing to keep in mind when using the PCIE based coral TPU. As I mentioned earlier I was getting the dreaded disconnected error. it is important to confirm that /dev/apex_0 is fully accessible with chmod 777 /dev/apex_0.


Thank you for this great component and the support.
VicThor
Posts: 39
Joined: Tue Oct 13, 2020 8:47 pm

Re: zmevennotification object detection on edge tpu

Post by VicThor »

Thank you, seems to be way faster as models are loaded in the memory.
I am seeing a few issues though:
- the match_past_detection does not seem to work as static objects are always detected
- bounding boxes are way off compared to non mlapi detection

Image
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: zmevennotification object detection on edge tpu

Post by asker »

This happens only for snapshots in mlapi. That is because mlapi detects on the frame that is the latest snapshot at that point of time. When the detections finish zmdetect gets the results from mlapi and draws boxes around the frame called snapshot then. In that difference in time snapshot may have moved. See convert_snapshot_to_fid in pyzm. It’s meant for this purpose and goes into stream_sequence.

As far as match past detections go it should work. Remember when you switch, most of the settings need to go into mlapiconfig.ini. See this. If you think everything is configured correctly, please post debug logs.
VicThor wrote: Mon Jun 28, 2021 1:00 am Thank you, seems to be way faster as models are loaded in the memory.
I am seeing a few issues though:
- the match_past_detection does not seem to work as static objects are always detected
- bounding boxes are way off compared to non mlapi detection
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
juan11perez
Posts: 64
Joined: Tue Apr 27, 2021 3:41 am

Re: zmevennotification object detection on edge tpu

Post by juan11perez »

@VicThor I've tidied up the docker and no longer requires a litany to run.
Start, create the user (it's created in the persistent config volume), restart.
VicThor
Posts: 39
Joined: Tue Oct 13, 2020 8:47 pm

Re: zmevennotification object detection on edge tpu

Post by VicThor »

Thanks asker,

That car is absolutely still throughout the recording, does that still apply?

I believe I configure everything correctly, have remote section in objectconfig.ini and the rest in mlapiconfig.ini in the docker container:

mlapiconfig.ini:

[ml]
# if enabled, will not grab exclusive locks before running inferencing
# locking seems to cause issues on some unique file systems
disable_locks = no


use_sequence = yes

stream_sequence = {
'frame_strategy': 'most_models',
'frame_set': 'alarm,snapshot',
'contig_frames_before_error': 5,
'max_attempts': 3,
'sleep_between_attempts': 5
# 'resize':800

}

ml_sequence= {
'general': {
'model_sequence': 'object',
'disable_locks': '{{disable_locks}}',
'disable_locks': '{{disable_locks}}',
'match_past_detections': 'yes',
'past_det_max_diff_area': '15%',
'car_past_det_max_diff_area': '15%',
},
'object': {
'general':{
'pattern':'{{object_detection_pattern}}',
'same_model_sequence_strategy': 'first' # also 'most', 'most_unique's
},
'sequence': [{
#First run on TPU with higher confidence
'name': 'TPU object detection',
'enabled': 'yes',
'object_weights':'{{tpu_object_weights_mobiledet}}',
'object_labels': '{{tpu_object_labels}}',
'object_min_confidence': {{tpu_min_confidence}},
'object_framework':'{{tpu_object_framework}}',
'tpu_max_processes': {{tpu_max_processes}},
'tpu_max_lock_wait': {{tpu_max_lock_wait}},
'max_detection_size':'{{max_detection_size}}',
'show_models':'{{show_models}}'


},
{
# 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}}',
'object_min_confidence': {{object_min_confidence}},
'object_framework':'{{yolo4_object_framework}}',
'object_processor': '{{yolo4_object_processor}}',
'gpu_max_processes': {{gpu_max_processes}},
'gpu_max_lock_wait': {{gpu_max_lock_wait}},
'cpu_max_processes': {{cpu_max_processes}},
'cpu_max_lock_wait': {{cpu_max_lock_wait}},
'max_detection_size':'{{max_detection_size}}',
'show_models':'{{show_models}}'

}]
}
}



asker wrote: Mon Jun 28, 2021 2:26 am This happens only for snapshots in mlapi. That is because mlapi detects on the frame that is the latest snapshot at that point of time. When the detections finish zmdetect gets the results from mlapi and draws boxes around the frame called snapshot then. In that difference in time snapshot may have moved. See convert_snapshot_to_fid in pyzm. It’s meant for this purpose and goes into stream_sequence.

As far as match past detections go it should work. Remember when you switch, most of the settings need to go into mlapiconfig.ini. See this. If you think everything is configured correctly, please post debug logs.
VicThor wrote: Mon Jun 28, 2021 1:00 am Thank you, seems to be way faster as models are loaded in the memory.
I am seeing a few issues though:
- the match_past_detection does not seem to work as static objects are always detected
- bounding boxes are way off compared to non mlapi detection
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: zmevennotification object detection on edge tpu

Post by asker »

Let’s have a look at mlapi debug logs. Configs look ok.
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
VicThor
Posts: 39
Joined: Tue Oct 13, 2020 8:47 pm

Re: zmevennotification object detection on edge tpu

Post by VicThor »

asker wrote: Tue Jun 29, 2021 1:57 am Let’s have a look at mlapi debug logs. Configs look ok.
Are these the logs u after? or they should be on mlapi server?

06/29/21 15:12:18 zmesdetect_m1[1188880] INF zm_detect.py:284 [---------| app:6.1.25, pyzm:0.3.49, ES:6.1.25
, OpenCV:4.5.2|------------]
06/29/21 15:12:18 zmesdetect_m1[1188880] INF utils.py:405 [Reading config from: /etc/zm/objectconfig.ini]
06/29/21 15:12:18 zmesdetect_m1[1188880] INF utils.py:410 [Reading secrets from: /etc/zm/secrets.ini]
06/29/21 15:12:18 zmesdetect_m1[1188880] INF zm_detect.py:313 [Importing remote shim classes for Object/Face]
06/29/21 15:12:18 zmesdetect_m1[1188880] INF zm_detect.py:334 [Connecting with ZM APIs]
06/29/21 15:12:18 zmesdetect_m1[1188880] INF zm_detect.py:48 [Detecting using remote API Gateway http://xxxxxxxx:5000/api/v1]
06/29/21 15:12:18 zmesdetect_m1[1188880] INF zm_detect.py:479 [Prediction string:[s] detected:(coral) car:63% (coral) person:61% ]
06/29/21 15:12:27 zmesdetect_m1[1188912] INF ZMLog.py:225 [Setting up signal handler for logs]
06/29/21 15:12:27 zmesdetect_m1[1188912] INF ZMLog.py:234 [Switching global logger to ZMLog]
06/29/21 15:12:27 zmesdetect_m1[1188912] INF zm_detect.py:284 [---------| app:6.1.25, pyzm:0.3.49, ES:6.1.25
, OpenCV:4.5.2|------------]
06/29/21 15:12:28 zmesdetect_m1[1188912] INF utils.py:405 [Reading config from: /etc/zm/objectconfig.ini]
06/29/21 15:12:28 zmesdetect_m1[1188912] INF utils.py:410 [Reading secrets from: /etc/zm/secrets.ini]
06/29/21 15:12:28 zmesdetect_m1[1188912] INF zm_detect.py:313 [Importing remote shim classes for Object/Face]
06/29/21 15:12:28 zmesdetect_m1[1188912] INF zm_detect.py:334 [Connecting with ZM APIs]
06/29/21 15:12:28 zmesdetect_m1[1188912] INF zm_detect.py:48 [Detecting using remote API Gateway http://xxxxxxxxx:5000/api/v1]
06/29/21 15:12:28 zmesdetect_m1[1188912] INF zm_detect.py:479 [Prediction string:[a] detected:(coral) car:62% ]
06/29/21 15:12:32 zmesdetect_m1[1188942] INF ZMLog.py:225 [Setting up signal handler for logs]
06/29/21 15:12:32 zmesdetect_m1[1188942] INF ZMLog.py:234 [Switching global logger to ZMLog]
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: zmevennotification object detection on edge tpu

Post by asker »

Mlapi logs and debug. Not INF.
Run manually with —debug or take a look at the docs (or my signature) on links for debug logging.
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
VicThor
Posts: 39
Joined: Tue Oct 13, 2020 8:47 pm

Re: zmevennotification object detection on edge tpu

Post by VicThor »

Code: Select all

root@pn50:/home/vic# sudo -u www-data /var/lib/zmeventnotification/bin/zm_detect.py --config /etc/zm/objectconfig.ini --debug --eventid 35384 --monitorid 1
06/30/21 07:56:32 zmesdetect_m1[1387220] INF ZMLog.py:225 [Setting up signal handler for logs]

06/30/21 07:56:32 zmesdetect_m1[1387220] INF ZMLog.py:234 [Switching global logger to ZMLog]

06/30/21 07:56:33 zmesdetect_m1[1387220] INF zm_detect.py:284 [---------| app:6.1.25, pyzm:0.3.49, ES:6.1.25
 , OpenCV:4.5.2|------------]

06/30/21 07:56:33 zmesdetect_m1[1387220] INF utils.py:405 [Reading config from: /etc/zm/objectconfig.ini]

06/30/21 07:56:33 zmesdetect_m1[1387220] INF utils.py:410 [Reading secrets from: /etc/zm/secrets.ini]

06/30/21 07:56:33 zmesdetect_m1[1387220] DBG2 utils.py:382 [Secret token found in config: !PLATEREC_ALPR_KEY]

06/30/21 07:56:33 zmesdetect_m1[1387220] DBG1 utils.py:445 [allowing self-signed certs to work...]

06/30/21 07:56:33 zmesdetect_m1[1387220] DBG2 utils.py:455 [Now checking for monitor overrides]

06/30/21 07:56:33 zmesdetect_m1[1387220] DBG3 utils.py:522 [Finally, doing parameter substitution]

06/30/21 07:56:33 zmesdetect_m1[1387220] INF zm_detect.py:313 [Importing remote shim classes for Object/Face]

06/30/21 07:56:33 zmesdetect_m1[1387220] INF zm_detect.py:334 [Connecting with ZM APIs]

06/30/21 07:56:33 zmesdetect_m1[1387220] DBG2 api.py:68 [Basic auth requested, configuring]

06/30/21 07:56:33 zmesdetect_m1[1387220] DBG2 api.py:72 [API SSL certificate check has been disbled]

06/30/21 07:56:33 zmesdetect_m1[1387220] DBG1 api.py:181 [using username/password for login]

06/30/21 07:56:33 zmesdetect_m1[1387220] DBG2 api.py:210 [Using new token API]

06/30/21 07:56:33 zmesdetect_m1[1387220] DBG1 api.py:217 [Access token expires on:2021-06-30 09:56:33.345025 [7200s]]

06/30/21 07:56:33 zmesdetect_m1[1387220] DBG1 api.py:221 [Refresh token expires on:2021-07-01 07:56:33.345526 [86400s]]

06/30/21 07:56:33 zmesdetect_m1[1387220] DBG2 zm_detect.py:342 [using ml_sequence]

06/30/21 07:56:33 zmesdetect_m1[1387220] DBG2 zm_detect.py:354 [using stream_sequence]

06/30/21 07:56:33 zmesdetect_m1[1387220] INF zm_detect.py:48 [Detecting using remote API Gateway http://xxxxxxxxxxx:5000/api/v1]

06/30/21 07:56:33 zmesdetect_m1[1387220] DBG2 zm_detect.py:57 [Found token file, checking if token has not expired]

06/30/21 07:56:33 zmesdetect_m1[1387220] DBG1 zm_detect.py:78 [Access token is valid for 93 more seconds]

06/30/21 07:56:33 zmesdetect_m1[1387220] DBG2 zm_detect.py:141 [Invoking mlapi with url:http://xxxxxxxxxxx:5000/api/v1/detect/object?type=object and json: mid=1 reason=None stream=35384, stream_options={'frame_strategy': 'most_models', 'frame_set': 'alarm,snapshot', 'contig_frames_before_error': 5, 'max_attempts': 3, 'sleep_between_attempts': 5, 'api': None, 'polygons': []} ml_overrides={'model_sequence': 'object', 'object': {'pattern': '(person|car|motorbike|bus|truck|cat|dog)'}, 'face': {'pattern': None}, 'alpr': {'pattern': None}} headers={'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE2MjUwMDM3MDAsIm5iZiI6MTYyNTAwMzcwMCwianRpIjoiYmYxNDc5NmYtZWUzMy00MGY3LTlkMTctZTljOTMxNjI1NThmIiwiZXhwIjoxNjI1MDA3MzAwLCJpZGVudGl0eSI6ImFkbWluIiwiZnJlc2giOmZhbHNlLCJ0eXBlIjoiYWNjZXNzIn0.ZhZhHnBoMNXGv2TpvJPIQGOyAEuDLshC-PYOJYacbdw'} params={'delete': True, 'response_format': 'zm_detect'} ]

06/30/21 07:56:34 zmesdetect_m1[1387220] DBG1 zm_detect.py:165 [remote detection inferencing took: 0:00:00.806411]

06/30/21 07:56:34 zmesdetect_m1[1387220] DBG2 zm_detect.py:174 [Grabbing image from http://xxxxxxxxxxx/zm/index.php?view=image&eid=35384&fid=alarm as we need to write objdetect.jpg]

06/30/21 07:56:34 zmesdetect_m1[1387220] DBG3 api.py:144 [No need to relogin as access token still has 119.98643466666667 minutes remaining]

06/30/21 07:56:34 zmesdetect_m1[1387220] DBG3 api.py:272 [make_request called with url=http://xxxxxxxxxxx/zm/index.php?view=image&eid=35384&fid=alarm payload={} type=get query={'token': 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJab25lTWluZGVyIiwiaWF0IjoxNjI1MDAzNzkzLCJleHAiOjE2MjUwMTA5OTMsInVzZXIiOiJhZG1pbiIsInR5cGUiOiJhY2Nlc3MifQ.b1R0hleQgqM-sFU6XQbtvJJKEpR0V7i7daCT4WVfPBM'}]

06/30/21 07:56:34 zmesdetect_m1[1387220] DBG2 zm_detect.py:188 [No need to resize as image widths are same from mlapi and zm_detect: 640]

06/30/21 07:56:34 zmesdetect_m1[1387220] DBG1 zm_detect.py:403 [Total remote detection detection took: 0:00:00.830993]

06/30/21 07:56:34 zmesdetect_m1[1387220] INF zm_detect.py:479 [Prediction string:[a] detected:(yolo) car:94% ]

06/30/21 07:56:34 zmesdetect_m1[1387220] DBG1 zm_detect.py:481 [Prediction string JSON:{"labels": ["car"], "boxes": [[564, 60, 648, 104]], "frame_id": "alarm", "confidences": [0.9436101317405701], "image_dimensions": {"original": [360, 640], "resized": [450, 800]}}]

[a] detected:(yolo) car:94% --SPLIT--{"labels": ["car"], "boxes": [[564, 60, 648, 104]], "frame_id": "alarm", "confidences": [0.9436101317405701], "image_dimensions": {"original": [360, 640], "resized": [450, 800]}}
Last edited by VicThor on Thu Jul 01, 2021 8:38 pm, edited 1 time in total.
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: zmevennotification object detection on edge tpu

Post by asker »

mlapi logs. Not ZM detect.
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
VicThor
Posts: 39
Joined: Tue Oct 13, 2020 8:47 pm

Re: zmevennotification object detection on edge tpu

Post by VicThor »

I am such a n00b. Where can I find these logs? Can't find any logs in the container.
Post Reply