Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not work with opencv #416

Open
sagitt opened this issue Jul 2, 2022 · 13 comments
Open

Not work with opencv #416

sagitt opened this issue Jul 2, 2022 · 13 comments

Comments

@sagitt
Copy link

sagitt commented Jul 2, 2022

i upgraded opencv:

root@SERVER:~# sudo pip3 install --upgrade opencv-contrib-python
Requirement already satisfied: opencv-contrib-python in /usr/local/lib/python3.6/dist-packages (4.5.5.64)
Collecting opencv-contrib-python
  Downloading opencv_contrib_python-4.6.0.66-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (67.1 MB)
     |████████████████████████████████| 67.1 MB 3.5 MB/s             
Requirement already satisfied: numpy>=1.13.3 in /usr/local/lib/python3.6/dist-packages (from opencv-contrib-python) (1.19.5)
Installing collected packages: opencv-contrib-python
  Attempting uninstall: opencv-contrib-python
    Found existing installation: opencv-contrib-python 4.5.5.64
    Uninstalling opencv-contrib-python-4.5.5.64:
      Successfully uninstalled opencv-contrib-python-4.5.5.64
Successfully installed opencv-contrib-python-4.6.0.66

And now ZM ES not works. Using last ZM ES version.
With my snapshot downgrade, all works fine.

@baudneo
Copy link

baudneo commented Jul 2, 2022

I have a fix for you. I will edit this message with url in 5 mins. Opencv 4.6+ needs a different way of parsing opencv version for unconnected layers fix

@baudneo
Copy link

baudneo commented Jul 2, 2022

https://github.com/baudneo/zmes_yolo_fix/blob/master/yolo.py

  1. Find your yolo.py by issuing sudo find /usr -mount -iname 'yolo.py' , output should be something like /usr/local/lib/python3.9/dist-packages/pyzm/ml/yolo.py
  2. wget the above URL: wget https://github.com/baudneo/zmes_yolo_fix/blob/master/yolo.py
  3. copy the new yolo to the existing location and rerun your detections. sudo cp ./yolo.py <output of find command>

@baudneo
Copy link

baudneo commented Jul 2, 2022

If the find command doesnt work try issuing it to search the root path sudo find / -mount -iname 'yolo.py'

@sagitt
Copy link
Author

sagitt commented Jul 2, 2022

If the find command doesnt work try issuing it to search the root path sudo find / -mount -iname 'yolo.py'

thank you!! i'll try it

@juan11perez
Copy link

@baudneo replaced with your yolo and throws this error

