【问题标题】:module 'dlib' has no attribute 'get_frontal_face_detector' ERROR模块“dlib”没有属性“get_frontal_face_detector”错误
【发布时间】:2020-09-04 19:53:56
【问题描述】:

我正在尝试在 Anaconda 上使用 Face_Recognition 包,我已经安装了 dlib 和 face_recognition 库

但是当我在我的代码上导入 face_recognition 时,我收到了这个错误消息

import dlib
import face_recognition



---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-32-cc760b0b6613> in <module>()
      1 import dlib
----> 2 import face_recognition

~\Anaconda3\lib\site-packages\face_recognition\__init__.py in <module>()
      5 __version__ = '1.2.3'
      6 
----> 7 from .api import load_image_file, face_locations, batch_face_locations, face_landmarks, face_encodings, compare_faces, face_distance

~\Anaconda3\lib\site-packages\face_recognition\api.py in <module>()
     15 ImageFile.LOAD_TRUNCATED_IMAGES = True
     16 
---> 17 face_detector = dlib.get_frontal_face_detector()
     18 
     19 predictor_68_point_model = face_recognition_models.pose_predictor_model_location()

AttributeError: module 'dlib' has no attribute 'get_frontal_face_detector'

【问题讨论】:

    标签: python anaconda face-recognition dlib


    【解决方案1】:

    查看本教程: http://www.programmersought.com/article/7562877819/

    运行代码时出错:检测器= dlib.get_frontal_face_detector() AttributeError: 模块 'Dlib' 没有 属性“get_frontal_face_detector”或无法打开 'get_frontal_face_detector' 等等,因为你没有下载 人脸数据库 shape_predictor_68_face_landmarks,你需要 下载它并解压缩并将其放在您的代码所在的文件夹中 位于。人脸库下载 链接:http://dlib.net/files/shape_predictor_68_face_landmarks.dat.bz2

    【讨论】:

    • 我在已安装的dlib文件中进行了搜索,发现人脸数据库shape_predictor_68_face_landmarks已经存在。重新安装 dlib 文件对我有用。
    【解决方案2】:

    尝试以下解决方案:

    1. 重新安装dlib 包(pip3 uninstall dlib,然后pip3 install dlib
    2. 从源代码安装dlib(对我有用。链接:http://dlib.net/compile.html

    【讨论】:

    • 谢谢,这个解决方案对我有用,但我必须手动删除所有 dlib 文件,然后重新安装。但它终于奏效了!
    • "pip3 uninstall dlib" 没有从你的 python 模块中删除所有 dlib 的文件?
    【解决方案3】:

    我关注了这个话题,并喜欢魅力。 点击[这里] (https://stackoverflow.com/a/49538054/14945612)!检查于 2021 年 7 月 问题可能出在 c++ 编译器 (Visual Studio) 和 Cmake 安装上。确保在要安装 dlib 的虚拟环境的 site_packages 文件夹中调用命令提示符。安装后尝试调用

    导入 dlib

    dlib.版本

    如果这有效,那么问题可能是一个错字。您可以确认您正在调用的函数是否存在 [这里] (http://dlib.net/python/index.html#dlib.get_frontal_face_detector)!

    【讨论】:

      猜你喜欢
      • 2021-07-30
      • 2017-01-23
      • 2020-02-09
      • 2017-11-04
      • 2021-03-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-01-29
      相关资源
      最近更新 更多