1

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'
Hind Ahmad
  • 11
  • 1
  • 1
  • 2

6 Answers6

0

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

  • I have searched within the installed dlib file and I found that face database shape_predictor_68_face_landmarks already exists. reinstalling dlib file has worked for me. – Hind Ahmad May 19 '20 at 01:12
0

Try the following solutions:

  1. Reinstall the dlib package (pip3 uninstall dlib, then pip3 install dlib
  2. Install dlib from source (works for me. Link: http://dlib.net/compile.html)
milempicki
  • 11
  • 2
  • Thank you, this solution have worked for me but I had to remove all the dlib files manually and then install it again. but it finally worked! – Hind Ahmad May 19 '20 at 01:09
  • "pip3 uninstall dlib" didn't remove all dlib's files from your python modules ? – milempicki May 19 '20 at 01:23
0

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)!

Jeethesh
  • 31
  • 5
0

One possibility is that 'dlib' is used as your file name or function name.

O0oo0O
  • 1
  • 1
0

Open Anaconda Prompt

First:

conda update conda

Second:

conda update anaconda

Third:

conda install -c conda-forge dlib
Suraj Rao
  • 29,388
  • 11
  • 94
  • 103
0

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.

Daniel
  • 1
  • 1