![](/img/trans.png)
[英]AttributeError: module 'dlib' has no attribute 'get_frontal_face_detector'
[英]module 'dlib' has no attribute 'get_frontal_face_detector' ERROR
我正在尝试在 Anaconda 上使用 Face_Recognition package,我已经安装了 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'
查看本教程: http://www.programmersought.com/article/7562877819/
运行代码时报错:detector = dlib.get_frontal_face_detector() AttributeError: module 'dlib' has no attribute 'get_frontal_face_detector' or can't open 'get_frontal_face_detector' 等,因为你没有下载人脸库shape_predictor_68_face_landmarks,你需要下载并解压缩并将其放在代码所在的文件夹中。 人脸库下载链接:http://dlib.net/files/shape_predictor_68_face_landmarks.dat.bz2
尝试以下解决方案:
dlib
package ( pip3 uninstall dlib
,然后pip3 install dlib
dlib
(对我有用。链接: http://dlib.net/compile.html )我跟着这个线程工作并喜欢魅力。 点击[这里]( 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 ) 确认您正在调用的 function 是否存在!
一种可能性是“dlib”用作您的文件名或 function 名称。
打开 Anaconda 提示
第一的:
conda update conda
第二:
conda update anaconda
第三:
conda install -c conda-forge dlib
首先安装 Visual Studio 并使用 C++ 启用桌面开发(如果以下步骤不起作用,可能是您缺少复选框,我使用 VS 2022 并检查了以下复选框 checkboxes1 checkboxes2 *我用西班牙语使用它,但它不应该'遵循它并不困难。
然后按照https://stackoverflow.com/a/49538054/14945612 (CMake 的下载和安装)中的步骤 1 到 3 进行操作。
最后使用 Python 3.9(使用 3.10 和 3.11 对我来说都不起作用)安装以下软件包版本(对我来说更新的软件包不起作用):
pip 安装“cmake==3.21.4”
pip 安装-v "dlib==19.22.1"
pip安装“人脸识别==1.3.0”
检查您是否将它们安装在正确的环境/解释器中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.