__init__.py 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. # copyright (c) 2024 PaddlePaddle Authors. All Rights Reserve.
  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. from __future__ import absolute_import
  15. from ... import c_lib_wrap as C
  16. class PPTinyPose(object):
  17. def __init__(self, det_model=None, pptinypose_model=None):
  18. """Set initialized detection model object and pptinypose model object
  19. :param det_model: (ultra_infer.vision.detection.PicoDet)Initialized detection model object
  20. :param pptinypose_model: (ultra_infer.vision.keypointdetection.PPTinyPose)Initialized pptinypose model object
  21. """
  22. assert (
  23. det_model is not None or pptinypose_model is not None
  24. ), "The det_model and pptinypose_model cannot be None."
  25. self._pipeline = C.pipeline.PPTinyPose(
  26. det_model._model, pptinypose_model._model
  27. )
  28. def predict(self, input_image):
  29. """Predict the keypoint detection result for an input image
  30. :param im: (numpy.ndarray)The input image data, 3-D array with layout HWC, BGR format
  31. :return: KeyPointDetectionResult
  32. """
  33. return self._pipeline.predict(input_image)
  34. @property
  35. def detection_model_score_threshold(self):
  36. """Atrribute of PPTinyPose pipeline model. Stating the score threshold for detectin model to filter bbox before inputting pptinypose model
  37. :return: value of detection_model_score_threshold(float)
  38. """
  39. return self._pipeline.detection_model_score_threshold
  40. @detection_model_score_threshold.setter
  41. def detection_model_score_threshold(self, value):
  42. """Set attribute detection_model_score_threshold of PPTinyPose pipeline model.
  43. :param value: (float)The value to set use_dark
  44. """
  45. assert isinstance(
  46. value, float
  47. ), "The value to set `detection_model_score_threshold` must be type of float."
  48. self._pipeline.detection_model_score_threshold = value