pptinypose_pybind.cc 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. #include "ultra_infer/pybind/main.h"
  15. namespace ultra_infer {
  16. void BindPPTinyPose(pybind11::module &m) {
  17. pybind11::class_<vision::keypointdetection::PPTinyPose, UltraInferModel>(
  18. m, "PPTinyPose")
  19. .def(pybind11::init<std::string, std::string, std::string, RuntimeOption,
  20. ModelFormat>())
  21. .def("predict",
  22. [](vision::keypointdetection::PPTinyPose &self,
  23. pybind11::array &data) {
  24. auto mat = PyArrayToCvMat(data);
  25. vision::KeyPointDetectionResult res;
  26. self.Predict(&mat, &res);
  27. return res;
  28. })
  29. .def("predict",
  30. [](vision::keypointdetection::PPTinyPose &self,
  31. pybind11::array &data,
  32. vision::DetectionResult &detection_result) {
  33. auto mat = PyArrayToCvMat(data);
  34. vision::KeyPointDetectionResult res;
  35. self.Predict(&mat, &res, detection_result);
  36. return res;
  37. })
  38. .def("disable_normalize",
  39. [](vision::keypointdetection::PPTinyPose &self) {
  40. self.DisableNormalize();
  41. })
  42. .def("disable_permute",
  43. [](vision::keypointdetection::PPTinyPose &self) {
  44. self.DisablePermute();
  45. })
  46. .def_readwrite("use_dark",
  47. &vision::keypointdetection::PPTinyPose::use_dark);
  48. }
  49. } // namespace ultra_infer