Caffe2预测代码:
bool FingerprintDNNLocating::initCaffe2(void)
{
string mdPath = map_mgr_.getCaff2ModelPath();
if ("" == mdPath)
return false;
string initNetPath = mdPath + "/init_net.pb";
string predictNetPath = mdPath + "/predict_net.pb";
if (!std::ifstream(initNetPath).good() ||
!std::ifstream(predictNetPath).good())
{
return false;
}
CAFFE_ENFORCE(ReadProtoFromFile(initNetPath, &initNet_));
// >>> with open(path_to_PREDICT_NET) as f:
CAFFE_ENFORCE(ReadProtoFromFile(predictNetPath, &predictNet_));
predictor_ = new caffe2::Predictor(initNet_, predictNet_);
return true;
}
bool FingerprintDNNLocating::runCaffe2(vector<double> &weights)
{
if(!predictor_)
return false;
caffe2::TensorCP