【问题标题】:Installing dlib to work with facial recognition [dlib has no attribute - get_frontal_face_detector]安装 dlib 以使用面部识别 [dlib 没有属性 - get_frontal_face_detector]
【发布时间】:2020-02-09 22:03:21
【问题描述】:

我在 python 中玩过一些面部识别,但在让 dlib 工作时遇到了麻烦。

我在 Windows 10 环境中,在 Pycharm 终端内使用 pip 安装所有内容。当我尝试在终端内安装 dlib 时,我收到一条消息,指出它失败,错误代码为 1。

Command "C:\Users\Jonathan\PycharmProjects\image_recognition\venv\Scripts\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Jonathan\\AppData\\Local\\Temp\\pip-install-87y4zmcs\\dlib\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read() .replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\Jonathan\AppData\Local\Temp\pip-record-ug95jqxj\install-record.txt --single-version-externally-managed --compile --install-headers C:\Users\Jonathan\PycharmProjects\image _recognition\venv\include\site\python3.7\dlib" failed with error code 1 in C:\Users\Jonathan\AppData\Local\Temp\pip-install-87y4zmcs\dlib\

所以我打开了 dlib tar.zip 文件,将其解压缩,然后运行 ​​setup.py 并将其中的 dlib 文件夹复制到我的站点包文件夹中。

之后,当我尝试使用 python 库 face_recognition 时,我从 dlib 收到此错误- C:\Users\Jonathan\PycharmProjects\image_recognition\venv\Scripts\python.exe C:/Users/Jonathan/PycharmProjects/image_recognition/image_recognition.py Traceback (most recent call last): File "C:/Users/Jonathan/PycharmProjects/image_recognition/image_recognition.py", line 1, in <module> import face_recognition File "C:\Users\Jonathan\PycharmProjects\image_recognition\face_recognition\__init__.py", line 7, in <module> from .api import load_image_file, face_locations, batch_face_locations, face_landmarks, face_encodings, compare_faces, face_distance File "C:\Users\Jonathan\PycharmProjects\image_recognition\face_recognition\api.py", line 17, in <module> face_detector = dlib.get_frontal_face_detector() AttributeError: module 'dlib' has no attribute 'get_frontal_face_detector'

在运行 face_recognition 之前,我已经在终端中安装了 cmake。任何帮助,将不胜感激。我将能够在大约 15-20 分钟内进行检查。

【问题讨论】:

    标签: python face-recognition dlib


    【解决方案1】:

    从以下链接检查此解决方案, AttributeError: 'module' object has no attribute 'get_frontal_face_detector'.

    并且人脸识别模块要求dlib版本应该在19.+以上。

    我在项目中使用 19.17 并通过 conda 环境安装,How can I solve Error of installation Dlib?)

    【讨论】:

      【解决方案2】:

      这解决了我的问题:

      AttributeError: 'module' 对象没有属性 'get_frontal_face_detector'

      pip uninstall dlib
      
      pip install dlib
      

      操作系统:Macos

      【讨论】:

      • 这是专门针对 OSX 的解决方案?
      猜你喜欢
      • 2021-07-30
      • 2020-09-04
      • 2017-11-04
      • 2020-08-16
      • 2019-04-02
      • 2021-03-15
      • 2021-10-16
      • 2017-06-27
      • 2021-07-23
      相关资源
      最近更新 更多