davisking/dlib-models

Convert facial recognition model to a TFLite or ml core model?

rafayk7 opened this issue · 3 comments

I want to convert the facial recognition .dat.bz2 file to a TFlite or a ML Core model (for Android/iOS). What's the structure of the model so I can convert it to those file types?

You can convert the network file to xml (http://dlib.net/dlib/dnn/utilities_abstract.h.html#net_to_xml) and then do whatever you like with the data.

You can convert the network file to xml (http://dlib.net/dlib/dnn/utilities_abstract.h.html#net_to_xml) and then do whatever you like with the data.

Just trying to understand the documentation and codebase - type net_type is the description of the network right? Does it support importing a .dat file and then converting that to xml? How would I go about that?

The dnn_* tutorials in the examples folder have some examples of this.

deserializing a model from disk:

https://github.com/davisking/dlib/blob/7e70a92765aa8d717e75c4a43cd41ef587e25104/examples/dnn_imagenet_ex.cpp#L124-L126

serializing a model to xml:

https://github.com/davisking/dlib/blob/6b581d91f6b9b847a8163420630ef947e7cc88db/examples/dnn_introduction_ex.cpp#L164

There is also a python utility running_a_dlib_model_with_caffe_example.py to convert to caffe format.

You could potentially map to caffe then use some popular caffe-to-TF conversion tool, or modify the underlying network visitor class to do it directly.

Also, see davisking/dlib#803 for a related discussion.