【问题标题】:Dlib Error deserializing object of type unsigned long while deserializing object of type std::stringDlib 在反序列化 std::string 类型的对象时反序列化 unsigned long 类型的对象时出错
【发布时间】: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.04Python 3.6

更新 1:

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

看来dlib.cnn_face_detection_model_v1函数有问题。如果我错了,请纠正我!

【问题讨论】:

    标签: python-3.x dlib


    【解决方案1】:

    我已经在 Twitter 上联系了 Davis King,他的 tshape_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')
    

    【讨论】:

      猜你喜欢
      • 2017-10-14
      • 2019-12-08
      • 2020-01-26
      • 1970-01-01
      • 2021-12-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多