boltgolt / howdy

πŸ›‘οΈ Windows Helloβ„’ style facial authentication for Linux
MIT License
5.75k stars 299 forks source link

module 'dlib' has no attribute 'get_frontal_face_detector' #924

Open TomTinking opened 3 months ago

TomTinking commented 3 months ago

When I first tried howdy was working fine but I was lured by the CNN option, so started digging which is where I think this has all gone wrong :)

I already had NVIDIA Cuda Dev Toolkit installed

nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2024 NVIDIA Corporation
Built on Wed_Apr_17_19:19:55_PDT_2024
Cuda compilation tools, release 12.5, V12.5.40
Build cuda_12.5.r12.5/compiler.34177558_0

Realised I needed DLIB with the CUDA flag so complied and installed that: Python 3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0] on linux Type "help", "copyright", "credits" or "license" for more information.

>>> import dlib
>>> dlib.DLIB_USE_CUDA
True
$ pip list | grep dlib
WARNING: Skipping /usr/local/lib/python3.11/dist-packages/dlib-19.24.99-py3.11-linux-x86_64.egg/EGG-INFO due to invalid metadata entry 'name' 
dlib                     19.24.99

(A little concerned on the 'warning' but it is just that a warning)

System:

inxi -S
System:
  Host: debian Kernel: 6.1.0-18-amd64 arch: x86_64 bits: 64 Desktop: Cinnamon
    v: 5.6.8 Distro: Debian GNU/Linux 12 (bookworm)

Issue i haves is:

sudo howdy add
Traceback (most recent call last):
  File "/usr/local/bin/howdy", line 95, in <module>
    import cli.add
  File "/usr/lib/security/howdy/cli/add.py", line 45, in <module>
    face_detector = dlib.get_frontal_face_detector()
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'dlib' has no attribute 'get_frontal_face_detector'

To check

To be sure I removed and tried a re-install of howdy via gdebi as root (full output below):

#gdebi howdy_2.6.1.deb 
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Reading state information... Done

Howdy: Windows Hello style authentication for Linux.
 Use your built-in IR emitters and camera in combination with face recognition
 to prove who you are.
Do you want to install the software package? [y/N]:y
/usr/bin/gdebi:113: FutureWarning: Possible nested set at position 1
  c = findall("[[(](\S+)/\S+[])]", msg)[0].lower()
Selecting previously unselected package howdy.
(Reading database ... 283962 files and directories currently installed.)
Preparing to unpack howdy_2.6.1.deb ...

WARNING: Could not automatically find the right webcam, manual configuration after installation required

Starting certainty auto config...

After detection, Howdy knows how certain it is that the match is correct.
How certain Howdy needs to be before authenticating you can be customized.

F: Fast.
Allows more fuzzy matches, but speeds up the scanning process greatly.

B: Balanced.
Still relatively quick detection, but might not log you in when further away.

S: Secure.
The safest option, but will take much longer to authenticate you.

You can always change this setting in the config.
What profile would you like to use? [f/b/s]: b

Unpacking howdy (2.6.1) ...
Setting up howdy (2.6.1) ...

>>> Upgrading pip to the latest version

WARNING: Skipping /usr/local/lib/python3.11/dist-packages/dlib-19.24.99-py3.11-linux-x86_64.egg/EGG-INFO due to invalid metadata entry 'name'
WARNING: Skipping /usr/local/lib/python3.11/dist-packages/dlib-19.24.99-py3.11-linux-x86_64.egg/EGG-INFO due to invalid metadata entry 'name'
Requirement already satisfied: pip in /usr/lib/python3/dist-packages (23.0.1)
Collecting pip
  Using cached pip-24.0-py3-none-any.whl (2.1 MB)
WARNING: Skipping /usr/local/lib/python3.11/dist-packages/dlib-19.24.99-py3.11-linux-x86_64.egg/EGG-INFO due to invalid metadata entry 'name'
Installing collected packages: pip
  Attempting uninstall: pip
    WARNING: Skipping /usr/local/lib/python3.11/dist-packages/dlib-19.24.99-py3.11-linux-x86_64.egg/EGG-INFO due to invalid metadata entry 'name'
    Found existing installation: pip 23.0.1
    Not uninstalling pip at /usr/lib/python3/dist-packages, outside environment /usr
    Can't uninstall 'pip'. No files were found to uninstall.
