python - AttributeError: 'module' object has no attribute 'get_frontal_face_detector' -


i trying use python's dlib library detect facial landmarks. using example given on face detector. have installed dependencies before installing dlib.

first installed cmake , libboost using "sudo apt-get install libboost-python-dev cmake" given on link above. installed dlib using "pip install dlib".

my code:

import sys import os import dlib import glob skimage import io  predictor_path = 'shape_predictor_68_face_landmarks.dat' faces_folder_path = './happy' detector = dlib.get_frontal_face_detector() predictor = dlib.shape_predictor(predictor_path) win = dlib.image_window()  f in glob.glob(os.path.join(faces_folder_path, "*.jpg")):     print("processing file: {}".format(f))     img = io.imread(f)      win.clear_overlay()     win.set_image(img)      # ask detector find bounding boxes of each face. 1 in     # second argument indicates should upsample image 1 time.     # make bigger , allow detect more faces.     dets = detector(img, 1)     print("number of faces detected: {}".format(len(dets)))     k, d in enumerate(dets):         print("detection {}: left: {} top: {} right: {} bottom: {}".format(             k, d.left(), d.top(), d.right(), d.bottom()))         # landmarks/parts face in box d.         shape = predictor(img, d)         print("part 0: {}, part 1: {} ...".format(shape.part(0),                                                   shape.part(1)))         # draw face landmarks on screen.         win.add_overlay(shape)      win.add_overlay(dets)     dlib.hit_enter_to_continue()  

but when run program, following error:

traceback (most recent call last):   file "dlib.py", line 2, in <module>     import dlib   file "/home/shivam/musicplayer/dlib.py", line 6, in <module>     detector = dlib.get_frontal_face_detector() #face detector attributeerror: 'module' object has no attribute 'get_frontal_face_detector' 

here directory structure of project: enter image description here

rename file dlib.py else, dlib_project.py.

your file, named so, shadowing dlib library has of functionality need, imported instead of library, being first in hierarchy.


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

Sound is not coming out while implementing Text-to-speech in Android activity -