runner.py 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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 ..text_rec.runner import TextRecRunner
  15. from ...base.utils.subprocess import CompletedProcess
  16. class TableRecRunner(TextRecRunner):
  17. """ Table Recognition Runner """
  18. def predict(self, config_path: str, cli_args: list,
  19. device: str) -> CompletedProcess:
  20. """run predicting using dynamic mode
  21. Args:
  22. config_path (str): the config file path used to predict.
  23. cli_args (list): the additional parameters.
  24. device (str): unused.
  25. Returns:
  26. CompletedProcess: the result of predicting subprocess execution.
  27. """
  28. cmd = [self.python, 'tools/infer_table.py', '-c', config_path]
  29. return self.run_cmd(cmd, switch_wdir=True, echo=True, silent=False)
  30. def infer(self, config_path: str, cli_args: list,
  31. device: str) -> CompletedProcess:
  32. """run predicting using inference model
  33. Args:
  34. config_path (str): the path of config file used to predict.
  35. cli_args (list): the additional parameters.
  36. device (str): unused.
  37. Returns:
  38. CompletedProcess: the result of infering subprocess execution.
  39. """
  40. cmd = [self.python, 'ppstructure/table/predict_structure.py', *cli_args]
  41. return self.run_cmd(cmd, switch_wdir=True, echo=True, silent=False)