ageitgey/face_recognition

Not working

45H15H opened this issue · 3 comments

45H15H commented
  • face_recognition version: 1.3.0
  • Python version: 3.11.6
  • Operating System: Windows

Description

I copied the code and modified it for my personal use.
I am getting this error:
Traceback (most recent call last):
File "d:\face-recognition\face-recognition\face_recognition_live.py", line 55, in
face_encodings = face_recognition.face_encodings(rgb_small_frame, face_locations)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\face-recognition\myenv\Lib\site-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 "D:\face-recognition\myenv\Lib\site-packages\face_recognition\api.py", line 214, in
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 0x000002A23C639FF0>, array([[[203, 199, 188],
[208, 198, 185],
[204, 195, 191],
...,
[225, 222, 222],
[223, 219, 222],
[224, 221, 224]],

   [[200, 198, 189],
    [199, 198, 188],
    [201, 197, 189],
    ...,
    [228, 221, 222],
    [228, 221, 225],
    [225, 220, 224]],

   [[199, 197, 189],
    [202, 197, 190],
    [203, 198, 187],
    ...,
    [223, 221, 221],
    [222, 220, 220],
    [224, 221, 222]],

   ...,

   [[164, 161, 163],
    [165, 159, 160],
    [166, 162, 155],
    ...,
    [162, 160, 154],
    [171, 164, 159],
    [177, 171, 165]],

   [[159, 160, 151],
    [166, 160, 156],
    [152, 145, 148],
    ...,
    [163, 161, 153],
    [169, 164, 154],
    [179, 173, 158]],

   [[159, 159, 148],
    [159, 158, 146],
    [112, 109, 120],
    ...,
    [164, 157, 156],
    [166, 161, 149],
    [178, 172, 162]]], dtype=uint8), <_dlib_pybind11.full_object_detection object at 0x000002A23C63A5B0>, 1

What I Did

I just ran the code as it is. And I changed the sample images.

Paste the command(s) you ran and the output.
If there was a crash, please include the traceback here.

same, but i´m in windows machine python 3.11.4

replace the code line,

rgb_small_frame = small_frame[:, :, ::-1]
with below code line,

rgb_small_frame = cv2.cvtColor(small_frame, cv2.COLOR_BGR2RGB)

replace the code line,

rgb_small_frame = small_frame[:, :, ::-1] with below code line,

rgb_small_frame = cv2.cvtColor(small_frame, cv2.COLOR_BGR2RGB)

这对我有所帮助,It works for me.