FastDeploy  latest
Fast & Easy to Deploy!
yolov5seg.h
1 // Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. //NOLINT
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 
17 #include "fastdeploy/fastdeploy_model.h"
18 #include "fastdeploy/vision/detection/contrib/yolov5seg/preprocessor.h"
19 #include "fastdeploy/vision/detection/contrib/yolov5seg/postprocessor.h"
20 
21 namespace fastdeploy {
22 namespace vision {
23 namespace detection {
26 class FASTDEPLOY_DECL YOLOv5Seg : public FastDeployModel {
27  public:
35  YOLOv5Seg(const std::string& model_file, const std::string& params_file = "",
36  const RuntimeOption& custom_option = RuntimeOption(),
37  const ModelFormat& model_format = ModelFormat::ONNX);
38 
39  std::string ModelName() const { return "yolov5seg"; }
40 
47  virtual bool Predict(const cv::Mat& img, DetectionResult* result);
48 
55  virtual bool BatchPredict(const std::vector<cv::Mat>& imgs,
56  std::vector<DetectionResult>* results);
57 
60  return preprocessor_;
61  }
62 
65  return postprocessor_;
66  }
67 
68  protected:
69  bool Initialize();
70  YOLOv5SegPreprocessor preprocessor_;
71  YOLOv5SegPostprocessor postprocessor_;
72 };
73 
74 } // namespace detection
75 } // namespace vision
76 } // namespace fastdeploy
Option object used when create a new Runtime object.
Definition: runtime_option.h:40
std::string ModelName() const
Get model&#39;s name.
Definition: yolov5seg.h:39
Base model object for all the vision models.
Definition: fastdeploy_model.h:21
Preprocessor object for YOLOv5Seg serials model.
Definition: preprocessor.h:25
ModelFormat
Definition: enum_variables.h:67
Detection result structure for all the object detection models and instance segmentation models...
Definition: result.h:106
virtual YOLOv5SegPreprocessor & GetPreprocessor()
Get preprocessor reference of YOLOv5Seg.
Definition: yolov5seg.h:59
YOLOv5Seg model object used when to load a YOLOv5Seg model exported by YOLOv5.
Definition: yolov5seg.h:26
Model with ONNX format.
Definition: enum_variables.h:70
virtual YOLOv5SegPostprocessor & GetPostprocessor()
Get postprocessor reference of YOLOv5Seg.
Definition: yolov5seg.h:64
Postprocessor object for YOLOv5Seg serials model.
Definition: postprocessor.h:25
All C++ FastDeploy APIs are defined inside this namespace.
Definition: option.h:16