FastDeploy  latest
Fast & Easy to Deploy!
yolov7end2end_ort.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 #include "fastdeploy/fastdeploy_model.h"
17 #include "fastdeploy/vision/common/processors/transform.h"
18 #include "fastdeploy/vision/common/result.h"
19 
20 namespace fastdeploy {
21 namespace vision {
22 namespace detection {
25 class FASTDEPLOY_DECL YOLOv7End2EndORT : public FastDeployModel {
26  public:
34  YOLOv7End2EndORT(const std::string& model_file,
35  const std::string& params_file = "",
36  const RuntimeOption& custom_option = RuntimeOption(),
37  const ModelFormat& model_format = ModelFormat::ONNX);
38 
39  virtual std::string ModelName() const { return "yolov7end2end_ort"; }
47  virtual bool Predict(cv::Mat* im, DetectionResult* result,
48  float conf_threshold = 0.25);
49 
53  std::vector<int> size;
54  // padding value, size should be the same as channels
55 
56  std::vector<float> padding_value;
57  // only pad to the minimum rectange which height and width is times of stride
58  bool is_mini_pad;
59  // while is_mini_pad = false and is_no_pad = true,
60  // will resize the image to the set size
61  bool is_no_pad;
62  // if is_scale_up is false, the input image only can be zoom out,
63  // the maximum resize scale cannot exceed 1.0
64  bool is_scale_up;
65  // padding stride, for is_mini_pad
66  int stride;
67 
68  private:
69  bool Initialize();
70 
71  bool Preprocess(Mat* mat, FDTensor* output,
72  std::map<std::string, std::array<float, 2>>* im_info);
73 
74  bool Postprocess(FDTensor& infer_result, DetectionResult* result,
75  const std::map<std::string, std::array<float, 2>>& im_info,
76  float conf_threshold);
77 
78  void LetterBox(Mat* mat, const std::vector<int>& size,
79  const std::vector<float>& color, bool _auto,
80  bool scale_fill = false, bool scale_up = true,
81  int stride = 32);
82 
83  bool is_dynamic_input_;
84 };
85 } // namespace detection
86 } // namespace vision
87 } // namespace fastdeploy
virtual std::string ModelName() const
Get model&#39;s name.
Definition: yolov7end2end_ort.h:39
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
FDTensor object used to represend data matrix.
Definition: fd_tensor.h:31
std::vector< int > size
Argument for image preprocessing step, tuple of (width, height), decide the target size after resize...
Definition: yolov7end2end_ort.h:53
Detection result structure for all the object detection models and instance segmentation models...
Definition: result.h:106
YOLOv7End2EndORT model object used when to load a YOLOv7End2EndORT model exported by YOLOv7...
Definition: yolov7end2end_ort.h:25
FDMat is a structure for replace cv::Mat.
Definition: mat.h:34
Model with ONNX format.
Definition: enum_variables.h:70
All C++ FastDeploy APIs are defined inside this namespace.
Definition: option.h:16