Trying to get object detection working

Forum for questions and support relating to the 1.34.x releases only.
Post Reply
mcpaha
Posts: 4
Joined: Sat Nov 21, 2020 11:29 pm

Trying to get object detection working

Post by mcpaha »

Hi!

Sorry for bother and noob warning... I've tried now multiple times but cannot get object detection working... anybody could help?

No need for face recognition just object detection with animal, human, vehicle etc...

Some data:

Code: Select all

ubupaha@ubupaha-kodi:/var/log/zm$ sudo -u www-data /usr/bin/zmeventnotification.pl --debug
INF:2021-02-07,17:27:21 PARENT: using config file: /etc/zm/zmeventnotification.ini
07.02.2021 17:27:21.411676 zmeventnotification[76842].INF [main:989] [PARENT: using config file: /etc/zm/zmeventnotification.ini]
INF:2021-02-07,17:27:21 PARENT: using secrets file: /etc/zm/secrets.ini
07.02.2021 17:27:21.427391 zmeventnotification[76842].INF [main:989] [PARENT: using secrets file: /etc/zm/secrets.ini]
DBG-2:2021-02-07,17:27:21 PARENT: Got secret token !ZMES_PICTURE_URL
DBG-2:2021-02-07,17:27:21 PARENT: Got secret token !ZM_USER
DBG-2:2021-02-07,17:27:21 PARENT: Got secret token !ZM_PASSWORD
DBG-3:2021-02-07,17:27:21 PARENT: config string substitution: {{base_data_path}} is '/var/lib/zmeventnotification'
DBG-3:2021-02-07,17:27:21 PARENT: config string substitution: {{base_data_path}} is '/var/lib/zmeventnotification'

Configuration (read /etc/zm/zmeventnotification.ini):

Secrets file.......................... /etc/zm/secrets.ini
Base data path........................ /var/lib/zmeventnotification
Restart interval (secs)............... (undefined)

Use admin interface .................. no
Admin interface password.............. (undefined)
Admin interface persistence file ..... /var/lib/zmeventnotification/misc/escontrol_interface.dat

Port ................................. 9090
Address .............................. [::]
Event check interval ................. 5
Monitor reload interval .............. 300
Skipped monitors...................... (undefined)

Auth enabled ......................... yes
Auth timeout ......................... 20

Use API Push.......................... no
API Push Script....................... (undefined)

Use FCM .............................. yes
Use FCM V1 APIs....................... yes
FCM Date Format....................... %I:%M %p, %d-%b
Only show latest FCMv1 message........ no
Android FCM push priority............. default

Token file ........................... /var/lib/zmeventnotification/push/tokens.txt

Use MQTT ............................. no
MQTT Server .......................... 127.0.0.1
MQTT Topic ........................... zoneminder
MQTT Username ........................ (undefined)
MQTT Password ........................ (undefined)
MQTT Retain .......................... no
MQTT Tick Interval ................... 15
MQTT TLS CA ........................ (undefined)
MQTT TLS Cert ........................ (undefined)
MQTT TLS Key ........................ (undefined)
MQTT TLS Insecure ........................ no

SSL enabled .......................... no
SSL cert file ........................ /path/to/cert/file.pem
SSL key file ......................... /path/to/key/file.pem

Verbose .............................. yes
ES Debug level.........................4
Read alarm cause ..................... yes
Tag alarm event id ................... yes
Use custom notification sound ........ no
Send event start notification..........yes
Send event end notification............yes
Monitor rules JSON file................(undefined)

Use Hooks............................. yes
Hook Script on Event Start ........... '/var/lib/zmeventnotification/bin/zm_event_start.sh'
User Script on Event Start.............(undefined)
Hook Script on Event End.............. '/var/lib/zmeventnotification/bin/zm_event_end.sh'
User Script on Event End.............(undefined)
Hook Skipped monitors................. (undefined)

Notify on Event Start (hook success).. all
Notify on Event Start (hook fail)..... none
Notify on Event End (hook success).... fcm,web,api
Notify on Event End (hook fail)....... none
Notify End only if Start success...... yes

