FastDeploy  latest
Fast & Easy to Deploy!
ppmatting.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 #pragma once
15 #include "fastdeploy/fastdeploy_model.h"
16 #include "fastdeploy/vision/common/processors/transform.h"
17 #include "fastdeploy/vision/common/result.h"
18 
19 namespace fastdeploy {
20 namespace vision {
24 namespace matting {
27 class FASTDEPLOY_DECL PPMatting : public FastDeployModel {
28  public:
37  PPMatting(const std::string& model_file, const std::string& params_file,
38  const std::string& config_file,
39  const RuntimeOption& custom_option = RuntimeOption(),
40  const ModelFormat& model_format = ModelFormat::PADDLE);
41 
42  std::string ModelName() const { return "PaddleMatting"; }
49  virtual bool Predict(cv::Mat* im, MattingResult* result);
50 
51  private:
52  bool Initialize();
53 
54  bool BuildPreprocessPipelineFromConfig();
55 
56  bool Preprocess(Mat* mat, FDTensor* outputs,
57  std::map<std::string, std::array<int, 2>>* im_info);
58 
59  bool Postprocess(std::vector<FDTensor>& infer_result, MattingResult* result,
60  const std::map<std::string, std::array<int, 2>>& im_info);
61 
62  std::vector<std::shared_ptr<Processor>> processors_;
63  std::string config_file_;
64  bool is_fixed_input_shape_;
65 };
66 
67 } // namespace matting
68 } // namespace vision
69 } // 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
PPMatting model object used when to load a PPMatting model exported by PPMatting. ...
Definition: ppmatting.h:27
ModelFormat
Definition: enum_variables.h:67
FDTensor object used to represend data matrix.
Definition: fd_tensor.h:31
Matting result structure for all the Matting models.
Definition: result.h:331
FDMat is a structure for replace cv::Mat.
Definition: mat.h:34
std::string ModelName() const
Get model&#39;s name.
Definition: ppmatting.h:42
Model with paddlepaddle format.
Definition: enum_variables.h:69
All C++ FastDeploy APIs are defined inside this namespace.
Definition: option.h:16