FastDeploy  latest
Fast & Easy to Deploy!
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/manager.h"
17 #include "fastdeploy/vision/common/processors/transform.h"
18 #include "fastdeploy/vision/common/result.h"
19 
20 namespace fastdeploy {
21 namespace vision {
22 
23 namespace classification {
26 class FASTDEPLOY_DECL PaddleClasPreprocessor : public ProcessorManager {
27  public:
32  explicit PaddleClasPreprocessor(const std::string& config_file);
33 
42  virtual bool Apply(FDMatBatch* image_batch,
43  std::vector<FDTensor>* outputs);
44 
46  void DisableNormalize();
48  void DisablePermute();
49 
56  void InitialResizeOnCpu(bool v) { initial_resize_on_cpu_ = v; }
57 
58  private:
59  bool BuildPreprocessPipelineFromConfig();
60  bool initialized_ = false;
61  std::vector<std::shared_ptr<Processor>> processors_;
62  // for recording the switch of hwc2chw
63  bool disable_permute_ = false;
64  // for recording the switch of normalize
65  bool disable_normalize_ = false;
66  // read config file
67  std::string config_file_;
68  bool initial_resize_on_cpu_ = false;
69 };
70 
71 } // namespace classification
72 } // namespace vision
73 } // namespace fastdeploy
Preprocessor object for PaddleClas serials model.
Definition: preprocessor.h:26
void InitialResizeOnCpu(bool v)
When the initial operator is Resize, and input image size is large, maybe it&#39;s better to run resize o...
Definition: preprocessor.h:56
FDMatBatch contains batch data for preprocess.
Definition: mat_batch.h:28
ProcessorManager for Preprocess.
Definition: manager.h:27
All C++ FastDeploy APIs are defined inside this namespace.
Definition: option.h:16