`07/03/22 17:37:24 zmesdetect[405] INF ZMLog.py:292 [Setting up signal handler for logs]

07/03/22 17:37:24 zmesdetect[405] INF ZMLog.py:301 [Switching global logger to ZMLog]

07/03/22 17:37:24 zmesdetect[405] INF zm_detect.py:284 [---------| app:6.1.28, pyzm:0.3.56, ES:6.1.28
, OpenCV:4.6.0-dev|------------]

07/03/22 17:37:24 zmesdetect[405] INF utils.py:405 [Reading config from: /etc/zm/objectconfig.ini]

07/03/22 17:37:24 zmesdetect[405] INF utils.py:410 [Reading secrets from: /etc/zm/secrets.ini]

07/03/22 17:37:24 zmesdetect[405] DBG2 utils.py:382 [Secret token found in config: !ZM_PORTAL]

07/03/22 17:37:24 zmesdetect[405] DBG2 utils.py:382 [Secret token found in config: !ZM_USER]

07/03/22 17:37:24 zmesdetect[405] DBG2 utils.py:382 [Secret token found in config: !ZM_PASSWORD]

07/03/22 17:37:24 zmesdetect[405] DBG2 utils.py:382 [Secret token found in config: !ZM_API_PORTAL]

07/03/22 17:37:24 zmesdetect[405] DBG2 utils.py:382 [Secret token found in config: !ML_USER]

07/03/22 17:37:24 zmesdetect[405] DBG2 utils.py:382 [Secret token found in config: !ML_PASSWORD]

07/03/22 17:37:24 zmesdetect[405] DBG2 utils.py:382 [Secret token found in config: !PLATEREC_ALPR_KEY]

07/03/22 17:37:24 zmesdetect[405] DBG1 utils.py:445 [allowing self-signed certs to work...]

07/03/22 17:37:24 zmesdetect[405] DBG2 utils.py:455 [Now checking for monitor overrides]

07/03/22 17:37:24 zmesdetect[405] INF utils.py:510 [Ignoring monitor specific settings, as you did not provide a monitor id]

07/03/22 17:37:24 zmesdetect[405] DBG3 utils.py:522 [Finally, doing parameter substitution]

07/03/22 17:37:24 zmesdetect[405] INF zm_detect.py:309 [Importing local classes for Object/Face]

07/03/22 17:37:24 zmesdetect[405] INF zm_detect.py:334 [Connecting with ZM APIs]

07/03/22 17:37:24 zmesdetect[405] DBG2 api.py:72 [API SSL certificate check has been disbled]

07/03/22 17:37:24 zmesdetect[405] DBG1 api.py:181 [using username/password for login]

07/03/22 17:37:24 zmesdetect[405] DBG2 api.py:210 [Using new token API]

07/03/22 17:37:24 zmesdetect[405] DBG2 zm_detect.py:342 [using ml_sequence]

07/03/22 17:37:24 zmesdetect[405] DBG2 zm_detect.py:354 [using stream_sequence]

07/03/22 17:37:24 zmesdetect[405] DBG1 detect_sequence.py:160 [Resetting models, will be loaded on next run]

07/03/22 17:37:24 zmesdetect[405] DBG3 detect_sequence.py:634 [Using automatic locking as we are switching between models]

07/03/22 17:37:24 zmesdetect[405] DBG2 Media.py:51 [Media get SSL certificate check has been disbled]

07/03/22 17:37:24 zmesdetect[405] DBG2 Media.py:99 [Using URL 25 for stream]

07/03/22 17:37:24 zmesdetect[405] DBG2 Media.py:114 [We will only process frames: ['snapshot', 'alarm']]

07/03/22 17:37:24 zmesdetect[405] DBG2 Media.py:137 [No need to start streams, we are picking images from http://192.168.99.97/zm/index.php?view=image&eid=25]

07/03/22 17:37:24 zmesdetect[405] DBG3 Media.py:271 [Reading http://192.168.99.97/zm/index.php?view=image&eid=25&fid=snapshot]

07/03/22 17:37:24 zmesdetect[405] DBG3 api.py:272 [make_request called with url=http://192.168.99.97/zm/index.php?view=image&eid=25&fid=snapshot payload={} type=get query={'token': None}]

07/03/22 17:37:24 zmesdetect[405] DBG1 detect_sequence.py:654 [perf: Starting for frame:snapshot]

07/03/22 17:37:24 zmesdetect[405] DBG1 detect_sequence.py:664 [Sequence of detection types to execute: ['object', 'face', 'alpr']]

07/03/22 17:37:24 zmesdetect[405] DBG1 detect_sequence.py:669 [============ Frame: snapshot Running object detection type in sequence ==================]

07/03/22 17:37:24 zmesdetect[405] DBG2 detect_sequence.py:174 [Skipping TPU object detection as it is disabled]

07/03/22 17:37:24 zmesdetect[405] DBG2 detect_sequence.py:178 [Loading sequence: YoloV4 GPU/CPU]

07/03/22 17:37:24 zmesdetect[405] 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': 3, 'gpu_max_lock_wait': 120, 'cpu_max_processes': 3, 'cpu_max_lock_wait': 300, 'max_detection_size': '90%', 'disable_locks': 'no'}]

07/03/22 17:37:24 zmesdetect[405] DBG2 yolo.py:45 [portalock: max:3, name:pyzm_uid33_gpu_lock, timeout:120]

07/03/22 17:37:24 zmesdetect[405] DBG3 detect_sequence.py:689 [object has a same_model_sequence strategy of first]

07/03/22 17:37:24 zmesdetect[405] DBG1 detect_sequence.py:701 [--------- Frame:snapshot Running variation: #1 -------------]

07/03/22 17:37:24 zmesdetect[405] DBG2 yolo.py:143 [detect extracted image dimensions as: 800wx450h]

07/03/22 17:37:24 zmesdetect[405] DBG2 yolo.py:59 [Waiting for pyzm_uid33_gpu_lock portalock...]

07/03/22 17:37:24 zmesdetect[405] DBG2 yolo.py:61 [Got pyzm_uid33_gpu_lock portalock]

07/03/22 17:37:24 zmesdetect[405] DBG1 yolo.py:93 [|--------- Loading "YoloV4 GPU/CPU" model from disk -------------|]

07/03/22 17:37:24 zmesdetect[405] DBG2 yolo.py:77 [Released pyzm_uid33_gpu_lock portalock]

07/03/22 17:37:24 zmesdetect[405] ERR detect_sequence.py:713 [Error running model: can only concatenate str (not "int") to str]

07/03/22 17:37:24 zmesdetect[405] DBG2 detect_sequence.py:714 [Traceback (most recent call last):
File "/usr/local/lib/python3.10/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.10/dist-packages/pyzm/ml/object.py", line 65, in detect
b,l,c,_model_names = self.model.detect(image)
File "/usr/local/lib/python3.10/dist-packages/pyzm/ml/yolo.py", line 164, in detect
self.load_model()
File "/usr/local/lib/python3.10/dist-packages/pyzm/ml/yolo.py", line 100, in load_model
cv2_ver = cv2_version()
File "/usr/local/lib/python3.10/dist-packages/pyzm/ml/yolo.py", line 20, in cv2_version
return int(maj + minor + patch)
TypeError: can only concatenate str (not "int") to str
]

07/03/22 17:37:24 zmesdetect[405] DBG2 detect_sequence.py:770 [We did not find any object matches in frame: snapshot]

07/03/22 17:37:24 zmesdetect[405] DBG1 detect_sequence.py:669 [============ Frame: snapshot Running face detection type in sequence ==================]

07/03/22 17:37:24 zmesdetect[405] DBG2 detect_sequence.py:190 [Skipping TPU face detection as it is disabled]

07/03/2022 17:37:26 zmesdetect[405] DBG1 face_dlib.py:42 [perf: processor:gpu Face Recognition library load time took: 0.00 ms ]

07/03/2022 17:37:26 zmesdetect[405] DBG1 face_dlib.py:50 [Initializing face recognition with model:cnn upsample:1, jitters:0]

07/03/2022 17:37:26 zmesdetect[405] DBG2 face_dlib.py:73 [portalock: max:3, name:pyzm_uid33_gpu_lock, timeout:120]

07/03/2022 17:37:26 zmesdetect[405] DBG1 face_dlib.py:97 [trained file not found, reading from images and doing training...]

07/03/2022 17:37:26 zmesdetect[405] 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]

07/03/2022 17:37:26 zmesdetect[405] ERR face_train_dlib.py:135 [No known faces found to train, encoding file not created]

07/03/2022 17:37:26 zmesdetect[405] DBG1 face_train_dlib.py:152 [perf: Face Recognition training took: 4.33 ms]

07/03/2022 17:37:26 zmesdetect[405] ERR face_dlib.py:110 [Error loading KNN model: [Errno 2] No such file or directory: '/var/lib/zmeventnotification/known_faces/faces.dat']

07/03/2022 17:37:26 zmesdetect[405] DBG3 detect_sequence.py:689 [face has a same_model_sequence strategy of union]

07/03/2022 17:37:26 zmesdetect[405] DBG1 detect_sequence.py:701 [--------- Frame:snapshot Running variation: #1 -------------]

07/03/2022 17:37:26 zmesdetect[405] DBG1 face_dlib.py:164 [|---------- Dlib Face recognition (input image: 800w*450h) ----------|]

07/03/2022 17:37:26 zmesdetect[405] 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': '5', 'face_upsample_times': '2', 'gpu_max_processes': 3, 'gpu_max_lock_wait': 120, 'cpu_max_processes': 3, 'cpu_max_lock_wait': 300, 'max_size': 800, 'disable_locks': 'no'}]

07/03/2022 17:37:26 zmesdetect[405] DBG2 face_dlib.py:123 [Waiting for pyzm_uid33_gpu_lock portalock...]

07/03/2022 17:37:26 zmesdetect[405] DBG2 face_dlib.py:125 [Got pyzm_uid33_gpu_lock lock...]

07/03/2022 17:37:29 zmesdetect[405] DBG1 face_dlib.py:206 [perf: processor:gpu Finding faces took 2422.13 ms]

07/03/2022 17:37:29 zmesdetect[405] DBG1 face_dlib.py:141 [Released pyzm_uid33_gpu_lock portalock]

07/03/2022 17:37:29 zmesdetect[405] DBG1 face_dlib.py:218 [perf: processor:gpu Computing face recognition distances took 65.30 ms]

07/03/2022 17:37:29 zmesdetect[405] DBG3 face_dlib.py:227 [Comparing to known faces...]

07/03/2022 17:37:29 zmesdetect[405] DBG1 face_dlib.py:246 [No faces to match, so creating empty set]

07/03/2022 17:37:29 zmesdetect[405] DBG1 face_dlib.py:249 [perf: processor:gpu Matching recognized faces to known faces took 0.29 ms]

07/03/2022 17:37:29 zmesdetect[405] INF face_dlib.py:286 [Saving cropped unknown face at [312,38,611,336 - includes leeway of 100px] to /var/lib/zmeventnotification/unknown_faces/Jul03-17h37m29s-bf2a1643-2228-44b6-a265-07231212e696.jpg]

07/03/2022 17:37:29 zmesdetect[405] DBG2 face_dlib.py:298 [Face Dlib:Returning: [[412, 138, 511, 236]], ['unknown'], [1]]

07/03/2022 17:37:29 zmesdetect[405] DBG2 detect_sequence.py:711 [This model iteration inside face found: labels: ['unknown'],conf:[1]]

07/03/2022 17:37:29 zmesdetect[405] DBG2 detect_sequence.py:424 [Max object size found to be: 90%]

07/03/2022 17:37:29 zmesdetect[405] DBG2 detect_sequence.py:432 [Converted 90% to 324000.0]

07/03/2022 17:37:29 zmesdetect[405] DBG2 detect_sequence.py:448 [No polygons, adding full image polygon: {'name': 'full_image', 'value': [(0, 0), (1920, 0), (1920, 1080), (0, 1080)], 'pattern': None}]

07/03/2022 17:37:29 zmesdetect[405] DBG3 detect_sequence.py:228 [resized polygons x=0.4166666666666667/y=0.4166666666666667: [{'name': 'full_image', 'value': [(0, 0), (800, 0), (800, 450), (0, 450)], 'pattern': None}]]

07/03/2022 17:37:29 zmesdetect[405] DBG2 detect_sequence.py:502 [intersection: object:unknown,POLYGON ((412 138, 511 138, 511 236, 412 236, 412 138)) intersects polygon:full_image,POLYGON ((0 0, 800 0, 800 450, 0 450, 0 0))]

07/03/2022 17:37:29 zmesdetect[405] DBG2 detect_sequence.py:518 [Using global match pattern: .*]

07/03/2022 17:37:29 zmesdetect[405] DBG2 detect_sequence.py:526 [full_image intersects object:unknown[[(412, 138), (511, 138), (511, 236), (412, 236)]]]

07/03/2022 17:37:29 zmesdetect[405] DBG1 detect_sequence.py:669 [============ Frame: snapshot Running alpr detection type in sequence ==================]

07/03/2022 17:37:29 zmesdetect[405] DBG2 detect_sequence.py:672 [Making sure we have matched one of ['car', 'motorbike', 'bus', 'truck', 'boat'] in ['unknown'] before we proceed]

07/03/2022 17:37:29 zmesdetect[405] DBG1 detect_sequence.py:674 [Did not find pre existing labels, not running detection type]

07/03/2022 17:37:29 zmesdetect[405] DBG3 Media.py:271 [Reading http://192.168.99.97/zm/index.php?view=image&eid=25&fid=alarm]

07/03/2022 17:37:29 zmesdetect[405] DBG3 api.py:272 [make_request called with url=http://192.168.99.97/zm/index.php?view=image&eid=25&fid=alarm payload={} type=get query={'token': None}]

07/03/2022 17:37:29 zmesdetect[405] DBG1 detect_sequence.py:654 [perf: Starting for frame:alarm]

07/03/2022 17:37:29 zmesdetect[405] DBG1 detect_sequence.py:664 [Sequence of detection types to execute: ['object', 'face', 'alpr']]

07/03/2022 17:37:29 zmesdetect[405] DBG1 detect_sequence.py:669 [============ Frame: alarm Running object detection type in sequence ==================]

07/03/2022 17:37:29 zmesdetect[405] DBG3 detect_sequence.py:689 [object has a same_model_sequence strategy of first]

07/03/2022 17:37:29 zmesdetect[405] DBG1 detect_sequence.py:701 [--------- Frame:alarm Running variation: #1 -------------]

07/03/2022 17:37:29 zmesdetect[405] DBG2 yolo.py:143 [detect extracted image dimensions as: 800wx450h]

07/03/2022 17:37:29 zmesdetect[405] DBG2 yolo.py:59 [Waiting for pyzm_uid33_gpu_lock portalock...]

07/03/2022 17:37:29 zmesdetect[405] DBG2 yolo.py:61 [Got pyzm_uid33_gpu_lock portalock]

07/03/2022 17:37:29 zmesdetect[405] DBG1 yolo.py:166 [|---------- YOLO (input image: 800w450h, model resize dimensions: 416w416h) ----------|]

07/03/2022 17:37:29 zmesdetect[405] DBG2 yolo.py:77 [Released pyzm_uid33_gpu_lock portalock]

07/03/2022 17:37:29 zmesdetect[405] ERR detect_sequence.py:713 [Error running model: invalid index to scalar variable.]

07/03/2022 17:37:29 zmesdetect[405] DBG2 detect_sequence.py:714 [Traceback (most recent call last):
File "/usr/local/lib/python3.10/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.10/dist-packages/pyzm/ml/object.py", line 65, in detect
b,l,c,_model_names = self.model.detect(image)
File "/usr/local/lib/python3.10/dist-packages/pyzm/ml/yolo.py", line 173, in detect
ln = self.get_output_layers()
File "/usr/local/lib/python3.10/dist-packages/pyzm/ml/yolo.py", line 136, in get_output_layers
output_layers = [
File "/usr/local/lib/python3.10/dist-packages/pyzm/ml/yolo.py", line 137, in
layer_names[i[0] - 1] for i in self.net.getUnconnectedOutLayers()
IndexError: invalid index to scalar variable.
]

07/03/2022 17:37:29 zmesdetect[405] DBG2 detect_sequence.py:770 [We did not find any object matches in frame: alarm]

07/03/2022 17:37:29 zmesdetect[405] DBG1 detect_sequence.py:669 [============ Frame: alarm Running face detection type in sequence ==================]

07/03/2022 17:37:29 zmesdetect[405] DBG3 detect_sequence.py:689 [face has a same_model_sequence strategy of union]

07/03/2022 17:37:29 zmesdetect[405] DBG1 detect_sequence.py:701 [--------- Frame:alarm Running variation: #1 -------------]

07/03/2022 17:37:29 zmesdetect[405] DBG1 face_dlib.py:164 [|---------- Dlib Face recognition (input image: 800w*450h) ----------|]

07/03/2022 17:37:29 zmesdetect[405] 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': '5', 'face_upsample_times': '2', 'gpu_max_processes': 3, 'gpu_max_lock_wait': 120, 'cpu_max_processes': 3, 'cpu_max_lock_wait': 300, 'max_size': 800, 'disable_locks': 'no'}]

07/03/2022 17:37:29 zmesdetect[405] DBG2 face_dlib.py:123 [Waiting for pyzm_uid33_gpu_lock portalock...]

07/03/2022 17:37:29 zmesdetect[405] DBG2 face_dlib.py:125 [Got pyzm_uid33_gpu_lock lock...]

07/03/2022 17:37:29 zmesdetect[405] DBG1 face_dlib.py:206 [perf: processor:gpu Finding faces took 105.68 ms]

07/03/2022 17:37:29 zmesdetect[405] DBG1 face_dlib.py:141 [Released pyzm_uid33_gpu_lock portalock]

07/03/2022 17:37:29 zmesdetect[405] DBG1 face_dlib.py:218 [perf: processor:gpu Computing face recognition distances took 0.37 ms]

07/03/2022 17:37:29 zmesdetect[405] DBG2 detect_sequence.py:711 [This model iteration inside face found: labels: [],conf:[]]

07/03/2022 17:37:29 zmesdetect[405] DBG2 detect_sequence.py:424 [Max object size found to be: 90%]

07/03/2022 17:37:29 zmesdetect[405] DBG2 detect_sequence.py:432 [Converted 90% to 324000.0]

07/03/2022 17:37:29 zmesdetect[405] DBG2 detect_sequence.py:770 [We did not find any face matches in frame: alarm]

07/03/2022 17:37:29 zmesdetect[405] DBG1 detect_sequence.py:669 [============ Frame: alarm Running alpr detection type in sequence ==================]

07/03/2022 17:37:29 zmesdetect[405] DBG2 detect_sequence.py:672 [Making sure we have matched one of ['car', 'motorbike', 'bus', 'truck', 'boat'] in [] before we proceed]

07/03/2022 17:37:29 zmesdetect[405] DBG1 detect_sequence.py:674 [Did not find pre existing labels, not running detection type]

07/03/2022 17:37:29 zmesdetect[405] DBG1 detect_sequence.py:827 [perf: TOTAL detection sequence (with image loads) took: 4872.47 ms to process 25]

07/03/2022 17:37:29 zmesdetect[405] INF zm_detect.py:479 [Prediction string:[s] detected:unknown:100% ]

07/03/2022 17:37:29 zmesdetect[405] DBG1 zm_detect.py:481 [Prediction string JSON:{"labels": ["unknown"], "boxes": [[412, 138, 511, 236]], "frame_id": "snapshot", "confidences": [1], "image_dimensions": {"original": [1080, 1920], "resized": [450, 800]}}]

[s] detected:unknown:100% --SPLIT--{"labels": ["unknown"], "boxes": [[412, 138, 511, 236]], "frame_id": "snapshot", "confidences": [1], "image_dimensions": {"original": [1080, 1920], "resized": [450, 800]}}
07/03/2022 17:37:29 zmesdetect[405] DBG1 zm_detect.py:557 [Closing logs]`

