Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python dlib面部地标检测器为何抛出运行时错误?_Python_Opencv_Dlib - Fatal编程技术网

Python dlib面部地标检测器为何抛出运行时错误?

Python dlib面部地标检测器为何抛出运行时错误?,python,opencv,dlib,Python,Opencv,Dlib,我对python编程相当陌生。我正在尝试运行dlib面部地标检测器的示例代码。不幸的是,我得到了以下错误: Traceback (most recent call last): File "facial_landmarks.py", line 109, in <module> predictor = dlib.shape_predictor(predictor_path) RuntimeError: Error deserializing object of type l

我对python编程相当陌生。我正在尝试运行dlib面部地标检测器的示例代码。不幸的是,我得到了以下错误:

Traceback (most recent call last):
  File "facial_landmarks.py", line 109, in <module>
    predictor = dlib.shape_predictor(predictor_path)
RuntimeError: Error deserializing object of type long
   while deserializing a dlib::matrix
回溯(最近一次呼叫最后一次):
文件“facial_landmarks.py”,第109行,在
预测器=dlib.形状预测器(预测器路径)
RuntimeError:反序列化long类型的对象时出错
反序列化dlib::矩阵时

有人知道如何解决吗?

此消息将由以下原因之一引起:

  • predictor_path指向的文件已损坏或丢失
  • 您忘记解压缩predictor_path指向的文件
  • 底层文件系统未将数据正确传递到dlib.shape_predictor的其他一些问题(例如磁盘损坏、文件权限、符号链接问题)
请更详细地了解dlib示例本身:
缺少dlib的形状预测器:

  • 下载并提取用于形状预测的模型(约60 MB):

  • 将预测器文件路径作为第一个参数传递给Python脚本:

    python facial_landmarks.py shape_predictor_68_face_landmarks.dat faces/*.jpg
    

  • 关于如何使用dlib进行面部地标检测,可以在这里找到一个很好的演练:

    很难只查看错误。为什么不发布相关代码?您是否解压缩了它试图加载的模型文件?
    python facial_landmarks.py shape_predictor_68_face_landmarks.dat faces/*.jpg