Use Hook Description.................. yes
Keep frame match type................. yes
Store Frame in ZM......................yes

Picture URL .......................... http://portal/zm/index.php?view=image&eid=EVENTID&fid=objdetect&width=600
Include picture....................... yes
Picture username ..................... admin
Picture password ..................... (defined)

INF:2021-02-07,17:27:21 PARENT: Push enabled via FCM
07.02.2021 17:27:21.568611 zmeventnotification[76842].INF [main:989] [PARENT: Push enabled via FCM]
DBG-4:2021-02-07,17:27:21 PARENT: fcmv1: --> FCM V1 APIs: 1
INF:2021-02-07,17:27:21 PARENT: MQTT Disabled
07.02.2021 17:27:21.578502 zmeventnotification[76842].INF [main:989] [PARENT: MQTT Disabled]
INF:2021-02-07,17:27:21 PARENT: |------- Starting ES version: 6.1.7 ---------|
07.02.2021 17:27:21.590377 zmeventnotification[76842].INF [main:989] [PARENT: |------- Starting ES version: 6.1.7 ---------|]
DBG-1:2021-02-07,17:27:21 PARENT: Started with: perl:/usr/bin/perl and command:/usr/bin/zmeventnotification.pl
Can't ignore signal CHLD, forcing to default.
DBG-1:2021-02-07,17:27:21 PARENT: ES invoked via ZMDC. Will exit when needed and have zmdc restart it
WAR:2021-02-07,17:27:21 PARENT: WARNING: SSL is disabled, which means all traffic will be unencrypted
07.02.2021 17:27:21.750103 zmeventnotification[76842].WAR [main:997] [PARENT: WARNING: SSL is disabled, which means all traffic will be unencrypted]
DBG-2:2021-02-07,17:27:21 PARENT: Parent<--Child pipe ready
INF:2021-02-07,17:27:21 PARENT: Event Notification daemon v 6.1.7 starting

07.02.2021 17:27:21.761768 zmeventnotification[76842].INF [main:989] [PARENT: Event Notification daemon v 6.1.7 starting]
DBG-1:2021-02-07,17:27:21 PARENT: Initializing FCM tokens...
DBG-1:2021-02-07,17:27:21 PARENT: Total event client connections: 0

INF:2021-02-07,17:27:21 PARENT: Re-loading monitors
07.02.2021 17:27:21.774674 zmeventnotification[76842].INF [main:989] [PARENT: Re-loading monitors]
DBG-1:2021-02-07,17:27:21 PARENT: Loading Tapo C200
DBG-1:2021-02-07,17:27:21 PARENT: Loading Hikkari
DBG-1:2021-02-07,17:27:21 PARENT: ESCONTROL_INTERFACE is disabled. Not saving control data
DBG-2:2021-02-07,17:27:21 PARENT: checkEvents() new events found=0
INF:2021-02-07,17:27:21 PARENT: Secure WS is disabled...
07.02.2021 17:27:21.788938 zmeventnotification[76842].INF [main:989] [PARENT: Secure WS is disabled...]
INF:2021-02-07,17:27:21 PARENT: Web Socket Event Server listening on port 9090
07.02.2021 17:27:21.800491 zmeventnotification[76842].INF [main:989] [PARENT: Web Socket Event Server listening on port 9090]
failed to listen on port 9090: Address already in use at /usr/bin/zmeventnotification.pl line 4546.

Code: Select all

ubupaha@ubupaha-kodi:~/zmeventnotification$ sudo -u www-data /var/lib/zmeventnotification/bin/zm_detect.py --config /etc/zm/objectconfig.ini --debug --eventid 20058  --monitorid 2 --eventpath=/tmp
02/07/21 17:23:04 zmesdetect_m2[71812] INF ZMLog.py:219 [Setting up signal handler for logs]

02/07/21 17:23:04 zmesdetect_m2[71812] INF zm_detect.py:240 [---------| pyzm version:0.3.28, hook version:6.1.7,  ES version:6.1.7 , OpenCV version:4.5.1|------------]

