FastDeploy  latest
Fast & Easy to Deploy!
base.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/fastdeploy_model.h"
17 #include "fastdeploy/vision/detection/ppdet/preprocessor.h"
18 #include "fastdeploy/vision/detection/ppdet/postprocessor.h"
19 #include "fastdeploy/vision/common/processors/transform.h"
20 #include "fastdeploy/vision/common/result.h"
21 
22 #include "fastdeploy/vision/utils/utils.h"
23 
24 namespace fastdeploy {
25 namespace vision {
29 namespace detection {
30 
33 class FASTDEPLOY_DECL PPDetBase : public FastDeployModel {
34  public:
43  PPDetBase(const std::string& model_file, const std::string& params_file,
44  const std::string& config_file,
45  const RuntimeOption& custom_option = RuntimeOption(),
46  const ModelFormat& model_format = ModelFormat::PADDLE);
47 
52  virtual std::unique_ptr<PPDetBase> Clone() const;
53 
55  virtual std::string ModelName() const { return "PaddleDetection/BaseModel"; }
56 
63  virtual bool Predict(cv::Mat* im, DetectionResult* result);
64 
70  virtual bool Predict(const cv::Mat& im, DetectionResult* result);
71 
77  virtual bool BatchPredict(const std::vector<cv::Mat>& imgs,
78  std::vector<DetectionResult>* results);
79 
80  PaddleDetPreprocessor& GetPreprocessor() {
81  return preprocessor_;
82  }
83 
84  PaddleDetPostprocessor& GetPostprocessor() {
85  return postprocessor_;
86  }
87 
88  protected:
89  virtual bool Initialize();
90  PaddleDetPreprocessor preprocessor_;
91  PaddleDetPostprocessor postprocessor_;
92 };
93 
94 } // namespace detection
95 } // namespace vision
96 } // namespace fastdeploy
Option object used when create a new Runtime object.
Definition: runtime_option.h:40
Base model object for all the vision models.
Definition: fastdeploy_model.h:21
Base model object used when to load a model exported by PaddleDetection.
Definition: base.h:33
ModelFormat
Definition: enum_variables.h:67
virtual std::string ModelName() const
Get model&#39;s name.
Definition: base.h:55
Detection result structure for all the object detection models and instance segmentation models...
Definition: result.h:106
Postprocessor object for PaddleDet serials model.
Definition: postprocessor.h:25
Preprocessor object for PaddleDet serials model.
Definition: preprocessor.h:26
Model with paddlepaddle format.
Definition: enum_variables.h:69
All C++ FastDeploy APIs are defined inside this namespace.
Definition: option.h:16