/etc/zm# sudo -u www-data /var/lib/zmeventnotification/bin/zm_train_faces.py 5
INF [zm_train_faces] [Setting up signal handler for logs]
INF [zm_train_faces] [Switching global logger to ZMLog]
INF [zm_train_faces] [Reading config from: /etc/zm/objectconfig.ini]
INF [zm_train_faces] [Reading secrets from: /etc/zm/secrets.ini]
INF [zm_train_faces] [Ignoring monitor specific settings, as you did not provide a monitor id]
04/26/23 22:56:06 zm_train_faces[35638] ERR face_train_dlib.py:128 [Error initializing face recognition: local variable 'person' referenced before assignment]
Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/pyzm/ml/face_train_dlib.py", line 118, in train
.format(person), len(face_locations))
UnboundLocalError: local variable 'person' referenced before assignment
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/var/lib/zmeventnotification/bin/zm_train_faces.py", line 33, in <module>
train.FaceTrain(options=g.config).train(size=args['size'])
File "/usr/local/lib/python3.10/dist-packages/pyzm/ml/face_train_dlib.py", line 129, in train
raise ValueError(
ValueError: Error opening known faces directory. Is the path correct?
[SOLVED] Problem with face recognition
- biologisch
- Posts: 96
- Joined: Fri Aug 24, 2007 10:37 am
[SOLVED] Problem with face recognition
After upgrade to ubuntu 22.04:
Last edited by biologisch on Sun Jun 11, 2023 10:18 am, edited 1 time in total.
ZM Versions = 1.36.33
zmeventnotification Version = "6.1.28"
zmeventnotification Version = "6.1.28"
Re: Problem with face recognition
What does you known faces directory/content look like? That's what I'd check.
-
- biologisch
- Posts: 96
- Joined: Fri Aug 24, 2007 10:37 am
Re: Problem with face recognition
Only old pictures from the time before I upgrade to ubuntu 22.04
ZM Versions = 1.36.33
zmeventnotification Version = "6.1.28"
zmeventnotification Version = "6.1.28"
Re: Problem with face recognition
Make sure it’s structured per the docs. If it’s just a folder of pictures, that’s not right.
-
- biologisch
- Posts: 96
- Joined: Fri Aug 24, 2007 10:37 am
Re: Problem with face recognition
FIX!
After a while and some time for investigation I found the bug and here is the fix:
1. After a sudo -u www-data /var/lib/zmeventnotification/bin/zm_train_faces.py
2. Modify this script here -> /usr/local/lib/python3.10/dist-packages/pyzm/ml/face_train_dlib.py
3. Go to line 80 and replace
with
4. Modify this script here -> /usr/local/lib/python3.10/dist-packages/pyzm/ml/face_dlib.py
5. Go to line 182 and replace
with
After a while and some time for investigation I found the bug and here is the fix:
1. After a sudo -u www-data /var/lib/zmeventnotification/bin/zm_train_faces.py
Code: Select all
dtype=uint8), <_dlib_pybind11.full_object_detection object at 0x7fe95a72ce70>, 1
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/var/lib/zmeventnotification/bin/zm_train_faces.py", line 33, in <module>
train.FaceTrain(options=g.config).train(size=args['size'])
File "/usr/local/lib/python3.10/dist-packages/pyzm/ml/face_train_dlib.py", line 130, in train
raise ValueError(
ValueError: Error opening known faces directory. Is the path correct?
3. Go to line 80 and replace
Code: Select all
known_face = known_face[:, :, ::-1]
Code: Select all
known_face = cv2.cvtColor(known_face, cv2.COLOR_BGR2RGB)
5. Go to line 182 and replace
Code: Select all
rgb_image = image[:, :, ::-1]
Code: Select all
rgb_image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
ZM Versions = 1.36.33
zmeventnotification Version = "6.1.28"
zmeventnotification Version = "6.1.28"
Re: [SOLVED] Problem with face recognition
Fixes merged
Re: [SOLVED] Problem with face recognition
oh. I got it Territorial io
Re: [SOLVED] Problem with face recognition
is this related?
Code: Select all
sudo -u www-data /var/lib/zmeventnotification/bin/zm_train_faces.py
INF [zm_train_faces] [Setting up signal handler for logs]
INF [zm_train_faces] [Switching global logger to ZMLog]
INF [zm_train_faces] [Reading config from: /etc/zm/objectconfig.ini]
INF [zm_train_faces] [Reading secrets from: /etc/zm/secrets.ini]
INF [zm_train_faces] [Ignoring monitor specific settings, as you did not provide a monitor id]
ERR [zm_train_faces] [Error initializing face recognition: module 'cv2' has no attribute 'COLOR_BG2RGB']
Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/pyzm/ml/face_train_dlib.py", line 81, in train
known_face = cv2.cvtColor(known_face, cv2.COLOR_BG2RGB)
AttributeError: module 'cv2' has no attribute 'COLOR_BG2RGB'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/var/lib/zmeventnotification/bin/zm_train_faces.py", line 33, in <module>
train.FaceTrain(options=g.config).train(size=args['size'])
File "/usr/local/lib/python3.9/dist-packages/pyzm/ml/face_train_dlib.py", line 131, in train
raise ValueError(
ValueError: Error opening known faces directory. Is the path correct?
Re: [SOLVED] Problem with face recognition
There may have been a typo on line 82 of face_train_dlib.py when the fixes were made. It should be cv2.COLOR_BGR2RGB.
Re: [SOLVED] Problem with face recognition
Current version has the typo applied. Was committed on July 9th.
Re: [SOLVED] Problem with face recognition
Can you clarify what you mean by current version? I was running ZM 1.37.50 and had the typo. I just did an apt update and apt upgrade and it did update to a new sub-release of zm 1.37.50, but it made no changes to /usr/local/lib/python3.10/dist-packages/pyzm/ml/face_train_dlib.py
Am I missing something?
Thanks!
Re: [SOLVED] Problem with face recognition
pyzm is packages separately from zoneminder. I doubt apt will pick up the changes (perhaps we should package it for apt, I'll look into that). You need to updateit with pip. Or pip3 .
sudo pip3 install pyzm --upgrade
Should get you 0.3.64
sudo pip3 install pyzm --upgrade
Should get you 0.3.64
Re: [SOLVED] Problem with face recognition
Thanks for the clarification!