Dlib 在反序列化 std::string 类型的对象时反序列化 unsigned long 类型的对象时出错

Dlib Error deserializing object of type unsigned long while deserializing object of type std::string

我尝试 运行 一个 Python 使用 Dlib 进行人脸检测的代码。但是当我尝试使用以下命令加载文件 shape_predictor_68_face_landmarks.datface_detector =dlib.cnn_face_detection_model_v1('shape_predictor_68_face_landmarks.dat') 我收到以下错误:

    Traceback (most recent call last):
  File "face_detector.py", line 6, in <module>
    face_detector = 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

我已经从 github 下载了形状预测器文件:https://github.com/davisking/dlib-models

这是我的 Python 代码

import dlib
import cv2


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

其余代码被省略,因为没有必要

我正在使用: Ubuntu 18.04Python 3.6

更新 1:

如果将同一个文件与函数 dlib.shape_predictor(shape_predictor_68_face_landmarks.dat) 一起使用,它 运行 没有任何问题!

看来函数dlib.cnn_face_detection_model_v1有问题。如有错误请指正!

我已经在推特上联系了 Davis King,他 shape_predictor_68_face_landmarks.dat 的文件不正确。 我必须为函数 dlib.cnn_face_detection_model_v1()

加载 mmod_human_face_detector.dat 文件

必须这样调用

face_detector = dlib.cnn_face_detection_model_v1('mmod_human_face_detector.dat')