Address review comments
This commit is contained in:
parent
6f953837fa
commit
6e78bac799
@ -271,11 +271,13 @@ DS_CreateModel(const char* aModelPath,
|
|||||||
return DS_ERR_NO_MODEL;
|
return DS_ERR_NO_MODEL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<ModelState> model(
|
||||||
#ifndef USE_TFLITE
|
#ifndef USE_TFLITE
|
||||||
std::unique_ptr<ModelState> model(new TFModelState());
|
new TFModelState()
|
||||||
#else
|
#else
|
||||||
std::unique_ptr<ModelState> model(new TFLiteModelState());
|
new TFLiteModelState()
|
||||||
#endif // USE_TFLITE
|
#endif
|
||||||
|
);
|
||||||
|
|
||||||
if (!model) {
|
if (!model) {
|
||||||
std::cerr << "Could not allocate model state." << std::endl;
|
std::cerr << "Could not allocate model state." << std::endl;
|
||||||
|
@ -35,7 +35,8 @@ tflite_get_output_tensor_by_name(const Interpreter* interpreter, const char* nam
|
|||||||
return interpreter->outputs()[idx];
|
return interpreter->outputs()[idx];
|
||||||
}
|
}
|
||||||
|
|
||||||
void push_back_if_not_present(std::deque<int>& list, int value)
|
void
|
||||||
|
push_back_if_not_present(std::deque<int>& list, int value)
|
||||||
{
|
{
|
||||||
if (std::find(list.begin(), list.end(), value) == list.end()) {
|
if (std::find(list.begin(), list.end(), value) == list.end()) {
|
||||||
list.push_back(value);
|
list.push_back(value);
|
||||||
@ -86,6 +87,10 @@ TFLiteModelState::TFLiteModelState()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TFLiteModelState::~TFLiteModelState()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
TFLiteModelState::init(const char* model_path,
|
TFLiteModelState::init(const char* model_path,
|
||||||
unsigned int n_features,
|
unsigned int n_features,
|
||||||
@ -235,8 +240,13 @@ TFLiteModelState::compute_mfcc(const vector<float>& samples, vector<float>& mfcc
|
|||||||
input_samples[i] = samples[i];
|
input_samples[i] = samples[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
interpreter_->SetExecutionPlan(mfcc_exec_plan_);
|
TfLiteStatus status = interpreter_->SetExecutionPlan(mfcc_exec_plan_);
|
||||||
TfLiteStatus status = interpreter_->Invoke();
|
if (status != kTfLiteOk) {
|
||||||
|
std::cerr << "Error setting execution plan: " << status << "\n";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
status = interpreter_->Invoke();
|
||||||
if (status != kTfLiteOk) {
|
if (status != kTfLiteOk) {
|
||||||
std::cerr << "Error running session: " << status << "\n";
|
std::cerr << "Error running session: " << status << "\n";
|
||||||
return;
|
return;
|
||||||
|
@ -32,6 +32,7 @@ struct TFLiteModelState : public ModelState
|
|||||||
std::vector<int> mfcc_exec_plan_;
|
std::vector<int> mfcc_exec_plan_;
|
||||||
|
|
||||||
TFLiteModelState();
|
TFLiteModelState();
|
||||||
|
virtual ~TFLiteModelState();
|
||||||
|
|
||||||
virtual int init(const char* model_path,
|
virtual int init(const char* model_path,
|
||||||
unsigned int n_features,
|
unsigned int n_features,
|
||||||
|
Loading…
Reference in New Issue
Block a user