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



我尝试使用Dlib运行用于人脸检测的Python代码。但是当我尝试使用以下命令加载文件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

这是我的蟒蛇代码

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.如果我错了,请纠正我!

我已经在推特上联系了戴维斯·金,他shape_predictor_68_face_landmarks.dat不是正确的文件。 我必须加载mmod_human_face_detector.dat文件以进行功能dlib.cnn_face_detection_model_v1()

必须这样称呼

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

最新更新