FastDeploy  latest
Fast & Easy to Deploy!
pptinypose.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/common/processors/transform.h"
18 #include "fastdeploy/vision/common/result.h"
19 
20 #include "fastdeploy/vision/keypointdet/pptinypose/pptinypose_utils.h"
21 
22 namespace fastdeploy {
23 namespace vision {
27 namespace keypointdetection {
28 
31 class FASTDEPLOY_DECL PPTinyPose : public FastDeployModel {
32  public:
41  PPTinyPose(const std::string& model_file, const std::string& params_file,
42  const std::string& config_file,
43  const RuntimeOption& custom_option = RuntimeOption(),
44  const ModelFormat& model_format = ModelFormat::PADDLE);
45 
47  std::string ModelName() const { return "PaddleDetection/PPTinyPose"; }
48 
55  bool Predict(cv::Mat* im, KeyPointDetectionResult* result);
56 
64  bool Predict(cv::Mat* im, KeyPointDetectionResult* result,
65  const DetectionResult& detection_result);
66 
69  bool use_dark = true;
70 
73  disable_normalize_ = true;
74  BuildPreprocessPipelineFromConfig();
75  }
76 
78  void DisablePermute() {
79  disable_permute_ = true;
80  BuildPreprocessPipelineFromConfig();
81  }
82 
83  protected:
84  bool Initialize();
86  bool BuildPreprocessPipelineFromConfig();
88  bool Preprocess(Mat* mat, std::vector<FDTensor>* outputs);
89 
91  bool Postprocess(std::vector<FDTensor>& infer_result,
93  const std::vector<float>& center,
94  const std::vector<float>& scale);
95 
96  private:
97  std::vector<std::shared_ptr<Processor>> processors_;
98  std::string config_file_;
99  // for recording the switch of hwc2chw
100  bool disable_permute_ = false;
101  // for recording the switch of normalize
102  bool disable_normalize_ = false;
103 };
104 } // namespace keypointdetection
105 } // namespace vision
106 } // 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
ModelFormat
Definition: enum_variables.h:67
void DisableNormalize()
This function will disable normalize in preprocessing step.
Definition: pptinypose.h:72
Detection result structure for all the object detection models and instance segmentation models...
Definition: result.h:106
std::string ModelName() const
Get model&#39;s name.
Definition: pptinypose.h:47
FDMat is a structure for replace cv::Mat.
Definition: mat.h:34
PPTinyPose model object used when to load a PPTinyPose model exported by PaddleDetection.
Definition: pptinypose.h:31
KeyPoint Detection result structure for all the keypoint detection models.
Definition: result.h:145
Model with paddlepaddle format.
Definition: enum_variables.h:69
All C++ FastDeploy APIs are defined inside this namespace.
Definition: option.h:16
void DisablePermute()
This function will disable hwc2chw in preprocessing step.
Definition: pptinypose.h:78