runner.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. # !/usr/bin/env python3
  2. # -*- coding: UTF-8 -*-
  3. ################################################################################
  4. #
  5. # Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved
  6. #
  7. ################################################################################
  8. """
  9. Author: PaddlePaddle Authors
  10. """
  11. from ..text_rec.runner import TextRecRunner
  12. from ...base.utils.subprocess import CompletedProcess
  13. class TextDetRunner(TextRecRunner):
  14. """ Text Detection Runner """
  15. def predict(self, config_path: str, cli_args: list,
  16. device: str) -> CompletedProcess:
  17. """run predicting using dynamic mode
  18. Args:
  19. config_path (str): the config file path used to predict.
  20. cli_args (list): the additional parameters.
  21. device (str): unused.
  22. Returns:
  23. CompletedProcess: the result of predicting subprocess execution.
  24. """
  25. # `cli_args` and `device` unused
  26. cmd = [self.python, 'tools/infer_det.py', '-c', config_path]
  27. return self.run_cmd(cmd, switch_wdir=True, echo=True, silent=False)
  28. def infer(self, config_path: str, cli_args: list,
  29. device: str) -> CompletedProcess:
  30. """run predicting using inference model
  31. Args:
  32. config_path (str): the path of config file used to predict.
  33. cli_args (list): the additional parameters.
  34. device (str): unused.
  35. Returns:
  36. CompletedProcess: the result of infering subprocess execution.
  37. """
  38. # `config_path` and `device` unused
  39. cmd = [self.python, 'tools/infer/predict_det.py', *cli_args]
  40. return self.run_cmd(cmd, switch_wdir=True, echo=True, silent=False)