go-face icon indicating copy to clipboard operation
go-face copied to clipboard

Build into one binary

Open imishinist opened this issue 5 years ago • 3 comments

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?

imishinist avatar Nov 25 '19 15:11 imishinist

Maybe go-bindata could be good solution?

tpoxa avatar Mar 11 '20 18:03 tpoxa

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.

Kagami avatar May 11 '20 10:05 Kagami

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

  1. xxd dat file to hpp header file
  2. 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);

lim6112j avatar Jan 14 '21 14:01 lim6112j