FastDeploy  latest
Fast & Easy to Deploy!
yolov5cls.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/classification/contrib/yolov5cls/preprocessor.h"
19 #include "fastdeploy/vision/classification/contrib/yolov5cls/postprocessor.h"
20 
21 namespace fastdeploy {
22 namespace vision {
23 namespace classification {
26 class FASTDEPLOY_DECL YOLOv5Cls : public FastDeployModel {
27  public:
35  YOLOv5Cls(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 "yolov5cls"; }
40 
47  virtual bool Predict(const cv::Mat& img, ClassifyResult* result);
48 
55  virtual bool BatchPredict(const std::vector<cv::Mat>& imgs,
56  std::vector<ClassifyResult>* results);
57 
60  return preprocessor_;
61  }
62 
65  return postprocessor_;
66  }
67 
68  protected:
69  bool Initialize();
70  YOLOv5ClsPreprocessor preprocessor_;
71  YOLOv5ClsPostprocessor postprocessor_;
72 };
73 
74 } // namespace classification
75 } // namespace vision
76 } // 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
std::string ModelName() const
Get model&#39;s name.
Definition: yolov5cls.h:39
Postprocessor object for YOLOv5Cls serials model.
Definition: postprocessor.h:25
Classify result structure for all the image classify models.
Definition: result.h:46
virtual YOLOv5ClsPostprocessor & GetPostprocessor()
Get postprocessor reference of YOLOv5Cls.
Definition: yolov5cls.h:64
YOLOv5Cls model object used when to load a YOLOv5Cls model exported by YOLOv5Cls. ...
Definition: yolov5cls.h:26
Model with ONNX format.
Definition: enum_variables.h:70
virtual YOLOv5ClsPreprocessor & GetPreprocessor()
Get preprocessor reference of YOLOv5Cls.
Definition: yolov5cls.h:59
Preprocessor object for YOLOv5Cls serials model.
Definition: preprocessor.h:25
All C++ FastDeploy APIs are defined inside this namespace.
Definition: option.h:16