FastDeploy  latest
Fast & Easy to Deploy!
rec_postprocessor.h
1 // Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #pragma once
16 #include "fastdeploy/vision/common/processors/transform.h"
17 #include "fastdeploy/vision/common/result.h"
18 #include "fastdeploy/vision/ocr/ppocr/utils/ocr_postprocess_op.h"
19 
20 namespace fastdeploy {
21 namespace vision {
22 
23 namespace ocr {
26 class FASTDEPLOY_DECL RecognizerPostprocessor {
27  public:
33  explicit RecognizerPostprocessor(const std::string& label_path);
34 
42  bool Run(const std::vector<FDTensor>& tensors,
43  std::vector<std::string>* texts, std::vector<float>* rec_scores);
44 
45  bool Run(const std::vector<FDTensor>& tensors,
46  std::vector<std::string>* texts, std::vector<float>* rec_scores,
47  size_t start_index, size_t total_size,
48  const std::vector<int>& indices);
49 
50  private:
51  bool SingleBatchPostprocessor(const float* out_data,
52  const std::vector<int64_t>& output_shape,
53  std::string* text, float* rec_score);
54  bool initialized_ = false;
55  std::vector<std::string> label_list_;
56 };
57 
58 } // namespace ocr
59 } // namespace vision
60 } // namespace fastdeploy
All C++ FastDeploy APIs are defined inside this namespace.
Definition: option.h:16
Postprocessor object for Recognizer serials model.
Definition: rec_postprocessor.h:26