roflcoopter / viseron

Self-hosted, local only NVR and AI Computer Vision software. With features such as object detection, motion detection, face recognition and more, it gives you the power to keep an eye on your home, office or any other place you want to monitor.
MIT License
1.77k stars 180 forks source link

[BUG] Compreface throws FileNotFoundError on train OFF #603

Open pierluigizagaria opened 1 year ago

pierluigizagaria commented 1 year ago

Compreface started logging this error and no predition is done.

compreface:
  face_recognition:
    host: localhost
    port: 8000
    recognition_api_key: 
    cameras:
      camera_1:
    labels:
      - person
2023-05-14 11:44:01 [2023-05-14 09:44:01] [WARNING ] [viseron.components.darknet.object_detector.camera_1] - scan_on_motion_only is enabled but no motion detector is configured. Disabling scan_on_motion_only
2023-05-14 11:44:01 [2023-05-14 09:44:01] [ERROR   ] [viseron.components] - Uncaught exception setting up domain face_recognition for component compreface: [Errno 2] No such file or directory: '/config/face_recognition/faces'
2023-05-14 11:44:01 Traceback (most recent call last):
2023-05-14 11:44:01   File "/src/viseron/components/__init__.py", line 407, in setup_domain
2023-05-14 11:44:01     result = domain_module.setup(
2023-05-14 11:44:01   File "/src/viseron/components/compreface/face_recognition.py", line 45, in setup
2023-05-14 11:44:01     FaceRecognition(vis, config, identifier)
2023-05-14 11:44:01   File "/src/viseron/components/compreface/face_recognition.py", line 54, in __init__
2023-05-14 11:44:01     super().__init__(
2023-05-14 11:44:01   File "/src/viseron/domains/face_recognition/__init__.py", line 90, in __init__
2023-05-14 11:44:01     for face_dir in os.listdir(config[CONFIG_FACE_RECOGNITION_PATH]):
2023-05-14 11:44:01 FileNotFoundError: [Errno 2] No such file or directory: '/config/face_recognition/faces'
2023-05-14 11:44:01 [2023-05-14 09:44:01] [INFO    ] [viseron.components] - Setup of domain object_detector for component darknet with identifier camera_1 took 0.0 seconds
2023-05-14 11:44:01 [2023-05-14 09:44:01] [ERROR   ] [viseron.components] - Setup of domain face_recognition for component compreface with identifier camera_1 failed
2023-05-14 11:44:01 [2023-05-14 09:44:01] [INFO    ] [viseron.components.nvr.nvr.camera_1] - Motion detector is disabled
2023-05-14 11:44:01 [2023-05-14 09:44:01] [INFO    ] [viseron.components.nvr.nvr.camera_1] - NVR for camera video_loop initialized
2023-05-14 11:44:01 [2023-05-14 09:44:01] [INFO    ] [viseron.components] - Setup of domain nvr for component nvr with identifier camera_1 took 0.0 seconds
2023-05-14 11:44:01 [2023-05-14 09:44:01] [INFO    ] [viseron.core] - Viseron initialized in 242.0 seconds
2023-05-14 11:44:04 [2023-05-14 09:44:04] [ERROR   ] [viseron.components.compreface.face_recognition.camera_1] - Error calling compreface: 'FaceRecognition' object has no attribute '_recognition'
2023-05-14 11:44:04 Traceback (most recent call last):
2023-05-14 11:44:04   File "/src/viseron/components/compreface/face_recognition.py", line 96, in face_recognition
2023-05-14 11:44:04     detections = self._recognition.recognize(
2023-05-14 11:44:04 AttributeError: 'FaceRecognition' object has no attribute '_recognition'
2023-05-14 11:44:05 [2023-05-14 09:44:05] [ERROR   ] [viseron.components.compreface.face_recognition.camera_1] - Error calling compreface: 'FaceRecognition' object has no attribute '_recognition'
2023-05-14 11:44:05 Traceback (most recent call last):
2023-05-14 11:44:05   File "/src/viseron/components/compreface/face_recognition.py", line 96, in face_recognition
2023-05-14 11:44:05     detections = self._recognition.recognize(
2023-05-14 11:44:05 AttributeError: 'FaceRecognition' object has no attribute '_recognition'
2023-05-14 11:44:06 [2023-05-14 09:44:06] [ERROR   ] [viseron.components.compreface.face_recognition.camera_1] - Error calling compreface: 'FaceRecognition' object has no attribute '_recognition'
pierluigizagaria commented 1 year ago

Training is disabled by default so I thought that no directory is needed in order to make compreface work

pierluigizagaria commented 1 year ago

https://github.com/roflcoopter/viseron/blob/c5da57d15bf1f7adecfe81e03cd127eb42d82610/viseron/components/compreface/__init__.py#L122

This condition seems to not work properly.

File "/src/viseron/domains/face_recognition/__init__.py", line 90, in __init__
for face_dir in os.listdir(config[CONFIG_FACE_RECOGNITION_PATH]):

Error is thrown even if train is set to false.