Skip to content

Commit 1f69d6a

Browse files
committed
fix: align type hints with paddlex signatures
- Widen layout param types (threshold, unclip_ratio, merge_bboxes_mode) to match paddlex per-pipeline signatures - Fix DocUnderstanding.predict input type: InputType → dict - Remove dict from layout_unclip_ratio in formula/seal pipelines where paddlex doesn't accept it - Use bare dict/tuple to match paddlex exactly, no refinement
1 parent a96572a commit 1f69d6a

File tree

11 files changed

+47
-47
lines changed

11 files changed

+47
-47
lines changed

paddleocr/_models/_object_detection.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ class ObjectDetection(PaddleXPredictorWrapper):
3131
def __init__(
3232
self,
3333
*,
34-
img_size: int | None = None,
35-
threshold: float | None = None,
34+
img_size: int | tuple[int, int] | None = None,
35+
threshold: float | dict | None = None,
3636
layout_nms: bool | None = None,
37-
layout_unclip_ratio: float | None = None,
38-
layout_merge_bboxes_mode: str | None = None,
37+
layout_unclip_ratio: float | tuple[float, float] | dict | None = None,
38+
layout_merge_bboxes_mode: str | dict | None = None,
3939
**kwargs: Any,
4040
) -> None:
4141
self._extra_init_args = {

paddleocr/_models/_text_detection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def __init__(
2727
thresh: float | None = None,
2828
box_thresh: float | None = None,
2929
unclip_ratio: float | None = None,
30-
input_shape: tuple[int, int, int] | None = None,
30+
input_shape: tuple | None = None,
3131
**kwargs: Any,
3232
) -> None:
3333
self._extra_init_args = {

paddleocr/_models/text_recognition.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class TextRecognition(PaddleXPredictorWrapper):
3030
def __init__(
3131
self,
3232
*,
33-
input_shape: tuple[int, int, int] | None = None,
33+
input_shape: tuple | None = None,
3434
**kwargs: Any,
3535
) -> None:
3636
self._extra_init_args = {

paddleocr/_pipelines/doc_understanding.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from paddlex.utils.pipeline_arguments import custom_type
2121

2222
from .._abstract import CLISubcommandExecutor
23-
from .._types import InputType, PredictResult
23+
from .._types import PredictResult
2424
from .._utils.cli import (
2525
add_simple_inference_args,
2626
get_subcommand_args,
@@ -50,12 +50,12 @@ def __init__(
5050
def _paddlex_pipeline_name(self) -> str:
5151
return "doc_understanding"
5252

53-
def predict_iter(self, input: InputType, **kwargs: Any) -> Iterator[PredictResult]:
53+
def predict_iter(self, input: dict, **kwargs: Any) -> Iterator[PredictResult]:
5454
return self.paddlex_pipeline.predict(input, **kwargs)
5555

5656
def predict(
5757
self,
58-
input: InputType,
58+
input: dict,
5959
**kwargs: Any,
6060
) -> list[PredictResult]:
6161
return list(self.predict_iter(input, **kwargs))

paddleocr/_pipelines/formula_recognition.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ def __init__(
4242
use_doc_unwarping: bool | None = None,
4343
layout_detection_model_name: str | None = None,
4444
layout_detection_model_dir: str | None = None,
45-
layout_threshold: float | None = None,
45+
layout_threshold: float | dict | None = None,
4646
layout_nms: bool | None = None,
47-
layout_unclip_ratio: float | None = None,
47+
layout_unclip_ratio: float | tuple[float, float] | None = None,
4848
layout_merge_bboxes_mode: str | None = None,
4949
layout_detection_batch_size: int | None = None,
5050
use_layout_detection: bool | None = None,
@@ -72,9 +72,9 @@ def predict_iter(
7272
use_doc_orientation_classify: bool | None = None,
7373
use_doc_unwarping: bool | None = None,
7474
layout_det_res: Any = None,
75-
layout_threshold: float | None = None,
75+
layout_threshold: float | dict | None = None,
7676
layout_nms: bool | None = None,
77-
layout_unclip_ratio: float | None = None,
77+
layout_unclip_ratio: float | tuple[float, float] | None = None,
7878
layout_merge_bboxes_mode: str | None = None,
7979
**kwargs: Any,
8080
) -> Iterator[PredictResult]:
@@ -99,9 +99,9 @@ def predict(
9999
use_doc_orientation_classify: bool | None = None,
100100
use_doc_unwarping: bool | None = None,
101101
layout_det_res: Any = None,
102-
layout_threshold: float | None = None,
102+
layout_threshold: float | dict | None = None,
103103
layout_nms: bool | None = None,
104-
layout_unclip_ratio: float | None = None,
104+
layout_unclip_ratio: float | tuple[float, float] | None = None,
105105
layout_merge_bboxes_mode: str | None = None,
106106
**kwargs: Any,
107107
) -> list[PredictResult]:

paddleocr/_pipelines/ocr.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,10 @@ def __init__(
8181
text_det_thresh: float | None = None,
8282
text_det_box_thresh: float | None = None,
8383
text_det_unclip_ratio: float | None = None,
84-
text_det_input_shape: tuple[int, int, int] | None = None,
84+
text_det_input_shape: tuple | None = None,
8585
text_rec_score_thresh: float | None = None,
8686
return_word_box: bool | None = None,
87-
text_rec_input_shape: tuple[int, int, int] | None = None,
87+
text_rec_input_shape: tuple | None = None,
8888
lang: str | None = None,
8989
ocr_version: str | None = None,
9090
**kwargs: Any,

paddleocr/_pipelines/paddleocr_vl.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ def __init__(
4747
pipeline_version: str = _DEFAULT_PIPELINE_VERSION,
4848
layout_detection_model_name: str | None = None,
4949
layout_detection_model_dir: str | None = None,
50-
layout_threshold: float | None = None,
50+
layout_threshold: float | dict | None = None,
5151
layout_nms: bool | None = None,
52-
layout_unclip_ratio: float | None = None,
52+
layout_unclip_ratio: float | tuple[float, float] | dict | None = None,
5353
layout_merge_bboxes_mode: str | None = None,
5454
vl_rec_model_name: str | None = None,
5555
vl_rec_model_dir: str | None = None,
@@ -112,9 +112,9 @@ def predict_iter(
112112
use_chart_recognition: bool | None = None,
113113
use_seal_recognition: bool | None = None,
114114
use_ocr_for_image_block: bool | None = None,
115-
layout_threshold: float | None = None,
115+
layout_threshold: float | dict | None = None,
116116
layout_nms: bool | None = None,
117-
layout_unclip_ratio: float | None = None,
117+
layout_unclip_ratio: float | tuple[float, float] | dict | None = None,
118118
layout_merge_bboxes_mode: str | None = None,
119119
layout_shape_mode: str = "auto",
120120
use_queues: bool | None = None,
@@ -169,9 +169,9 @@ def predict(
169169
use_chart_recognition: bool | None = None,
170170
use_seal_recognition: bool | None = None,
171171
use_ocr_for_image_block: bool | None = None,
172-
layout_threshold: float | None = None,
172+
layout_threshold: float | dict | None = None,
173173
layout_nms: bool | None = None,
174-
layout_unclip_ratio: float | None = None,
174+
layout_unclip_ratio: float | tuple[float, float] | dict | None = None,
175175
layout_merge_bboxes_mode: str | None = None,
176176
layout_shape_mode: str = "auto",
177177
use_queues: bool | None = None,

paddleocr/_pipelines/pp_chatocrv4_doc.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ def __init__(
5656
use_textline_orientation: bool | None = None,
5757
use_seal_recognition: bool | None = None,
5858
use_table_recognition: bool | None = None,
59-
layout_threshold: float | None = None,
59+
layout_threshold: float | dict | None = None,
6060
layout_nms: bool | None = None,
61-
layout_unclip_ratio: float | None = None,
61+
layout_unclip_ratio: float | tuple[float, float] | dict | None = None,
6262
layout_merge_bboxes_mode: str | None = None,
6363
text_det_limit_side_len: int | None = None,
6464
text_det_limit_type: str | None = None,
@@ -124,9 +124,9 @@ def visual_predict_iter(
124124
use_textline_orientation: bool | None = None,
125125
use_seal_recognition: bool | None = None,
126126
use_table_recognition: bool | None = None,
127-
layout_threshold: float | None = None,
127+
layout_threshold: float | dict | None = None,
128128
layout_nms: bool | None = None,
129-
layout_unclip_ratio: float | None = None,
129+
layout_unclip_ratio: float | tuple[float, float] | dict | None = None,
130130
layout_merge_bboxes_mode: str | None = None,
131131
text_det_limit_side_len: int | None = None,
132132
text_det_limit_type: str | None = None,
@@ -177,9 +177,9 @@ def visual_predict(
177177
use_textline_orientation: bool | None = None,
178178
use_seal_recognition: bool | None = None,
179179
use_table_recognition: bool | None = None,
180-
layout_threshold: float | None = None,
180+
layout_threshold: float | dict | None = None,
181181
layout_nms: bool | None = None,
182-
layout_unclip_ratio: float | None = None,
182+
layout_unclip_ratio: float | tuple[float, float] | dict | None = None,
183183
layout_merge_bboxes_mode: str | None = None,
184184
text_det_limit_side_len: int | None = None,
185185
text_det_limit_type: str | None = None,

paddleocr/_pipelines/pp_doctranslation.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ def __init__(
3333
self,
3434
layout_detection_model_name: str | None = None,
3535
layout_detection_model_dir: str | None = None,
36-
layout_threshold: float | None = None,
36+
layout_threshold: float | dict | None = None,
3737
layout_nms: bool | None = None,
38-
layout_unclip_ratio: float | None = None,
38+
layout_unclip_ratio: float | tuple[float, float] | dict | None = None,
3939
layout_merge_bboxes_mode: str | None = None,
4040
chart_recognition_model_name: str | None = None,
4141
chart_recognition_model_dir: str | None = None,
@@ -120,9 +120,9 @@ def visual_predict_iter(
120120
use_formula_recognition: bool | None = None,
121121
use_chart_recognition: bool | None = None,
122122
use_region_detection: bool | None = None,
123-
layout_threshold: float | None = None,
123+
layout_threshold: float | dict | None = None,
124124
layout_nms: bool | None = None,
125-
layout_unclip_ratio: float | None = None,
125+
layout_unclip_ratio: float | tuple[float, float] | dict | None = None,
126126
layout_merge_bboxes_mode: str | None = None,
127127
text_det_limit_side_len: int | None = None,
128128
text_det_limit_type: str | None = None,
@@ -191,9 +191,9 @@ def visual_predict(
191191
use_formula_recognition: bool | None = None,
192192
use_chart_recognition: bool | None = None,
193193
use_region_detection: bool | None = None,
194-
layout_threshold: float | None = None,
194+
layout_threshold: float | dict | None = None,
195195
layout_nms: bool | None = None,
196-
layout_unclip_ratio: float | None = None,
196+
layout_unclip_ratio: float | tuple[float, float] | dict | None = None,
197197
layout_merge_bboxes_mode: str | None = None,
198198
text_det_limit_side_len: int | None = None,
199199
text_det_limit_type: str | None = None,

paddleocr/_pipelines/pp_structurev3.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ def __init__(
4040
self,
4141
layout_detection_model_name: str | None = None,
4242
layout_detection_model_dir: str | None = None,
43-
layout_threshold: float | None = None,
43+
layout_threshold: float | dict | None = None,
4444
layout_nms: bool | None = None,
45-
layout_unclip_ratio: float | None = None,
45+
layout_unclip_ratio: float | tuple[float, float] | dict | None = None,
4646
layout_merge_bboxes_mode: str | None = None,
4747
chart_recognition_model_name: str | None = None,
4848
chart_recognition_model_dir: str | None = None,
@@ -165,9 +165,9 @@ def predict_iter(
165165
use_chart_recognition: bool | None = None,
166166
use_region_detection: bool | None = None,
167167
format_block_content: bool | None = None,
168-
layout_threshold: float | None = None,
168+
layout_threshold: float | dict | None = None,
169169
layout_nms: bool | None = None,
170-
layout_unclip_ratio: float | None = None,
170+
layout_unclip_ratio: float | tuple[float, float] | dict | None = None,
171171
layout_merge_bboxes_mode: str | None = None,
172172
text_det_limit_side_len: int | None = None,
173173
text_det_limit_type: str | None = None,
@@ -240,9 +240,9 @@ def predict(
240240
use_chart_recognition: bool | None = None,
241241
use_region_detection: bool | None = None,
242242
format_block_content: bool | None = None,
243-
layout_threshold: float | None = None,
243+
layout_threshold: float | dict | None = None,
244244
layout_nms: bool | None = None,
245-
layout_unclip_ratio: float | None = None,
245+
layout_unclip_ratio: float | tuple[float, float] | dict | None = None,
246246
layout_merge_bboxes_mode: str | None = None,
247247
text_det_limit_side_len: int | None = None,
248248
text_det_limit_type: str | None = None,

0 commit comments

Comments
 (0)