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

compute_face_descriptor(): incompatible function arguments #1582

Open
neilyoung opened this issue Aug 16, 2024 · 3 comments
Open

compute_face_descriptor(): incompatible function arguments #1582

neilyoung opened this issue Aug 16, 2024 · 3 comments

Comments

@neilyoung
Copy link

  • face_recognition version: 1.2.3
  • Python version: 3.10.12
  • Operating System: Ubuntu 22.04

Description

I'm running into a problem with a fresh installation of dlib and face_recognition according to the doc. The sample code I ran is https://github.com/ageitgey/face_recognition/blob/master/examples/facerec_from_webcam_faster.py

What I Did

  • Provided obama.jpg and biden.jpg in the root of my project
  • Created a test.py which is literally the sample code from_webcam_faster.py, but video capture replaced by RTSP input and video display replaced by image write. I can share the code, if required.
python3 test.py

I'm getting this (and I'm getting this with various other samples too, so I suppose some incompatibility between face_recognition and dlib):

~/dlibtest$ python3 test.py
Traceback (most recent call last):
  File "/home/ubuntu/dlibtest/test.py", line 50, in <module>
    face_encodings = face_recognition.face_encodings(rgb_small_frame, face_locations)
  File "/usr/local/lib/python3.10/dist-packages/face_recognition/api.py", line 214, in face_encodings
    return [np.array(face_encoder.compute_face_descriptor(face_image, raw_landmark_set, num_jitters)) for raw_landmark_set in raw_landmarks]
  File "/usr/local/lib/python3.10/dist-packages/face_recognition/api.py", line 214, in <listcomp>
    return [np.array(face_encoder.compute_face_descriptor(face_image, raw_landmark_set, num_jitters)) for raw_landmark_set in raw_landmarks]
TypeError: compute_face_descriptor(): incompatible function arguments. The following argument types are supported:
    1. (self: _dlib_pybind11.face_recognition_model_v1, img: numpy.ndarray[(rows,cols,3),numpy.uint8], face: _dlib_pybind11.full_object_detection, num_jitters: int = 0, padding: float = 0.25) -> _dlib_pybind11.vector
    2. (self: _dlib_pybind11.face_recognition_model_v1, img: numpy.ndarray[(rows,cols,3),numpy.uint8], num_jitters: int = 0) -> _dlib_pybind11.vector
    3. (self: _dlib_pybind11.face_recognition_model_v1, img: numpy.ndarray[(rows,cols,3),numpy.uint8], faces: _dlib_pybind11.full_object_detections, num_jitters: int = 0, padding: float = 0.25) -> _dlib_pybind11.vectors
    4. (self: _dlib_pybind11.face_recognition_model_v1, batch_img: list[numpy.ndarray[(rows,cols,3),numpy.uint8]], batch_faces: list[_dlib_pybind11.full_object_detections], num_jitters: int = 0, padding: float = 0.25) -> _dlib_pybind11.vectorss
    5. (self: _dlib_pybind11.face_recognition_model_v1, batch_img: list[numpy.ndarray[(rows,cols,3),numpy.uint8]], num_jitters: int = 0) -> _dlib_pybind11.vectors

Invoked with: <_dlib_pybind11.face_recognition_model_v1 object at 0x7814e5b164b0>, array([[[164, 138,  99],
        [164, 138,  99],
        [164, 138,  99],
        ...,
        [ 93,  80,  57],
        [ 92,  79,  56],
        [ 92,  79,  56]],

       [[164, 138,  99],
        [164, 138,  99],
        [164, 138,  99],
        ...,
        [ 93,  80,  57],
        [ 92,  79,  56],
        [ 92,  79,  56]],

       [[164, 138,  99],
        [164, 138,  99],
        [164, 138,  99],
        ...,
        [ 97,  82,  62],
        [ 95,  80,  60],
        [ 95,  80,  60]],

       ...,

       [[ 59,  28,   5],
        [ 62,  31,   8],
        [ 66,  35,  12],
        ...,
        [119, 121, 117],
        [117, 119, 118],
        [107, 109, 109]],

       [[ 56,  25,   2],
        [ 60,  29,   6],
        [ 64,  33,  10],
        ...,
        [119, 121, 114],
        [116, 120, 115],
        [106, 111, 107]],

       [[ 56,  25,   2],
        [ 59,  28,   5],
        [ 62,  31,   8],
        ...,
        [118, 119, 113],
        [116, 120, 115],
        [111, 116, 112]]], dtype=uint8), <_dlib_pybind11.full_object_detection object at 0x7814e5af3e30>,

@Suresh-vkl
Copy link

Suresh-vkl commented Aug 16, 2024

Try this GRAY conversion before calling face_recognition.face_locations. It resolved this issue for me.

rgb_small_frame = small_frame[:, :, ::-1]
rgb_small_frame = cv2.cvtColor(rgb_small_frame , cv2.COLOR_BGR2RGB)
face_locations = face_recognition.face_locations(rgb_small_frame)

@neilyoung
Copy link
Author

Yes, that solved the issue. Thanks

@testvgg2024
Copy link

It is working.

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