02/07/21 17:23:04 zmesdetect_m2[71812] DBG1 utils.py:406 [secret filename: /etc/zm/secrets.ini]

02/07/21 17:23:04 zmesdetect_m2[71812] DBG2 utils.py:379 [Secret token found in config: !ZM_PORTAL]

02/07/21 17:23:04 zmesdetect_m2[71812] DBG2 utils.py:379 [Secret token found in config: !ZM_USER]

02/07/21 17:23:04 zmesdetect_m2[71812] DBG2 utils.py:379 [Secret token found in config: !ZM_PASSWORD]

02/07/21 17:23:04 zmesdetect_m2[71812] DBG2 utils.py:379 [Secret token found in config: !ZM_API_PORTAL]

02/07/21 17:23:04 zmesdetect_m2[71812] DBG2 utils.py:379 [Secret token found in config: !ML_USER]

02/07/21 17:23:04 zmesdetect_m2[71812] DBG2 utils.py:379 [Secret token found in config: !ML_PASSWORD]

02/07/21 17:23:04 zmesdetect_m2[71812] DBG2 utils.py:379 [Secret token found in config: !PLATEREC_ALPR_KEY]

02/07/21 17:23:04 zmesdetect_m2[71812] DBG1 utils.py:441 [allowing self-signed certs to work...]

02/07/21 17:23:04 zmesdetect_m2[71812] DBG4 utils.py:451 [Now checking for monitor overrides]

02/07/21 17:23:04 zmesdetect_m2[71812] DBG4 utils.py:514 [Finally, doing parameter substitution]

02/07/21 17:23:04 zmesdetect_m2[71812] INF zm_detect.py:265 [Importing local classes for Object/Face]

02/07/21 17:23:04 zmesdetect_m2[71812] INF zm_detect.py:288 [Connecting with ZM APIs]

02/07/21 17:23:04 zmesdetect_m2[71812] DBG2 api.py:69 [API SSL certificate check has been disbled]

02/07/21 17:23:04 zmesdetect_m2[71812] DBG1 api.py:168 [using username/password for login]

02/07/21 17:23:04 zmesdetect_m2[71812] DBG2 api.py:197 [Using new token API]

