table_structure_recognition.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. class TableStructureRecognition(PaddleXPredictorWrapper):
  21. def __init__(
  22. self,
  23. *args,
  24. **kwargs,
  25. ):
  26. self._extra_init_args = {}
  27. super().__init__(*args, **kwargs)
  28. @property
  29. def default_model_name(self):
  30. return "SLANet"
  31. @classmethod
  32. def get_cli_subcommand_executor(cls):
  33. return TableStructureRecognitionSubcommandExecutor()
  34. def _get_extra_paddlex_predictor_init_args(self):
  35. return self._extra_init_args
  36. class TableStructureRecognitionSubcommandExecutor(PredictorCLISubcommandExecutor):
  37. @property
  38. def subparser_name(self):
  39. return "table_structure_recognition"
  40. def _update_subparser(self, subparser):
  41. add_simple_inference_args(subparser)
  42. def execute_with_args(self, args):
  43. params = get_subcommand_args(args)
  44. perform_simple_inference(TableStructureRecognition, params)