paddleocr 0.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. paddleocr/__init__.py +65 -0
  2. paddleocr/__main__.py +39 -0
  3. paddleocr/_abstract.py +25 -0
  4. paddleocr/_cli.py +118 -0
  5. paddleocr/_common_args.py +142 -0
  6. paddleocr/_constants.py +21 -0
  7. paddleocr/_env.py +19 -0
  8. paddleocr/_mkldnn_blocklists.py +31 -0
  9. paddleocr/_models/__init__.py +41 -0
  10. paddleocr/_models/_image_classification.py +52 -0
  11. paddleocr/_models/_object_detection.py +87 -0
  12. paddleocr/_models/_text_detection.py +75 -0
  13. paddleocr/_models/base.py +108 -0
  14. paddleocr/_models/doc_img_orientation_classification.py +40 -0
  15. paddleocr/_models/doc_vlm.py +63 -0
  16. paddleocr/_models/formula_recognition.py +54 -0
  17. paddleocr/_models/layout_detection.py +38 -0
  18. paddleocr/_models/seal_text_detection.py +47 -0
  19. paddleocr/_models/table_cells_detection.py +38 -0
  20. paddleocr/_models/table_classification.py +38 -0
  21. paddleocr/_models/table_structure_recognition.py +54 -0
  22. paddleocr/_models/text_detection.py +47 -0
  23. paddleocr/_models/text_image_unwarping.py +54 -0
  24. paddleocr/_models/text_line_orientation_classification.py +40 -0
  25. paddleocr/_models/text_recognition.py +64 -0
  26. paddleocr/_pipelines/__init__.py +33 -0
  27. paddleocr/_pipelines/base.py +133 -0
  28. paddleocr/_pipelines/doc_preprocessor.py +147 -0
  29. paddleocr/_pipelines/doc_understanding.py +107 -0
  30. paddleocr/_pipelines/formula_recognition.py +283 -0
  31. paddleocr/_pipelines/ocr.py +578 -0
  32. paddleocr/_pipelines/pp_chatocrv4_doc.py +681 -0
  33. paddleocr/_pipelines/pp_structurev3.py +736 -0
  34. paddleocr/_pipelines/seal_recognition.py +375 -0
  35. paddleocr/_pipelines/table_recognition_v2.py +434 -0
  36. paddleocr/_pipelines/utils.py +30 -0
  37. paddleocr/_utils/__init__.py +13 -0
  38. paddleocr/_utils/cli.py +63 -0
  39. paddleocr/_utils/deprecation.py +42 -0
  40. paddleocr/_utils/logging.py +39 -0
  41. paddleocr/_version.py +20 -0
  42. paddleocr-0.0.0.dist-info/LICENSE +201 -0
  43. paddleocr-0.0.0.dist-info/METADATA +314 -0
  44. paddleocr-0.0.0.dist-info/RECORD +47 -0
  45. paddleocr-0.0.0.dist-info/WHEEL +5 -0
  46. paddleocr-0.0.0.dist-info/entry_points.txt +2 -0
  47. paddleocr-0.0.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,75 @@
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
+
15
+
16
+ class TextDetectionMixin:
17
+ def __init__(
18
+ self,
19
+ *,
20
+ limit_side_len=None,
21
+ limit_type=None,
22
+ thresh=None,
23
+ box_thresh=None,
24
+ unclip_ratio=None,
25
+ input_shape=None,
26
+ **kwargs,
27
+ ):
28
+ self._extra_init_args = {
29
+ "limit_side_len": limit_side_len,
30
+ "limit_type": limit_type,
31
+ "thresh": thresh,
32
+ "box_thresh": box_thresh,
33
+ "unclip_ratio": unclip_ratio,
34
+ "input_shape": input_shape,
35
+ }
36
+ super().__init__(**kwargs)
37
+
38
+ def _get_extra_paddlex_predictor_init_args(self):
39
+ return self._extra_init_args
40
+
41
+
42
+ class TextDetectionSubcommandExecutorMixin:
43
+ def _add_text_detection_args(self, subparser):
44
+ subparser.add_argument(
45
+ "--limit_side_len",
46
+ type=int,
47
+ help="This sets a limit on the side length of the input image for the model.",
48
+ )
49
+ subparser.add_argument(
50
+ "--limit_type",
51
+ type=str,
52
+ help="This determines how the side length limit is applied to the input image before feeding it into the model.",
53
+ )
54
+ subparser.add_argument(
55
+ "--thresh",
56
+ type=float,
57
+ help="Detection pixel threshold for the model. Pixels with scores greater than this threshold in the output probability map are considered text pixels.",
58
+ )
59
+ subparser.add_argument(
60
+ "--box_thresh",
61
+ type=float,
62
+ help="Detection box threshold for the model. A detection result is considered a text region if the average score of all pixels within the border of the result is greater than this threshold.",
63
+ )
64
+ subparser.add_argument(
65
+ "--unclip_ratio",
66
+ type=float,
67
+ help="Expansion coefficient, which expands the text region using this method. The larger the value, the larger the expansion area.",
68
+ )
69
+ subparser.add_argument(
70
+ "--input_shape",
71
+ nargs=3,
72
+ type=int,
73
+ metavar=("C", "H", "W"),
74
+ help="Input shape of the model.",
75
+ )
@@ -0,0 +1,108 @@
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
+
15
+ import abc
16
+
17
+ from paddlex import create_predictor
18
+
19
+ from .._abstract import CLISubcommandExecutor
20
+ from .._common_args import (
21
+ add_common_cli_opts,
22
+ parse_common_args,
23
+ prepare_common_init_args,
24
+ )
25
+ from .._mkldnn_blocklists import MODEL_MKLDNN_BLOCKLIST
26
+ from .._utils.logging import logger
27
+
28
+ _DEFAULT_ENABLE_HPI = False
29
+
30
+
31
+ class PaddleXPredictorWrapper(metaclass=abc.ABCMeta):
32
+ def __init__(
33
+ self,
34
+ *,
35
+ model_name=None,
36
+ model_dir=None,
37
+ **common_args,
38
+ ):
39
+ super().__init__()
40
+ self._model_name = (
41
+ model_name if model_name is not None else self.default_model_name
42
+ )
43
+ self._model_dir = model_dir
44
+ if (
45
+ common_args.get("enable_mkldnn", None) is None
46
+ and self._model_name in MODEL_MKLDNN_BLOCKLIST
47
+ ):
48
+ logger.warning(
49
+ f"oneDNN will be disabled for the {repr(self._model_name)} model."
50
+ )
51
+ common_args["enable_mkldnn"] = False
52
+ self._common_args = parse_common_args(
53
+ common_args, default_enable_hpi=_DEFAULT_ENABLE_HPI
54
+ )
55
+ self.paddlex_predictor = self._create_paddlex_predictor()
56
+
57
+ @property
58
+ @abc.abstractmethod
59
+ def default_model_name(self):
60
+ raise NotImplementedError
61
+
62
+ def predict_iter(self, *args, **kwargs):
63
+ return self.paddlex_predictor.predict(*args, **kwargs)
64
+
65
+ def predict(self, *args, **kwargs):
66
+ result = list(self.predict_iter(*args, **kwargs))
67
+ return result
68
+
69
+ @classmethod
70
+ @abc.abstractmethod
71
+ def get_cli_subcommand_executor(cls):
72
+ raise NotImplementedError
73
+
74
+ def _get_extra_paddlex_predictor_init_args(self):
75
+ return {}
76
+
77
+ def _create_paddlex_predictor(self):
78
+ kwargs = prepare_common_init_args(self._model_name, self._common_args)
79
+ kwargs = {**self._get_extra_paddlex_predictor_init_args(), **kwargs}
80
+ # Should we check model names?
81
+ return create_predictor(
82
+ model_name=self._model_name, model_dir=self._model_dir, **kwargs
83
+ )
84
+
85
+
86
+ class PredictorCLISubcommandExecutor(CLISubcommandExecutor):
87
+ @property
88
+ @abc.abstractmethod
89
+ def subparser_name(self):
90
+ raise NotImplementedError
91
+
92
+ def add_subparser(self, subparsers):
93
+ subparser = subparsers.add_parser(name=self.subparser_name)
94
+ self._update_subparser(subparser)
95
+ subparser.add_argument("--model_name", type=str, help="Name of the model.")
96
+ subparser.add_argument(
97
+ "--model_dir", type=str, help="Directory where the model is stored."
98
+ )
99
+ add_common_cli_opts(
100
+ subparser,
101
+ default_enable_hpi=_DEFAULT_ENABLE_HPI,
102
+ allow_multiple_devices=False,
103
+ )
104
+ return subparser
105
+
106
+ @abc.abstractmethod
107
+ def _update_subparser(self, subparser):
108
+ raise NotImplementedError
@@ -0,0 +1,40 @@
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
+
15
+ from ._image_classification import (
16
+ ImageClassification,
17
+ ImageClassificationSubcommandExecutor,
18
+ )
19
+
20
+
21
+ class DocImgOrientationClassification(ImageClassification):
22
+ @property
23
+ def default_model_name(self):
24
+ return "PP-LCNet_x1_0_doc_ori"
25
+
26
+ @classmethod
27
+ def get_cli_subcommand_executor(cls):
28
+ return DocImgOrientationClassificationSubcommandExecutor()
29
+
30
+
31
+ class DocImgOrientationClassificationSubcommandExecutor(
32
+ ImageClassificationSubcommandExecutor
33
+ ):
34
+ @property
35
+ def subparser_name(self):
36
+ return "doc_img_orientation_classification"
37
+
38
+ @property
39
+ def wrapper_cls(self):
40
+ return DocImgOrientationClassification
@@ -0,0 +1,63 @@
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
+
15
+ from paddlex.utils.pipeline_arguments import custom_type
16
+
17
+ from .._utils.cli import (
18
+ add_simple_inference_args,
19
+ get_subcommand_args,
20
+ perform_simple_inference,
21
+ )
22
+ from .base import PaddleXPredictorWrapper, PredictorCLISubcommandExecutor
23
+ from paddlex.utils.pipeline_arguments import custom_type
24
+
25
+
26
+ class DocVLM(PaddleXPredictorWrapper):
27
+ def __init__(
28
+ self,
29
+ *args,
30
+ **kwargs,
31
+ ):
32
+ self._extra_init_args = {}
33
+ super().__init__(*args, **kwargs)
34
+
35
+ @property
36
+ def default_model_name(self):
37
+ return "PP-DocBee2-3B"
38
+
39
+ @classmethod
40
+ def get_cli_subcommand_executor(cls):
41
+ return DocVLMSubcommandExecutor()
42
+
43
+ def _get_extra_paddlex_predictor_init_args(self):
44
+ return self._extra_init_args
45
+
46
+
47
+ class DocVLMSubcommandExecutor(PredictorCLISubcommandExecutor):
48
+ input_validator = staticmethod(custom_type(dict))
49
+
50
+ @property
51
+ def subparser_name(self):
52
+ return "doc_vlm"
53
+
54
+ def _update_subparser(self, subparser):
55
+ add_simple_inference_args(
56
+ subparser,
57
+ input_help='Input dict, e.g. `{"image": "https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/medal_table.png", "query": "Recognize this table"}`.',
58
+ )
59
+
60
+ def execute_with_args(self, args):
61
+ params = get_subcommand_args(args)
62
+ params["input"] = self.input_validator(params["input"])
63
+ perform_simple_inference(DocVLM, params)
@@ -0,0 +1,54 @@
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
+
15
+ from .._utils.cli import (
16
+ add_simple_inference_args,
17
+ get_subcommand_args,
18
+ perform_simple_inference,
19
+ )
20
+ from .base import PaddleXPredictorWrapper, PredictorCLISubcommandExecutor
21
+
22
+
23
+ class FormulaRecognition(PaddleXPredictorWrapper):
24
+ def __init__(
25
+ self,
26
+ *args,
27
+ **kwargs,
28
+ ):
29
+ self._extra_init_args = {}
30
+ super().__init__(*args, **kwargs)
31
+
32
+ @property
33
+ def default_model_name(self):
34
+ return "PP-FormulaNet_plus-M"
35
+
36
+ @classmethod
37
+ def get_cli_subcommand_executor(cls):
38
+ return FormulaRecognitionSubcommandExecutor()
39
+
40
+ def _get_extra_paddlex_predictor_init_args(self):
41
+ return self._extra_init_args
42
+
43
+
44
+ class FormulaRecognitionSubcommandExecutor(PredictorCLISubcommandExecutor):
45
+ @property
46
+ def subparser_name(self):
47
+ return "formula_recognition"
48
+
49
+ def _update_subparser(self, subparser):
50
+ add_simple_inference_args(subparser)
51
+
52
+ def execute_with_args(self, args):
53
+ params = get_subcommand_args(args)
54
+ perform_simple_inference(FormulaRecognition, params)
@@ -0,0 +1,38 @@
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
+
15
+ from ._object_detection import (
16
+ ObjectDetection,
17
+ ObjectDetectionSubcommandExecutor,
18
+ )
19
+
20
+
21
+ class LayoutDetection(ObjectDetection):
22
+ @property
23
+ def default_model_name(self):
24
+ return "PP-DocLayout-L"
25
+
26
+ @classmethod
27
+ def get_cli_subcommand_executor(cls):
28
+ return LayoutDetectionSubcommandExecutor()
29
+
30
+
31
+ class LayoutDetectionSubcommandExecutor(ObjectDetectionSubcommandExecutor):
32
+ @property
33
+ def subparser_name(self):
34
+ return "layout_detection"
35
+
36
+ @property
37
+ def wrapper_cls(self):
38
+ return LayoutDetection
@@ -0,0 +1,47 @@
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
+
15
+ from .._utils.cli import (
16
+ add_simple_inference_args,
17
+ get_subcommand_args,
18
+ perform_simple_inference,
19
+ )
20
+ from .base import PaddleXPredictorWrapper, PredictorCLISubcommandExecutor
21
+ from ._text_detection import TextDetectionMixin, TextDetectionSubcommandExecutorMixin
22
+
23
+
24
+ class SealTextDetection(TextDetectionMixin, PaddleXPredictorWrapper):
25
+ @property
26
+ def default_model_name(self):
27
+ return "PP-OCRv4_mobile_seal_det"
28
+
29
+ @classmethod
30
+ def get_cli_subcommand_executor(cls):
31
+ return SealTextDetectionSubcommandExecutor()
32
+
33
+
34
+ class SealTextDetectionSubcommandExecutor(
35
+ TextDetectionSubcommandExecutorMixin, PredictorCLISubcommandExecutor
36
+ ):
37
+ @property
38
+ def subparser_name(self):
39
+ return "seal_text_detection"
40
+
41
+ def _update_subparser(self, subparser):
42
+ add_simple_inference_args(subparser)
43
+ self._add_text_detection_args(subparser)
44
+
45
+ def execute_with_args(self, args):
46
+ params = get_subcommand_args(args)
47
+ perform_simple_inference(SealTextDetection, params)
@@ -0,0 +1,38 @@
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
+
15
+ from ._object_detection import (
16
+ ObjectDetection,
17
+ ObjectDetectionSubcommandExecutor,
18
+ )
19
+
20
+
21
+ class TableCellsDetection(ObjectDetection):
22
+ @property
23
+ def default_model_name(self):
24
+ return "RT-DETR-L_wired_table_cell_det"
25
+
26
+ @classmethod
27
+ def get_cli_subcommand_executor(cls):
28
+ return TableCellsDetectionSubcommandExecutor()
29
+
30
+
31
+ class TableCellsDetectionSubcommandExecutor(ObjectDetectionSubcommandExecutor):
32
+ @property
33
+ def subparser_name(self):
34
+ return "table_cells_detection"
35
+
36
+ @property
37
+ def wrapper_cls(self):
38
+ return TableCellsDetection
@@ -0,0 +1,38 @@
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
+
15
+ from ._image_classification import (
16
+ ImageClassification,
17
+ ImageClassificationSubcommandExecutor,
18
+ )
19
+
20
+
21
+ class TableClassification(ImageClassification):
22
+ @property
23
+ def default_model_name(self):
24
+ return "PP-LCNet_x1_0_table_cls"
25
+
26
+ @classmethod
27
+ def get_cli_subcommand_executor(cls):
28
+ return TableClassificationSubcommandExecutor()
29
+
30
+
31
+ class TableClassificationSubcommandExecutor(ImageClassificationSubcommandExecutor):
32
+ @property
33
+ def subparser_name(self):
34
+ return "table_classification"
35
+
36
+ @property
37
+ def wrapper_cls(self):
38
+ return TableClassification
@@ -0,0 +1,54 @@
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
+
15
+ from .._utils.cli import (
16
+ add_simple_inference_args,
17
+ get_subcommand_args,
18
+ perform_simple_inference,
19
+ )
20
+ from .base import PaddleXPredictorWrapper, PredictorCLISubcommandExecutor
21
+
22
+
23
+ class TableStructureRecognition(PaddleXPredictorWrapper):
24
+ def __init__(
25
+ self,
26
+ *args,
27
+ **kwargs,
28
+ ):
29
+ self._extra_init_args = {}
30
+ super().__init__(*args, **kwargs)
31
+
32
+ @property
33
+ def default_model_name(self):
34
+ return "SLANet"
35
+
36
+ @classmethod
37
+ def get_cli_subcommand_executor(cls):
38
+ return TableStructureRecognitionSubcommandExecutor()
39
+
40
+ def _get_extra_paddlex_predictor_init_args(self):
41
+ return self._extra_init_args
42
+
43
+
44
+ class TableStructureRecognitionSubcommandExecutor(PredictorCLISubcommandExecutor):
45
+ @property
46
+ def subparser_name(self):
47
+ return "table_structure_recognition"
48
+
49
+ def _update_subparser(self, subparser):
50
+ add_simple_inference_args(subparser)
51
+
52
+ def execute_with_args(self, args):
53
+ params = get_subcommand_args(args)
54
+ perform_simple_inference(TableStructureRecognition, params)
@@ -0,0 +1,47 @@
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
+
15
+ from .._utils.cli import (
16
+ add_simple_inference_args,
17
+ get_subcommand_args,
18
+ perform_simple_inference,
19
+ )
20
+ from .base import PaddleXPredictorWrapper, PredictorCLISubcommandExecutor
21
+ from ._text_detection import TextDetectionMixin, TextDetectionSubcommandExecutorMixin
22
+
23
+
24
+ class TextDetection(TextDetectionMixin, PaddleXPredictorWrapper):
25
+ @property
26
+ def default_model_name(self):
27
+ return "PP-OCRv4_mobile_det"
28
+
29
+ @classmethod
30
+ def get_cli_subcommand_executor(cls):
31
+ return TextDetectionSubcommandExecutor()
32
+
33
+
34
+ class TextDetectionSubcommandExecutor(
35
+ TextDetectionSubcommandExecutorMixin, PredictorCLISubcommandExecutor
36
+ ):
37
+ @property
38
+ def subparser_name(self):
39
+ return "text_detection"
40
+
41
+ def _update_subparser(self, subparser):
42
+ add_simple_inference_args(subparser)
43
+ self._add_text_detection_args(subparser)
44
+
45
+ def execute_with_args(self, args):
46
+ params = get_subcommand_args(args)
47
+ perform_simple_inference(TextDetection, params)
@@ -0,0 +1,54 @@
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
+
15
+ from .._utils.cli import (
16
+ add_simple_inference_args,
17
+ get_subcommand_args,
18
+ perform_simple_inference,
19
+ )
20
+ from .base import PaddleXPredictorWrapper, PredictorCLISubcommandExecutor
21
+
22
+
23
+ class TextImageUnwarping(PaddleXPredictorWrapper):
24
+ def __init__(
25
+ self,
26
+ *args,
27
+ **kwargs,
28
+ ):
29
+ self._extra_init_args = {}
30
+ super().__init__(*args, **kwargs)
31
+
32
+ @property
33
+ def default_model_name(self):
34
+ return "UVDoc"
35
+
36
+ @classmethod
37
+ def get_cli_subcommand_executor(cls):
38
+ return TextImageUnwarpingSubcommandExecutor()
39
+
40
+ def _get_extra_paddlex_predictor_init_args(self):
41
+ return self._extra_init_args
42
+
43
+
44
+ class TextImageUnwarpingSubcommandExecutor(PredictorCLISubcommandExecutor):
45
+ @property
46
+ def subparser_name(self):
47
+ return "text_image_unwarping"
48
+
49
+ def _update_subparser(self, subparser):
50
+ add_simple_inference_args(subparser)
51
+
52
+ def execute_with_args(self, args):
53
+ params = get_subcommand_args(args)
54
+ perform_simple_inference(TextImageUnwarping, params)