go-face
go-face copied to clipboard
Build into one binary
I want to build into one binary.
face.Recognizer
requires model directory.
Is it possible to build with model files into one binary ? Could you give me your advice?
Maybe go-bindata could be good solution?
Need to rewrite this:
std::string dir = model_dir;
std::string shape_predictor_path = dir + "/shape_predictor_5_face_landmarks.dat";
std::string resnet_path = dir + "/dlib_face_recognition_resnet_model_v1.dat";
std::string cnn_resnet_path = dir + "/mmod_human_face_detector.dat";
deserialize(shape_predictor_path) >> sp_;
deserialize(resnet_path) >> net_;
deserialize(cnn_resnet_path) >> cnn_net_;
to make it accept memory buffers with models.
Not sure if dlib's deserialize allows it.
you can find a way here https://stackoverflow.com/questions/37724457/is-it-possible-to-load-read-shape-predictor-68-face-landmarks-dat-at-compile-tim
- xxd dat file to hpp header file
- facerec.cc modify like below as kagami said
#include "shape_predictor_5_face_landmarks.hpp" #include "mmod_human_face_detector.hpp" #include "dlib_face_recognition_resnet_model_v1.hpp" std::stringstream shapestream; std::stringstream resnetstream; std::stringstream cnnstream; shapestream.write((const char*)shape_predictor_5_face_landmarks_dat, shape_predictor_5_face_landmarks_dat_len); resnetstream.write((const char*)dlib_face_recognition_resnet_model_v1_dat, dlib_face_recognition_resnet_model_v1_dat_len); cnnstream.write((const char*)mmod_human_face_detector_dat, mmod_human_face_detector_dat_len);
deserialize(sp_, shapestream); deserialize(net_, resnetstream); deserialize(cnn_net_, cnnstream);