cmusatyalab/openface

predictor = dlib.shape_predictor(p) RuntimeError: Unable to open shape_predictor_68_face_landmarks.dat

RaynerPailus opened this issue · 22 comments

Below is the runtime error where it is unable to open the shape_predictor_68_face_landmark.dat.
I have successfully installed dlib, pip install dlib and when I typed import dlib in a python 2.7.14 it doesn't give any issue.
predictor = dlib.shape_predictor(p)
RuntimeError: Unable to open shape_predictor_68_face_landmarks.dat
After installed dlib, tested dlib as below, and no issue in importing dlib
C:\Python27>python
Python 2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 20:19:30) [MSC v.1500 32 bit (In
tel)] on win32
Type "help", "copyright", "credits" or "license" for more information.

import dlib

ok I have already solved it by copying the shape_predictor_68_face_landmarks.dat file in the same directory as my python file. Thanks.

@RaynerPailus

If the problem is solved would you please close the issue. Perhaps if it is present it would confuse contributors

Thanks

stale commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@RaynerPailus can you please explain the detailed procedure to slove the issue..Iam unable to resolve it after trying in many ways

ok I have already solved it by copying the shape_predictor_68_face_landmarks.dat file in the same directory as my python file. Thanks.

can u plesase explain how you resolve this issue

ok I have already solved it by copying the shape_predictor_68_face_landmarks.dat file in the same directory as my python file. Thanks.

can you please share the link of shape_predictor_68_face_landmarks.dat file it will be very helpfull and currently i am using python 3.7,3.6 is it ok

ok I have already solved it by copying the shape_predictor_68_face_landmarks.dat file in the same directory as my python file. Thanks.

can u plesase explain how you resolve this issue

So, you can resolve this by removing ".." from FACE_PREDICTOR_PATH = os.path.join(CURRENT_PATH,'common','predictors','shape_predictor_68_face_landmarks.dat')
and PREDICT_DICTIONARY = os.path.join(CURRENT_PATH,'common','dictionaries','grid.txt') in predict.py file

15927068765213115348309338560721
Can any one have any solution for this problem

can you please share the link of shape_predictor_68_face_landmarks.dat file

15927068765213115348309338560721
Can any one have any solution for this problem

Being an Attribute Error, this indicates unsuccessful installation of dlib modules.
Follow this for correct installation and setup www.learnopencv.com/install-dlib-on-ubuntu/

Well if u have installed dlib correctly
Just paste this .dat file in the same working directory as your code and try to run the code.
You can find the .dat file here after extracting a bz2 file that can be downloaded from the dlib.net website.
The link is
http://dlib.net/files/shape_predictor_68_face_landmarks.dat.bz2

15927068765213115348309338560721
Can any one have any solution for this problem

This error is shown due to unsuccessful installation.
You have to install Cmake!
After installing Cmake your problem will be solved!
https://cmake.org/download/

ok I have already solved it by copying the shape_predictor_68_face_landmarks.dat file in the same directory as my python file. Thanks.

IT WORKS

ok I have already solved it by copying the shape_predictor_68_face_landmarks.dat file in the same directory as my python file. Thanks.

IT WORKS

Hi can you tell me how to solve this problem? I'm using it in google colab.

For those who cant get the shape_predictor_68_face_landmarks.dat file
Go to http://dlib.net/files/ and click 'shape_predictor_68_face_landmarks.dat.bz2'

It worked this way but didnt work when I clicked http://dlib.net/files/shape_predictor_68_face_landmarks.dat.bz2 link found directly from github or stack overflow answers

I had to place the shape_predictor_68_face_landmarks.dat file in the same directory as my python file and run the python script from within the same directory.

I had to place the shape_predictor_68_face_landmarks.dat file in the same directory as my python file and run the python script from within the same directory.

This works. Many thanks!!!

Hey I am trying to run this function :

def run_alignment(image_path):  

      if not os.path.exists("shape_predictor_68_face_landmarks.dat"):
          print('Downloading files for aligning face image...')
          os.system('wget http://dlib.net/files/shape_predictor_68_face_landmarks.dat.bz2')
          os.system('bzip2 -dk shape_predictor_68_face_landmarks.dat.bz2')
          print('Done.')
     predictor = dlib.shape_predictor("shape_predictor_68_face_landmarks.dat")
     aligned_image = align_face(filepath=image_path, predictor=predictor) 
     print("Aligned image has shape: {}".format(aligned_image.size))
     return aligned_image

in google colab [link here] and I am running into this error :

/content/restyle/scripts/align_faces_parallel.py in get_landmark(filepath, predictor)
    43         shape = predictor(img, d)
    44 
---> 45     t = list(shape.parts())
    46     a = []
    47     for tt in t:

AttributeError: 'NoneType' object has no attribute 'parts'

It is related to the shape_predictor_landmarks_68.bat file

http://dlib.net/files/ in this link last '"shape_predictor_landmarks_68.bat" use this .bat file it working

mac os
$ python -V
Python 3.9.16

$ pip list|grep dlib
dlib 19.24.1

$ ls -lah shape_predictor_68_face_landmarks.dat
-rwxrwxrwx@ 1 51pwn  staff    95M  4  6 17:21 shape_predictor_68_face_landmarks.dat

face_encoder = dlib.cnn_face_detection_model_v1('shape_predictor_68_face_landmarks.dat')

$ python saveTz.py WX20230406-141252@2x.png                                
Traceback (most recent call last):
  File "/Volumes/Home/ai/face/saveTz.py", line 14, in <module>
    face_encoder = dlib.cnn_face_detection_model_v1('shape_predictor_68_face_landmarks.dat')
RuntimeError: An error occurred while trying to read the first object from the file 'shape_predictor_68_face_landmarks.dat'.
ERROR: Error deserializing object of type unsigned long
   while deserializing object of type std::string

Hey Guys I have tried everything. I have placed the shape_predictor_68_face_landmarks.dat file in the same folder where i have my .py file. I have downloaded the file from this source http://dlib.net/files/ but getting the same error again and again. RuntimeError: An error occurred while trying to read the first object from the file 'shape_predictor_68_face_landmarks.dat'. ERROR: Error deserializing object of type unsigned long while deserializing object of type std::string any other solution for this?