ppmsvsr.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. #pragma once
  15. #include "ultra_infer/ultra_infer_model.h"
  16. #include "ultra_infer/vision/common/processors/transform.h"
  17. namespace ultra_infer {
  18. namespace vision {
  19. namespace sr {
  20. class ULTRAINFER_DECL PPMSVSR : public UltraInferModel {
  21. public:
  22. /**
  23. * Set path of model file and configuration file, and the configuration of
  24. * runtime
  25. * @param[in] model_file Path of model file, e.g PPMSVSR/model.pdmodel
  26. * @param[in] params_file Path of parameter file, e.g PPMSVSR/model.pdiparams
  27. * @param[in] custom_option RuntimeOption for inference, the default will use
  28. * cpu, and choose the backend defined in `valid_cpu_backends`
  29. * @param[in] model_format Model format of the loaded model, default is Paddle
  30. * format
  31. */
  32. PPMSVSR(const std::string &model_file, const std::string &params_file,
  33. const RuntimeOption &custom_option = RuntimeOption(),
  34. const ModelFormat &model_format = ModelFormat::PADDLE);
  35. /// model name contained PP-MSVSR。
  36. std::string ModelName() const override { return "PPMSVSR"; }
  37. /**
  38. * get super resolution frame sequence
  39. * @param[in] imgs origin frame sequences
  40. * @param[in] results super resolution frame sequence
  41. * @return true if the prediction succeeded, otherwise false
  42. */
  43. virtual bool Predict(std::vector<cv::Mat> &imgs,
  44. std::vector<cv::Mat> &results);
  45. protected:
  46. PPMSVSR(){};
  47. virtual bool Initialize();
  48. virtual bool Preprocess(Mat *mat, std::vector<float> &output);
  49. virtual bool Postprocess(std::vector<FDTensor> &infer_results,
  50. std::vector<cv::Mat> &results);
  51. std::vector<float> mean_;
  52. std::vector<float> scale_;
  53. };
  54. } // namespace sr
  55. } // namespace vision
  56. } // namespace ultra_infer