FastDeploy  latest
Fast & Easy to Deploy!
All Classes Namespaces Files Functions Variables Enumerations Enumerator Pages
preprocessor.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/vision/common/processors/transform.h"
17 #include "fastdeploy/vision/common/result.h"
18 
19 namespace fastdeploy {
20 namespace vision {
21 
22 namespace classification {
25 class FASTDEPLOY_DECL YOLOv5ClsPreprocessor {
26  public:
30 
38  bool Run(std::vector<FDMat>* images, std::vector<FDTensor>* outputs,
39  std::vector<std::map<std::string, std::array<float, 2>>>* ims_info);
40 
42  void SetSize(const std::vector<int>& size) { size_ = size; }
43 
45  std::vector<int> GetSize() const { return size_; }
46 
47  protected:
48  bool Preprocess(FDMat* mat, FDTensor* output,
49  std::map<std::string, std::array<float, 2>>* im_info);
50 
51  // target size, tuple of (width, height), default size = {224, 224}
52  std::vector<int> size_;
53 };
54 
55 } // namespace classification
56 } // namespace vision
57 } // namespace fastdeploy
std::vector< int > GetSize() const
Get target size, tuple of (width, height), default size = {224, 224}.
Definition: preprocessor.h:45
FDTensor object used to represend data matrix.
Definition: fd_tensor.h:31
void SetSize(const std::vector< int > &size)
Set target size, tuple of (width, height), default size = {224, 224}.
Definition: preprocessor.h:42
FDMat is a structure for replace cv::Mat.
Definition: mat.h:34
Preprocessor object for YOLOv5Cls serials model.
Definition: preprocessor.h:25
All C++ FastDeploy APIs are defined inside this namespace.
Definition: option.h:16