|
|
|
@ -39,18 +39,21 @@ void CRNNRecognizer::Run(std::vector<std::vector<std::vector<int>>> boxes,
|
|
|
|
|
|
|
|
|
|
this->permute_op_.Run(&resize_img, input.data());
|
|
|
|
|
|
|
|
|
|
auto input_names = this->predictor_->GetInputNames();
|
|
|
|
|
auto input_t = this->predictor_->GetInputTensor(input_names[0]);
|
|
|
|
|
input_t->Reshape({1, 3, resize_img.rows, resize_img.cols});
|
|
|
|
|
input_t->copy_from_cpu(input.data());
|
|
|
|
|
|
|
|
|
|
this->predictor_->ZeroCopyRun();
|
|
|
|
|
// Inference.
|
|
|
|
|
paddle::PaddleTensor input_t;
|
|
|
|
|
input_t.shape = {1, 3, resize_img.rows, resize_img.cols};
|
|
|
|
|
input_t.data =
|
|
|
|
|
paddle::PaddleBuf(input.data(), input.size() * sizeof(float));
|
|
|
|
|
input_t.dtype = PaddleDType::FLOAT32;
|
|
|
|
|
std::vector<paddle::PaddleTensor> outputs;
|
|
|
|
|
this->predictor_->Run({input_t}, &outputs, 1);
|
|
|
|
|
|
|
|
|
|
std::vector<int64_t> rec_idx;
|
|
|
|
|
auto output_names = this->predictor_->GetOutputNames();
|
|
|
|
|
auto output_t = this->predictor_->GetOutputTensor(output_names[0]);
|
|
|
|
|
auto rec_idx_lod = output_t->lod();
|
|
|
|
|
auto shape_out = output_t->shape();
|
|
|
|
|
|
|
|
|
|
int out_num = std::accumulate(shape_out.begin(), shape_out.end(), 1,
|
|
|
|
|
std::multiplies<int>());
|
|
|
|
|
|
|
|
|
@ -120,7 +123,8 @@ void CRNNRecognizer::LoadModel(const std::string &model_dir) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// false for zero copy tensor
|
|
|
|
|
config.SwitchUseFeedFetchOps(false);
|
|
|
|
|
// true for commom tensor
|
|
|
|
|
config.SwitchUseFeedFetchOps(true);
|
|
|
|
|
// true for multiple input
|
|
|
|
|
config.SwitchSpecifyInputNames(true);
|
|
|
|
|
|
|
|
|
|