02/07/21 17:23:04 zmesdetect_m2[71812] DBG4 api.py:267 [make_request called with url=http://192.168.1.60/zm/api/host/gettimezone.json payload={} type=get query={'token': None}]

02/07/21 17:23:04 zmesdetect_m2[71812] DBG2 zm_detect.py:296 [using ml_sequence]

02/07/21 17:23:04 zmesdetect_m2[71812] DBG2 zm_detect.py:308 [using stream_sequence]

02/07/21 17:23:04 zmesdetect_m2[71812] DBG3 detect_sequence.py:375 [Using automatic locking as we are switching between models]

02/07/21 17:23:04 zmesdetect_m2[71812] DBG2 Media.py:49 [Media get SSL certificate check has been disbled]

02/07/21 17:23:04 zmesdetect_m2[71812] DBG2 Media.py:96 [Using URL 20058 for stream]

02/07/21 17:23:04 zmesdetect_m2[71812] DBG2 Media.py:109 [We will only process frames: ['snapshot', 'alarm']]

02/07/21 17:23:04 zmesdetect_m2[71812] DBG2 Media.py:132 [No need to start streams, we are picking images from http://192.168.1.60/zm/index.php?view=image&eid=20058]

02/07/21 17:23:04 zmesdetect_m2[71812] DBG3 Media.py:245 [Reading http://192.168.1.60/zm/index.php?view=image&eid=20058&fid=snapshot]

02/07/21 17:23:04 zmesdetect_m2[71812] DBG4 api.py:267 [make_request called with url=http://192.168.1.60/zm/index.php?view=image&eid=20058&fid=snapshot payload={} type=get query={'token': None}]

02/07/21 17:23:05 zmesdetect_m2[71812] DBG1 detect_sequence.py:413 [============ Frame: snapshot Running object model in sequence ==================]

02/07/21 17:23:05 zmesdetect_m2[71812] DBG3 detect_sequence.py:135 [load_models (just init, actual load happens at first detect): ['object']]

02/07/21 17:23:05 zmesdetect_m2[71812] DBG2 detect_sequence.py:144 [Initializing model  type:object with options:{'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': 100, 'max_detection_size': '90%', 'disable_locks': 'no'}]

02/07/21 17:23:05 zmesdetect_m2[71812] DBG2 coral_edgetpu.py:39 [portalock: max:1, name:pyzm_uid33_tpu_lock, timeout:100]

02/07/21 17:23:05 zmesdetect_m2[71812] DBG2 detect_sequence.py:144 [Initializing model  type:object with options:{'object_config': '/var/lib/zmeventnotification/models/yolov4/yolov4.cfg', 'object_weights': '/var/lib/zmeventnotification/models/yolov4/yolov4.weights', 'object_labels': '/var/lib/zmeventnotification/models/yolov4/coco.names', 'object_min_confidence': 0.3, 'object_framework': 'opencv', 'object_processor': 'gpu', 'gpu_max_processes': 1, 'gpu_max_lock_wait': 100, 'cpu_max_processes': 3, 'cpu_max_lock_wait': 100, 'max_detection_size': '90%', 'disable_locks': 'no'}]

02/07/21 17:23:05 zmesdetect_m2[71812] DBG2 yolo.py:37 [portalock: max:1, name:pyzm_uid33_gpu_lock, timeout:100]

02/07/21 17:23:05 zmesdetect_m2[71812] DBG3 detect_sequence.py:433 [object has a same_model_sequence strategy of first]

02/07/21 17:23:05 zmesdetect_m2[71812] DBG3 detect_sequence.py:444 [--------- Frame:snapshot Running variation: #1 -------------]

02/07/21 17:23:05 zmesdetect_m2[71812] DBG2 coral_edgetpu.py:53 [Waiting for pyzm_uid33_tpu_lock portalock...]

filenames [PosixPath('/tmp/pyzm_uid33_tpu_lock.00.lock')]
trying lock [PosixPath('/tmp/pyzm_uid33_tpu_lock.00.lock')]
trying lock for /tmp/pyzm_uid33_tpu_lock.00.lock
locked /tmp/pyzm_uid33_tpu_lock.00.lock
02/07/21 17:23:05 zmesdetect_m2[71812] DBG2 coral_edgetpu.py:55 [Got pyzm_uid33_tpu_lock portalock]

02/07/21 17:23:05 zmesdetect_m2[71812] DBG1 coral_edgetpu.py:84 [|--------- Loading TPU model from disk -------------|]

02/07/21 17:23:05 zmesdetect_m2[71812] DBG2 coral_edgetpu.py:70 [Released portalock pyzm_uid33_tpu_lock]

02/07/21 17:23:05 zmesdetect_m2[71812] ERR detect_sequence.py:450 [Error running model: Failed to load delegate from libedgetpu.so.1
]

02/07/21 17:23:05 zmesdetect_m2[71812] DBG2 detect_sequence.py:451 [Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/tflite_runtime/interpreter.py", line 152, in load_delegate
    delegate = Delegate(library, options)
  File "/usr/local/lib/python3.8/dist-packages/tflite_runtime/interpreter.py", line 111, in __init__
    raise ValueError(capture.message)
ValueError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/pyzm/ml/detect_sequence.py", line 447, in detect_stream
    _b,_l,_c = m.detect(image=frame)
  File "/usr/local/lib/python3.8/dist-packages/pyzm/ml/object.py", line 54, in detect
    b,l,c = self.model.detect(image)
  File "/usr/local/lib/python3.8/dist-packages/pyzm/ml/coral_edgetpu.py", line 156, in detect
    self.load_model()
  File "/usr/local/lib/python3.8/dist-packages/pyzm/ml/coral_edgetpu.py", line 89, in load_model
    self.model = make_interpreter(self.options.get('object_weights'))
  File "/usr/local/lib/python3.8/dist-packages/pycoral/utils/edgetpu.py", line 66, in make_interpreter
    delegates = [load_edgetpu_delegate({'device': device} if device else {})]
  File "/usr/local/lib/python3.8/dist-packages/pycoral/utils/edgetpu.py", line 42, in load_edgetpu_delegate
    return tflite.load_delegate(_EDGETPU_SHARED_LIB, options or {})
  File "/usr/local/lib/python3.8/dist-packages/tflite_runtime/interpreter.py", line 154, in load_delegate
    raise ValueError('Failed to load delegate from {}\n{}'.format(
ValueError: Failed to load delegate from libedgetpu.so.1

]

02/07/21 17:23:05 zmesdetect_m2[71812] DBG3 detect_sequence.py:444 [--------- Frame:snapshot Running variation: #2 -------------]

02/07/21 17:23:05 zmesdetect_m2[71812] DBG2 yolo.py:49 [Waiting for pyzm_uid33_gpu_lock portalock...]

filenames [PosixPath('/tmp/pyzm_uid33_gpu_lock.00.lock')]
trying lock [PosixPath('/tmp/pyzm_uid33_gpu_lock.00.lock')]
trying lock for /tmp/pyzm_uid33_gpu_lock.00.lock
locked /tmp/pyzm_uid33_gpu_lock.00.lock
02/07/21 17:23:05 zmesdetect_m2[71812] DBG2 yolo.py:51 [Got pyzm_uid33_gpu_lock portalock]

02/07/21 17:23:05 zmesdetect_m2[71812] DBG1 yolo.py:80 [|--------- Loading Yolo model from disk ---------|]

02/07/21 17:23:05 zmesdetect_m2[71812] DBG1 yolo.py:86 [perf: processor:gpu Yolo initialization (loading /var/lib/zmeventnotification/models/yolov4/yolov4.weights model from disk) took: 0:00:00.151858]

02/07/21 17:23:05 zmesdetect_m2[71812] DBG2 yolo.py:102 [Setting CUDA backend for OpenCV]

02/07/21 17:23:05 zmesdetect_m2[71812] DBG3 yolo.py:103 [If you did not set your CUDA_ARCH_BIN correctly during OpenCV compilation, you will get errors during detection related to invalid device/make_policy]

02/07/21 17:23:05 zmesdetect_m2[71812] DBG1 yolo.py:141 [|---------- YOLO (input image: 800w*450h, model resize dimensions: 416w*416h) ----------|]

[ WARN:0] global /tmp/pip-req-build-ms668fyv/opencv/modules/dnn/src/dnn.cpp (1442) setUpNet DNN module was not built with CUDA backend; switching to CPU
02/07/21 17:23:06 zmesdetect_m2[71812] DBG2 yolo.py:67 [Released pyzm_uid33_gpu_lock portalock]

02/07/21 17:23:06 zmesdetect_m2[71812] DBG1 yolo.py:167 [perf: processor:gpu Yolo detection took: 0:00:01.692682]

02/07/21 17:23:07 zmesdetect_m2[71812] DBG2 yolo.py:201 [perf: processor:gpu Yolo NMS filtering took: 0:00:00.001292]

02/07/21 17:23:07 zmesdetect_m2[71812] DBG3 object.py:55 [core model detection over, got 1 objects. Now filtering]

02/07/21 17:23:07 zmesdetect_m2[71812] DBG3 object.py:59 [Max object size found to be: 90%]

02/07/21 17:23:07 zmesdetect_m2[71812] DBG2 object.py:67 [Converted 90% to 324000.0]

02/07/21 17:23:07 zmesdetect_m2[71812] DBG2 object.py:90 [Returning filtered list of 1 objects.]

02/07/21 17:23:07 zmesdetect_m2[71812] DBG4 detect_sequence.py:448 [This model iteration inside object found: labels: ['person'],conf:[0.7679345607757568]]

02/07/21 17:23:07 zmesdetect_m2[71812] DBG2 detect_sequence.py:221 [No polygons, adding full image polygon: {'name': 'full_image', 'value': [(0, 0), (1920, 0), (1920, 1080), (0, 1080)], 'pattern': None}]

02/07/21 17:23:07 zmesdetect_m2[71812] DBG3 detect_sequence.py:190 [resized polygons x=0.4166666666666667/y=0.4166666666666667: [{'name': 'full_image', 'value': [(0, 0), (800, 0), (800, 450), (0, 450)], 'pattern': None}]]

02/07/21 17:23:07 zmesdetect_m2[71812] DBG3 detect_sequence.py:250 [intersection: comparing object:person,POLYGON ((515 115, 699 115, 699 451, 515 451, 515 115)) to polygon:full_image,POLYGON ((0 0, 800 0, 800 450, 0 450, 0 0))]

02/07/21 17:23:07 zmesdetect_m2[71812] DBG2 detect_sequence.py:268 [Using global match pattern: (person|car|motorbike|bus|truck|boat)]

02/07/21 17:23:07 zmesdetect_m2[71812] DBG3 detect_sequence.py:276 [full_image intersects object:person[[(515, 115), (699, 115), (699, 451), (515, 451)]]]

02/07/21 17:23:07 zmesdetect_m2[71812] DBG3 detect_sequence.py:477 [breaking out of same model loop, as matches found and strategy is "first"]

02/07/21 17:23:07 zmesdetect_m2[71812] DBG1 detect_sequence.py:413 [============ Frame: snapshot Running face model in sequence ==================]

02/07/21 17:23:07 zmesdetect_m2[71812] DBG3 detect_sequence.py:135 [load_models (just init, actual load happens at first detect): ['face']]

02/07/21 17:23:07 zmesdetect_m2[71812] ERR detect_sequence.py:177 [Error loading same model variation for face:No module named 'face_recognition']

02/07/21 17:23:07 zmesdetect_m2[71812] DBG2 detect_sequence.py:178 [Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/pyzm/ml/detect_sequence.py", line 151, in _load_models
    import pyzm.ml.face as FaceDetect
  File "/usr/local/lib/python3.8/dist-packages/pyzm/ml/face.py", line 3, in <module>
    import pyzm.ml.face_train as train
  File "/usr/local/lib/python3.8/dist-packages/pyzm/ml/face_train.py", line 15, in <module>
    import face_recognition
ModuleNotFoundError: No module named 'face_recognition'
]

02/07/21 17:23:07 zmesdetect_m2[71812] DBG3 detect_sequence.py:433 [face has a same_model_sequence strategy of first]

02/07/21 17:23:07 zmesdetect_m2[71812] FAT zm_detect.py:534 [Unrecoverable error:'face' Traceback:Traceback (most recent call last):
  File "/var/lib/zmeventnotification/bin/zm_detect.py", line 531, in <module>
    main_handler()
  File "/var/lib/zmeventnotification/bin/zm_detect.py", line 379, in main_handler
    matched_data,all_data = m.detect_stream(stream=stream, options=stream_options)
  File "/usr/local/lib/python3.8/dist-packages/pyzm/ml/detect_sequence.py", line 443, in detect_stream
    for m in self.models[seq]:
KeyError: 'face'
]


Magic919
Posts: 1381
Joined: Wed Sep 18, 2013 6:56 am

Re: Trying to get object detection working

Post by Magic919 »

It found a person. Looks like your work is done.
-
mcpaha
Posts: 4
Joined: Sat Nov 21, 2020 11:29 pm

Re: Trying to get object detection working

Post by mcpaha »

Ok, but why it doesn't show at "cause":

Image

Like this:

Image
Magic919
Posts: 1381
Joined: Wed Sep 18, 2013 6:56 am

Re: Trying to get object detection working

Post by Magic919 »

Turn off the modes you don’t want and then it’ll have a chance to complete.
-
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: Trying to get object detection working

Post by asker »

Read the logs you posted. There are multiple errors. If you don't want tpu/face, remove them
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
Minglarn
Posts: 7
Joined: Mon Sep 14, 2020 7:57 am

Re: Trying to get object detection working

Post by Minglarn »

A quick question... Does zme require OpenCV to be installed even if only Coral TPU is used?
Post Reply