@baudneo
Copy link

baudneo commented Jul 3, 2022

One moment, you'll need to re wget the file and copy it again. I just need to push a quick change. I think it's the "patch" var being set as 0. Should be "0" instead

@baudneo
Copy link

baudneo commented Jul 3, 2022

Rerun the wget and copy CMD and let me.k ow if it works now.

I run my own custom versions of ZMES so I can't test this code myself.

Edit: I see it's 4.6.0-dev, can you run this command for me please python3 -c 'import cv2; x = cv2.__version__; print(x); print(x.split(".")); quit()'

@baudneo
Copy link

baudneo commented Jul 3, 2022

try rerunning wget and copying now. Im assuming OpenCV devs are going to change their version formatting on the next minor release just to piss more people off and break code again.

@juan11perez
Copy link

@baudneo

root@zone:/# python3 -c 'import cv2; x = cv2.__version__; print(x); print(x.split(".")); quit()' 4.6.0-dev ['4', '6', '0-dev']

Downloaded your recent fix. still throwing errors.

`07/03/22 21:49:40 zmesdetect[692] INF ZMLog.py:301 [Switching global logger to ZMLog]

07/03/22 21:49:40 zmesdetect[692] INF zm_detect.py:284 [---------| app:6.1.28, pyzm:0.3.56, ES:6.1.28
, OpenCV:4.6.0-dev|------------]

07/03/22 21:49:40 zmesdetect[692] INF utils.py:405 [Reading config from: /etc/zm/objectconfig.ini]

07/03/22 21:49:40 zmesdetect[692] INF utils.py:410 [Reading secrets from: /etc/zm/secrets.ini]

07/03/22 21:49:40 zmesdetect[692] DBG2 utils.py:382 [Secret token found in config: !ZM_PORTAL]

07/03/22 21:49:40 zmesdetect[692] DBG2 utils.py:382 [Secret token found in config: !ZM_USER]

07/03/22 21:49:40 zmesdetect[692] DBG2 utils.py:382 [Secret token found in config: !ZM_PASSWORD]

07/03/22 21:49:40 zmesdetect[692] DBG2 utils.py:382 [Secret token found in config: !ZM_API_PORTAL]

07/03/22 21:49:40 zmesdetect[692] DBG2 utils.py:382 [Secret token found in config: !ML_USER]

07/03/22 21:49:40 zmesdetect[692] DBG2 utils.py:382 [Secret token found in config: !ML_PASSWORD]

07/03/22 21:49:40 zmesdetect[692] DBG2 utils.py:382 [Secret token found in config: !PLATEREC_ALPR_KEY]

07/03/22 21:49:40 zmesdetect[692] DBG1 utils.py:445 [allowing self-signed certs to work...]

07/03/22 21:49:40 zmesdetect[692] DBG2 utils.py:455 [Now checking for monitor overrides]

07/03/22 21:49:40 zmesdetect[692] INF utils.py:510 [Ignoring monitor specific settings, as you did not provide a monitor id]

07/03/22 21:49:40 zmesdetect[692] DBG3 utils.py:522 [Finally, doing parameter substitution]

07/03/22 21:49:40 zmesdetect[692] INF zm_detect.py:309 [Importing local classes for Object/Face]

07/03/22 21:49:40 zmesdetect[692] INF zm_detect.py:334 [Connecting with ZM APIs]

07/03/22 21:49:40 zmesdetect[692] DBG2 api.py:72 [API SSL certificate check has been disbled]

07/03/22 21:49:40 zmesdetect[692] DBG1 api.py:181 [using username/password for login]

07/03/22 21:49:40 zmesdetect[692] DBG2 api.py:210 [Using new token API]

07/03/22 21:49:40 zmesdetect[692] DBG2 zm_detect.py:342 [using ml_sequence]

07/03/22 21:49:40 zmesdetect[692] DBG2 zm_detect.py:354 [using stream_sequence]

07/03/22 21:49:40 zmesdetect[692] DBG1 detect_sequence.py:160 [Resetting models, will be loaded on next run]

07/03/22 21:49:40 zmesdetect[692] DBG3 detect_sequence.py:634 [Using automatic locking as we are switching between models]

07/03/22 21:49:40 zmesdetect[692] DBG2 Media.py:51 [Media get SSL certificate check has been disbled]

07/03/22 21:49:40 zmesdetect[692] DBG2 Media.py:99 [Using URL 25 for stream]

07/03/22 21:49:40 zmesdetect[692] DBG2 Media.py:114 [We will only process frames: ['snapshot', 'alarm']]

07/03/22 21:49:40 zmesdetect[692] DBG2 Media.py:137 [No need to start streams, we are picking images from http://192.168.99.97/zm/index.php?view=image&eid=25]

07/03/22 21:49:40 zmesdetect[692] DBG3 Media.py:271 [Reading http://192.168.99.97/zm/index.php?view=image&eid=25&fid=snapshot]

07/03/22 21:49:40 zmesdetect[692] DBG3 api.py:272 [make_request called with url=http://192.168.99.97/zm/index.php?view=image&eid=25&fid=snapshot payload={} type=get query={'token': None}]

07/03/22 21:49:40 zmesdetect[692] DBG1 detect_sequence.py:654 [perf: Starting for frame:snapshot]

07/03/22 21:49:40 zmesdetect[692] DBG1 detect_sequence.py:664 [Sequence of detection types to execute: ['object', 'face', 'alpr']]

07/03/22 21:49:40 zmesdetect[692] DBG1 detect_sequence.py:669 [============ Frame: snapshot Running object detection type in sequence ==================]

07/03/22 21:49:40 zmesdetect[692] DBG2 detect_sequence.py:174 [Skipping TPU object detection as it is disabled]

07/03/22 21:49:40 zmesdetect[692] DBG2 detect_sequence.py:178 [Loading sequence: YoloV4 GPU/CPU]

07/03/22 21:49:40 zmesdetect[692] 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': 3, 'gpu_max_lock_wait': 120, 'cpu_max_processes': 3, 'cpu_max_lock_wait': 300, 'max_detection_size': '90%', 'disable_locks': 'no'}]

07/03/22 21:49:40 zmesdetect[692] DBG2 yolo.py:54 [portalock: max:3, name:pyzm_uid33_gpu_lock, timeout:120]

07/03/22 21:49:40 zmesdetect[692] DBG3 detect_sequence.py:689 [object has a same_model_sequence strategy of first]

07/03/22 21:49:40 zmesdetect[692] DBG1 detect_sequence.py:701 [--------- Frame:snapshot Running variation: #1 -------------]

07/03/22 21:49:40 zmesdetect[692] DBG2 yolo.py:152 [detect extracted image dimensions as: 800wx450h]

07/03/22 21:49:40 zmesdetect[692] DBG2 yolo.py:68 [Waiting for pyzm_uid33_gpu_lock portalock...]

07/03/22 21:49:40 zmesdetect[692] DBG2 yolo.py:70 [Got pyzm_uid33_gpu_lock portalock]

07/03/22 21:49:40 zmesdetect[692] DBG1 yolo.py:102 [|--------- Loading "YoloV4 GPU/CPU" model from disk -------------|]

07/03/22 21:49:40 zmesdetect[692] DBG2 yolo.py:86 [Released pyzm_uid33_gpu_lock portalock]

07/03/22 21:49:40 zmesdetect[692] ERR detect_sequence.py:713 [Error running model: name 'ver' is not defined]

07/03/22 21:49:40 zmesdetect[692] DBG2 detect_sequence.py:714 [Traceback (most recent call last):
File "/usr/local/lib/python3.10/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.10/dist-packages/pyzm/ml/object.py", line 65, in detect
b,l,c,_model_names = self.model.detect(image)
File "/usr/local/lib/python3.10/dist-packages/pyzm/ml/yolo.py", line 173, in detect
self.load_model()
File "/usr/local/lib/python3.10/dist-packages/pyzm/ml/yolo.py", line 109, in load_model
cv2_ver = cv2_version()
File "/usr/local/lib/python3.10/dist-packages/pyzm/ml/yolo.py", line 19, in cv2_version
x = ver.split(".")
NameError: name 'ver' is not defined
]

07/03/22 21:49:40 zmesdetect[692] DBG2 detect_sequence.py:770 [We did not find any object matches in frame: snapshot]

07/03/22 21:49:40 zmesdetect[692] DBG1 detect_sequence.py:669 [============ Frame: snapshot Running face detection type in sequence ==================]

07/03/22 21:49:40 zmesdetect[692] DBG2 detect_sequence.py:190 [Skipping TPU face detection as it is disabled]

07/03/2022 21:49:42 zmesdetect[692] DBG1 face_dlib.py:42 [perf: processor:gpu Face Recognition library load time took: 0.00 ms ]

07/03/2022 21:49:42 zmesdetect[692] DBG1 face_dlib.py:50 [Initializing face recognition with model:cnn upsample:1, jitters:0]

07/03/2022 21:49:42 zmesdetect[692] DBG2 face_dlib.py:73 [portalock: max:3, name:pyzm_uid33_gpu_lock, timeout:120]

07/03/2022 21:49:42 zmesdetect[692] DBG1 face_dlib.py:97 [trained file not found, reading from images and doing training...]

07/03/2022 21:49:42 zmesdetect[692] 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]

07/03/2022 21:49:42 zmesdetect[692] ERR face_train_dlib.py:135 [No known faces found to train, encoding file not created]

07/03/2022 21:49:42 zmesdetect[692] DBG1 face_train_dlib.py:152 [perf: Face Recognition training took: 3.88 ms]

07/03/2022 21:49:42 zmesdetect[692] ERR face_dlib.py:110 [Error loading KNN model: [Errno 2] No such file or directory: '/var/lib/zmeventnotification/known_faces/faces.dat']

07/03/2022 21:49:42 zmesdetect[692] DBG3 detect_sequence.py:689 [face has a same_model_sequence strategy of union]

07/03/2022 21:49:42 zmesdetect[692] DBG1 detect_sequence.py:701 [--------- Frame:snapshot Running variation: #1 -------------]

07/03/2022 21:49:42 zmesdetect[692] DBG1 face_dlib.py:164 [|---------- Dlib Face recognition (input image: 800w*450h) ----------|]

07/03/2022 21:49:42 zmesdetect[692] 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': '5', 'face_upsample_times': '2', 'gpu_max_processes': 3, 'gpu_max_lock_wait': 120, 'cpu_max_processes': 3, 'cpu_max_lock_wait': 300, 'max_size': 800, 'disable_locks': 'no'}]

07/03/2022 21:49:42 zmesdetect[692] DBG2 face_dlib.py:123 [Waiting for pyzm_uid33_gpu_lock portalock...]

07/03/2022 21:49:42 zmesdetect[692] DBG2 face_dlib.py:125 [Got pyzm_uid33_gpu_lock lock...]

07/03/2022 21:49:46 zmesdetect[692] DBG1 face_dlib.py:206 [perf: processor:gpu Finding faces took 3817.05 ms]

07/03/2022 21:49:46 zmesdetect[692] DBG1 face_dlib.py:141 [Released pyzm_uid33_gpu_lock portalock]

07/03/2022 21:49:46 zmesdetect[692] DBG1 face_dlib.py:218 [perf: processor:gpu Computing face recognition distances took 66.30 ms]

07/03/2022 21:49:46 zmesdetect[692] DBG3 face_dlib.py:227 [Comparing to known faces...]

07/03/2022 21:49:46 zmesdetect[692] DBG1 face_dlib.py:246 [No faces to match, so creating empty set]

07/03/2022 21:49:46 zmesdetect[692] DBG1 face_dlib.py:249 [perf: processor:gpu Matching recognized faces to known faces took 0.29 ms]

07/03/2022 21:49:46 zmesdetect[692] INF face_dlib.py:286 [Saving cropped unknown face at [312,38,611,336 - includes leeway of 100px] to /var/lib/zmeventnotification/unknown_faces/Jul03-21h49m46s-3882acb6-f613-425a-b19c-2cd6b4f267ce.jpg]

07/03/2022 21:49:46 zmesdetect[692] DBG2 face_dlib.py:298 [Face Dlib:Returning: [[412, 138, 511, 236]], ['unknown'], [1]]

07/03/2022 21:49:46 zmesdetect[692] DBG2 detect_sequence.py:711 [This model iteration inside face found: labels: ['unknown'],conf:[1]]

07/03/2022 21:49:46 zmesdetect[692] DBG2 detect_sequence.py:424 [Max object size found to be: 90%]

07/03/2022 21:49:46 zmesdetect[692] DBG2 detect_sequence.py:432 [Converted 90% to 324000.0]

07/03/2022 21:49:46 zmesdetect[692] DBG2 detect_sequence.py:448 [No polygons, adding full image polygon: {'name': 'full_image', 'value': [(0, 0), (1920, 0), (1920, 1080), (0, 1080)], 'pattern': None}]

07/03/2022 21:49:46 zmesdetect[692] DBG3 detect_sequence.py:228 [resized polygons x=0.4166666666666667/y=0.4166666666666667: [{'name': 'full_image', 'value': [(0, 0), (800, 0), (800, 450), (0, 450)], 'pattern': None}]]

07/03/2022 21:49:46 zmesdetect[692] DBG2 detect_sequence.py:502 [intersection: object:unknown,POLYGON ((412 138, 511 138, 511 236, 412 236, 412 138)) intersects polygon:full_image,POLYGON ((0 0, 800 0, 800 450, 0 450, 0 0))]

07/03/2022 21:49:46 zmesdetect[692] DBG2 detect_sequence.py:518 [Using global match pattern: .*]

07/03/2022 21:49:46 zmesdetect[692] DBG2 detect_sequence.py:526 [full_image intersects object:unknown[[(412, 138), (511, 138), (511, 236), (412, 236)]]]

07/03/2022 21:49:46 zmesdetect[692] DBG1 detect_sequence.py:669 [============ Frame: snapshot Running alpr detection type in sequence ==================]

07/03/2022 21:49:46 zmesdetect[692] DBG2 detect_sequence.py:672 [Making sure we have matched one of ['car', 'motorbike', 'bus', 'truck', 'boat'] in ['unknown'] before we proceed]

07/03/2022 21:49:46 zmesdetect[692] DBG1 detect_sequence.py:674 [Did not find pre existing labels, not running detection type]

07/03/2022 21:49:46 zmesdetect[692] DBG3 Media.py:271 [Reading http://192.168.99.97/zm/index.php?view=image&eid=25&fid=alarm]

07/03/2022 21:49:46 zmesdetect[692] DBG3 api.py:272 [make_request called with url=http://192.168.99.97/zm/index.php?view=image&eid=25&fid=alarm payload={} type=get query={'token': None}]

07/03/2022 21:49:46 zmesdetect[692] DBG1 detect_sequence.py:654 [perf: Starting for frame:alarm]

07/03/2022 21:49:46 zmesdetect[692] DBG1 detect_sequence.py:664 [Sequence of detection types to execute: ['object', 'face', 'alpr']]

07/03/2022 21:49:46 zmesdetect[692] DBG1 detect_sequence.py:669 [============ Frame: alarm Running object detection type in sequence ==================]

07/03/2022 21:49:46 zmesdetect[692] DBG3 detect_sequence.py:689 [object has a same_model_sequence strategy of first]

07/03/2022 21:49:46 zmesdetect[692] DBG1 detect_sequence.py:701 [--------- Frame:alarm Running variation: #1 -------------]

07/03/2022 21:49:46 zmesdetect[692] DBG2 yolo.py:152 [detect extracted image dimensions as: 800wx450h]

07/03/2022 21:49:46 zmesdetect[692] DBG2 yolo.py:68 [Waiting for pyzm_uid33_gpu_lock portalock...]

07/03/2022 21:49:46 zmesdetect[692] DBG2 yolo.py:70 [Got pyzm_uid33_gpu_lock portalock]

07/03/2022 21:49:46 zmesdetect[692] DBG1 yolo.py:175 [|---------- YOLO (input image: 800w450h, model resize dimensions: 416w416h) ----------|]

07/03/2022 21:49:46 zmesdetect[692] DBG2 yolo.py:86 [Released pyzm_uid33_gpu_lock portalock]

07/03/2022 21:49:46 zmesdetect[692] ERR detect_sequence.py:713 [Error running model: invalid index to scalar variable.]

07/03/2022 21:49:46 zmesdetect[692] DBG2 detect_sequence.py:714 [Traceback (most recent call last):
File "/usr/local/lib/python3.10/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.10/dist-packages/pyzm/ml/object.py", line 65, in detect
b,l,c,_model_names = self.model.detect(image)
File "/usr/local/lib/python3.10/dist-packages/pyzm/ml/yolo.py", line 182, in detect
ln = self.get_output_layers()
File "/usr/local/lib/python3.10/dist-packages/pyzm/ml/yolo.py", line 145, in get_output_layers
output_layers = [
File "/usr/local/lib/python3.10/dist-packages/pyzm/ml/yolo.py", line 146, in
layer_names[i[0] - 1] for i in self.net.getUnconnectedOutLayers()
IndexError: invalid index to scalar variable.
]

07/03/2022 21:49:46 zmesdetect[692] DBG2 detect_sequence.py:770 [We did not find any object matches in frame: alarm]

07/03/2022 21:49:46 zmesdetect[692] DBG1 detect_sequence.py:669 [============ Frame: alarm Running face detection type in sequence ==================]

07/03/2022 21:49:46 zmesdetect[692] DBG3 detect_sequence.py:689 [face has a same_model_sequence strategy of union]

07/03/2022 21:49:46 zmesdetect[692] DBG1 detect_sequence.py:701 [--------- Frame:alarm Running variation: #1 -------------]

07/03/2022 21:49:46 zmesdetect[692] DBG1 face_dlib.py:164 [|---------- Dlib Face recognition (input image: 800w*450h) ----------|]

07/03/2022 21:49:46 zmesdetect[692] 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': '5', 'face_upsample_times': '2', 'gpu_max_processes': 3, 'gpu_max_lock_wait': 120, 'cpu_max_processes': 3, 'cpu_max_lock_wait': 300, 'max_size': 800, 'disable_locks': 'no'}]

07/03/2022 21:49:46 zmesdetect[692] DBG2 face_dlib.py:123 [Waiting for pyzm_uid33_gpu_lock portalock...]

07/03/2022 21:49:46 zmesdetect[692] DBG2 face_dlib.py:125 [Got pyzm_uid33_gpu_lock lock...]

07/03/2022 21:49:46 zmesdetect[692] DBG1 face_dlib.py:206 [perf: processor:gpu Finding faces took 108.23 ms]

07/03/2022 21:49:46 zmesdetect[692] DBG1 face_dlib.py:141 [Released pyzm_uid33_gpu_lock portalock]

07/03/2022 21:49:46 zmesdetect[692] DBG1 face_dlib.py:218 [perf: processor:gpu Computing face recognition distances took 0.41 ms]

07/03/2022 21:49:46 zmesdetect[692] DBG2 detect_sequence.py:711 [This model iteration inside face found: labels: [],conf:[]]

07/03/2022 21:49:46 zmesdetect[692] DBG2 detect_sequence.py:424 [Max object size found to be: 90%]

07/03/2022 21:49:46 zmesdetect[692] DBG2 detect_sequence.py:432 [Converted 90% to 324000.0]

07/03/2022 21:49:46 zmesdetect[692] DBG2 detect_sequence.py:770 [We did not find any face matches in frame: alarm]

07/03/2022 21:49:46 zmesdetect[692] DBG1 detect_sequence.py:669 [============ Frame: alarm Running alpr detection type in sequence ==================]

07/03/2022 21:49:46 zmesdetect[692] DBG2 detect_sequence.py:672 [Making sure we have matched one of ['car', 'motorbike', 'bus', 'truck', 'boat'] in [] before we proceed]

07/03/2022 21:49:46 zmesdetect[692] DBG1 detect_sequence.py:674 [Did not find pre existing labels, not running detection type]

07/03/2022 21:49:46 zmesdetect[692] DBG1 detect_sequence.py:827 [perf: TOTAL detection sequence (with image loads) took: 6293.32 ms to process 25]

07/03/2022 21:49:46 zmesdetect[692] INF zm_detect.py:479 [Prediction string:[s] detected:unknown:100% ]

07/03/2022 21:49:46 zmesdetect[692] DBG1 zm_detect.py:481 [Prediction string JSON:{"labels": ["unknown"], "boxes": [[412, 138, 511, 236]], "frame_id": "snapshot", "confidences": [1], "image_dimensions": {"original": [1080, 1920], "resized": [450, 800]}}]

[s] detected:unknown:100% --SPLIT--{"labels": ["unknown"], "boxes": [[412, 138, 511, 236]], "frame_id": "snapshot", "confidences": [1], "image_dimensions": {"original": [1080, 1920], "resized": [450, 800]}}
07/03/2022 21:49:46 zmesdetect[692] DBG1 zm_detect.py:557 [Closing logs]`

@baudneo
Copy link

baudneo commented Jul 3, 2022

Fu*k sakes. Give me a minute. Sick and tired of opencv changing shit every minor version bump

@baudneo
Copy link

baudneo commented Jul 3, 2022

Wget and copy

@juan11perez
Copy link

@baudneo
Yes, that fixed it. Thank you.

@sagitt
Copy link
Author

sagitt commented Jul 12, 2022

works fine! thank you so much. I hope in an official fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants