Forráskód Böngészése

Update serving interface (#3638)

* Update interfaces

* Fix and update
Lin Manhui 8 hónapja
szülő
commit
1ea3eb3b24
22 módosított fájl, 160 hozzáadás és 66 törlés
  1. 24 0
      docs/pipeline_usage/tutorials/information_extraction_pipelines/document_scene_information_extraction_v3.en.md
  2. 25 1
      docs/pipeline_usage/tutorials/information_extraction_pipelines/document_scene_information_extraction_v3.md
  3. 24 0
      docs/pipeline_usage/tutorials/information_extraction_pipelines/document_scene_information_extraction_v4.en.md
  4. 25 1
      docs/pipeline_usage/tutorials/information_extraction_pipelines/document_scene_information_extraction_v4.md
  5. 2 2
      docs/pipeline_usage/tutorials/ocr_pipelines/PP-StructureV3.en.md
  6. 4 4
      docs/pipeline_usage/tutorials/ocr_pipelines/PP-StructureV3.md
  7. 1 0
      paddlex/inference/serving/basic_serving/_pipeline_apps/layout_parsing.py
  8. 4 0
      paddlex/inference/serving/basic_serving/_pipeline_apps/pp_chatocrv3_doc.py
  9. 4 0
      paddlex/inference/serving/basic_serving/_pipeline_apps/pp_chatocrv4_doc.py
  10. 1 0
      paddlex/inference/serving/basic_serving/_pipeline_apps/pp_structurev3.py
  11. 3 6
      paddlex/inference/serving/schemas/formula_recognition.py
  12. 4 4
      paddlex/inference/serving/schemas/human_keypoint_detection.py
  13. 3 6
      paddlex/inference/serving/schemas/layout_parsing.py
  14. 3 4
      paddlex/inference/serving/schemas/m_3d_bev_detection.py
  15. 5 1
      paddlex/inference/serving/schemas/pp_chatocrv3_doc.py
  16. 5 1
      paddlex/inference/serving/schemas/pp_chatocrv4_doc.py
  17. 4 7
      paddlex/inference/serving/schemas/pp_structurev3.py
  18. 3 6
      paddlex/inference/serving/schemas/seal_recognition.py
  19. 4 4
      paddlex/inference/serving/schemas/shared/image_segmentation.py
  20. 5 6
      paddlex/inference/serving/schemas/shared/object_detection.py
  21. 3 6
      paddlex/inference/serving/schemas/table_recognition.py
  22. 4 7
      paddlex/inference/serving/schemas/table_recognition_v2.py

+ 24 - 0
docs/pipeline_usage/tutorials/information_extraction_pipelines/document_scene_information_extraction_v3.en.md

@@ -1284,6 +1284,30 @@ Below are the API references for basic serving and multi-language service invoca
 <td>No</td>
 </tr>
 <tr>
+<td><code>layoutThreshold</code></td>
+<td><code>number</code> | <code>null</code></td>
+<td>Please refer to the description of the <code>layout_threshold</code> parameter of the pipeline object's <code>visual_predict</code> method.</td>
+<td>No</td>
+</tr>
+<tr>
+<td><code>layoutNms</code></td>
+<td><code>boolean</code> | <code>null</code></td>
+<td>Please refer to the description of the <code>layout_nms</code> parameter of the pipeline object's <code>visual_predict</code> method.</td>
+<td>No</td>
+</tr>
+<tr>
+<td><code>layoutUnclipRatio</code></td>
+<td><code>number</code> | <code>array</code> | <code>object</code> | <code>null</code></td>
+<td>Please refer to the description of the <code>layout_unclip_ratio</code> parameter of the pipeline object's <code>visual_predict</code> method.</td>
+<td>No</td>
+</tr>
+<tr>
+<td><code>layoutMergeBboxesMode</code></td>
+<td><code>string</code> | <code>object</code> | <code>null</code></td>
+<td>Please refer to the description of the <code>layout_merge_bboxes_mode</code> parameter of the pipeline object's <code>visual_predict</code> method.</td>
+<td>No</td>
+</tr>
+<tr>
 <td><code>textDetLimitSideLen</code></td>
 <td><code>integer</code> | <code>null</code></td>
 <td>Please refer to the description of the <code>text_det_limit_side_len</code> parameter of the pipeline object's <code>visual_predict</code> method.</td>

+ 25 - 1
docs/pipeline_usage/tutorials/information_extraction_pipelines/document_scene_information_extraction_v3.md

@@ -611,7 +611,7 @@ PP-ChatOCRv3-doc 预测的流程、API说明、产出说明如下:
 <td>
 <ul>
 <li><b>str</b>:large,small, union.分别表示重叠框过滤时选择保留大框,小框还是同时保留</li>
-<li><b>dict</b>, 字典的key为<b>int</b>类型,代表<code>cls_id</code>, value为<b>str</b>类型, 如<code>{0: "large", 2: "small"}</code>, 表示对第0类别检测框使用large模式,对第2类别检测框使用small模式</li>  
+<li><b>dict</b>, 字典的key为<b>int</b>类型,代表<code>cls_id</code>, value为<b>str</b>类型, 如<code>{0: "large", 2: "small"}</code>, 表示对第0类别检测框使用large模式,对第2类别检测框使用small模式</li>
 <li><b>None</b>:如果设置为 <code>None</code>, 将默认使用产线初始化的该参数值,初始化为 <code>large</code>;</li>
 </ul>
 </td>
@@ -1288,6 +1288,30 @@ for res in visual_predict_res:
 <td>否</td>
 </tr>
 <tr>
+<td><code>layoutThreshold</code></td>
+<td><code>number</code> | <code>null</code></td>
+<td>请参阅产线对象中 <code>visual_predict</code> 方法的 <code>layout_threshold</code> 参数相关说明。</td>
+<td>否</td>
+</tr>
+<tr>
+<td><code>layoutNms</code></td>
+<td><code>boolean</code> | <code>null</code></td>
+<td>请参阅产线对象中 <code>visual_predict</code> 方法的 <code>layout_nms</code> 参数相关说明。</td>
+<td>否</td>
+</tr>
+<tr>
+<td><code>layoutUnclipRatio</code></td>
+<td><code>number</code> | <code>array</code> | <code>object</code> | <code>null</code></td>
+<td>请参阅产线对象中 <code>visual_predict</code> 方法的 <code>layout_unclip_ratio</code> 参数相关说明。</td>
+<td>否</td>
+</tr>
+<tr>
+<td><code>layoutMergeBboxesMode</code></td>
+<td><code>string</code> | <code>object</code> | <code>null</code></td>
+<td>请参阅产线对象中 <code>visual_predict</code> 方法的 <code>layout_merge_bboxes_mode</code> 参数相关说明。</td>
+<td>否</td>
+</tr>
+<tr>
 <td><code>textDetLimitSideLen</code></td>
 <td><code>integer</code> | <code>null</code></td>
 <td>请参阅产线对象中 <code>visual_predict</code> 方法的 <code>text_det_limit_side_len</code> 参数相关说明。</td>

+ 24 - 0
docs/pipeline_usage/tutorials/information_extraction_pipelines/document_scene_information_extraction_v4.en.md

@@ -1421,6 +1421,30 @@ Below are the API references for basic serving and multi-language service invoca
 <td>No</td>
 </tr>
 <tr>
+<td><code>layoutThreshold</code></td>
+<td><code>number</code> | <code>null</code></td>
+<td>Please refer to the description of the <code>layout_threshold</code> parameter of the pipeline object's <code>visual_predict</code> method.</td>
+<td>No</td>
+</tr>
+<tr>
+<td><code>layoutNms</code></td>
+<td><code>boolean</code> | <code>null</code></td>
+<td>Please refer to the description of the <code>layout_nms</code> parameter of the pipeline object's <code>visual_predict</code> method.</td>
+<td>No</td>
+</tr>
+<tr>
+<td><code>layoutUnclipRatio</code></td>
+<td><code>number</code> | <code>array</code> | <code>object</code> | <code>null</code></td>
+<td>Please refer to the description of the <code>layout_unclip_ratio</code> parameter of the pipeline object's <code>visual_predict</code> method.</td>
+<td>No</td>
+</tr>
+<tr>
+<td><code>layoutMergeBboxesMode</code></td>
+<td><code>string</code> | <code>object</code> | <code>null</code></td>
+<td>Please refer to the description of the <code>layout_merge_bboxes_mode</code> parameter of the pipeline object's <code>visual_predict</code> method.</td>
+<td>No</td>
+</tr>
+<tr>
 <td><code>textDetLimitSideLen</code></td>
 <td><code>integer</code> | <code>null</code></td>
 <td>Please refer to the description of the <code>text_det_limit_side_len</code> parameter of the pipeline object's <code>visual_predict</code> method.</td>

+ 25 - 1
docs/pipeline_usage/tutorials/information_extraction_pipelines/document_scene_information_extraction_v4.md

@@ -859,7 +859,7 @@ PP-ChatOCRv4 预测的流程、API说明、产出说明如下:
 <td>
 <ul>
   <li><b>str</b>:large,small, union.分别表示重叠框过滤时选择保留大框,小框还是同时保留</li>
-  字典的key为<b>int</b>类型,代表<code>cls_id</code>, value为<b>str</b>类型, 如<code>{0: "large", 2: "small"}</code>, 表示对第0类别检测框使用large模式,对第2类别检测框使用small模式</li> 
+  字典的key为<b>int</b>类型,代表<code>cls_id</code>, value为<b>str</b>类型, 如<code>{0: "large", 2: "small"}</code>, 表示对第0类别检测框使用large模式,对第2类别检测框使用small模式</li>
   <li><b>None</b>:如果设置为 <code>None</code>, 将默认使用产线初始化的该参数值,初始化为 <code>large</code>;</li>
 </ul>
 </td>
@@ -1623,6 +1623,30 @@ for res in visual_predict_res:
 <td>否</td>
 </tr>
 <tr>
+<td><code>layoutThreshold</code></td>
+<td><code>number</code> | <code>null</code></td>
+<td>请参阅产线对象中 <code>visual_predict</code> 方法的 <code>layout_threshold</code> 参数相关说明。</td>
+<td>否</td>
+</tr>
+<tr>
+<td><code>layoutNms</code></td>
+<td><code>boolean</code> | <code>null</code></td>
+<td>请参阅产线对象中 <code>visual_predict</code> 方法的 <code>layout_nms</code> 参数相关说明。</td>
+<td>否</td>
+</tr>
+<tr>
+<td><code>layoutUnclipRatio</code></td>
+<td><code>number</code> | <code>array</code> | <code>object</code> | <code>null</code></td>
+<td>请参阅产线对象中 <code>visual_predict</code> 方法的 <code>layout_unclip_ratio</code> 参数相关说明。</td>
+<td>否</td>
+</tr>
+<tr>
+<td><code>layoutMergeBboxesMode</code></td>
+<td><code>string</code> | <code>object</code> | <code>null</code></td>
+<td>请参阅产线对象中 <code>visual_predict</code> 方法的 <code>layout_merge_bboxes_mode</code> 参数相关说明。</td>
+<td>否</td>
+</tr>
+<tr>
 <td><code>textDetLimitSideLen</code></td>
 <td><code>integer</code> | <code>null</code></td>
 <td>请参阅产线对象中 <code>visual_predict</code> 方法的 <code>text_det_limit_side_len</code> 参数相关说明。</td>

+ 2 - 2
docs/pipeline_usage/tutorials/ocr_pipelines/PP-StructureV3.en.md

@@ -1556,13 +1556,13 @@ Below is the API reference for basic serving deployment and examples of service
 </tr>
 <tr>
 <td><code>layoutUnclipRatio</code></td>
-<td><code>number</code> | <code>array</code> | <code>null</code></td>
+<td><code>number</code> | <code>array</code> | <code>object</code> | <code>null</code></td>
 <td>Please refer to the description of the <code>layout_unclip_ratio</code> parameter of the pipeline object's <code>predict</code> method.</td>
 <td>No</td>
 </tr>
 <tr>
 <td><code>layoutMergeBboxesMode</code></td>
-<td><code>string</code> | <code>null</code></td>
+<td><code>string</code> | <code>object</code> | <code>null</code></td>
 <td>Please refer to the description of the <code>layout_merge_bboxes_mode</code> parameter of the pipeline object's <code>predict</code> method.</td>
 <td>No</td>
 </tr>

+ 4 - 4
docs/pipeline_usage/tutorials/ocr_pipelines/PP-StructureV3.md

@@ -869,7 +869,7 @@ for item in markdown_images:
 <ul>
 <li><b>float</b>:任意大于 <code>0</code>  浮点数;</li>
 <li><b>Tuple[float,float]</b>:在横纵两个方向各自的扩张系数;</li>
-<li><b>字典</b>, 字典的key为<b>int</b>类型,代表<code>cls_id</code>, value为<b>tuple</b>类型,如<code>{0: (1.1, 2.0)}</code>, 表示将模型输出的第0类别检测框中心不变,宽度扩张1.1倍,高度扩张2.0倍</li>        
+<li><b>字典</b>, 字典的key为<b>int</b>类型,代表<code>cls_id</code>, value为<b>tuple</b>类型,如<code>{0: (1.1, 2.0)}</code>, 表示将模型输出的第0类别检测框中心不变,宽度扩张1.1倍,高度扩张2.0倍</li>
 <li><b>None</b>:如果设置为 <code>None</code>, 将默认使用产线初始化的该参数值,初始化为 <code>1.0</code>;</li>
 </ul>
 </td>
@@ -882,7 +882,7 @@ for item in markdown_images:
 <td>
 <ul>
 <li><b>str</b>:<code>large</code>,<code>small</code>, <code>union</code>,分别表示重叠框过滤时选择保留大框,小框还是同时保留</li>
-<li><b>dict</b>, 字典的key为<b>int</b>类型,代表<code>cls_id</code>, value为<b>str</b>类型, 如<code>{0: "large", 2: "small"}</code>, 表示对第0类别检测框使用large模式,对第2类别检测框使用small模式</li> 
+<li><b>dict</b>, 字典的key为<b>int</b>类型,代表<code>cls_id</code>, value为<b>str</b>类型, 如<code>{0: "large", 2: "small"}</code>, 表示对第0类别检测框使用large模式,对第2类别检测框使用small模式</li>
 <li><b>None</b>:如果设置为 <code>None</code>, 将默认使用产线初始化的该参数值,初始化为 <code>large</code>;</li>
 </ul>
 </td>
@@ -1503,13 +1503,13 @@ for res in output:
 </tr>
 <tr>
 <td><code>layoutUnclipRatio</code></td>
-<td><code>number</code> | <code>array</code> | <code>null</code></td>
+<td><code>number</code> | <code>array</code> | <code>object</code> | <code>null</code></td>
 <td>请参阅产线对象中 <code>predict</code> 方法的 <code>layout_unclip_ratio</code> 参数相关说明。</td>
 <td>否</td>
 </tr>
 <tr>
 <td><code>layoutMergeBboxesMode</code></td>
-<td><code>string</code> | <code>null</code></td>
+<td><code>string</code> | <code>object</code> | <code>null</code></td>
 <td>请参阅产线对象中 <code>predict</code> 方法的 <code>layout_merge_bboxes_mode</code> 参数相关说明。</td>
 <td>否</td>
 </tr>

+ 1 - 0
paddlex/inference/serving/basic_serving/_pipeline_apps/layout_parsing.py

@@ -67,6 +67,7 @@ def create_pipeline_app(pipeline: Any, app_config: AppConfig) -> FastAPI:
             seal_det_box_thresh=request.sealDetBoxThresh,
             seal_det_unclip_ratio=request.sealDetUnclipRatio,
             seal_rec_score_thresh=request.sealRecScoreThresh,
+            layout_threshold=request.layoutThreshold,
             layout_nms=request.layoutNms,
             layout_unclip_ratio=request.layoutUnclipRatio,
             layout_merge_bboxes_mode=request.layoutMergeBboxesMode,

+ 4 - 0
paddlex/inference/serving/basic_serving/_pipeline_apps/pp_chatocrv3_doc.py

@@ -54,6 +54,10 @@ def create_pipeline_app(pipeline: Any, app_config: AppConfig) -> FastAPI:
             use_general_ocr=request.useGeneralOcr,
             use_seal_recognition=request.useSealRecognition,
             use_table_recognition=request.useTableRecognition,
+            layout_threshold=request.layoutThreshold,
+            layout_nms=request.layoutNms,
+            layout_unclip_ratio=request.layoutUnclipRatio,
+            layout_merge_bboxes_mode=request.layoutMergeBboxesMode,
             text_det_limit_side_len=request.textDetLimitSideLen,
             text_det_limit_type=request.textDetLimitType,
             text_det_thresh=request.textDetThresh,

+ 4 - 0
paddlex/inference/serving/basic_serving/_pipeline_apps/pp_chatocrv4_doc.py

@@ -54,6 +54,10 @@ def create_pipeline_app(pipeline: Any, app_config: AppConfig) -> FastAPI:
             use_general_ocr=request.useGeneralOcr,
             use_seal_recognition=request.useSealRecognition,
             use_table_recognition=request.useTableRecognition,
+            layout_threshold=request.layoutThreshold,
+            layout_nms=request.layoutNms,
+            layout_unclip_ratio=request.layoutUnclipRatio,
+            layout_merge_bboxes_mode=request.layoutMergeBboxesMode,
             text_det_limit_side_len=request.textDetLimitSideLen,
             text_det_limit_type=request.textDetLimitType,
             text_det_thresh=request.textDetThresh,

+ 1 - 0
paddlex/inference/serving/basic_serving/_pipeline_apps/pp_structurev3.py

@@ -67,6 +67,7 @@ def create_pipeline_app(pipeline: Any, app_config: AppConfig) -> FastAPI:
             seal_det_box_thresh=request.sealDetBoxThresh,
             seal_det_unclip_ratio=request.sealDetUnclipRatio,
             seal_rec_score_thresh=request.sealRecScoreThresh,
+            layout_threshold=request.layoutThreshold,
             layout_nms=request.layoutNms,
             layout_unclip_ratio=request.layoutUnclipRatio,
             layout_merge_bboxes_mode=request.layoutMergeBboxesMode,

+ 3 - 6
paddlex/inference/serving/schemas/formula_recognition.py

@@ -12,10 +12,9 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from typing import Dict, Final, List, Optional, Union
+from typing import Dict, Final, List, Optional, Tuple, Union
 
-from pydantic import BaseModel, Field
-from typing_extensions import Annotated
+from pydantic import BaseModel
 
 from ..infra.models import DataInfo, PrimaryOperations
 from .shared import ocr
@@ -37,9 +36,7 @@ class InferRequest(ocr.BaseInferRequest):
     useDocUnwarping: Optional[bool] = None
     layoutThreshold: Optional[float] = None
     layoutNms: Optional[bool] = None
-    layoutUnclipRatio: Optional[
-        Union[float, Annotated[List[float], Field(min_length=2, max_length=2)]]
-    ] = None
+    layoutUnclipRatio: Optional[Union[float, Tuple[float, float]]] = None
     layoutMergeBboxesMode: Optional[str] = None
 
 

+ 4 - 4
paddlex/inference/serving/schemas/human_keypoint_detection.py

@@ -12,10 +12,10 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from typing import Final, List, Optional
+from typing import Final, List, Optional, Tuple
 
-from pydantic import BaseModel, Field
-from typing_extensions import Annotated, TypeAlias
+from pydantic import BaseModel
+from typing_extensions import TypeAlias
 
 from ..infra.models import PrimaryOperations
 from .shared import object_detection
@@ -29,7 +29,7 @@ __all__ = [
     "PRIMARY_OPERATIONS",
 ]
 
-KeyPoint: TypeAlias = Annotated[List[float], Field(min_length=3, max_length=3)]
+KeyPoint: TypeAlias = Tuple[float, float, float]
 INFER_ENDPOINT: Final[str] = "/human-keypoint-detection"
 
 

+ 3 - 6
paddlex/inference/serving/schemas/layout_parsing.py

@@ -12,10 +12,9 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from typing import Dict, Final, List, Optional, Union
+from typing import Dict, Final, List, Optional, Tuple, Union
 
-from pydantic import BaseModel, Field
-from typing_extensions import Annotated
+from pydantic import BaseModel
 
 from ..infra.models import DataInfo, PrimaryOperations
 from .shared import ocr
@@ -53,9 +52,7 @@ class InferRequest(ocr.BaseInferRequest):
     sealRecScoreThresh: Optional[float] = None
     layoutThreshold: Optional[float] = None
     layoutNms: Optional[bool] = None
-    layoutUnclipRatio: Optional[
-        Union[float, Annotated[List[float], Field(min_length=2, max_length=2)]]
-    ] = None
+    layoutUnclipRatio: Optional[Union[float, Tuple[float, float]]] = None
     layoutMergeBboxesMode: Optional[str] = None
 
 

+ 3 - 4
paddlex/inference/serving/schemas/m_3d_bev_detection.py

@@ -12,10 +12,9 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from typing import Final, List
+from typing import Final, List, Tuple
 
-from pydantic import BaseModel, Field
-from typing_extensions import Annotated
+from pydantic import BaseModel
 
 from ..infra.models import PrimaryOperations
 
@@ -35,7 +34,7 @@ class InferRequest(BaseModel):
 
 
 class DetectedObject(BaseModel):
-    bbox: Annotated[List[float], Field(min_length=9, max_length=9)]
+    bbox: Tuple[float, float, float, float, float, float, float, float, float]
     categoryId: int
     score: float
 

+ 5 - 1
paddlex/inference/serving/schemas/pp_chatocrv3_doc.py

@@ -12,7 +12,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from typing import Dict, Final, List, Optional
+from typing import Dict, Final, List, Optional, Tuple, Union
 
 from pydantic import BaseModel
 
@@ -42,6 +42,10 @@ class AnalyzeImagesRequest(ocr.BaseInferRequest):
     useGeneralOcr: Optional[bool] = None
     useSealRecognition: Optional[bool] = None
     useTableRecognition: Optional[bool] = None
+    layoutThreshold: Optional[float] = None
+    layoutNms: Optional[bool] = None
+    layoutUnclipRatio: Optional[Union[float, Tuple[float, float], dict]] = None
+    layoutMergeBboxesMode: Optional[Union[str, dict]] = None
     textDetLimitSideLen: Optional[int] = None
     textDetLimitType: Optional[str] = None
     textDetThresh: Optional[float] = None

+ 5 - 1
paddlex/inference/serving/schemas/pp_chatocrv4_doc.py

@@ -12,7 +12,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from typing import Dict, Final, List, Optional
+from typing import Dict, Final, List, Optional, Tuple, Union
 
 from pydantic import BaseModel
 
@@ -45,6 +45,10 @@ class AnalyzeImagesRequest(ocr.BaseInferRequest):
     useGeneralOcr: Optional[bool] = None
     useSealRecognition: Optional[bool] = None
     useTableRecognition: Optional[bool] = None
+    layoutThreshold: Optional[float] = None
+    layoutNms: Optional[bool] = None
+    layoutUnclipRatio: Optional[Union[float, Tuple[float, float], dict]] = None
+    layoutMergeBboxesMode: Optional[Union[str, dict]] = None
     textDetLimitSideLen: Optional[int] = None
     textDetLimitType: Optional[str] = None
     textDetThresh: Optional[float] = None

+ 4 - 7
paddlex/inference/serving/schemas/pp_structurev3.py

@@ -12,10 +12,9 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from typing import Dict, Final, List, Optional, Union
+from typing import Dict, Final, List, Optional, Tuple, Union
 
-from pydantic import BaseModel, Field
-from typing_extensions import Annotated
+from pydantic import BaseModel
 
 from ..infra.models import DataInfo, PrimaryOperations
 from .shared import ocr
@@ -54,10 +53,8 @@ class InferRequest(ocr.BaseInferRequest):
     sealRecScoreThresh: Optional[float] = None
     layoutThreshold: Optional[float] = None
     layoutNms: Optional[bool] = None
-    layoutUnclipRatio: Optional[
-        Union[float, Annotated[List[float], Field(min_length=2, max_length=2)]]
-    ] = None
-    layoutMergeBboxesMode: Optional[str] = None
+    layoutUnclipRatio: Optional[Union[float, Tuple[float, float], dict]] = None
+    layoutMergeBboxesMode: Optional[Union[str, dict]] = None
 
 
 class MarkdownData(BaseModel):

+ 3 - 6
paddlex/inference/serving/schemas/seal_recognition.py

@@ -12,10 +12,9 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from typing import Dict, Final, List, Optional, Union
+from typing import Dict, Final, List, Optional, Tuple, Union
 
-from pydantic import BaseModel, Field
-from typing_extensions import Annotated
+from pydantic import BaseModel
 
 from ..infra.models import DataInfo, PrimaryOperations
 from .shared import ocr
@@ -37,9 +36,7 @@ class InferRequest(ocr.BaseInferRequest):
     useLayoutDetection: Optional[bool] = None
     layoutThreshold: Optional[float] = None
     layoutNms: Optional[bool] = None
-    layoutUnclipRatio: Optional[
-        Union[float, Annotated[List[float], Field(min_length=2, max_length=2)]]
-    ] = None
+    layoutUnclipRatio: Optional[Union[float, Tuple[float, float]]] = None
     layoutMergeBboxesMode: Optional[str] = None
     sealDetLimitSideLen: Optional[int] = None
     sealDetLimitType: Optional[str] = None

+ 4 - 4
paddlex/inference/serving/schemas/shared/image_segmentation.py

@@ -12,15 +12,15 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from typing import List
+from typing import Tuple
 
-from pydantic import BaseModel, Field
-from typing_extensions import Annotated, TypeAlias
+from pydantic import BaseModel
+from typing_extensions import TypeAlias
 
 __all__ = ["Size", "Mask"]
 
 
-Size: TypeAlias = Annotated[List[int], Field(min_length=2, max_length=2)]
+Size: TypeAlias = Tuple[int, int]
 
 
 class Mask(BaseModel):

+ 5 - 6
paddlex/inference/serving/schemas/shared/object_detection.py

@@ -12,14 +12,13 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from typing import List
+from typing import Tuple
 
-from pydantic import Field
-from typing_extensions import Annotated, TypeAlias
+from typing_extensions import TypeAlias
 
 __all__ = ["BoundingBox", "RotatedBoundingBox"]
 
-BoundingBox: TypeAlias = Annotated[List[float], Field(min_length=4, max_length=4)]
-RotatedBoundingBox: TypeAlias = Annotated[
-    List[float], Field(min_length=8, max_length=8)
+BoundingBox: TypeAlias = Tuple[float, float, float, float]
+RotatedBoundingBox: TypeAlias = Tuple[
+    float, float, float, float, float, float, float, float
 ]

+ 3 - 6
paddlex/inference/serving/schemas/table_recognition.py

@@ -12,10 +12,9 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from typing import Dict, Final, List, Optional, Union
+from typing import Dict, Final, List, Optional, Tuple, Union
 
-from pydantic import BaseModel, Field
-from typing_extensions import Annotated
+from pydantic import BaseModel
 
 from ..infra.models import DataInfo, PrimaryOperations
 from .shared import ocr
@@ -38,9 +37,7 @@ class InferRequest(ocr.BaseInferRequest):
     useOcrModel: Optional[bool] = None
     layoutThreshold: Optional[float] = None
     layoutNms: Optional[bool] = None
-    layoutUnclipRatio: Optional[
-        Union[float, Annotated[List[float], Field(min_length=2, max_length=2)]]
-    ] = None
+    layoutUnclipRatio: Optional[Union[float, Tuple[float, float]]] = None
     layoutMergeBboxesMode: Optional[str] = None
     textDetLimitSideLen: Optional[int] = None
     textDetLimitType: Optional[str] = None

+ 4 - 7
paddlex/inference/serving/schemas/table_recognition_v2.py

@@ -12,10 +12,9 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from typing import Dict, Final, List, Optional, Union
+from typing import Dict, Final, List, Optional, Tuple, Union
 
-from pydantic import BaseModel, Field
-from typing_extensions import Annotated
+from pydantic import BaseModel
 
 from ..infra.models import DataInfo, PrimaryOperations
 from .shared import ocr
@@ -38,10 +37,8 @@ class InferRequest(ocr.BaseInferRequest):
     useOcrModel: Optional[bool] = None
     layoutThreshold: Optional[float] = None
     layoutNms: Optional[bool] = None
-    layoutUnclipRatio: Optional[
-        Union[float, Annotated[List[float], Field(min_length=2, max_length=2)]]
-    ] = None
-    layoutMergeBboxesMode: Optional[str] = None
+    layoutUnclipRatio: Optional[Union[float, Tuple[float, float], dict]] = None
+    layoutMergeBboxesMode: Optional[Union[str, dict]] = None
     textDetLimitSideLen: Optional[int] = None
     textDetLimitType: Optional[str] = None
     textDetThresh: Optional[float] = None