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
  • 2

5 Answers5

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
  • 33
  • 3
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
  • 28,850
  • 10
  • 94
  • 99