davisking / dlib

A toolkit for making real world machine learning and data analysis applications in C++
http://dlib.net
Boost Software License 1.0
13.59k stars 3.38k forks source link

Problem with shape predictor 5 face land marks #1142

Closed papisilv closed 6 years ago

papisilv commented 6 years ago

sp = dlib.shape_predictor(predictor_path) RuntimeError: Unable to open shape_predictor_5_face_landmarks.dat

I get that error , what am i doing wrong, I have Dlib install, cmake,python, and other libraries currently running in ubuntu

import os
import dlib
import glob
from skimage import io

predictor_path = 'shape_predictor_5_face_landmarks.dat'
face_rec_model_path = 'dlib_face_recognition_resnet_model_v1.dat'
faces_folder_path = '../examples/faces'

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

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

    dets = detector(img, 1)
    print("Number of faces detected: {}".format(len(dets)))

    for k, d in enumerate(dets):
        print("Detection {}: Left: {} Top: {} Right: {} Bottom: {}".format(
            k, d.left(), d.top(), d.right(), d.bottom()))

        shape = sp(img, d)

        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()
davisking commented 6 years ago

You don't have a shape_predictor_5_face_landmarks.dat file. That's what the error is telling you.

papisilv commented 6 years ago

I do have the file that’s why I was asking why is not hable to open it or how can i get it to work , my folder looks something lIke this

Face detector/ -“shape predictor......dat -“dlib face recognition....dat -examples(folder) -faces(folder) -images.jpg

papisilv commented 6 years ago

Also the python file

liobrando commented 6 years ago

Similar issue. I train a shape predictor, create the .dat file but when trying to load it instead of the 68 landmarks shape predictor, i get a runtime error , could not open newpredictor.dat

Solved: file permissions

TheBlue24 commented 5 years ago

RuntimeError: Unexpected version found while deserializing dlib::shape_predictor.

How to solve this error??