text_detection.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # Copyright (c) 2025 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. from .._utils.cli import (
  15. add_simple_inference_args,
  16. get_subcommand_args,
  17. perform_simple_inference,
  18. )
  19. from .base import PaddleXPredictorWrapper, PredictorCLISubcommandExecutor
  20. from ._text_detection import TextDetectionMixin, TextDetectionSubcommandExecutorMixin
  21. class TextDetection(TextDetectionMixin, PaddleXPredictorWrapper):
  22. @property
  23. def default_model_name(self):
  24. return "PP-OCRv5_server_det"
  25. @classmethod
  26. def get_cli_subcommand_executor(cls):
  27. return TextDetectionSubcommandExecutor()
  28. class TextDetectionSubcommandExecutor(
  29. TextDetectionSubcommandExecutorMixin, PredictorCLISubcommandExecutor
  30. ):
  31. @property
  32. def subparser_name(self):
  33. return "text_detection"
  34. def _update_subparser(self, subparser):
  35. add_simple_inference_args(subparser)
  36. self._add_text_detection_args(subparser)
  37. def execute_with_args(self, args):
  38. params = get_subcommand_args(args)
  39. perform_simple_inference(TextDetection, params)