2017-06-07 1 views
1

J'ai téléchargé le fichier et je l'ai placé dans le même répertoire que celui où est exécuté mon code. Mais ici facerec = dlib.face_recognition_model_v1(face_rec_model_path) Je reçois toujours cette erreur Atribute. J'ai donné le plein à l'endroit où c'est mais toujours l'erreur.
ceci est mon code, je ne suis pas capable d'identifier où le problème est?Python: comment résoudre l'erreur AttributeError: l'objet 'module' n'a pas d'attribut 'face_recognition_model_v1'

import sys 
import os 
import dlib 
import glob 
from skimage import io 

predictor_path = '/home/irum/Desktop/DLIB-recognition/shape_predictor_68_face_landmarks.dat' 
face_rec_model_path = '/home/irum/Desktop/DLIB-recognition/dlib_face_recognition_resnet_model_v1.dat' 
faces_folder_path = '/home/irum/Desktop/DLIB-recognition/att_faces/ERSHIAN' 

# Load all the models we need: a detector to find the faces, a shape predictor 
# to find face landmarks so we can precisely localize the face, and finally the 

# face recognition model. 
detector = dlib.get_frontal_face_detector() 
sp = dlib.shape_predictor(predictor_path) 
facerec = dlib.face_recognition_model_v1(face_rec_model_path) 

win = dlib.image_window() 

# Now process all the images 
for f in glob.glob(os.path.join(faces_folder_path, "*.png")): 
    print("Processing file: {}".format(f)) 
    img = io.imread(f) 

    win.clear_overlay() 
    win.set_image(img) 

    # Ask the detector to find the bounding boxes of each face. The 1 in the 
    # second argument indicates that we should upsample the image 1 time. This 
    # will make everything bigger and allow us to detect more faces. 
    dets = detector(img, 1) 
    print("Number of faces detected: {}".format(len(dets))) 

    # Now process each face we found. 
    for k, d in enumerate(dets): 
     print("Detection {}: Left: {} Top: {} Right: {} Bottom: {}".format(
      k, d.left(), d.top(), d.right(), d.bottom())) 
     # Get the landmarks/parts for the face in box d. 
     shape = sp(img, d) 
     # Draw the face landmarks on the screen so we can see what face is currently being processed. 
     win.clear_overlay() 
     win.add_overlay(d) 
     win.add_overlay(shape) 


     face_descriptor = facerec.compute_face_descriptor(img, shape) 
     print(face_descriptor) 

     dlib.hit_enter_to_continue() 
+0

Le message d'erreur vous indique que 'dlib' n'a pas d'attribut appelé' face_recognition_model_v1'. Je ne sais pas ce qu'est dlib, donc je ne peux pas vous en dire plus, mais vous pouvez vérifier le fichier dlib.py que vous avez téléchargé et vérifier là. – OldGeeksGuide

Répondre

2

mettre à jour dlib. Exécutez cette commande: pip install dlib==19.4.0

0

Vous devez installer dlib. Exécuter pip install dlib

+0

Besoin déjà satisfait: dlib dans /usr/local/lib/python2.7/dist-packages/dlib-19.2.0-py2.7-linux-x86_64.egg –

+2

Avez-vous essayé la dernière version de dlib? lancez pip install dlib == 19.4.0. –