Event Server Object Detection not working

Discussion topics related to mobile applications and ZoneMinder Event Server (including machine learning)
jrosetto
Posts: 15
Joined: Fri Nov 05, 2021 4:44 pm

Event Server Object Detection not working

Post by jrosetto »

Facial recognition is working but object detection isn't.

Ubuntu 20.04
Zoneminder v1.37.1

Followed the article here on setup https://zmeventnotification.readthedocs ... hooks.html
Using OpenCV with YOLOv4 with NVIDIA GPU support

Code: Select all

root@NVR:/etc/zm# sudo -u www-data /var/lib/zmeventnotification/bin/zm_detect.py --config /etc/zm/objectconfig.ini --debug --eventid 27  --monitorid 3 --eventpath=/tmp
INF [zmesdetect_m3] [Setting up signal handler for logs]
INF [zmesdetect_m3] [Switching global logger to ZMLog]
INF [zmesdetect_m3] [---------| app:6.1.28, pyzm:0.3.56, ES:6.1.28
 , OpenCV:4.5.4-dev|------------]
INF [zmesdetect_m3] [Reading config from: /etc/zm/objectconfig.ini]
INF [zmesdetect_m3] [Reading secrets from: /etc/zm/secrets.ini]
DBG2 [zmesdetect_m3] [Secret token found in config: !ML_USER]
DBG2 [zmesdetect_m3] [Secret token found in config: !ML_PASSWORD]
DBG2 [zmesdetect_m3] [Secret token found in config: !PLATEREC_ALPR_KEY]
DBG1 [zmesdetect_m3] [allowing self-signed certs to work...]
DBG2 [zmesdetect_m3] [Now checking for monitor overrides]
DBG3 [zmesdetect_m3] [Finally, doing parameter substitution]
INF [zmesdetect_m3] [Importing local classes for Object/Face]
INF [zmesdetect_m3] [Connecting with ZM APIs]
DBG2 [zmesdetect_m3] [API SSL certificate check has been disbled]
DBG1 [zmesdetect_m3] [using username/password for login]
DBG2 [zmesdetect_m3] [Using new token API]
DBG1 [zmesdetect_m3] [Access token expires on:2021-11-05 14:34:38.601172 [7200s]]
DBG1 [zmesdetect_m3] [Refresh token expires on:2021-11-06 12:34:38.601827 [86400s]]
DBG2 [zmesdetect_m3] [using ml_sequence]
DBG2 [zmesdetect_m3] [using stream_sequence]
DBG1 [zmesdetect_m3] [Resetting models, will be loaded on next run]
DBG3 [zmesdetect_m3] [Using automatic locking as we are switching between models]
DBG2 [zmesdetect_m3] [Media get SSL certificate check has been disbled]
DBG2 [zmesdetect_m3] [Using URL 27 for stream]
DBG2 [zmesdetect_m3] [We will only process frames: ['snapshot', 'alarm']]
DBG2 [zmesdetect_m3] [No need to start streams, we are picking images from https://example.com/zm/index.php?view=image&eid=27]
DBG3 [zmesdetect_m3] [Reading https://example.com/zm/index.php?view=image&eid=27&fid=snapshot]
DBG3 [zmesdetect_m3] [No need to relogin as access token still has 119.9992968 minutes remaining]
DBG3 [zmesdetect_m3] [make_request called with url=https://example.com/zm/index.php?view=image&eid=27&fid=snapshot payload={} type=get query={'token': 'removed'}]
DBG1 [zmesdetect_m3] [perf: Starting for frame:snapshot]
DBG1 [zmesdetect_m3] [Sequence of detection types to execute: ['object', 'face', 'alpr']]
DBG1 [zmesdetect_m3] [============ Frame: snapshot Running object detection type in sequence ==================]
DBG2 [zmesdetect_m3] [Skipping TPU object detection as it is disabled]
DBG2 [zmesdetect_m3] [Loading sequence: YoloV4 GPU/CPU]
DBG2 [zmesdetect_m3] [Initializing model  type:object with options:{'name': 'YoloV4 GPU/CPU', 'enabled': 'yes', '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'}]
DBG2 [zmesdetect_m3] [portalock: max:1, name:pyzm_uid33_gpu_lock, timeout:100]
DBG3 [zmesdetect_m3] [object has a same_model_sequence strategy of first]
DBG1 [zmesdetect_m3] [--------- Frame:snapshot Running variation: #1 -------------]
DBG2 [zmesdetect_m3] [detect extracted image dimensions as: 800wx450h]
DBG2 [zmesdetect_m3] [Waiting for pyzm_uid33_gpu_lock portalock...]
DBG2 [zmesdetect_m3] [Got pyzm_uid33_gpu_lock portalock]
DBG1 [zmesdetect_m3] [|--------- Loading "YoloV4 GPU/CPU" model from disk -------------|]
DBG1 [zmesdetect_m3] [perf: processor:gpu Yolo initialization (loading /var/lib/zmeventnotification/models/yolov4/yolov4.weights model from disk) took: 159.07 ms]
DBG2 [zmesdetect_m3] [Setting CUDA backend for OpenCV]
DBG3 [zmesdetect_m3] [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]
DBG1 [zmesdetect_m3] [|---------- YOLO (input image: 800w*450h, model resize dimensions: 416w*416h) ----------|]
DBG2 [zmesdetect_m3] [Released pyzm_uid33_gpu_lock portalock]
[b]11/05/21 12:34:38 zmesdetect_m3[8215] ERR detect_sequence.py:713 [Error running model: invalid index to scalar variable.]

DBG2 [zmesdetect_m3] [Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/pyzm/ml/detect_sequence.py", line 710, in detect_stream
    _b,_l,_c,_m = m.detect(image=frame)
  File "/usr/local/lib/python3.8/dist-packages/pyzm/ml/object.py", line 65, in detect
    b,l,c,_model_names = self.model.detect(image)
  File "/usr/local/lib/python3.8/dist-packages/pyzm/ml/yolo.py", line 168, in detect
    ln = self.get_output_layers()
  File "/usr/local/lib/python3.8/dist-packages/pyzm/ml/yolo.py", line 129, in get_output_layers
    output_layers = [
  File "/usr/local/lib/python3.8/dist-packages/pyzm/ml/yolo.py", line 130, in <listcomp>
    layer_names[i[0] - 1] for i in self.net.getUnconnectedOutLayers()
IndexError: invalid index to scalar variable.
][/b]
DBG2 [zmesdetect_m3] [We did not find any object matches in frame: snapshot]
DBG1 [zmesdetect_m3] [============ Frame: snapshot Running face detection type in sequence ==================]
DBG2 [zmesdetect_m3] [Skipping TPU face detection as it is disabled]
DBG1 [zmesdetect_m3] [perf: processor:cpu Face Recognition library load time took: 0.00 ms ]
DBG1 [zmesdetect_m3] [Initializing face recognition with model:cnn upsample:1, jitters:0]
DBG2 [zmesdetect_m3] [portalock: max:3, name:pyzm_uid33_cpu_lock, timeout:100]
DBG1 [zmesdetect_m3] [pre-trained faces found, using that. If you want to add new images, remove: /var/lib/zmeventnotification/known_faces/faces.dat]
DBG3 [zmesdetect_m3] [face has a same_model_sequence strategy of union]
DBG1 [zmesdetect_m3] [--------- Frame:snapshot Running variation: #1 -------------]
DBG1 [zmesdetect_m3] [|---------- Dlib Face recognition (input image: 800w*450h) ----------|]
DBG3 [zmesdetect_m3] [Face options={'name': 'DLIB based face recognition', 'enabled': 'yes', 'save_unknown_faces': 'yes', 'save_unknown_faces_leeway_pixels': 100, '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': '1', 'face_upsample_times': '1', 'gpu_max_processes': 1, 'gpu_max_lock_wait': 100, 'cpu_max_processes': 3, 'cpu_max_lock_wait': 100, 'max_size': 800, 'disable_locks': 'no'}]
DBG2 [zmesdetect_m3] [Waiting for pyzm_uid33_cpu_lock portalock...]
DBG2 [zmesdetect_m3] [Got pyzm_uid33_cpu_lock lock...]
DBG1 [zmesdetect_m3] [perf: processor:cpu Finding faces took 5684.75 ms]
DBG1 [zmesdetect_m3] [Released pyzm_uid33_cpu_lock portalock]
DBG1 [zmesdetect_m3] [perf: processor:cpu Computing face recognition distances took 0.88 ms]
DBG2 [zmesdetect_m3] [This model iteration inside face found: labels: [],conf:[]]
DBG2 [zmesdetect_m3] [Max object size found to be: 90%]
DBG2 [zmesdetect_m3] [Converted 90% to 324000.0]
DBG2 [zmesdetect_m3] [No polygons, adding full image polygon: {'name': 'full_image', 'value': [(0, 0), (2304, 0), (2304, 1296), (0, 1296)], 'pattern': None}]
DBG3 [zmesdetect_m3] [resized polygons x=0.3472222222222222/y=0.3472222222222222: [{'name': 'full_image', 'value': [(0, 0), (800, 0), (800, 450), (0, 450)], 'pattern': None}]]
DBG2 [zmesdetect_m3] [We did not find any face matches in frame: snapshot]
DBG1 [zmesdetect_m3] [============ Frame: snapshot Running alpr detection type in sequence ==================]
DBG2 [zmesdetect_m3] [Making sure we have matched one of ['car', 'motorbike', 'bus', 'truck', 'boat'] in [] before we proceed]
DBG1 [zmesdetect_m3] [Did not find pre existing labels, not running detection type]
DBG3 [zmesdetect_m3] [Reading https://example.com/zm/index.php?view=image&eid=27&fid=alarm]
DBG3 [zmesdetect_m3] [No need to relogin as access token still has 119.85817178333333 minutes remaining]
DBG3 [zmesdetect_m3] [make_request called with url=https://example.com/zm/index.php?view=image&eid=27&fid=alarm payload={} type=get query={'token': 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJab25lTWluZGVyIiwiaWF0IjoxNjM2MTMwMDc4LCJleHAiOjE2MzYxMzcyNzgsInVzZXIiOiJhZG1pbiIsInR5cGUiOiJhY2Nlc3MifQ.vtGnZD7Hlfmwuh5KNsYY2nfaH4MdFbcbv_7Sndmp5T4'}]
DBG1 [zmesdetect_m3] [perf: Starting for frame:alarm]
DBG1 [zmesdetect_m3] [Sequence of detection types to execute: ['object', 'face', 'alpr']]
DBG1 [zmesdetect_m3] [============ Frame: alarm Running object detection type in sequence ==================]
DBG3 [zmesdetect_m3] [object has a same_model_sequence strategy of first]
DBG1 [zmesdetect_m3] [--------- Frame:alarm Running variation: #1 -------------]
DBG2 [zmesdetect_m3] [detect extracted image dimensions as: 800wx450h]
DBG2 [zmesdetect_m3] [Waiting for pyzm_uid33_gpu_lock portalock...]
DBG2 [zmesdetect_m3] [Got pyzm_uid33_gpu_lock portalock]
DBG1 [zmesdetect_m3] [|---------- YOLO (input image: 800w*450h, model resize dimensions: 416w*416h) ----------|]
DBG2 [zmesdetect_m3] [Released pyzm_uid33_gpu_lock portalock]
[b]11/05/21 12:34:47 zmesdetect_m3[8215] ERR detect_sequence.py:713 [Error running model: invalid index to scalar variable.]

DBG2 [zmesdetect_m3] [Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/pyzm/ml/detect_sequence.py", line 710, in detect_stream
    _b,_l,_c,_m = m.detect(image=frame)
  File "/usr/local/lib/python3.8/dist-packages/pyzm/ml/object.py", line 65, in detect
    b,l,c,_model_names = self.model.detect(image)
  File "/usr/local/lib/python3.8/dist-packages/pyzm/ml/yolo.py", line 168, in detect
    ln = self.get_output_layers()
  File "/usr/local/lib/python3.8/dist-packages/pyzm/ml/yolo.py", line 129, in get_output_layers
    output_layers = [
  File "/usr/local/lib/python3.8/dist-packages/pyzm/ml/yolo.py", line 130, in <listcomp>
    layer_names[i[0] - 1] for i in self.net.getUnconnectedOutLayers()
IndexError: invalid index to scalar variable.
][/b]
DBG2 [zmesdetect_m3] [We did not find any object matches in frame: alarm]
DBG1 [zmesdetect_m3] [============ Frame: alarm Running face detection type in sequence ==================]
DBG3 [zmesdetect_m3] [face has a same_model_sequence strategy of union]
DBG1 [zmesdetect_m3] [--------- Frame:alarm Running variation: #1 -------------]
DBG1 [zmesdetect_m3] [|---------- Dlib Face recognition (input image: 800w*450h) ----------|]
DBG3 [zmesdetect_m3] [Face options={'name': 'DLIB based face recognition', 'enabled': 'yes', 'save_unknown_faces': 'yes', 'save_unknown_faces_leeway_pixels': 100, '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': '1', 'face_upsample_times': '1', 'gpu_max_processes': 1, 'gpu_max_lock_wait': 100, 'cpu_max_processes': 3, 'cpu_max_lock_wait': 100, 'max_size': 800, 'disable_locks': 'no'}]
DBG2 [zmesdetect_m3] [Waiting for pyzm_uid33_cpu_lock portalock...]
DBG2 [zmesdetect_m3] [Got pyzm_uid33_cpu_lock lock...]
DBG1 [zmesdetect_m3] [perf: processor:cpu Finding faces took 5687.92 ms]
DBG1 [zmesdetect_m3] [Released pyzm_uid33_cpu_lock portalock]
DBG1 [zmesdetect_m3] [perf: processor:cpu Computing face recognition distances took 0.79 ms]
DBG2 [zmesdetect_m3] [This model iteration inside face found: labels: [],conf:[]]
DBG2 [zmesdetect_m3] [Max object size found to be: 90%]
DBG2 [zmesdetect_m3] [Converted 90% to 324000.0]
DBG2 [zmesdetect_m3] [We did not find any face matches in frame: alarm]
DBG1 [zmesdetect_m3] [============ Frame: alarm Running alpr detection type in sequence ==================]
DBG2 [zmesdetect_m3] [Making sure we have matched one of ['car', 'motorbike', 'bus', 'truck', 'boat'] in [] before we proceed]
DBG1 [zmesdetect_m3] [Did not find pre existing labels, not running detection type]
DBG1 [zmesdetect_m3] [perf: TOTAL detection sequence (with image loads) took: 14289.41 ms  to process 27]
DBG1 [zmesdetect_m3] [Closing logs]
I found a similar issue here but does not seem to apply to me because I can't find the code they are referring to.
viewtopic.php?f=43&t=31129&p=123238&hil ... le#p123238

Any help or suggestions would be greatly appreciated as I am stumped.

Thanks!
Last edited by jrosetto on Fri Nov 05, 2021 4:58 pm, edited 2 times in total.
tsp84
Posts: 227
Joined: Thu Dec 24, 2020 4:04 am

Re: Event Server Object Detection not working

Post by tsp84 »

Sanitize your log output. You have your URL and also a JWT auth token displayed in your logs.

I will take a look and try and.helpnyou out but thought I should let you know about the sensitive data.
tsp84
Posts: 227
Joined: Thu Dec 24, 2020 4:04 am

Re: Event Server Object Detection not working

Post by tsp84 »

The scalar value received a push yesterday to fix it.

Remove the zmeventnotification directory you cloned and then re run git clone to redownload the repo. Uninstall pyzm and then rerun the install script to update the python files for the new non nested logic.

Code: Select all

sudo pip3 uninstall pyzm
# Careful using RM -rf MAKE SURE OF THE CORRECT PATH
rm -rf /path/to/zmeventnotification/git
git clone <url for repo>
cd zmeventnotification 
sudo ./install.sh
Last edited by tsp84 on Fri Nov 05, 2021 5:04 pm, edited 2 times in total.
jrosetto
Posts: 15
Joined: Fri Nov 05, 2021 4:44 pm

Re: Event Server Object Detection not working

Post by jrosetto »

Thanks! I realized right after I posted and was in the process of fixing. Let me know if there is anything additional that I can provide.
jrosetto
Posts: 15
Joined: Fri Nov 05, 2021 4:44 pm

Re: Event Server Object Detection not working

Post by jrosetto »

Seem to have the same issue. Here is my terminal output if that helps.

Code: Select all

root@NVR:~# sudo pip3 uninstall pyzm
Found existing installation: pyzm 0.3.56
Uninstalling pyzm-0.3.56:
  Would remove:
    /usr/local/lib/python3.8/dist-packages/pyzm-0.3.56.dist-info/*
    /usr/local/lib/python3.8/dist-packages/pyzm/*
Proceed (Y/n)? y
root@NVR:~# cd /root/
root@NVR:~# ls
opencv  opencv_contrib  opencv_contrib.zip  opencv.zip  snap  zmeventnotification
root@NVR:~# rm -r -f zmeventnotification/
root@NVR:~# git clone https://github.com/pliablepixels/zmeventnotification
Cloning into 'zmeventnotification'...
remote: Enumerating objects: 7694, done.
remote: Counting objects: 100% (753/753), done.
remote: Compressing objects: 100% (286/286), done.
remote: Total 7694 (delta 513), reused 669 (delta 439), pack-reused 6941
Receiving objects: 100% (7694/7694), 20.16 MiB | 5.51 MiB/s, done.
Resolving deltas: 100% (5166/5166), done.
root@NVR:~# cd zmeventnotification/
root@NVR:~/zmeventnotification# sudo ./install.sh

----------- Configured Values ----------------------------
Your webserver user seems to be www-data
Your webserver group seems to be www-data
wget is /usr/bin/wget
installer software is /usr/bin/apt-get
Install Event Server: prompt
Install Event Server config: prompt
Install Hooks: prompt
Install Hooks config: prompt
Upgrade Hooks config (if applicable): yes
Download and install models (if needed): yes

The Event Server will be installed to /usr/bin
The Event Server config will be installed to /etc/zm
Hooks will be installed to /var/lib/zmeventnotification sub-folders
Hook config files will be installed to /etc/zm

Models that will be checked/installed:
(Note, if you have already downloaded a model, it will not be deleted)
Yolo V3 (INSTALL_YOLOV3): yes
TinyYolo V3 (INSTALL_TINYYOLOV3): yes
Yolo V4 (INSTALL_YOLOV4): yes
Tiny Yolo V4 (INSTALL_TINYYOLOV4): yes
Google Coral Edge TPU (INSTALL_CORAL_EDGETPU): no

If any of this looks wrong, please hit Ctrl+C and edit the variables in this script...


Install Event Server [y/N]:y
*** Installing ES ***
Success:Completed, but you will still have to install ES dependencies as per https://zmeventnotification.readthedocs.io/en/latest/guides/install.html#install-dependencies


Install Event Server Config [y/N]:y
Replacing ES config & rules file
Success:config copied
Replacing ES rules file
Success:rules copied
====> Remember to fill in the right values in the config files, or your system won't work! <=============



Install Hook [y/N]:y
*** Installing Hooks ***
Checking for YoloV3 data files....
yolov3.cfg exists, no need to download
coco.names exists, no need to download
yolov3.weights exists, no need to download

Checking for TinyYOLOV3 data files...
yolov3-tiny.cfg exists, no need to download
coco.names exists, no need to download
yolov3-tiny.weights exists, no need to download

Checking for TinyYOLOV4 data files...
yolov4-tiny.cfg exists, no need to download
coco.names exists, no need to download
yolov4-tiny.weights exists, no need to download

Checking for YOLOV4 data files...
WARNING:Note, you need OpenCV 4.4+ for Yolov4 to work
yolov4.cfg exists, no need to download
coco.names exists, no need to download
yolov4.weights exists, no need to download
*** Installing push api plugins ***
*** Installing detection scripts ***

*** Installing user contributions ***
Copying over contrib/example.py...
Copying over contrib/ftp_selective_upload.py...

Removing old version of zmes_hook_helpers, if any
Traceback (most recent call last):
  File "./hook/zm_detect.py", line 26, in <module>
    import pyzm.ZMLog as log
ModuleNotFoundError: No module named 'pyzm'
Using pip 21.3.1 from /usr/local/lib/python3.8/dist-packages/pip (python 3.8)
Processing ./hook
  Running command python setup.py egg_info
  VERBOSE: Reading /root/zmeventnotification/hook/zmes_hook_helpers/__init__.py
  VERBOSE: version_file is __version__ = ""
  VERSION=__version__

  running egg_info
  creating /tmp/pip-pip-egg-info-l2nzkrbz/zmes_hook_helpers.egg-info
  writing /tmp/pip-pip-egg-info-l2nzkrbz/zmes_hook_helpers.egg-info/PKG-INFO
  writing dependency_links to /tmp/pip-pip-egg-info-l2nzkrbz/zmes_hook_helpers.egg-info/dependency_links.txt
  writing requirements to /tmp/pip-pip-egg-info-l2nzkrbz/zmes_hook_helpers.egg-info/requires.txt
  writing top-level names to /tmp/pip-pip-egg-info-l2nzkrbz/zmes_hook_helpers.egg-info/top_level.txt
  writing manifest file '/tmp/pip-pip-egg-info-l2nzkrbz/zmes_hook_helpers.egg-info/SOURCES.txt'
  reading manifest file '/tmp/pip-pip-egg-info-l2nzkrbz/zmes_hook_helpers.egg-info/SOURCES.txt'
  reading manifest template 'MANIFEST.in'
  writing manifest file '/tmp/pip-pip-egg-info-l2nzkrbz/zmes_hook_helpers.egg-info/SOURCES.txt'
  /usr/lib/python3/dist-packages/setuptools/dist.py:481: UserWarning: The version specified ('') is an invalid version, this may not work as expected with newer versions of setuptools, pip, and PyPI. Please see PEP 440 for more details.
    warnings.warn(
  Preparing metadata (setup.py) ... done
Requirement already satisfied: Pillow in /usr/local/lib/python3.8/dist-packages (from zmes-hook-helpers==0.0.0) (8.4.0)
Requirement already satisfied: Shapely in /usr/local/lib/python3.8/dist-packages (from zmes-hook-helpers==0.0.0) (1.8.0)
Requirement already satisfied: configupdater in /usr/local/lib/python3.8/dist-packages (from zmes-hook-helpers==0.0.0) (3.0.1)
Requirement already satisfied: future in /usr/local/lib/python3.8/dist-packages (from zmes-hook-helpers==0.0.0) (0.18.2)
Requirement already satisfied: imageio in /usr/local/lib/python3.8/dist-packages (from zmes-hook-helpers==0.0.0) (2.10.2)
Requirement already satisfied: imageio-ffmpeg in /usr/local/lib/python3.8/dist-packages (from zmes-hook-helpers==0.0.0) (0.4.5)
Requirement already satisfied: imutils in /usr/local/lib/python3.8/dist-packages (from zmes-hook-helpers==0.0.0) (0.5.4)
Requirement already satisfied: numpy in /usr/local/lib/python3.8/dist-packages (from zmes-hook-helpers==0.0.0) (1.21.4)
Requirement already satisfied: pygifsicle in /usr/local/lib/python3.8/dist-packages (from zmes-hook-helpers==0.0.0) (1.0.5)
Collecting pyzm>=0.3.56
  Using cached pyzm-0.3.56-py3-none-any.whl
Requirement already satisfied: requests in /usr/lib/python3/dist-packages (from zmes-hook-helpers==0.0.0) (2.22.0)
Requirement already satisfied: scikit-learn in /usr/local/lib/python3.8/dist-packages (from zmes-hook-helpers==0.0.0) (1.0.1)
Requirement already satisfied: dateparser>=1.0.0 in /usr/local/lib/python3.8/dist-packages (from pyzm>=0.3.56->zmes-hook-helpers==0.0.0) (1.1.0)
Requirement already satisfied: mysql-connector-python>=8.0.16 in /usr/local/lib/python3.8/dist-packages (from pyzm>=0.3.56->zmes-hook-helpers==0.0.0) (8.0.27)
Requirement already satisfied: portalocker>=2.3.0 in /usr/local/lib/python3.8/dist-packages (from pyzm>=0.3.56->zmes-hook-helpers==0.0.0) (2.3.2)
Requirement already satisfied: websocket-client>=0.57.0 in /usr/local/lib/python3.8/dist-packages (from pyzm>=0.3.56->zmes-hook-helpers==0.0.0) (1.2.1)
Requirement already satisfied: progressbar2>=3.53.1 in /usr/local/lib/python3.8/dist-packages (from pyzm>=0.3.56->zmes-hook-helpers==0.0.0) (3.55.0)
Requirement already satisfied: SQLAlchemy<1.4.0,>=1.3.20 in /usr/local/lib/python3.8/dist-packages (from pyzm>=0.3.56->zmes-hook-helpers==0.0.0) (1.3.24)
Requirement already satisfied: psutil>=5.7.3 in /usr/local/lib/python3.8/dist-packages (from pyzm>=0.3.56->zmes-hook-helpers==0.0.0) (5.8.0)
Requirement already satisfied: python-dotenv in /usr/local/lib/python3.8/dist-packages (from pyzm>=0.3.56->zmes-hook-helpers==0.0.0) (0.19.1)
Requirement already satisfied: scipy>=1.1.0 in /usr/local/lib/python3.8/dist-packages (from scikit-learn->zmes-hook-helpers==0.0.0) (1.7.1)
Requirement already satisfied: threadpoolctl>=2.0.0 in /usr/local/lib/python3.8/dist-packages (from scikit-learn->zmes-hook-helpers==0.0.0) (3.0.0)
Requirement already satisfied: joblib>=0.11 in /usr/local/lib/python3.8/dist-packages (from scikit-learn->zmes-hook-helpers==0.0.0) (1.1.0)
Requirement already satisfied: python-dateutil in /usr/lib/python3/dist-packages (from dateparser>=1.0.0->pyzm>=0.3.56->zmes-hook-helpers==0.0.0) (2.7.3)
Requirement already satisfied: pytz in /usr/lib/python3/dist-packages (from dateparser>=1.0.0->pyzm>=0.3.56->zmes-hook-helpers==0.0.0) (2019.3)
Requirement already satisfied: tzlocal in /usr/local/lib/python3.8/dist-packages (from dateparser>=1.0.0->pyzm>=0.3.56->zmes-hook-helpers==0.0.0) (4.1)
Requirement already satisfied: regex!=2019.02.19,!=2021.8.27 in /usr/local/lib/python3.8/dist-packages (from dateparser>=1.0.0->pyzm>=0.3.56->zmes-hook-helpers==0.0.0) (2021.11.2)
Requirement already satisfied: protobuf>=3.0.0 in /usr/lib/python3/dist-packages (from mysql-connector-python>=8.0.16->pyzm>=0.3.56->zmes-hook-helpers==0.0.0) (3.6.1)
Requirement already satisfied: python-utils>=2.3.0 in /usr/local/lib/python3.8/dist-packages (from progressbar2>=3.53.1->pyzm>=0.3.56->zmes-hook-helpers==0.0.0) (2.5.6)
Requirement already satisfied: six in /usr/lib/python3/dist-packages (from progressbar2>=3.53.1->pyzm>=0.3.56->zmes-hook-helpers==0.0.0) (1.14.0)
Requirement already satisfied: backports.zoneinfo in /usr/local/lib/python3.8/dist-packages (from tzlocal->dateparser>=1.0.0->pyzm>=0.3.56->zmes-hook-helpers==0.0.0) (0.2.1)
Requirement already satisfied: pytz-deprecation-shim in /usr/local/lib/python3.8/dist-packages (from tzlocal->dateparser>=1.0.0->pyzm>=0.3.56->zmes-hook-helpers==0.0.0) (0.1.0.post0)
Requirement already satisfied: tzdata in /usr/local/lib/python3.8/dist-packages (from pytz-deprecation-shim->tzlocal->dateparser>=1.0.0->pyzm>=0.3.56->zmes-hook-helpers==0.0.0) (2021.5)
Building wheels for collected packages: zmes-hook-helpers
  Running command /usr/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/root/zmeventnotification/hook/setup.py'"'"'; __file__='"'"'/root/zmeventnotification/hook/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-nwh82ihj
  VERBOSE: Reading /root/zmeventnotification/hook/zmes_hook_helpers/__init__.py
  VERBOSE: version_file is __version__ = ""
  VERSION=__version__

  /usr/lib/python3/dist-packages/setuptools/dist.py:481: UserWarning: The version specified ('') is an invalid version, this may not work as expected with newer versions of setuptools, pip, and PyPI. Please see PEP 440 for more details.
    warnings.warn(
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib
  creating build/lib/zmes_hook_helpers
  copying zmes_hook_helpers/__init__.py -> build/lib/zmes_hook_helpers
  copying zmes_hook_helpers/common_params.py -> build/lib/zmes_hook_helpers
  copying zmes_hook_helpers/log.py -> build/lib/zmes_hook_helpers
  copying zmes_hook_helpers/image_manip.py -> build/lib/zmes_hook_helpers
  copying zmes_hook_helpers/apigw.py -> build/lib/zmes_hook_helpers
  copying zmes_hook_helpers/utils.py -> build/lib/zmes_hook_helpers
  installing to build/bdist.linux-x86_64/wheel
  running install
  running install_lib
  creating build/bdist.linux-x86_64
  creating build/bdist.linux-x86_64/wheel
  creating build/bdist.linux-x86_64/wheel/zmes_hook_helpers
  copying build/lib/zmes_hook_helpers/utils.py -> build/bdist.linux-x86_64/wheel/zmes_hook_helpers
  copying build/lib/zmes_hook_helpers/common_params.py -> build/bdist.linux-x86_64/wheel/zmes_hook_helpers
  copying build/lib/zmes_hook_helpers/apigw.py -> build/bdist.linux-x86_64/wheel/zmes_hook_helpers
  copying build/lib/zmes_hook_helpers/__init__.py -> build/bdist.linux-x86_64/wheel/zmes_hook_helpers
  copying build/lib/zmes_hook_helpers/image_manip.py -> build/bdist.linux-x86_64/wheel/zmes_hook_helpers
  copying build/lib/zmes_hook_helpers/log.py -> build/bdist.linux-x86_64/wheel/zmes_hook_helpers
  running install_egg_info
  running egg_info
  creating zmes_hook_helpers.egg-info
  writing zmes_hook_helpers.egg-info/PKG-INFO
  writing dependency_links to zmes_hook_helpers.egg-info/dependency_links.txt
  writing requirements to zmes_hook_helpers.egg-info/requires.txt
  writing top-level names to zmes_hook_helpers.egg-info/top_level.txt
  writing manifest file 'zmes_hook_helpers.egg-info/SOURCES.txt'
  reading manifest file 'zmes_hook_helpers.egg-info/SOURCES.txt'
  reading manifest template 'MANIFEST.in'
  writing manifest file 'zmes_hook_helpers.egg-info/SOURCES.txt'
  Copying zmes_hook_helpers.egg-info to build/bdist.linux-x86_64/wheel/zmes_hook_helpers-0.0.0.egg-info
  running install_scripts
  adding license file "LICENSE" (matched pattern "LICEN[CS]E*")
  creating build/bdist.linux-x86_64/wheel/zmes_hook_helpers-0.0.0.dist-info/WHEEL
  creating '/tmp/pip-wheel-nwh82ihj/zmes_hook_helpers-0.0.0-py3-none-any.whl' and adding 'build/bdist.linux-x86_64/wheel' to it
  adding 'zmes_hook_helpers/__init__.py'
  adding 'zmes_hook_helpers/apigw.py'
  adding 'zmes_hook_helpers/common_params.py'
  adding 'zmes_hook_helpers/image_manip.py'
  adding 'zmes_hook_helpers/log.py'
  adding 'zmes_hook_helpers/utils.py'
  adding 'zmes_hook_helpers-0.0.0.dist-info/LICENSE'
  adding 'zmes_hook_helpers-0.0.0.dist-info/METADATA'
  adding 'zmes_hook_helpers-0.0.0.dist-info/WHEEL'
  adding 'zmes_hook_helpers-0.0.0.dist-info/top_level.txt'
  adding 'zmes_hook_helpers-0.0.0.dist-info/RECORD'
  removing build/bdist.linux-x86_64/wheel
  Building wheel for zmes-hook-helpers (setup.py) ... done
  Created wheel for zmes-hook-helpers: filename=zmes_hook_helpers-0.0.0-py3-none-any.whl size=13021 sha256=b7c1857e49d3476b334668a8ac721eb7f8dcbfecf07e43a67d69e6e6e0949146
  Stored in directory: /tmp/pip-ephem-wheel-cache-si3ifu4t/wheels/e9/9f/4a/99d8d2fb329de5fab6aea7f61623dfb63d09645ce460640ec6
Successfully built zmes-hook-helpers
Installing collected packages: pyzm, zmes-hook-helpers
Successfully installed pyzm-0.3.56 zmes-hook-helpers-0.0.0
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
Success:Done

    |-------------------------- NOTE -------------------------------------|

     Hooks are installed, but please make sure you have the right version
     of OpenCV installed. I recommend removing any pip packages you may
     have installed of opencv* and compiling OpenCV 4.4.x+ from source.
     See https://zmeventnotification.readthedocs.io/en/latest/guides/hooks.html#opencv-install

    |----------------------------------------------------------------------|

Installing package deps...
Installing gifsicle, if needed...


Install Hook Config [y/N]:y
Replacing Hook config file
Success:config copied
====> Remember to fill in the right values in the config files, or your system won't work! <=============
====> If you changed /etc/zm remember to fix  /var/lib/zmeventnotification/bin/zm_event_start.sh! <========


Creating a migrated objectconfig if required
Current version of file is 1.2
Nothing to migrate

*** Please remember to start the Event Server after this update ***

I modified the ini files to point to the correct locations again after reinstall

Output when running the command

Code: Select all

root@NVR:/etc/zm# sudo -u www-data /var/lib/zmeventnotification/bin/zm_detect.py --config /etc/zm/objectconfig.ini --debug --eventid 27  --monitorid 3 --eventpath=/tmp
INF [zmesdetect_m3] [Setting up signal handler for logs]
INF [zmesdetect_m3] [Switching global logger to ZMLog]
INF [zmesdetect_m3] [---------| app:6.1.28, pyzm:0.3.56, ES:6.1.28
 , OpenCV:4.5.4-dev|------------]
INF [zmesdetect_m3] [Reading config from: /etc/zm/objectconfig.ini]
INF [zmesdetect_m3] [Reading secrets from: /etc/zm/secrets.ini]
DBG2 [zmesdetect_m3] [Secret token found in config: !ML_USER]
DBG2 [zmesdetect_m3] [Secret token found in config: !ML_PASSWORD]
DBG2 [zmesdetect_m3] [Secret token found in config: !PLATEREC_ALPR_KEY]
DBG1 [zmesdetect_m3] [allowing self-signed certs to work...]
DBG2 [zmesdetect_m3] [Now checking for monitor overrides]
DBG3 [zmesdetect_m3] [Finally, doing parameter substitution]
INF [zmesdetect_m3] [Importing local classes for Object/Face]
INF [zmesdetect_m3] [Connecting with ZM APIs]
DBG2 [zmesdetect_m3] [API SSL certificate check has been disbled]
DBG1 [zmesdetect_m3] [using username/password for login]
DBG2 [zmesdetect_m3] [Using new token API]
DBG1 [zmesdetect_m3] [Access token expires on:2021-11-05 15:11:35.738630 [7200s]]
DBG1 [zmesdetect_m3] [Refresh token expires on:2021-11-06 13:11:35.739282 [86400s]]
DBG2 [zmesdetect_m3] [using ml_sequence]
DBG2 [zmesdetect_m3] [using stream_sequence]
DBG1 [zmesdetect_m3] [Resetting models, will be loaded on next run]
DBG3 [zmesdetect_m3] [Using automatic locking as we are switching between models]
DBG2 [zmesdetect_m3] [Media get SSL certificate check has been disbled]
DBG2 [zmesdetect_m3] [Using URL 27 for stream]
DBG2 [zmesdetect_m3] [We will only process frames: ['snapshot', 'alarm']]
DBG2 [zmesdetect_m3] [No need to start streams, we are picking images from https://example.com/zm/index.php?view=image&eid=27]
DBG3 [zmesdetect_m3] [Reading https://example.com/zm/index.php?view=image&eid=27&fid=snapshot]
DBG3 [zmesdetect_m3] [No need to relogin as access token still has 119.99941296666665 minutes remaining]
DBG3 [zmesdetect_m3] [make_request called with url=https://example.com/zm/index.php?view=image&eid=27&fid=snapshot payload={} type=get query={'token': 'removed'}]
DBG1 [zmesdetect_m3] [perf: Starting for frame:snapshot]
DBG1 [zmesdetect_m3] [Sequence of detection types to execute: ['object', 'face', 'alpr']]
DBG1 [zmesdetect_m3] [============ Frame: snapshot Running object detection type in sequence ==================]
DBG2 [zmesdetect_m3] [Skipping TPU object detection as it is disabled]
DBG2 [zmesdetect_m3] [Loading sequence: YoloV4 GPU/CPU]
DBG2 [zmesdetect_m3] [Initializing model  type:object with options:{'name': 'YoloV4 GPU/CPU', 'enabled': 'yes', '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'}]
DBG2 [zmesdetect_m3] [portalock: max:1, name:pyzm_uid33_gpu_lock, timeout:100]
DBG3 [zmesdetect_m3] [object has a same_model_sequence strategy of first]
DBG1 [zmesdetect_m3] [--------- Frame:snapshot Running variation: #1 -------------]
DBG2 [zmesdetect_m3] [detect extracted image dimensions as: 800wx450h]
DBG2 [zmesdetect_m3] [Waiting for pyzm_uid33_gpu_lock portalock...]
DBG2 [zmesdetect_m3] [Got pyzm_uid33_gpu_lock portalock]
DBG1 [zmesdetect_m3] [|--------- Loading "YoloV4 GPU/CPU" model from disk -------------|]
DBG1 [zmesdetect_m3] [perf: processor:gpu Yolo initialization (loading /var/lib/zmeventnotification/models/yolov4/yolov4.weights model from disk) took: 155.19 ms]
DBG2 [zmesdetect_m3] [Setting CUDA backend for OpenCV]
DBG3 [zmesdetect_m3] [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]
DBG1 [zmesdetect_m3] [|---------- YOLO (input image: 800w*450h, model resize dimensions: 416w*416h) ----------|]
DBG2 [zmesdetect_m3] [Released pyzm_uid33_gpu_lock portalock]
11/05/21 13:11:36 zmesdetect_m3[8812] ERR detect_sequence.py:713 [Error running model: invalid index to scalar variable.]

DBG2 [zmesdetect_m3] [Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/pyzm/ml/detect_sequence.py", line 710, in detect_stream
    _b,_l,_c,_m = m.detect(image=frame)
  File "/usr/local/lib/python3.8/dist-packages/pyzm/ml/object.py", line 65, in detect
    b,l,c,_model_names = self.model.detect(image)
  File "/usr/local/lib/python3.8/dist-packages/pyzm/ml/yolo.py", line 168, in detect
    ln = self.get_output_layers()
  File "/usr/local/lib/python3.8/dist-packages/pyzm/ml/yolo.py", line 129, in get_output_layers
    output_layers = [
  File "/usr/local/lib/python3.8/dist-packages/pyzm/ml/yolo.py", line 130, in <listcomp>
    layer_names[i[0] - 1] for i in self.net.getUnconnectedOutLayers()
IndexError: invalid index to scalar variable.
]
DBG2 [zmesdetect_m3] [We did not find any object matches in frame: snapshot]
DBG1 [zmesdetect_m3] [============ Frame: snapshot Running face detection type in sequence ==================]
DBG2 [zmesdetect_m3] [Skipping TPU face detection as it is disabled]
DBG1 [zmesdetect_m3] [perf: processor:cpu Face Recognition library load time took: 0.01 ms ]
DBG1 [zmesdetect_m3] [Initializing face recognition with model:cnn upsample:1, jitters:0]
DBG2 [zmesdetect_m3] [portalock: max:3, name:pyzm_uid33_cpu_lock, timeout:100]
DBG1 [zmesdetect_m3] [pre-trained faces found, using that. If you want to add new images, remove: /var/lib/zmeventnotification/known_faces/faces.dat]
DBG3 [zmesdetect_m3] [face has a same_model_sequence strategy of union]
DBG1 [zmesdetect_m3] [--------- Frame:snapshot Running variation: #1 -------------]
DBG1 [zmesdetect_m3] [|---------- Dlib Face recognition (input image: 800w*450h) ----------|]
DBG3 [zmesdetect_m3] [Face options={'name': 'DLIB based face recognition', 'enabled': 'yes', 'save_unknown_faces': 'yes', 'save_unknown_faces_leeway_pixels': 100, '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': '1', 'face_upsample_times': '1', 'gpu_max_processes': 1, 'gpu_max_lock_wait': 100, 'cpu_max_processes': 3, 'cpu_max_lock_wait': 100, 'max_size': 800, 'disable_locks': 'no'}]
DBG2 [zmesdetect_m3] [Waiting for pyzm_uid33_cpu_lock portalock...]
DBG2 [zmesdetect_m3] [Got pyzm_uid33_cpu_lock lock...]
DBG1 [zmesdetect_m3] [perf: processor:cpu Finding faces took 5685.84 ms]
DBG1 [zmesdetect_m3] [Released pyzm_uid33_cpu_lock portalock]
DBG1 [zmesdetect_m3] [perf: processor:cpu Computing face recognition distances took 0.89 ms]
DBG2 [zmesdetect_m3] [This model iteration inside face found: labels: [],conf:[]]
DBG2 [zmesdetect_m3] [Max object size found to be: 90%]
DBG2 [zmesdetect_m3] [Converted 90% to 324000.0]
DBG2 [zmesdetect_m3] [No polygons, adding full image polygon: {'name': 'full_image', 'value': [(0, 0), (2304, 0), (2304, 1296), (0, 1296)], 'pattern': None}]
DBG3 [zmesdetect_m3] [resized polygons x=0.3472222222222222/y=0.3472222222222222: [{'name': 'full_image', 'value': [(0, 0), (800, 0), (800, 450), (0, 450)], 'pattern': None}]]
DBG2 [zmesdetect_m3] [We did not find any face matches in frame: snapshot]
DBG1 [zmesdetect_m3] [============ Frame: snapshot Running alpr detection type in sequence ==================]
DBG2 [zmesdetect_m3] [Making sure we have matched one of ['car', 'motorbike', 'bus', 'truck', 'boat'] in [] before we proceed]
DBG1 [zmesdetect_m3] [Did not find pre existing labels, not running detection type]
DBG3 [zmesdetect_m3] [Reading https://example.com/zm/index.php?view=image&eid=27&fid=alarm]
DBG3 [zmesdetect_m3] [No need to relogin as access token still has 119.86104918333334 minutes remaining]
DBG3 [zmesdetect_m3] [make_request called with url=https://example.com/zm/index.php?view=image&eid=27&fid=alarm payload={} type=get query={'token': 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJab25lTWluZGVyIiwiaWF0IjoxNjM2MTMyMjk1LCJleHAiOjE2MzYxMzk0OTUsInVzZXIiOiJhZG1pbiIsInR5cGUiOiJhY2Nlc3MifQ.grhIeOWutYAygDjYgkc-xfjC2hU3UEBr-KBi0-7DN0w'}]
DBG1 [zmesdetect_m3] [perf: Starting for frame:alarm]
DBG1 [zmesdetect_m3] [Sequence of detection types to execute: ['object', 'face', 'alpr']]
DBG1 [zmesdetect_m3] [============ Frame: alarm Running object detection type in sequence ==================]
DBG3 [zmesdetect_m3] [object has a same_model_sequence strategy of first]
DBG1 [zmesdetect_m3] [--------- Frame:alarm Running variation: #1 -------------]
DBG2 [zmesdetect_m3] [detect extracted image dimensions as: 800wx450h]
DBG2 [zmesdetect_m3] [Waiting for pyzm_uid33_gpu_lock portalock...]
DBG2 [zmesdetect_m3] [Got pyzm_uid33_gpu_lock portalock]
DBG1 [zmesdetect_m3] [|---------- YOLO (input image: 800w*450h, model resize dimensions: 416w*416h) ----------|]
DBG2 [zmesdetect_m3] [Released pyzm_uid33_gpu_lock portalock]
11/05/21 13:11:44 zmesdetect_m3[8812] ERR detect_sequence.py:713 [Error running model: invalid index to scalar variable.]

DBG2 [zmesdetect_m3] [Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/pyzm/ml/detect_sequence.py", line 710, in detect_stream
    _b,_l,_c,_m = m.detect(image=frame)
  File "/usr/local/lib/python3.8/dist-packages/pyzm/ml/object.py", line 65, in detect
    b,l,c,_model_names = self.model.detect(image)
  File "/usr/local/lib/python3.8/dist-packages/pyzm/ml/yolo.py", line 168, in detect
    ln = self.get_output_layers()
  File "/usr/local/lib/python3.8/dist-packages/pyzm/ml/yolo.py", line 129, in get_output_layers
    output_layers = [
  File "/usr/local/lib/python3.8/dist-packages/pyzm/ml/yolo.py", line 130, in <listcomp>
    layer_names[i[0] - 1] for i in self.net.getUnconnectedOutLayers()
IndexError: invalid index to scalar variable.
]
DBG2 [zmesdetect_m3] [We did not find any object matches in frame: alarm]
DBG1 [zmesdetect_m3] [============ Frame: alarm Running face detection type in sequence ==================]
DBG3 [zmesdetect_m3] [face has a same_model_sequence strategy of union]
DBG1 [zmesdetect_m3] [--------- Frame:alarm Running variation: #1 -------------]
DBG1 [zmesdetect_m3] [|---------- Dlib Face recognition (input image: 800w*450h) ----------|]
DBG3 [zmesdetect_m3] [Face options={'name': 'DLIB based face recognition', 'enabled': 'yes', 'save_unknown_faces': 'yes', 'save_unknown_faces_leeway_pixels': 100, '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': '1', 'face_upsample_times': '1', 'gpu_max_processes': 1, 'gpu_max_lock_wait': 100, 'cpu_max_processes': 3, 'cpu_max_lock_wait': 100, 'max_size': 800, 'disable_locks': 'no'}]
DBG2 [zmesdetect_m3] [Waiting for pyzm_uid33_cpu_lock portalock...]
DBG2 [zmesdetect_m3] [Got pyzm_uid33_cpu_lock lock...]
DBG1 [zmesdetect_m3] [perf: processor:cpu Finding faces took 5741.13 ms]
DBG1 [zmesdetect_m3] [Released pyzm_uid33_cpu_lock portalock]
DBG1 [zmesdetect_m3] [perf: processor:cpu Computing face recognition distances took 1.01 ms]
DBG2 [zmesdetect_m3] [This model iteration inside face found: labels: [],conf:[]]
DBG2 [zmesdetect_m3] [Max object size found to be: 90%]
DBG2 [zmesdetect_m3] [Converted 90% to 324000.0]
DBG2 [zmesdetect_m3] [We did not find any face matches in frame: alarm]
DBG1 [zmesdetect_m3] [============ Frame: alarm Running alpr detection type in sequence ==================]
DBG2 [zmesdetect_m3] [Making sure we have matched one of ['car', 'motorbike', 'bus', 'truck', 'boat'] in [] before we proceed]
DBG1 [zmesdetect_m3] [Did not find pre existing labels, not running detection type]
DBG1 [zmesdetect_m3] [perf: TOTAL detection sequence (with image loads) took: 14461.90 ms  to process 27]
DBG1 [zmesdetect_m3] [Closing logs]
tsp84
Posts: 227
Joined: Thu Dec 24, 2020 4:04 am

Re: Event Server Object Detection not working

Post by tsp84 »

Try this command -> you might have a different version of python so you might have to change the Python3.8 part of the dir to your version of python

Code: Select all

grep -nr '.* self.is_get_unconnected_api_list.*' /usr/local/lib/python3.8/dist-packages/pyzm/ml
Post the output, it will let us know if your pyzm has the updated yolo.py. You may have to clone the pyzm repo and install pyzm from there if pip doesn't have the new pyzm propagated yet.

The easier option is to go to the new yolo.py and display it as a RAW type so you can copy and paste. Remove the old yolo.py, create a new one and paste the code into it. Done.

Select all and copy the new yolo.py displayed RAW -> https://raw.githubusercontent.com/ZoneM ... ml/yolo.py

Code: Select all


sudo rm /usr/local/lib/python3.8/dist-packages/pyzm/ml/yolo.py
sudo nano /usr/local/lib/python3.8/dist-packages/pyzm/ml/yolo.py
# If using ssh or in a terminal use CTRL+SHIFT+V to paste the buffer into nano
CTRL+S, CTRL+X
jrosetto
Posts: 15
Joined: Fri Nov 05, 2021 4:44 pm

Re: Event Server Object Detection not working

Post by jrosetto »

Code: Select all

root@NVR:/etc/zm# grep -nr '.* self.is_get_unconnected_api_list.*' /usr/local/lib/python3.8/dist-packages/pyzm/ml
/usr/local/lib/python3.8/dist-packages/pyzm/ml/yolo.py:31:        self.is_get_unconnected_api_list = False
/usr/local/lib/python3.8/dist-packages/pyzm/ml/yolo.py:99:            self.is_get_unconnected_api_list = True
/usr/local/lib/python3.8/dist-packages/pyzm/ml/yolo.py:124:        if self.is_get_unconnected_api_list:
/usr/local/lib/python3.8/dist-packages/pyzm/ml/yolo.py:229:            if not self.is_get_unconnected_api_list:
root@NVR:/etc/zm# sudo rm /usr/local/lib/python3.8/dist-packages/pyzm/ml/yolo.py
root@NVR:/etc/zm# sudo nano /usr/local/lib/python3.8/dist-packages/pyzm/ml/yolo.py
root@NVR:/etc/zm# grep -nr '.* self.is_get_unconnected_api_list.*' /usr/local/lib/python3.8/dist-packages/pyzm/ml
/usr/local/lib/python3.8/dist-packages/pyzm/ml/yolo.py:31:        self.is_get_unconnected_api_list = False
/usr/local/lib/python3.8/dist-packages/pyzm/ml/yolo.py:99:            self.is_get_unconnected_api_list = True
/usr/local/lib/python3.8/dist-packages/pyzm/ml/yolo.py:124:        if self.is_get_unconnected_api_list:
/usr/local/lib/python3.8/dist-packages/pyzm/ml/yolo.py:229:            if not self.is_get_unconnected_api_list:
Thank you for the quick responses. Ran grep on the original file, removed it, pasted the raw dataset, and ran the grep command again for comparison. Same error message.
tsp84
Posts: 227
Joined: Thu Dec 24, 2020 4:04 am

Re: Event Server Object Detection not working

Post by tsp84 »

Ok so OpenCV 4.5.4-dev must report the patch weordy for the new code to not detect to use the new API non nested logic.

Try this ->

Code: Select all

python3
# The python3 interpreter will open

>>> import cv2

>>> cv2.__version__

>>> exit()
Post the output of the cv2 version so pliable pixels can update the version catching logic.
jrosetto
Posts: 15
Joined: Fri Nov 05, 2021 4:44 pm

Re: Event Server Object Detection not working

Post by jrosetto »

root@NVR:/etc/zm# python3
Python 3.8.10 (default, Sep 28 2021, 16:10:42)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> cv2.__version__
'4.2.0'
tsp84
Posts: 227
Joined: Thu Dec 24, 2020 4:04 am

Re: Event Server Object Detection not working

Post by tsp84 »

We have an issue here. ZMES is reporting using 4.5.4-dev which means I think you have pip3 package of opencv installed.

Code: Select all

# If you made a venv to do all the opencv stuff activate it
pip3 list | grep 'opencv.*'
pip list | grep 'opencv.*'

# Then do system wide
sudo pip3 list | grep 'opencv.*'
sudo pip list | grep 'opencv.*'

Edit: Here is a link to an article I wrote to set up OpenCV 4.5.4 with GPU. In that article, I install my own forked version of ZMES. Instead of following that part just review the pertinent parts of where I am compiling OpenCV 4.5.4. Article -> https://medium.com/@baudneo/install-zm- ... 76edd5d619


Review the NVIDIA drivers and CUDA part and then the OpenCV building section. If you use a newer version of CUDA you don't have to do the whole GCC-6 part. The GCC-6 part is specific to using older versions of CUDA like 10.2.
Last edited by tsp84 on Fri Nov 05, 2021 7:24 pm, edited 1 time in total.
jrosetto
Posts: 15
Joined: Fri Nov 05, 2021 4:44 pm

Re: Event Server Object Detection not working

Post by jrosetto »

You were definitely on the money with that one. I am missing a bunch of dependencies before I can build the newer version and it is going to take some time. I'm half tempted to start over using your tutorial because it seems to be more complete than the one I followed initially. I'll report back after the weekend. Thanks for your help so far.
tsp84
Posts: 227
Joined: Thu Dec 24, 2020 4:04 am

Re: Event Server Object Detection not working

Post by tsp84 »

No problem if you get stuck just post and I will try and help you through it. The more people we get on board using this system the better for ZM and its community.
jrosetto
Posts: 15
Joined: Fri Nov 05, 2021 4:44 pm

Re: Event Server Object Detection not working

Post by jrosetto »

OK so I went ahead and did a clean install following your article and it definitely seems like I am making headway.

Code: Select all

root@NVR:/var/lib/zmeventnotification/bin# ./zm_detect.py --config /etc/zm/objectconfig.ini --eventid 1 --monitorid 1 --debug
11/08/21 14:11:34 zmesdetect_m1[100298] INF ZMLog.py:292 [Setting up signal handler for logs]

11/08/21 14:11:34 zmesdetect_m1[100298] INF ZMLog.py:301 [Switching global logger to ZMLog]

11/08/21 14:11:34 zmesdetect_m1[100298] INF zm_detect.py:284 [---------| app:6.1.28, pyzm:0.3.56, ES:6.1.28
 , OpenCV:4.5.4|------------]

11/08/21 14:11:34 zmesdetect_m1[100298] INF utils.py:405 [Reading config from: /etc/zm/objectconfig.ini]

11/08/21 14:11:34 zmesdetect_m1[100298] INF utils.py:410 [Reading secrets from: /etc/zm/secrets.ini]

11/08/21 14:11:34 zmesdetect_m1[100298] DBG2 utils.py:382 [Secret token found in config: !ML_USER]

11/08/21 14:11:34 zmesdetect_m1[100298] DBG2 utils.py:382 [Secret token found in config: !ML_PASSWORD]

11/08/21 14:11:34 zmesdetect_m1[100298] DBG2 utils.py:382 [Secret token found in config: !PLATEREC_ALPR_KEY]

11/08/21 14:11:34 zmesdetect_m1[100298] DBG1 utils.py:445 [allowing self-signed certs to work...]

11/08/21 14:11:34 zmesdetect_m1[100298] DBG2 utils.py:455 [Now checking for monitor overrides]

11/08/21 14:11:34 zmesdetect_m1[100298] DBG3 utils.py:522 [Finally, doing parameter substitution]

11/08/21 14:11:34 zmesdetect_m1[100298] INF zm_detect.py:309 [Importing local classes for Object/Face]

11/08/21 14:11:35 zmesdetect_m1[100298] INF zm_detect.py:334 [Connecting with ZM APIs]

11/08/21 14:11:35 zmesdetect_m1[100298] DBG2 api.py:72 [API SSL certificate check has been disbled]

11/08/21 14:11:35 zmesdetect_m1[100298] DBG1 api.py:181 [using username/password for login]

11/08/21 14:11:35 zmesdetect_m1[100298] DBG2 api.py:210 [Using new token API]

11/08/21 14:11:35 zmesdetect_m1[100298] DBG1 api.py:217 [Access token expires on:2021-11-08 16:11:35.881469 [7200s]]

11/08/21 14:11:35 zmesdetect_m1[100298] DBG1 api.py:221 [Refresh token expires on:2021-11-09 14:11:35.882074 [86400s]]

11/08/21 14:11:35 zmesdetect_m1[100298] DBG2 zm_detect.py:342 [using ml_sequence]

11/08/21 14:11:35 zmesdetect_m1[100298] DBG2 zm_detect.py:354 [using stream_sequence]

11/08/21 14:11:35 zmesdetect_m1[100298] DBG1 detect_sequence.py:160 [Resetting models, will be loaded on next run]

11/08/21 14:11:35 zmesdetect_m1[100298] DBG3 detect_sequence.py:634 [Using automatic locking as we are switching between models]

11/08/21 14:11:35 zmesdetect_m1[100298] DBG2 Media.py:51 [Media get SSL certificate check has been disbled]

11/08/21 14:11:35 zmesdetect_m1[100298] DBG2 Media.py:99 [Using URL 1 for stream]

11/08/21 14:11:35 zmesdetect_m1[100298] DBG2 Media.py:114 [We will only process frames: ['snapshot', 'alarm']]

11/08/21 14:11:35 zmesdetect_m1[100298] DBG2 Media.py:137 [No need to start streams, we are picking images from https://example.com/zm/index.php?view=image&eid=1]

11/08/21 14:11:35 zmesdetect_m1[100298] DBG3 Media.py:271 [Reading https://example.com/zm/index.php?view=image&eid=1&fid=snapshot]

11/08/21 14:11:35 zmesdetect_m1[100298] DBG3 api.py:144 [No need to relogin as access token still has 119.99983278333335 minutes remaining]

11/08/21 14:11:35 zmesdetect_m1[100298] DBG3 api.py:272 [make_request called with url=https://example.com/zm/index.php?view=image&eid=1&fid=snapshot payload={} type=get query={'token': 'fake token'}]

11/08/21 14:11:35 zmesdetect_m1[100298] DBG1 detect_sequence.py:654 [perf: Starting for frame:snapshot]

11/08/21 14:11:35 zmesdetect_m1[100298] DBG1 detect_sequence.py:664 [Sequence of detection types to execute: ['object', 'face', 'alpr']]

11/08/21 14:11:35 zmesdetect_m1[100298] DBG1 detect_sequence.py:669 [============ Frame: snapshot Running object detection type in sequence ==================]

11/08/21 14:11:35 zmesdetect_m1[100298] DBG2 detect_sequence.py:174 [Skipping TPU object detection as it is disabled]

11/08/21 14:11:35 zmesdetect_m1[100298] DBG2 detect_sequence.py:178 [Loading sequence: YoloV4 GPU/CPU]

11/08/21 14:11:35 zmesdetect_m1[100298] DBG2 detect_sequence.py:179 [Initializing model  type:object with options:{'name': 'YoloV4 GPU/CPU', 'enabled': 'yes', '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'}]

11/08/21 14:11:35 zmesdetect_m1[100298] DBG2 yolo.py:38 [portalock: max:1, name:pyzm_uid0_gpu_lock, timeout:100]

11/08/21 14:11:35 zmesdetect_m1[100298] DBG3 detect_sequence.py:689 [object has a same_model_sequence strategy of first]

11/08/21 14:11:35 zmesdetect_m1[100298] DBG1 detect_sequence.py:701 [--------- Frame:snapshot Running variation: #1 -------------]

11/08/21 14:11:35 zmesdetect_m1[100298] DBG2 yolo.py:136 [detect extracted image dimensions as: 800wx600h]

11/08/21 14:11:35 zmesdetect_m1[100298] DBG2 yolo.py:50 [Waiting for pyzm_uid0_gpu_lock portalock...]

11/08/21 14:11:35 zmesdetect_m1[100298] DBG2 yolo.py:52 [Got pyzm_uid0_gpu_lock portalock]

11/08/21 14:11:35 zmesdetect_m1[100298] DBG1 yolo.py:85 [|--------- Loading "YoloV4 GPU/CPU" model from disk -------------|]

11/08/21 14:11:36 zmesdetect_m1[100298] DBG1 yolo.py:98 [You are using OpenCV >= 4.5.4, making sure we fix getUnconnectedOutLayers() API]

11/08/21 14:11:36 zmesdetect_m1[100298] DBG1 yolo.py:100 [perf: processor:gpu Yolo initialization (loading /var/lib/zmeventnotification/models/yolov4/yolov4.weights model from disk) took: 487.49 ms]

11/08/21 14:11:36 zmesdetect_m1[100298] DBG2 yolo.py:115 [Setting CUDA backend for OpenCV]

11/08/21 14:11:36 zmesdetect_m1[100298] DBG3 yolo.py:116 [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]

11/08/21 14:11:36 zmesdetect_m1[100298] DBG1 yolo.py:160 [|---------- YOLO (input image: 800w*600h, model resize dimensions: 416w*416h) ----------|]

11/08/21 14:11:37 zmesdetect_m1[100298] DBG2 yolo.py:68 [Released pyzm_uid0_gpu_lock portalock]

11/08/21 14:11:37 zmesdetect_m1[100298] ERR detect_sequence.py:713 [Error running model: OpenCV(4.5.4) /root/opencv-4.5.4/modules/dnn/src/layers/../cuda4dnn/primitives/../csl/cudnn/convolution.hpp:420: error: (-217:Gpu API call) CUDNN_STATUS_EXECUTION_FAILED in function 'convolve'
]

11/08/21 14:11:37 zmesdetect_m1[100298] DBG2 detect_sequence.py:714 [Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/pyzm/ml/detect_sequence.py", line 710, in detect_stream
    _b,_l,_c,_m = m.detect(image=frame)
  File "/usr/local/lib/python3.8/dist-packages/pyzm/ml/object.py", line 65, in detect
    b,l,c,_model_names = self.model.detect(image)
  File "/usr/local/lib/python3.8/dist-packages/pyzm/ml/yolo.py", line 175, in detect
    outs = self.net.forward(ln)
cv2.error: OpenCV(4.5.4) /root/opencv-4.5.4/modules/dnn/src/layers/../cuda4dnn/primitives/../csl/cudnn/convolution.hpp:420: error: (-217:Gpu API call) CUDNN_STATUS_EXECUTION_FAILED in function 'convolve'

]

11/08/21 14:11:37 zmesdetect_m1[100298] DBG2 detect_sequence.py:770 [We did not find any object matches in frame: snapshot]

11/08/21 14:11:37 zmesdetect_m1[100298] DBG1 detect_sequence.py:669 [============ Frame: snapshot Running face detection type in sequence ==================]

11/08/21 14:11:37 zmesdetect_m1[100298] DBG2 detect_sequence.py:190 [Skipping TPU face detection as it is disabled]

11/08/21 14:11:40 zmesdetect_m1[100298] DBG1 face_dlib.py:42 [perf: processor:gpu Face Recognition library load time took: 0.00 ms ]

11/08/21 14:11:40 zmesdetect_m1[100298] DBG1 face_dlib.py:50 [Initializing face recognition with model:cnn upsample:1, jitters:0]

11/08/21 14:11:40 zmesdetect_m1[100298] DBG2 face_dlib.py:73 [portalock: max:1, name:pyzm_uid0_gpu_lock, timeout:100]

11/08/21 14:11:40 zmesdetect_m1[100298] DBG1 face_dlib.py:97 [trained file not found, reading from images and doing training...]

11/08/21 14:11:40 zmesdetect_m1[100298] DBG1 face_dlib.py:100 [If you are using a GPU and run out of memory, do the training using zm_train_faces.py. In this case, other models like yolo may already take up a lot of GPU memory]

11/08/21 14:11:40 zmesdetect_m1[100298] ERR face_train_dlib.py:135 [No known faces found to train, encoding file not created]

11/08/21 14:11:40 zmesdetect_m1[100298] DBG1 face_train_dlib.py:152 [perf: Face Recognition training took: 11.14 ms]

11/08/21 14:11:40 zmesdetect_m1[100298] ERR face_dlib.py:110 [Error loading KNN model: [Errno 2] No such file or directory: '/var/lib/zmeventnotification/known_faces/faces.dat']

11/08/21 14:11:40 zmesdetect_m1[100298] DBG3 detect_sequence.py:689 [face has a same_model_sequence strategy of union]

11/08/21 14:11:40 zmesdetect_m1[100298] DBG1 detect_sequence.py:701 [--------- Frame:snapshot Running variation: #1 -------------]

11/08/21 14:11:40 zmesdetect_m1[100298] DBG1 face_dlib.py:164 [|---------- Dlib Face recognition (input image: 800w*600h) ----------|]

11/08/21 14:11:40 zmesdetect_m1[100298] DBG3 face_dlib.py:174 [Face options={'name': 'DLIB based face recognition', 'enabled': 'yes', 'save_unknown_faces': 'yes', 'save_unknown_faces_leeway_pixels': 100, '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': '1', 'face_upsample_times': '1', 'gpu_max_processes': 1, 'gpu_max_lock_wait': 100, 'cpu_max_processes': 3, 'cpu_max_lock_wait': 100, 'max_size': 800, 'disable_locks': 'no'}]

11/08/21 14:11:40 zmesdetect_m1[100298] DBG2 face_dlib.py:123 [Waiting for pyzm_uid0_gpu_lock portalock...]

11/08/21 14:11:40 zmesdetect_m1[100298] DBG2 face_dlib.py:125 [Got pyzm_uid0_gpu_lock lock...]

11/08/21 14:11:40 zmesdetect_m1[100298] ERR detect_sequence.py:713 [Error running model: Error while calling cudaOccupancyMaxPotentialBlockSize(&num_blocks,&num_threads,K) in file /tmp/pip-install-lq210re3/dlib_ac9deb2babba4252aa2ae20fb24a43ae/dlib/cuda/cuda_utils.h:164. code: 98, reason: invalid device function]

11/08/21 14:11:40 zmesdetect_m1[100298] DBG2 detect_sequence.py:714 [Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/pyzm/ml/detect_sequence.py", line 710, in detect_stream
    _b,_l,_c,_m = m.detect(image=frame)
  File "/usr/local/lib/python3.8/dist-packages/pyzm/ml/face.py", line 23, in detect
    return self.model.detect(image)
  File "/usr/local/lib/python3.8/dist-packages/pyzm/ml/face_dlib.py", line 200, in detect
    face_locations = face_recognition.face_locations(
  File "/usr/local/lib/python3.8/dist-packages/face_recognition/api.py", line 119, in face_locations
    return [_trim_css_to_bounds(_rect_to_css(face.rect), img.shape) for face in _raw_face_locations(img, number_of_times_to_upsample, "cnn")]
  File "/usr/local/lib/python3.8/dist-packages/face_recognition/api.py", line 103, in _raw_face_locations
    return cnn_face_detector(img, number_of_times_to_upsample)
RuntimeError: Error while calling cudaOccupancyMaxPotentialBlockSize(&num_blocks,&num_threads,K) in file /tmp/pip-install-lq210re3/dlib_ac9deb2babba4252aa2ae20fb24a43ae/dlib/cuda/cuda_utils.h:164. code: 98, reason: invalid device function
]

11/08/21 14:11:40 zmesdetect_m1[100298] DBG2 detect_sequence.py:770 [We did not find any face matches in frame: snapshot]

11/08/21 14:11:40 zmesdetect_m1[100298] DBG1 detect_sequence.py:669 [============ Frame: snapshot Running alpr detection type in sequence ==================]

11/08/21 14:11:40 zmesdetect_m1[100298] DBG2 detect_sequence.py:672 [Making sure we have matched one of ['car', 'motorbike', 'bus', 'truck', 'boat'] in [] before we proceed]

11/08/21 14:11:40 zmesdetect_m1[100298] DBG1 detect_sequence.py:674 [Did not find pre existing labels, not running detection type]

11/08/21 14:11:40 zmesdetect_m1[100298] DBG3 Media.py:271 [Reading https://example.com/zm/index.php?view=image&eid=1&fid=alarm]

11/08/21 14:11:40 zmesdetect_m1[100298] DBG3 api.py:144 [No need to relogin as access token still has 119.91868403333334 minutes remaining]

11/08/21 14:11:40 zmesdetect_m1[100298] DBG3 api.py:272 [make_request called with url=https://example.com/zm/index.php?view=image&eid=1&fid=alarm payload={} type=get query={'token': 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJab25lTWluZGVyIiwiaWF0IjoxNjM2Mzk4Njk1LCJleHAiOjE2MzY0MDU4OTUsInVzZXIiOiJqcm9zZXR0byIsInR5cGUiOiJhY2Nlc3MifQ.lgzpA9-6K61y9EG2OF4c02rMw6NZ318iV24Ib56-uNM'}]

11/08/21 14:11:40 zmesdetect_m1[100298] DBG1 detect_sequence.py:654 [perf: Starting for frame:alarm]

11/08/21 14:11:40 zmesdetect_m1[100298] DBG1 detect_sequence.py:664 [Sequence of detection types to execute: ['object', 'face', 'alpr']]

11/08/21 14:11:40 zmesdetect_m1[100298] DBG1 detect_sequence.py:669 [============ Frame: alarm Running object detection type in sequence ==================]

11/08/21 14:11:40 zmesdetect_m1[100298] DBG3 detect_sequence.py:689 [object has a same_model_sequence strategy of first]

11/08/21 14:11:40 zmesdetect_m1[100298] DBG1 detect_sequence.py:701 [--------- Frame:alarm Running variation: #1 -------------]

11/08/21 14:11:40 zmesdetect_m1[100298] DBG2 yolo.py:136 [detect extracted image dimensions as: 800wx600h]

11/08/21 14:11:40 zmesdetect_m1[100298] DBG2 yolo.py:50 [Waiting for pyzm_uid0_gpu_lock portalock...]

11/08/21 14:13:20 zmesdetect_m1[100298] ERR yolo.py:56 [Timeout waiting for pyzm_uid0_gpu_lock portalock for 100 seconds]

11/08/21 14:13:20 zmesdetect_m1[100298] ERR detect_sequence.py:713 [Error running model: Timeout waiting for pyzm_uid0_gpu_lock portalock for 100 seconds]

11/08/21 14:13:20 zmesdetect_m1[100298] DBG2 detect_sequence.py:714 [Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/pyzm/ml/yolo.py", line 51, in acquire_lock
    self.lock.acquire()
  File "/usr/local/lib/python3.8/dist-packages/portalocker/utils.py", line 410, in acquire
    raise exceptions.AlreadyLocked()
portalocker.exceptions.AlreadyLocked

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 710, in detect_stream
    _b,_l,_c,_m = m.detect(image=frame)
  File "/usr/local/lib/python3.8/dist-packages/pyzm/ml/object.py", line 65, in detect
    b,l,c,_model_names = self.model.detect(image)
  File "/usr/local/lib/python3.8/dist-packages/pyzm/ml/yolo.py", line 154, in detect
    self.acquire_lock()
  File "/usr/local/lib/python3.8/dist-packages/pyzm/ml/yolo.py", line 57, in acquire_lock
    raise ValueError ('Timeout waiting for {} portalock for {} seconds'.format(self.lock_name, self.lock_timeout))
ValueError: Timeout waiting for pyzm_uid0_gpu_lock portalock for 100 seconds
]

11/08/21 14:13:20 zmesdetect_m1[100298] DBG2 detect_sequence.py:770 [We did not find any object matches in frame: alarm]

11/08/21 14:13:20 zmesdetect_m1[100298] DBG1 detect_sequence.py:669 [============ Frame: alarm Running face detection type in sequence ==================]

11/08/21 14:13:20 zmesdetect_m1[100298] DBG3 detect_sequence.py:689 [face has a same_model_sequence strategy of union]

11/08/21 14:13:20 zmesdetect_m1[100298] DBG1 detect_sequence.py:701 [--------- Frame:alarm Running variation: #1 -------------]

11/08/21 14:13:20 zmesdetect_m1[100298] DBG1 face_dlib.py:164 [|---------- Dlib Face recognition (input image: 800w*600h) ----------|]

11/08/21 14:13:20 zmesdetect_m1[100298] DBG3 face_dlib.py:174 [Face options={'name': 'DLIB based face recognition', 'enabled': 'yes', 'save_unknown_faces': 'yes', 'save_unknown_faces_leeway_pixels': 100, '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': '1', 'face_upsample_times': '1', 'gpu_max_processes': 1, 'gpu_max_lock_wait': 100, 'cpu_max_processes': 3, 'cpu_max_lock_wait': 100, 'max_size': 800, 'disable_locks': 'no'}]

11/08/21 14:13:20 zmesdetect_m1[100298] DBG2 face_dlib.py:120 [pyzm_uid0_gpu_lock portalock already acquired]

11/08/21 14:13:20 zmesdetect_m1[100298] ERR detect_sequence.py:713 [Error running model: Error while calling cudaGetLastError() in file /tmp/pip-install-lq210re3/dlib_ac9deb2babba4252aa2ae20fb24a43ae/dlib/cuda/gpu_data.cpp:117. code: 98, reason: invalid device function]

11/08/21 14:13:20 zmesdetect_m1[100298] DBG2 detect_sequence.py:714 [Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/pyzm/ml/detect_sequence.py", line 710, in detect_stream
    _b,_l,_c,_m = m.detect(image=frame)
  File "/usr/local/lib/python3.8/dist-packages/pyzm/ml/face.py", line 23, in detect
    return self.model.detect(image)
  File "/usr/local/lib/python3.8/dist-packages/pyzm/ml/face_dlib.py", line 200, in detect
    face_locations = face_recognition.face_locations(
  File "/usr/local/lib/python3.8/dist-packages/face_recognition/api.py", line 119, in face_locations
    return [_trim_css_to_bounds(_rect_to_css(face.rect), img.shape) for face in _raw_face_locations(img, number_of_times_to_upsample, "cnn")]
  File "/usr/local/lib/python3.8/dist-packages/face_recognition/api.py", line 103, in _raw_face_locations
    return cnn_face_detector(img, number_of_times_to_upsample)
RuntimeError: Error while calling cudaGetLastError() in file /tmp/pip-install-lq210re3/dlib_ac9deb2babba4252aa2ae20fb24a43ae/dlib/cuda/gpu_data.cpp:117. code: 98, reason: invalid device function
]

11/08/21 14:13:20 zmesdetect_m1[100298] DBG2 detect_sequence.py:770 [We did not find any face matches in frame: alarm]

11/08/21 14:13:20 zmesdetect_m1[100298] DBG1 detect_sequence.py:669 [============ Frame: alarm Running alpr detection type in sequence ==================]

11/08/21 14:13:20 zmesdetect_m1[100298] DBG2 detect_sequence.py:672 [Making sure we have matched one of ['car', 'motorbike', 'bus', 'truck', 'boat'] in [] before we proceed]

11/08/21 14:13:20 zmesdetect_m1[100298] DBG1 detect_sequence.py:674 [Did not find pre existing labels, not running detection type]

11/08/21 14:13:20 zmesdetect_m1[100298] DBG1 detect_sequence.py:827 [perf: TOTAL detection sequence (with image loads) took: 105050.03 ms  to process 1]

11/08/21 14:13:20 zmesdetect_m1[100298] DBG1 zm_detect.py:557 [Closing logs]
Now I seem to be stuck here

11/08/21 14:46:10 zmesdetect_m1[2468] DBG2 detect_sequence.py:714 [Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/pyzm/ml/detect_sequence.py", line 710, in detect_stream
_b,_l,_c,_m = m.detect(image=frame)
File "/usr/local/lib/python3.8/dist-packages/pyzm/ml/face.py", line 23, in detect
return self.model.detect(image)
File "/usr/local/lib/python3.8/dist-packages/pyzm/ml/face_dlib.py", line 200, in detect
face_locations = face_recognition.face_locations(
File "/usr/local/lib/python3.8/dist-packages/face_recognition/api.py", line 119, in face_locations
return [_trim_css_to_bounds(_rect_to_css(face.rect), img.shape) for face in _raw_face_locations(img, number_of_times_to_upsample, "cnn")]
File "/usr/local/lib/python3.8/dist-packages/face_recognition/api.py", line 103, in _raw_face_locations
return cnn_face_detector(img, number_of_times_to_upsample)
RuntimeError: Error while calling cudaGetLastError() in file /tmp/pip-install-lq210re3/dlib_ac9deb2babba4252aa2ae20fb24a43ae/dlib/cuda/gpu_data.cpp:117. code: 98, reason: invalid device function
]
jrosetto
Posts: 15
Joined: Fri Nov 05, 2021 4:44 pm

Re: Event Server Object Detection not working

Post by jrosetto »

The video card I am using is quite old and I'm starting to wonder if maybe the error that was thrown has something to do with that.

NVIDIA GeForce GT 730 with CUDA compute 3.5

Let me know if I need to provide anything else. I have scoured the internet looking for the error to no avail.
tsp84
Posts: 227
Joined: Thu Dec 24, 2020 4:04 am

Re: Event Server Object Detection not working

Post by tsp84 »

I cant say for sure but because it is that old it may not be able to run FP32 models. The source zmes only runs in FP32 mode, so I think you are out of luck. The 'convolve' error I have never seen before so I am assuming that is what the problem is. From reading online it seems people have luck using FP16 to process models on older cards but IDK.

Are you familiar with python at all? I could walk you through using FP16 mode to see if it might work.
Post Reply