【发布时间】:2018-10-25 06:21:20
【问题描述】:
我尝试使用 Dlib 运行 Python 代码进行人脸检测。但是当我尝试使用以下命令加载文件shape_predictor_68_face_landmarks.dat
face_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.04 和 Python 3.6
更新 1:
如果使用与函数dlib.shape_predictor(shape_predictor_68_face_landmarks.dat) 相同的文件,它运行没有任何问题!
看来dlib.cnn_face_detection_model_v1函数有问题。如果我错了,请纠正我!
【问题讨论】:
标签: python-3.x dlib