I am trying to use Face_Recognition package on Anaconda, I have installed both dlib and face_recognition library
but when I import face_recognition on my code, I get this error message
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'
Check this tutorial: http://www.programmersought.com/article/7562877819/
when running the code error: detector = dlib.get_frontal_face_detector() AttributeError: module ' Dlib' has no attribute 'get_frontal_face_detector' or can't open 'get_frontal_face_detector' and so on, because you did not download the face database shape_predictor_68_face_landmarks, you need to download it and unzip it and put it in the folder where your code is located. Face Library Download Link:http://dlib.net/files/shape_predictor_68_face_landmarks.dat.bz2
Try the following solutions:
dlib
package ( pip3 uninstall dlib
, then pip3 install dlib
dlib
from source (works for me. Link: http://dlib.net/compile.html )I followed this thread and worked liked charm. Click [here] ( https://stackoverflow.com/a/49538054/14945612 ). checked on Jul 2021 The problem might be with the c++ compiler (Visual Studio) and Cmake installation. Make sure Command prompt is called in the site_packages folder of the virtual environment you want to install dlib. After installation try to call
import dlib
dlib. version
if this works then the problem might be a typo. You can confirm whether the function you are calling exists from [here] ( http://dlib.net/python/index.html#dlib.get_frontal_face_detector )!
One possibility is that 'dlib' is used as your file name or function name.
Open Anaconda Prompt
First:
conda update conda
Second:
conda update anaconda
Third:
conda install -c conda-forge dlib
First Install Visual Studio and enable Desktop development with C++ (if the following steps don't work, is possible that you are missing a checkbox, I use VS 2022 and I checked the followings checkboxes1 checkboxes2 *I use it in Spanish but it shouldn't be difficult to follow it.
Then follow steps 1 to 3 from https://stackoverflow.com/a/49538054/14945612 (Download and Installation of CMake).
Finally using Python 3.9 (didn't work for me using 3.10 nor 3.11) install the following packages versions (it didn't work for me with newer ones):
pip install "cmake==3.21.4"
pip install -v "dlib==19.22.1"
pip install "face-recognition==1.3.0"
Check that you install them in your correct environment/interpreter.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.