FastDeploy  latest
Fast & Easy to Deploy!
model.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/segmentation/ppseg/preprocessor.h"
18 #include "fastdeploy/vision/segmentation/ppseg/postprocessor.h"
19 
20 namespace fastdeploy {
21 namespace vision {
25 namespace segmentation {
26 
29 class FASTDEPLOY_DECL PaddleSegModel : public FastDeployModel {
30  public:
39  PaddleSegModel(const std::string& model_file, const std::string& params_file,
40  const std::string& config_file,
41  const RuntimeOption& custom_option = RuntimeOption(),
42  const ModelFormat& model_format = ModelFormat::PADDLE);
43 
48  virtual std::unique_ptr<PaddleSegModel> Clone() const;
49 
51  std::string ModelName() const { return "PaddleSeg"; }
52 
59  virtual bool Predict(cv::Mat* im, SegmentationResult* result);
60 
67  virtual bool Predict(const cv::Mat& im, SegmentationResult* result);
68 
75  virtual bool BatchPredict(const std::vector<cv::Mat>& imgs,
76  std::vector<SegmentationResult>* results);
77 
80  return preprocessor_;
81  }
82 
85  return postprocessor_;
86  }
87 
88  protected:
89  bool Initialize();
90  PaddleSegPreprocessor preprocessor_;
91  PaddleSegPostprocessor postprocessor_;
92 };
93 
94 } // namespace segmentation
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
std::string ModelName() const
Get model&#39;s name.
Definition: model.h:51
Segmentation result structure for all the segmentation models.
Definition: result.h:270
ModelFormat
Definition: enum_variables.h:67
virtual PaddleSegPreprocessor & GetPreprocessor()
Get preprocessor reference of PaddleSegModel.
Definition: model.h:79
Preprocessor object for PaddleSeg serials model.
Definition: preprocessor.h:23
Postprocessor object for PaddleSeg serials model.
Definition: postprocessor.h:25
virtual PaddleSegPostprocessor & GetPostprocessor()
Get postprocessor reference of PaddleSegModel.
Definition: model.h:84
PaddleSeg serials model object used when to load a PaddleSeg model exported by PaddleSeg repository...
Definition: model.h:29
Model with paddlepaddle format.
Definition: enum_variables.h:69
All C++ FastDeploy APIs are defined inside this namespace.
Definition: option.h:16