Skip to content

Commit

Permalink
FIX: do not segfault when cannot find ncnn model files
Browse files Browse the repository at this point in the history
  • Loading branch information
fantes committed Jul 23, 2019
1 parent f9433a6 commit 6aee195
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/backends/ncnn/ncnnlib.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,24 @@ namespace dd
template <class TInputConnectorStrategy, class TOutputConnectorStrategy, class TMLModel>
void NCNNLib<TInputConnectorStrategy,TOutputConnectorStrategy,TMLModel>::init_mllib(const APIData &ad)
{
_net->load_param(this->_mlmodel._params.c_str());
_net->load_model(this->_mlmodel._weights.c_str());
int res = _net->load_param(this->_mlmodel._params.c_str());
if (res != 0)
{
this->_logger->error("problem while loading ncnn params {} from repo {}",
this->_mlmodel._params, this->_mlmodel._repo);
throw MLLibBadParamException("could not load ncnn params [" +
this->_mlmodel._params+"] from repo ["+
this->_mlmodel._repo+"]");
}
res = _net->load_model(this->_mlmodel._weights.c_str());
if (res != 0)
{
this->_logger->error("problem while loading ncnn weigths {} from repo {}",
this->_mlmodel._weights, this->_mlmodel._repo);
throw MLLibBadParamException("could not load ncnn weights [" +
this->_mlmodel._weights+"] from repo ["+
this->_mlmodel._repo+"]");
}
_old_height = this->_inputc.height();
_net->set_input_h(_old_height);

Expand Down

0 comments on commit 6aee195

Please sign in to comment.