Successfully installed pip-24.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

>>> Upgrading numpy to the latest version

WARNING: Skipping /usr/local/lib/python3.11/dist-packages/dlib-19.24.99-py3.11-linux-x86_64.egg/EGG-INFO due to invalid metadata entry 'name'
WARNING: Skipping /usr/local/lib/python3.11/dist-packages/dlib-19.24.99-py3.11-linux-x86_64.egg/EGG-INFO due to invalid metadata entry 'name'
Requirement already satisfied: numpy in /usr/lib/python3/dist-packages (1.24.2)
Collecting numpy
  Downloading numpy-1.26.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (61 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 61.0/61.0 kB 544.8 kB/s eta 0:00:00
Downloading numpy-1.26.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (18.3 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 18.3/18.3 MB 25.4 MB/s eta 0:00:00
WARNING: Skipping /usr/local/lib/python3.11/dist-packages/dlib-19.24.99-py3.11-linux-x86_64.egg/EGG-INFO due to invalid metadata entry 'name'
Installing collected packages: numpy
  Attempting uninstall: numpy
    WARNING: Skipping /usr/local/lib/python3.11/dist-packages/dlib-19.24.99-py3.11-linux-x86_64.egg/EGG-INFO due to invalid metadata entry 'name'
    Found existing installation: numpy 1.24.2
    Uninstalling numpy-1.24.2:
      Successfully uninstalled numpy-1.24.2
Successfully installed numpy-1.26.4
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
WARNING: Skipping /usr/local/lib/python3.11/dist-packages/dlib-19.24.99-py3.11-linux-x86_64.egg/EGG-INFO due to invalid metadata entry 'name'

>>> Downloading and unpacking data files

Downloading 3 required data files...
dlib_face_recognition_resnet_model_v1.da 100%[===============================================================================>]  20.44M  89.6MB/s    in 0.2s    
mmod_human_face_detector.dat.bz2         100%[===============================================================================>] 678.41K  --.-KB/s    in 0.03s   
shape_predictor_5_face_landmarks.dat.bz2 100%[===============================================================================>]   5.44M  --.-KB/s    in 0.07s   
Unpacking...

>>> Downloading dlib

--2024-06-04 18:34:51--  https://github.com/davisking/dlib/archive/v19.16.tar.gz
Resolving github.com (github.com)... 20.26.156.215
Connecting to github.com (github.com)|20.26.156.215|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://codeload.github.com/davisking/dlib/tar.gz/refs/tags/v19.16 [following]
--2024-06-04 18:34:52--  https://codeload.github.com/davisking/dlib/tar.gz/refs/tags/v19.16
Resolving codeload.github.com (codeload.github.com)... 20.26.156.216
Connecting to codeload.github.com (codeload.github.com)|20.26.156.216|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [application/x-gzip]
Saving to: β€˜/tmp/v19.16.tar.gz’

/tmp/v19.16.tar.gz                           [    <=>                                                                         ]   9.93M  13.0MB/s    in 0.8s    

2024-06-04 18:34:53 (13.0 MB/s) - β€˜/tmp/v19.16.tar.gz’ saved [10411975]

>>> Building dlib

Traceback (most recent call last):
  File "/tmp/dlib-19.16/setup.py", line 221, in <module>
    setup(
  File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 107, in setup
    _install_setup_requires(attrs)
  File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 75, in _install_setup_requires
    dist = MinimalDistribution(attrs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 57, in __init__
    super().__init__(filtered)
  File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 473, in __init__
    for ep in metadata.entry_points(group='distutils.setup_keywords'):
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/importlib/metadata/__init__.py", line 1040, in entry_points
    return SelectableGroups.load(eps).select(**params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/importlib/metadata/__init__.py", line 476, in load
    ordered = sorted(eps, key=by_group)
              ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/importlib/metadata/__init__.py", line 1037, in <genexpr>
    eps = itertools.chain.from_iterable(
                                       ^
  File "/usr/lib/python3.11/importlib/metadata/_itertools.py", line 16, in unique_everseen
    k = key(element)
        ^^^^^^^^^^^^
  File "/usr/lib/python3.11/importlib/metadata/__init__.py", line 954, in _normalized_name
    or super()._normalized_name
       ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/importlib/metadata/__init__.py", line 627, in _normalized_name
    return Prepared.normalize(self.name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/importlib/metadata/__init__.py", line 882, in normalize
    return re.sub(r"[-_.]+", "-", name).lower().replace('-', '_')
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/re/__init__.py", line 185, in sub
    return _compile(pattern, flags).sub(repl, string, count)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: expected string or bytes-like object, got 'NoneType'

>>> Cleaning up dlib

Temporary dlib files removed

>>> Installing OpenCV

WARNING: Skipping /usr/local/lib/python3.11/dist-packages/dlib-19.24.99-py3.11-linux-x86_64.egg/EGG-INFO due to invalid metadata entry 'name'
WARNING: Skipping /usr/local/lib/python3.11/dist-packages/dlib-19.24.99-py3.11-linux-x86_64.egg/EGG-INFO due to invalid metadata entry 'name'
Collecting opencv-python
  Downloading opencv_python-4.10.0.82-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (20 kB)
Requirement already satisfied: numpy>=1.21.2 in /usr/local/lib/python3.11/dist-packages (from opencv-python) (1.26.4)
Downloading opencv_python-4.10.0.82-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (62.5 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 62.5/62.5 MB 115.7 MB/s eta 0:00:00
WARNING: Skipping /usr/local/lib/python3.11/dist-packages/dlib-19.24.99-py3.11-linux-x86_64.egg/EGG-INFO due to invalid metadata entry 'name'
Installing collected packages: opencv-python
Successfully installed opencv-python-4.10.0.82
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
WARNING: Skipping /usr/local/lib/python3.11/dist-packages/dlib-19.24.99-py3.11-linux-x86_64.egg/EGG-INFO due to invalid metadata entry 'name'

>>> Configuring howdy

Camera ID saved
Permissions set
Howdy command installed

>>> Adding howdy as PAM module

Installation complete.
Processing triggers for man-db (2.11.2-2) ...
xxxx@debian:~/Downloads# exit
logout
xxxx@debian:~$ sudo howdy add
Traceback (most recent call last):
  File "/usr/local/bin/howdy", line 95, in <module>
    import cli.add
  File "/usr/lib/security/howdy/cli/add.py", line 45, in <module>
    face_detector = dlib.get_frontal_face_detector()
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'dlib' has no attribute 'get_frontal_face_detector'
xxxx@debian:~$ sudo howdy config
Opening config.ini in the default editor
xxxx@debian:~$ sudo howdy add
Traceback (most recent call last):
  File "/usr/local/bin/howdy", line 95, in <module>
    import cli.add
  File "/usr/lib/security/howdy/cli/add.py", line 45, in <module>
    face_detector = dlib.get_frontal_face_detector()
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'dlib' has no attribute 'get_frontal_face_detector'
xxxx@debian:~$ sudo howdy snapshot
Generated snapshot saved as
/usr/lib/security/howdy/snapshots/20240604T173619.jpg
xxxx@debian:~$ 

Howdy Snapshot works fine and camera fires up image is captured.

Howdy is complaining about the face-recognition

sudo howdy add
Traceback (most recent call last):
  File "/usr/local/bin/howdy", line 95, in <module>
    import cli.add
  File "/usr/lib/security/howdy/cli/add.py", line 45, in <module>
    face_detector = dlib.get_frontal_face_detector()
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'dlib' has no attribute 'get_frontal_face_detector'

yet data is present

sudo ls -l /lib/security/howdy/dlib-data
total 31604
-rwxr--r-- 1 root root 22466066 Jun  4 18:34 dlib_face_recognition_resnet_model_v1.dat
-rwxr--r-- 1 root root     1313 Jun 22  2020 install.sh
-rwxr--r-- 1 root root   729940 Jun  4 18:34 mmod_human_face_detector.dat
-rwxr--r-- 1 root root      412 Jan  6  2019 Readme.md
-rwxr--r-- 1 root root  9150489 Jun  4 18:34 shape_predictor_5_face_landmarks.dat

I can see that the installer skips dlib build but that is ok as I already have it system wide.

Can anyone point me to route to resolve. ? Is this just down to the version of dlib I have built in which is 19.24.99?