Face_recognition 模块在框架 Python3 中时崩溃

问题描述 投票:0回答:1

我正在尝试使用来自 face_recognition Github 页面的这个example,但我一直遇到错误。

当我运行测试文件时,会弹出一个窗口,显示相机看到的内容,一旦我进入画面,程序就会出现此错误。

Traceback (most recent call last):
  File "/home/mark/python-dist-sys/test.py", line 42, in <module>
    face_encodings = face_recognition.face_encodings(rgb_frame, face_locations)
  File "/home/mark/anaconda3/lib/python3.9/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 "/home/mark/anaconda3/lib/python3.9/site-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 0x7f1ee11dc2f0>, array([[[126,  93,  86],
        [124,  91,  84],
        [121,  86,  89],
        ...,
        [255, 255, 211],
        [255, 255, 211],
        [255, 255, 211]],

       [[122,  92,  84],
        [120,  90,  82],
        [121,  86,  87],
        ...,
        [255, 255, 211],
        [255, 255, 211],
        [255, 255, 211]],

       [[122,  92,  82],
        [120,  90,  80],
        [119,  88,  85],
        ...,
        [255, 255, 211],
        [253, 255, 210],
        [253, 255, 210]],

       ...,

       [[173, 167, 178],
        [172, 166, 177],
        [169, 165, 176],
        ...,
        [255, 255, 253],
        [255, 255, 253],
        [255, 255, 253]],

       [[171, 164, 180],
        [171, 164, 180],
        [171, 164, 178],
        ...,
        [255, 255, 253],
        [255, 255, 253],
        [255, 255, 253]],

       [[170, 162, 179],
        [170, 162, 179],
        [171, 164, 178],
        ...,
        [255, 255, 253],
        [255, 255, 253],
        [255, 255, 253]]], dtype=uint8), <_dlib_pybind11.full_object_detection object at 0x7f1ee370e5f0>, 1

我正在使用 Ubuntu 22.04.

python-3.x opencv face-recognition
1个回答
0
投票

代码在我这边运行良好。这很可能是依赖项版本的问题。我在用

python = 3.7.9
dlib = 19.24.0
face-recognition = 1.3.0
face-recognition-models = 0.3.0
opencv-python = 4.0.1.23

您可以通过使用 conda 导出 environment.yaml 文件来检查依赖项的版本。

conda env export > environment.yaml

© www.soinside.com 2019 - 2024. All rights reserved.