Skip to content

Commit

Permalink
FIX: small glitch in init, was ok before, but clearer now
Browse files Browse the repository at this point in the history
  • Loading branch information
fantes committed Apr 16, 2019
1 parent 656d871 commit bfd9fa9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/backends/ncnn/ncnnlib.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "ncnninputconns.h"
#include "cpu.h"
#include "net.h"
#include <iostream>

namespace dd
{
Expand Down Expand Up @@ -57,6 +58,7 @@ namespace dd
_nclasses = tl._nclasses;
_threads = tl._threads;
_timeserie = tl._timeserie;
_old_height = tl._old_height;
}

template <class TInputConnectorStrategy, class TOutputConnectorStrategy, class TMLModel>
Expand All @@ -71,6 +73,8 @@ namespace dd
{
_net->load_param(this->_mlmodel._params.c_str());
_net->load_model(this->_mlmodel._weights.c_str());
_old_height = this->_inputc.height();
_net->set_input_h(_old_height);

if (ad.has("nclasses"))
_nclasses = ad.get("nclasses").get<int>();
Expand Down Expand Up @@ -115,6 +119,7 @@ namespace dd
int NCNNLib<TInputConnectorStrategy,TOutputConnectorStrategy,TMLModel>::predict(const APIData &ad,
APIData &out)
{

TInputConnectorStrategy inputc(this->_inputc);
TOutputConnectorStrategy tout;
try {
Expand All @@ -123,6 +128,7 @@ namespace dd
throw;
}


// if height (timestep) changes we need to clear net before recreating an extractor with new
// height,
// and to reload params and models after clear()
Expand All @@ -133,8 +139,8 @@ namespace dd
_net->load_param(this->_mlmodel._params.c_str());
_net->load_model(this->_mlmodel._weights.c_str());
_old_height = inputc.height();
_net->set_input_h(_old_height);
}
_net->set_input_h(inputc.height());

ncnn::Extractor ex = _net->create_extractor();

Expand Down

0 comments on commit bfd9fa9

Please sign in to comment.