Skip to content

Commit

Permalink
Loading tflite buffer from buffer working
Browse files Browse the repository at this point in the history
  • Loading branch information
bernardohenz committed Sep 28, 2020
1 parent b6dbd09 commit 4726e4a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions native_client/tflitemodelstate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,10 @@ TFLiteModelState::init(const std::string &model_string, bool init_from_bytes)
}

if (init_from_bytes){
fbmodel_ = tflite::FlatBufferModel::BuildFromBuffer(model_string.c_str(), model_string.size_t);
char *tmp_buffer = new char[model_string.size()];
std::copy(model_string.begin(), model_string.end(), tmp_buffer);
// Using c_str does not work
fbmodel_ = tflite::FlatBufferModel::VerifyAndBuildFromBuffer(tmp_buffer,model_string.size());
if (!fbmodel_) {
std::cerr << "Error at reading model buffer " << std::endl;
return DS_ERR_FAIL_INIT_MMAP;
Expand All @@ -177,7 +180,6 @@ TFLiteModelState::init(const std::string &model_string, bool init_from_bytes)
}
}


tflite::ops::builtin::BuiltinOpResolver resolver;
tflite::InterpreterBuilder(*fbmodel_, resolver)(&interpreter_);
if (!interpreter_) {
Expand Down

0 comments on commit 4726e4a

Please sign in to comment.