davisking / dlib

A toolkit for making real world machine learning and data analysis applications in C++
http://dlib.net
Boost Software License 1.0
13.58k stars 3.38k forks source link

Deserialization error while initializing cnn_face_detection_model_v1 with dlib_face_recognition_resnet_model_v1 #1691

Closed kirillbobyrev closed 5 years ago

kirillbobyrev commented 5 years ago

Expected Behavior

I'm trying to initialize dlib.cnn_face_detection_model_v1 using dlib_face_recognition_resnet_model_v1.dat (or mmod_human_face_detector.dat to double-check).

Current Behavior

When using dlib_face_recognition_resnet_model_v1.dat, dlib reports deserialization error. Trying the same with mmod_human_face_detector.dat yields no such error.

Steps to Reproduce

1) Download pre-trained models:

2) Try to initialize dlib.cnn_face_detection_model_v1:

$ python
Python 3.6.7 |Anaconda custom (64-bit)| (default, Oct 23 2018, 19:16:44)
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import dlib
>>> dlib.cnn_face_detection_model_v1('dlib_face_recognition_resnet_model_v1.dat')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
RuntimeError: An error occurred while trying to read the first object from the file dlib_face_recognition_resnet_model_v1.dat.
ERROR: Unexpected version found while deserializing dlib::loss_mmod_.
>>> dlib.cnn_face_detection_model_v1('mmod_human_face_detector.dat')
<dlib.cnn_face_detection_model_v1 object at 0x7f963a0348f0>

Information

davisking commented 5 years ago

dlib_face_recognition_resnet_model_v1.dat is not a face detector. So this error is appropriate.