Эх сурвалжийг харах

Update the HPI (#3227)

* update

* fix

* update doc

* update

* update

* update

* update

* fix dt_ploys format to enable correct slicing
zhang-prog 9 сар өмнө
parent
commit
95d904550f
21 өөрчлөгдсөн 1639 нэмэгдсэн , 306 устгасан
  1. 58 34
      docs/pipeline_deploy/high_performance_inference.md
  2. 59 69
      docs/practical_tutorials/deployment_tutorial.md
  3. 1403 132
      libs/paddlex-hpi/src/paddlex_hpi/model_info_collection.json
  4. 4 3
      libs/paddlex-hpi/src/paddlex_hpi/models/anomaly_detection.py
  5. 3 1
      libs/paddlex-hpi/src/paddlex_hpi/models/base.py
  6. 4 3
      libs/paddlex-hpi/src/paddlex_hpi/models/formula_recognition.py
  7. 4 3
      libs/paddlex-hpi/src/paddlex_hpi/models/general_recognition.py
  8. 6 3
      libs/paddlex-hpi/src/paddlex_hpi/models/image_classification.py
  9. 4 3
      libs/paddlex-hpi/src/paddlex_hpi/models/image_unwarping.py
  10. 9 5
      libs/paddlex-hpi/src/paddlex_hpi/models/instance_segmentation.py
  11. 10 6
      libs/paddlex-hpi/src/paddlex_hpi/models/multilabel_classification.py
  12. 43 5
      libs/paddlex-hpi/src/paddlex_hpi/models/object_detection.py
  13. 9 5
      libs/paddlex-hpi/src/paddlex_hpi/models/semantic_segmentation.py
  14. 4 3
      libs/paddlex-hpi/src/paddlex_hpi/models/table_recognition.py
  15. 12 8
      libs/paddlex-hpi/src/paddlex_hpi/models/text_detection.py
  16. 4 3
      libs/paddlex-hpi/src/paddlex_hpi/models/text_recognition.py
  17. 1 1
      libs/paddlex-hpi/src/paddlex_hpi/models/ts_ad.py
  18. 1 1
      libs/paddlex-hpi/src/paddlex_hpi/models/ts_cls.py
  19. 1 1
      libs/paddlex-hpi/src/paddlex_hpi/models/ts_fc.py
  20. 0 7
      libs/ultra-infer/python/ultra_infer/__init__.py
  21. 0 10
      libs/ultra-infer/ultra_infer/runtime/runtime.cc

+ 58 - 34
docs/pipeline_deploy/high_performance_inference.md

@@ -22,6 +22,8 @@ comments: true
 
 ### 1.1 安装高性能推理插件
 
+* 注意:若您使用的是 Windows 系统,请参考[PaddleX本地安装教程——2.1基于Docker获取PaddleX](../installation/installation.md#21-基于docker获取paddlex) 使用 Docker 启动 PaddleX 容器。启动容器后,您可以继续阅读本指南以使用高性能推理。
+
 根据设备类型,执行如下指令,安装高性能推理插件:
 
 如果你的设备是 CPU,请使用以下命令安装 PaddleX 的 CPU 版本:
@@ -105,12 +107,12 @@ output = pipeline.predict("https://paddle-model-ecology.bj.bcebos.com/paddlex/im
 from paddlex import create_model
 
 model = create_model(
-    "ResNet18",
+    model_name="ResNet18",
     device="gpu",
     use_hpip=True
 )
 
-output = pipeline.predict("https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/general_image_classification_001.jpg")
+output = model.predict("https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/general_image_classification_001.jpg")
 ```
 
 启用高性能推理插件得到的推理结果与未启用插件时一致。对于部分模型,在首次启用高性能推理插件时,可能需要花费较长时间完成推理引擎的构建。PaddleX 将在推理引擎的第一次构建完成后将相关信息缓存在模型目录,并在后续复用缓存中的内容以提升初始化速度。
@@ -323,38 +325,44 @@ python -m pip install ../../python/dist/ultra_infer*.whl
   <tr>
     <td rowspan="2">通用OCR</td>
     <td>文本检测</td>
-    <td><b>2</b> / 2 </td>
+    <td><b>4</b> / 4 </td>
     <td>无 </td>
   </tr>
 
   <tr>
     <td>文本识别</td>
-    <td><b>2</b> / 2 </td>
+    <td><b>4</b> / 4 </td>
     <td>无 </td>
   </tr>
 
   <tr>
     <td rowspan="7">文档场景信息抽取v3</td>
-    <td>表格识别</td>
-    <td><b>2</b> / 2 </td>
-    <td>无 </td>
+    <td>表格结构识别</td>
+    <td><b>2</b> / 4 </td>
+    <td>
+      <details>
+        <summary>查看详情</summary>
+        SLANeXt_wired</br>
+        SLANeXt_wireless</br>
+      </details>
+    </td>
   </tr>
 
   <tr>
     <td>版面区域检测</td>
-    <td><b>8</b> / 8 </td>
-    <td>无 </td>
+    <td><b>11</b> / 11 </td>
+    <td>无</td>
   </tr>
 
   <tr>
     <td>文本检测</td>
-    <td><b>2</b> / 2 </td>
+    <td><b>4</b> / 4 </td>
     <td>无 </td>
   </tr>
 
   <tr>
     <td>文本识别</td>
-    <td><b>2</b> / 2 </td>
+    <td><b>4</b> / 4 </td>
     <td>无 </td>
   </tr>
 
@@ -379,38 +387,48 @@ python -m pip install ../../python/dist/ultra_infer*.whl
   <tr>
     <td rowspan="4">通用表格识别</td>
     <td>版面区域检测</td>
-    <td><b>8</b> / 8 </td>
-    <td>无 </td>
+    <td><b>11</b> / 11 </td>
+    <td>无</td>
   </tr>
 
   <tr>
-    <td>表格识别</td>
-    <td><b>2</b> / 2 </td>
-    <td>无 </td>
+    <td>表格结构识别</td>
+    <td><b>2</b> / 4 </td>
+    <td>
+      <details>
+        <summary>查看详情</summary>
+        SLANeXt_wired</br>
+        SLANeXt_wireless</br>
+      </details>
+    </td>
   </tr>
 
   <tr>
     <td>文本检测</td>
-    <td><b>2</b> / 2 </td>
+    <td><b>4</b> / 4 </td>
     <td>无 </td>
   </tr>
 
   <tr>
     <td>文本识别</td>
-    <td><b>2</b> / 2 </td>
+    <td><b>4</b> / 4 </td>
     <td>无</td>
   </tr>
 
   <tr>
     <td>通用目标检测</td>
     <td>目标检测</td>
-    <td><b>34</b> / 37</td>
+    <td><b>34</b> / 41</td>
     <td>
       <details>
         <summary>查看详情</summary>
         FasterRCNN-Swin-Tiny-FPN<br>
         CenterNet-DLA-34<br>
-        CenterNet-ResNet50
+        CenterNet-ResNet50<br>
+        Co-DINO-R50<br>
+        Co-DINO-Swin-L<br>
+        Co-Deformable-DETR-R50<br>
+        Co-Deformable-DETR-Swin-T<br>
       </details>
     </td>
   </tr>
@@ -439,7 +457,7 @@ python -m pip install ../../python/dist/ultra_infer*.whl
   <tr>
     <td>通用语义分割</td>
     <td>语义分割</td>
-    <td><b>14</b> / 14 </td>
+    <td><b>20</b> / 20 </td>
     <td>无</td>
   </tr>
 
@@ -493,25 +511,31 @@ python -m pip install ../../python/dist/ultra_infer*.whl
   <tr>
     <td rowspan="8">通用版面解析</td>
     <td>表格结构识别</td>
-    <td><b>2</b> / 2 </td>
-    <td>无 </td>
+    <td><b>2</b> / 4 </td>
+    <td>
+      <details>
+        <summary>查看详情</summary>
+        SLANeXt_wired</br>
+        SLANeXt_wireless</br>
+      </details>
+    </td>
   </tr>
 
   <tr>
-    <td>版面区域分析</td>
-    <td><b>8</b> / 8 </td>
-    <td>无 </td>
+    <td>版面区域检测</td>
+    <td><b>11</b> / 11 </td>
+    <td>无</td>
   </tr>
 
   <tr>
     <td>文本检测</td>
-    <td><b>2</b> / 2 </td>
+    <td><b>4</b> / 4 </td>
     <td>无 </td>
   </tr>
 
   <tr>
     <td>文本识别</td>
-    <td><b>2</b> / 2 </td>
+    <td><b>4</b> / 4 </td>
     <td>无 </td>
   </tr>
 
@@ -542,8 +566,8 @@ python -m pip install ../../python/dist/ultra_infer*.whl
   <tr>
     <td rowspan="2">公式识别</td>
     <td>版面区域检测</td>
-    <td><b>8</b> / 8 </td>
-    <td>无 </td>
+    <td><b>11</b> / 11 </td>
+    <td>无</td>
   </tr>
 
   <tr>
@@ -561,9 +585,9 @@ python -m pip install ../../python/dist/ultra_infer*.whl
 
   <tr>
     <td rowspan="3">印章文本识别</td>
-    <td>版面区域分析</td>
-    <td><b>8</b> / 8 </td>
-    <td>无 </td>
+    <td>版面区域检测</td>
+    <td><b>11</b> / 11 </td>
+    <td>无</td>
   </tr>
 
   <tr>
@@ -574,7 +598,7 @@ python -m pip install ../../python/dist/ultra_infer*.whl
 
   <tr>
     <td>文本识别</td>
-    <td><b>2</b> / 2 </td>
+    <td><b>4</b> / 4 </td>
     <td>无 </td>
   </tr>
 

+ 59 - 69
docs/practical_tutorials/deployment_tutorial.md

@@ -9,32 +9,32 @@ comments: true
 PaddleX 的三种部署方式详细说明如下:
 
 * 高性能推理:在实际生产环境中,许多应用对部署策略的性能指标(尤其是响应速度)有着较严苛的标准,以确保系统的高效运行与用户体验的流畅性。为此,PaddleX 提供高性能推理插件,旨在对模型推理及前后处理进行深度性能优化,实现端到端流程的显著提速,详细的高性能推理流程请参考 [PaddleX 高性能推理指南](../pipeline_deploy/high_performance_inference.md)。
+
 * 服务化部署:服务化部署是实际生产环境中常见的一种部署形式。通过将推理功能封装为服务,客户端可以通过网络请求来访问这些服务,以获取推理结果。PaddleX 支持用户以低成本实现产线的服务化部署,详细的服务化部署流程请参考 [PaddleX 服务化部署指南](../pipeline_deploy/serving.md)。
+
 * 端侧部署:端侧部署是一种将计算和数据处理功能放在用户设备本身上的方式,设备可以直接处理数据,而不需要依赖远程的服务器。PaddleX 支持将模型部署在 Android 等端侧设备上,详细的端侧部署流程请参考 [PaddleX端侧部署指南](../pipeline_deploy/edge_deploy.md)。
 
 本教程将举三个实际应用例子,来依次介绍 PaddleX 的三种部署方式。
 
 ## 1 高性能推理示例
 
-### 1.1 获取序列号与激活
-
-在 [飞桨AI Studio星河社区-人工智能学习与实训社区](https://aistudio.baidu.com/paddlex/commercialization) 页面的“开源模型产线部署序列号咨询与获取”部分选择“立即获取”,如下图所示:
+### 1.1 安装高性能推理插件
 
-<img src="https://raw.githubusercontent.com/cuicheng01/PaddleX_doc_images/main/images/pipeline_deploy/image-1.png">
+根据设备类型,执行如下指令,安装高性能推理插件:
 
-选择需要部署的产线,并点击“获取”。之后,可以在页面下方的“开源产线部署SDK序列号管理”部分找到获取到的序列号
+如果你的设备是 CPU,请使用以下命令安装 PaddleX 的 CPU 版本
 
-<img src="https://raw.githubusercontent.com/cuicheng01/PaddleX_doc_images/main/images/pipeline_deploy/image-2.png">
-
-使用序列号完成激活后,即可使用高性能推理插件。PaddleX 提供离线激活和在线激活两种方式(均只支持 Linux 系统):
+```bash
+paddlex --install hpi-cpu
+```
 
-* 联网激活:在使用推理 API 或 CLI 时,通过参数指定序列号及联网激活,使程序自动完成激活。
-* 离线激活:按照序列号管理界面中的指引(点击“操作”中的“离线激活”),获取机器的设备指纹,并将序列号与设备指纹绑定以获取证书,完成激活。使用这种激活方式,需要手动将证书存放在机器的 `${HOME}/.baidu/paddlex/licenses` 目录中(如果目录不存在,需要创建目录),并在使用推理 API 或 CLI 时指定序列号。
-请注意:每个序列号只能绑定到唯一的设备指纹,且只能绑定一次。这意味着用户如果使用不同的机器部署模型,则必须为每台机器准备单独的序列号。
+如果你的设备是 GPU,请使用以下命令安装 PaddleX 的 GPU 版本。请注意,GPU 版本包含了 CPU 版本的所有功能,因此无需单独安装 CPU 版本:
 
-### 1.2 安装高性能推理插件
+```bash
+paddlex --install hpi-gpu
+```
 
-在下表中根据处理器架构、操作系统、设备类型、Python 版本等信息,找到对应的安装指令并在部署环境中执行:
+目前高性能推理支持的处理器架构、操作系统、设备类型和 Python 版本如下表所示
 
 <table>
   <tr>
@@ -42,7 +42,6 @@ PaddleX 的三种部署方式详细说明如下:
     <th>操作系统</th>
     <th>设备类型</th>
     <th>Python 版本</th>
-    <th>安装指令</th>
   </tr>
   <tr>
     <td rowspan="7">x86-64</td>
@@ -51,86 +50,80 @@ PaddleX 的三种部署方式详细说明如下:
   </tr>
   <tr>
     <td>3.8</td>
-    <td>curl -s https://paddle-model-ecology.bj.bcebos.com/paddlex/PaddleX3.0/deploy/paddlex_hpi/install_script/latest/install_paddlex_hpi.py | python3.8 - --arch x86_64 --os linux --device cpu --py 38</td>
   </tr>
   <tr>
     <td>3.9</td>
-    <td>curl -s https://paddle-model-ecology.bj.bcebos.com/paddlex/PaddleX3.0/deploy/paddlex_hpi/install_script/latest/install_paddlex_hpi.py | python3.9 - --arch x86_64 --os linux --device cpu --py 39</td>
   </tr>
   <tr>
     <td>3.10</td>
-    <td>curl -s https://paddle-model-ecology.bj.bcebos.com/paddlex/PaddleX3.0/deploy/paddlex_hpi/install_script/latest/install_paddlex_hpi.py | python3.10 - --arch x86_64 --os linux --device cpu --py 310</td>
   </tr>
   <tr>
     <td rowspan="3">GPU&nbsp;(CUDA&nbsp;11.8&nbsp;+&nbsp;cuDNN&nbsp;8.6)</td>
     <td>3.8</td>
-    <td>curl -s https://paddle-model-ecology.bj.bcebos.com/paddlex/PaddleX3.0/deploy/paddlex_hpi/install_script/latest/install_paddlex_hpi.py | python3.8 - --arch x86_64 --os linux --device gpu_cuda118_cudnn86 --py 38</td>
   </tr>
   <tr>
     <td>3.9</td>
-    <td>curl -s https://paddle-model-ecology.bj.bcebos.com/paddlex/PaddleX3.0/deploy/paddlex_hpi/install_script/latest/install_paddlex_hpi.py | python3.9 - --arch x86_64 --os linux --device gpu_cuda118_cudnn86 --py 39</td>
   </tr>
   <tr>
     <td>3.10</td>
-    <td>curl -s https://paddle-model-ecology.bj.bcebos.com/paddlex/PaddleX3.0/deploy/paddlex_hpi/install_script/latest/install_paddlex_hpi.py | python3.10 - --arch x86_64 --os linux --device gpu_cuda118_cudnn86 --py 310</td>
   </tr>
 </table>
 
-* 当设备类型为 GPU 时,请使用与环境匹配的 CUDA 和 cuDNN 版本对应的安装指令,否则,将无法正常使用高性能推理插件。
-* 对于 Linux 系统,使用 Bash 执行安装指令。
-* 当设备类型为 CPU 时,安装的高性能推理插件仅支持使用 CPU 进行推理;对于其他设备类型,安装的高性能推理插件则支持使用 CPU 或其他设备进行推理。
-
-### 1.3 启用高性能推理插件
-
-在启用高性能插件前,请确保当前环境的 `LD_LIBRARY_PATH` 没有指定 TensorRT 的共享库目录,因为插件中已经集成了 TensorRT,避免 TensorRT 版本冲突导致插件无法正常使用。
+### 1.2 启用高性能推理插件
 
-对于 PaddleX CLI,指定 `--use_hpip`,并设置序列号,即可启用高性能推理插件。如果希望进行联网激活,在第一次使用序列号时,需指定 `--update_license`,以通用OCR产线为例:
+对于 PaddleX CLI,指定 `--use_hpip`,即可启用高性能推理插件。以通用图像分类产线为例:
 
-```
-paddlex \
-    --pipeline OCR \
-    --input https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/general_ocr_002.png \
-    --device gpu:0 \
-    --use_hpip \
-    --serial_number {序列号}
-
-# 如果希望进行联网激活
+```bash
 paddlex \
-    --pipeline OCR \
-    --input https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/general_ocr_002.png \
+    --pipeline image_classification \
+    --input https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/general_image_classification_001.jpg \
     --device gpu:0 \
-    --use_hpip \
-    --update_license \
-    --serial_number {序列号}
+    --use_hpip
 ```
 
-对于 PaddleX Python API,启用高性能推理插件的方法类似。仍以通用OCR产线为例:
+对于 PaddleX Python API,启用高性能推理插件的方法类似。以通用图像分类产线和图像分类模块为例:
 
-```
+通用图像分类产线:
+
+```python
 from paddlex import create_pipeline
 
 pipeline = create_pipeline(
-    pipeline="OCR",
-    use_hpip=True,
-    hpi_params={"serial_number": xxx}
+    pipeline="image_classification",
+    device="gpu",
+    use_hpip=True
 )
 
-output = pipeline.predict("https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/general_ocr_002.png ")
+output = pipeline.predict("https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/general_image_classification_001.jpg")
+```
+
+图像分类模块:
+
+```python
+from paddlex import create_model
+
+model = create_model(
+    model_name="ResNet18",
+    device="gpu",
+    use_hpip=True
+)
+
+output = model.predict("https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/general_image_classification_001.jpg")
 ```
 
 启用高性能推理插件得到的推理结果与未启用插件时一致。对于部分模型,在首次启用高性能推理插件时,可能需要花费较长时间完成推理引擎的构建。PaddleX 将在推理引擎的第一次构建完成后将相关信息缓存在模型目录,并在后续复用缓存中的内容以提升初始化速度。
 
-### 1.4 推理步骤
+### 1.3 推理步骤
 
 本推理步骤基于 <b>PaddleX CLI、联网激活序列号、Python 3.10.0、设备类型为CPU</b> 的方式使用高性能推理插件,其他使用方式(如不同 Python 版本、设备类型或 PaddleX Python API)可参考 [PaddleX 高性能推理指南](../pipeline_deploy/high_performance_inference.md) 替换相应的指令。
 
 ```bash
 # 安装高性能推理插件
-curl -s https://paddle-model-ecology.bj.bcebos.com/paddlex/PaddleX3.0/deploy/paddlex_hpi/install_script/latest/install_paddlex_hpi.py | python3.10 - --arch x86_64 --os linux --device cpu --py 310
+paddlex --install hpi-gpu
 # 确保当前环境的 `LD_LIBRARY_PATH` 没有指定 TensorRT 的共享库目录 可以使用下面命令去除或手动去除
 export LD_LIBRARY_PATH=$(echo $LD_LIBRARY_PATH | tr ':' '\n' | grep -v TensorRT | tr '\n' ':' | sed 's/:*$//')
 # 执行推理
-paddlex --pipeline OCR --input https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/general_ocr_002.png --device gpu:0 --use_hpip --serial_number {序列号} --update_license True --save_path ./output
+paddlex --pipeline OCR --input https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/general_ocr_002.png --device gpu:0 --save_path ./output
 ```
 
 运行结果:
@@ -138,14 +131,14 @@ paddlex --pipeline OCR --input https://paddle-model-ecology.bj.bcebos.com/paddle
 <img src="https://raw.githubusercontent.com/cuicheng01/PaddleX_doc_images/main/images/practical_tutorials/deployment/01.png"  width="700" />
 <img src="https://raw.githubusercontent.com/cuicheng01/PaddleX_doc_images/main/images/practical_tutorials/deployment/02.png"  width="700" />
 
-### 1.5 更换产线或模型
+### 1.4 更换产线或模型
 
 - 更换产线:
 
   若想更换其他产线使用高性能推理插件,则替换 `--pipeline` 传入的值即可,以下以通用目标检测产线为例:
 
   ```bash
-  paddlex --pipeline object_detection --input https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/general_object_detection_002.png --device gpu:0 --use_hpip --serial_number {序列号} --update_license True --save_path ./output
+  paddlex --pipeline object_detection --input https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/general_object_detection_002.png --device gpu:0 --use_hpip --save_path ./output
   ```
 
 - 更换模型:
@@ -153,28 +146,25 @@ paddlex --pipeline OCR --input https://paddle-model-ecology.bj.bcebos.com/paddle
   OCR 产线默认使用 PP-OCRv4_mobile_det、PP-OCRv4_mobile_rec 模型,若想更换其他模型,如 PP-OCRv4_server_det、PP-OCRv4_server_rec 模型,可参考 [通用OCR产线使用教程](../pipeline_usage/tutorials/ocr_pipelines/OCR.md),具体操作如下:
 
   ```bash
-  # 1. 获取 OCR 产线配置文件并保存到 ./OCR.yaml
-  paddlex --get_pipeline_config OCR --save_path ./OCR.yaml
-
-  # 2. 修改 ./OCR.yaml 配置文件
-  #    将 Pipeline.text_det_model 的值改为 PP-OCRv4_server_det 模型所在路径
-  #    将 Pipeline.text_rec_model 的值改为 PP-OCRv4_server_rec 模型所在路径
-
-  # 3. 执行推理时使用修改后的配置文件
-  paddlex --pipeline ./OCR.yaml --input https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/general_ocr_002.png --device gpu:0 --use_hpip --serial_number {序列号} --update_license True --save_path ./output
+  # 1. 修改 OCR 产线配置文件
+  #    将 SubModules.TextDetection.model_name 的值改为 PP-OCRv4_server_det
+  #    将 SubModules.TextDetection.model_dir 的值改为 PP-OCRv4_server_det 模型所在路径
+  #    将 SubModules.TextRecognition.model_name 的值改为 PP-OCRv4_server_rec
+  #    将 SubModules.TextRecognition.model_dir 的值改为 PP-OCRv4_server_rec 模型所在路径
+
+  # 2. 执行推理
+  paddlex --pipeline OCR --input https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/general_ocr_002.png --device gpu:0 --use_hpip --save_path ./output
   ```
 
   通用目标检测产线默认使用 PicoDet-S 模型,若想更换其他模型,如 RT-DETR 模型,可参考 [通用目标检测产线使用教程](../pipeline_usage/tutorials/cv_pipelines/object_detection.md),具体操作如下:
 
   ```bash
-  # 1. 获取 OCR 产线配置文件并保存到 ./object_detection.yaml
-  paddlex --get_pipeline_config object_detection --save_path ./object_detection.yaml
-
-  # 2. 修改 ./object_detection.yaml 配置文件
-  #    将 Pipeline.model 的值改为 RT-DETR 模型所在路径
+  # 1. 修改 object_detection 产线配置文件
+  #    将 SubModules.ObjectDetection.model_name 的值改为 RT-DETR
+  #    将 SubModules.ObjectDetection.model_dir 的值改为 RT-DETR 模型所在路径
 
-  # 3. 执行推理时使用修改后的配置文件
-  paddlex --pipeline ./object_detection.yaml --input https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/general_ocr_002.png --device gpu:0 --use_hpip --serial_number {序列号} --update_license True --save_path ./output
+  # 2. 执行推理
+  paddlex --pipeline object_detection --input https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/general_ocr_002.png --device gpu:0 --use_hpip --save_path ./output
   ```
 
   其他产线的操作与上述两条产线的操作类似,更多细节可参考产线使用教程。

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 1403 - 132
libs/paddlex-hpi/src/paddlex_hpi/model_info_collection.json


+ 4 - 3
libs/paddlex-hpi/src/paddlex_hpi/models/anomaly_detection.py

@@ -17,7 +17,7 @@ from typing import Any, Dict, List
 import ultra_infer as ui
 import numpy as np
 from paddlex.inference.common.batch_sampler import ImageBatchSampler
-from paddlex.inference.models_new.anomaly_detection.result import UadResult
+from paddlex.inference.models.anomaly_detection.result import UadResult
 from paddlex.modules.anomaly_detection.model_list import MODELS
 
 from paddlex_hpi.models.base import CVPredictor
@@ -44,7 +44,7 @@ class UadPredictor(CVPredictor):
         return UadResult
 
     def process(self, batch_data: List[Any]) -> Dict[str, List[Any]]:
-        batch_raw_imgs = self._data_reader(imgs=batch_data)
+        batch_raw_imgs = self._data_reader(imgs=batch_data.instances)
         imgs = [np.ascontiguousarray(img) for img in batch_raw_imgs]
         ui_results = self._ui_model.batch_predict(imgs)
 
@@ -57,7 +57,8 @@ class UadPredictor(CVPredictor):
             preds_list.append(pred)
 
         return {
-            "input_path": batch_data,
+            "input_path": batch_data.input_paths,
+            "page_index": batch_data.page_indexes,
             "input_img": batch_raw_imgs,
             "pred": preds_list,
         }

+ 3 - 1
libs/paddlex-hpi/src/paddlex_hpi/models/base.py

@@ -28,7 +28,7 @@ from typing import (
 import ultra_infer as ui
 from ultra_infer.model import BaseUltraInferModel
 from paddlex.inference.common.reader import ReadImage, ReadTS
-from paddlex.inference.models_new import BasePredictor
+from paddlex.inference.models import BasePredictor
 from paddlex.inference.utils.new_ir_blacklist import NEWIR_BLOCKLIST
 from paddlex.utils import device as device_helper
 from paddlex.utils import logging
@@ -53,11 +53,13 @@ class HPPredictor(BasePredictor, metaclass=AutoRegisterABCMetaClass):
         model_dir: Union[str, PathLike],
         config: Optional[Dict[str, Any]] = None,
         device: Optional[str] = None,
+        batch_size: int = 1,
         use_onnx_model: Optional[bool] = None,
         hpi_params: Optional[HPIParams] = None,
     ) -> None:
         super().__init__(model_dir=model_dir, config=config)
         self._device = device or device_helper.get_default_device()
+        self.batch_sampler.batch_size = batch_size
         self._onnx_format = use_onnx_model
         self._check_and_choose_model_format()
         self._hpi_params = hpi_params or {}

+ 4 - 3
libs/paddlex-hpi/src/paddlex_hpi/models/formula_recognition.py

@@ -17,7 +17,7 @@ from typing import Any, Dict, List
 import ultra_infer as ui
 import numpy as np
 from paddlex.inference.common.batch_sampler import ImageBatchSampler
-from paddlex.inference.models_new.formula_recognition.result import FormulaRecResult
+from paddlex.inference.models.formula_recognition.result import FormulaRecResult
 from paddlex.modules.formula_recognition.model_list import MODELS
 
 from paddlex_hpi.models.base import CVPredictor
@@ -44,7 +44,7 @@ class LaTeXOCRPredictor(CVPredictor):
         return FormulaRecResult
 
     def process(self, batch_data: List[Any]) -> Dict[str, List[Any]]:
-        batch_raw_imgs = self._data_reader(imgs=batch_data)
+        batch_raw_imgs = self._data_reader(imgs=batch_data.instances)
         imgs = [np.ascontiguousarray(img) for img in batch_raw_imgs]
         ui_results = self._ui_model.batch_predict(imgs)
 
@@ -53,7 +53,8 @@ class LaTeXOCRPredictor(CVPredictor):
             rec_text_list.append(ui_result.rec_text)
 
         return {
-            "input_path": batch_data,
+            "input_path": batch_data.input_paths,
+            "page_index": batch_data.page_indexes,
             "input_img": batch_raw_imgs,
             "rec_text": rec_text_list,
         }

+ 4 - 3
libs/paddlex-hpi/src/paddlex_hpi/models/general_recognition.py

@@ -17,7 +17,7 @@ from typing import Any, Dict, List
 import ultra_infer as ui
 import numpy as np
 from paddlex.inference.common.batch_sampler import ImageBatchSampler
-from paddlex.inference.models_new.image_feature.result import IdentityResult
+from paddlex.inference.models.image_feature.result import IdentityResult
 from paddlex.modules.general_recognition.model_list import MODELS
 
 from paddlex_hpi.models.base import CVPredictor
@@ -44,7 +44,7 @@ class ShiTuRecPredictor(CVPredictor):
         return IdentityResult
 
     def process(self, batch_data: List[Any]) -> Dict[str, List[Any]]:
-        batch_raw_imgs = self._data_reader(imgs=batch_data)
+        batch_raw_imgs = self._data_reader(imgs=batch_data.instances)
         imgs = [np.ascontiguousarray(img) for img in batch_raw_imgs]
         ui_results = self._ui_model.batch_predict(imgs)
 
@@ -53,7 +53,8 @@ class ShiTuRecPredictor(CVPredictor):
             feature_list.append(np.array(ui_result.feature, dtype="float32"))
 
         return {
-            "input_path": batch_data,
+            "input_path": batch_data.input_paths,
+            "page_index": batch_data.page_indexes,
             "input_img": batch_raw_imgs,
             "feature": feature_list,
         }

+ 6 - 3
libs/paddlex-hpi/src/paddlex_hpi/models/image_classification.py

@@ -18,7 +18,7 @@ from typing import Any, Dict, List, Optional, Union
 import ultra_infer as ui
 import numpy as np
 from paddlex.inference.common.batch_sampler import ImageBatchSampler
-from paddlex.inference.models_new.image_classification.result import TopkResult
+from paddlex.inference.models.image_classification.result import TopkResult
 from paddlex.modules.image_classification.model_list import MODELS
 from pydantic import BaseModel
 
@@ -38,6 +38,7 @@ class ClasPredictor(CVPredictor):
         model_dir: Union[str, os.PathLike],
         config: Optional[Dict[str, Any]] = None,
         device: Optional[str] = None,
+        batch_size: int = 1,
         use_onnx_model: Optional[bool] = None,
         hpi_params: Optional[HPIParams] = None,
         topk: Union[int, None] = None,
@@ -46,6 +47,7 @@ class ClasPredictor(CVPredictor):
             model_dir=model_dir,
             config=config,
             device=device,
+            batch_size=batch_size,
             use_onnx_model=use_onnx_model,
             hpi_params=hpi_params,
         )
@@ -81,7 +83,7 @@ class ClasPredictor(CVPredictor):
     def process(
         self, batch_data: List[Any], topk: Union[int, None] = None
     ) -> Dict[str, List[Any]]:
-        batch_raw_imgs = self._data_reader(imgs=batch_data)
+        batch_raw_imgs = self._data_reader(imgs=batch_data.instances)
         imgs = [np.ascontiguousarray(img) for img in batch_raw_imgs]
         self._ui_model.postprocessor.topk = topk or self._topk
         ui_results = self._ui_model.batch_predict(imgs)
@@ -98,7 +100,8 @@ class ClasPredictor(CVPredictor):
                 )
 
         return {
-            "input_path": batch_data,
+            "input_path": batch_data.input_paths,
+            "page_index": batch_data.page_indexes,
             "input_img": batch_raw_imgs,
             "class_ids": class_ids_list,
             "scores": scores_list,

+ 4 - 3
libs/paddlex-hpi/src/paddlex_hpi/models/image_unwarping.py

@@ -17,7 +17,7 @@ from typing import Any, Dict, List
 import ultra_infer as ui
 import numpy as np
 from paddlex.inference.common.batch_sampler import ImageBatchSampler
-from paddlex.inference.models_new.image_unwarping.result import DocTrResult
+from paddlex.inference.models.image_unwarping.result import DocTrResult
 from paddlex.modules.image_unwarping.model_list import MODELS
 
 from paddlex_hpi.models.base import CVPredictor
@@ -41,7 +41,7 @@ class WarpPredictor(CVPredictor):
         return DocTrResult
 
     def process(self, batch_data: List[Any]) -> Dict[str, List[Any]]:
-        batch_raw_imgs = self._data_reader(imgs=batch_data)
+        batch_raw_imgs = self._data_reader(imgs=batch_data.instances)
         imgs = [np.ascontiguousarray(img) for img in batch_raw_imgs]
         ui_results = self._ui_model.batch_predict(imgs)
 
@@ -55,7 +55,8 @@ class WarpPredictor(CVPredictor):
             doctr_img_list.append(img)
 
         return {
-            "input_path": batch_data,
+            "input_path": batch_data.input_paths,
+            "page_index": batch_data.page_indexes,
             "input_img": batch_raw_imgs,
             "doctr_img": doctr_img_list,
         }

+ 9 - 5
libs/paddlex-hpi/src/paddlex_hpi/models/instance_segmentation.py

@@ -18,8 +18,9 @@ from typing import Any, Dict, List, Optional, Union
 import ultra_infer as ui
 import numpy as np
 from paddlex.inference.common.batch_sampler import ImageBatchSampler
-from paddlex.inference.models_new.instance_segmentation.result import InstanceSegResult
+from paddlex.inference.models.instance_segmentation.result import InstanceSegResult
 from paddlex.modules.instance_segmentation.model_list import MODELS
+from paddlex.utils import logging
 from pydantic import BaseModel
 
 from paddlex_hpi.models.base import CVPredictor, HPIParams
@@ -38,6 +39,7 @@ class InstanceSegPredictor(CVPredictor):
         model_dir: Union[str, os.PathLike],
         config: Optional[Dict[str, Any]] = None,
         device: Optional[str] = None,
+        batch_size: int = 1,
         hpi_params: Optional[HPIParams] = None,
         threshold: Optional[float] = None,
     ) -> None:
@@ -45,10 +47,11 @@ class InstanceSegPredictor(CVPredictor):
             model_dir=model_dir,
             config=config,
             device=device,
+            batch_size=batch_size,
             hpi_params=hpi_params,
         )
         if threshold and self.model_name == "SOLOv2":
-            raise TypeError("SOLOv2 does not support `threshold` in PaddleX HPI.")
+            logging.warning("SOLOv2 does not support `threshold` in PaddleX HPI.")
         self._pp_params = self._get_pp_params()
         self._threshold = threshold or self._pp_params.threshold
 
@@ -73,9 +76,9 @@ class InstanceSegPredictor(CVPredictor):
         self, batch_data: List[Any], threshold: Optional[float] = None
     ) -> Dict[str, List[Any]]:
         if threshold and self.model_name == "SOLOv2":
-            raise TypeError("SOLOv2 does not support `threshold` in PaddleX HPI.")
+            logging.warning("SOLOv2 does not support `threshold` in PaddleX HPI.")
 
-        batch_raw_imgs = self._data_reader(imgs=batch_data)
+        batch_raw_imgs = self._data_reader(imgs=batch_data.instances)
         imgs = [np.ascontiguousarray(img) for img in batch_raw_imgs]
         threshold = threshold or self._threshold
         ui_results = self._ui_model.batch_predict(imgs)
@@ -111,7 +114,8 @@ class InstanceSegPredictor(CVPredictor):
             masks_list.append(masks)
 
         return {
-            "input_path": batch_data,
+            "input_path": batch_data.input_paths,
+            "page_index": batch_data.page_indexes,
             "input_img": batch_raw_imgs,
             "boxes": boxes_list,
             "masks": masks_list,

+ 10 - 6
libs/paddlex-hpi/src/paddlex_hpi/models/multilabel_classification.py

@@ -21,10 +21,11 @@ from pathlib import Path
 import tempfile
 import yaml
 from paddlex.inference.common.batch_sampler import ImageBatchSampler
-from paddlex.inference.models_new.image_multilabel_classification.result import (
+from paddlex.inference.models.image_multilabel_classification.result import (
     MLClassResult,
 )
 from paddlex.modules.multilabel_classification.model_list import MODELS
+from paddlex.utils import logging
 
 from paddlex_hpi.models.base import CVPredictor, HPIParams
 
@@ -37,6 +38,7 @@ class MLClasPredictor(CVPredictor):
         model_dir: Union[str, os.PathLike],
         config: Optional[Dict[str, Any]] = None,
         device: Optional[str] = None,
+        batch_size: int = 1,
         hpi_params: Optional[HPIParams] = None,
         threshold: Union[float, dict, list, None] = None,
     ) -> None:
@@ -45,6 +47,7 @@ class MLClasPredictor(CVPredictor):
             model_dir=model_dir,
             config=config,
             device=device,
+            batch_size=batch_size,
             hpi_params=hpi_params,
         )
         self._label_list = self._get_label_list()
@@ -53,8 +56,8 @@ class MLClasPredictor(CVPredictor):
         self, option: ui.RuntimeOption
     ) -> ui.vision.classification.PyOnlyMultilabelClassificationModel:
         if self._threshold:
-            if isinstance(self._threshold, (dict, list)):
-                raise TypeError("`threshold` must be float or None in PaddleX HPI")
+            if not isinstance(self._threshold, (float, None)):
+                logging.warning("`threshold` must be float or None in PaddleX HPI")
 
             with open(self.config_path, "r") as file:
                 config = yaml.safe_load(file)
@@ -96,11 +99,11 @@ class MLClasPredictor(CVPredictor):
         threshold: Union[float, dict, list, None] = None,
     ) -> Dict[str, List[Any]]:
         if threshold:
-            raise TypeError(
+            logging.warning(
                 "`threshold` is not supported for multilabel classification in PaddleX HPI"
             )
 
-        batch_raw_imgs = self._data_reader(imgs=batch_data)
+        batch_raw_imgs = self._data_reader(imgs=batch_data.instances)
         imgs = [np.ascontiguousarray(img) for img in batch_raw_imgs]
         ui_results = self._ui_model.batch_predict(imgs)
 
@@ -116,7 +119,8 @@ class MLClasPredictor(CVPredictor):
                 )
 
         return {
-            "input_path": batch_data,
+            "input_path": batch_data.input_paths,
+            "page_index": batch_data.page_indexes,
             "input_img": batch_raw_imgs,
             "class_ids": class_ids_list,
             "scores": scores_list,

+ 43 - 5
libs/paddlex-hpi/src/paddlex_hpi/models/object_detection.py

@@ -13,13 +13,14 @@
 # limitations under the License.
 
 import os
-from typing import Any, Dict, List, Optional, Union
+from typing import Any, Dict, List, Optional, Tuple, Union
 
 import ultra_infer as ui
 import numpy as np
 from paddlex.inference.common.batch_sampler import ImageBatchSampler
-from paddlex.inference.models_new.object_detection.result import DetResult
+from paddlex.inference.models.object_detection.result import DetResult
 from paddlex.modules.object_detection.model_list import MODELS
+from paddlex.utils import logging
 from pydantic import BaseModel
 
 from paddlex_hpi.models.base import CVPredictor, HPIParams
@@ -38,18 +39,36 @@ class DetPredictor(CVPredictor):
         model_dir: Union[str, os.PathLike],
         config: Optional[Dict[str, Any]] = None,
         device: Optional[str] = None,
+        batch_size: int = 1,
         hpi_params: Optional[HPIParams] = None,
+        img_size: Optional[Union[int, Tuple[int, int]]] = None,
         threshold: Optional[float] = None,
+        layout_nms: Optional[bool] = None,
+        layout_unclip_ratio: Optional[Union[float, Tuple[float, float]]] = None,
+        layout_merge_bboxes_mode: Optional[str] = None,
     ) -> None:
         super().__init__(
             model_dir=model_dir,
             config=config,
             device=device,
+            batch_size=batch_size,
             hpi_params=hpi_params,
         )
         self._pp_params = self._get_pp_params()
         self._threshold = threshold or self._pp_params.threshold
 
+        unsupported_params = {
+            "img_size": img_size,
+            "layout_nms": layout_nms,
+            "layout_unclip_ratio": layout_unclip_ratio,
+            "layout_merge_bboxes_mode": layout_merge_bboxes_mode,
+        }
+        for param_name, param_value in unsupported_params.items():
+            if param_value:
+                logging.warning(
+                    f"`{param_name}` is not supported for multilabel classification in PaddleX HPI"
+                )
+
     def _build_ui_model(
         self, option: ui.RuntimeOption
     ) -> ui.vision.detection.PaddleDetectionModel:
@@ -68,9 +87,27 @@ class DetPredictor(CVPredictor):
         return DetResult
 
     def process(
-        self, batch_data: List[Any], threshold: Optional[float] = None
+        self,
+        batch_data: List[Any],
+        img_size: Optional[Union[int, Tuple[int, int]]] = None,
+        threshold: Optional[float] = None,
+        layout_nms: Optional[bool] = None,
+        layout_unclip_ratio: Optional[Union[float, Tuple[float, float]]] = None,
+        layout_merge_bboxes_mode: Optional[str] = None,
     ) -> Dict[str, List[Any]]:
-        batch_raw_imgs = self._data_reader(imgs=batch_data)
+        unsupported_params = {
+            "img_size": img_size,
+            "layout_nms": layout_nms,
+            "layout_unclip_ratio": layout_unclip_ratio,
+            "layout_merge_bboxes_mode": layout_merge_bboxes_mode,
+        }
+        for param_name, param_value in unsupported_params.items():
+            if param_value:
+                logging.warning(
+                    f"`{param_name}` is not supported for multilabel classification in PaddleX HPI"
+                )
+
+        batch_raw_imgs = self._data_reader(imgs=batch_data.instances)
         imgs = [np.ascontiguousarray(img) for img in batch_raw_imgs]
         threshold = threshold or self._threshold
         ui_results = self._ui_model.batch_predict(imgs)
@@ -99,7 +136,8 @@ class DetPredictor(CVPredictor):
             boxes_list.append(boxes)
 
         return {
-            "input_path": batch_data,
+            "input_path": batch_data.input_paths,
+            "page_index": batch_data.page_indexes,
             "input_img": batch_raw_imgs,
             "boxes": boxes_list,
         }

+ 9 - 5
libs/paddlex-hpi/src/paddlex_hpi/models/semantic_segmentation.py

@@ -18,8 +18,9 @@ from typing import Any, Dict, List, Optional, Tuple, Union
 import ultra_infer as ui
 import numpy as np
 from paddlex.inference.common.batch_sampler import ImageBatchSampler
-from paddlex.inference.models_new.semantic_segmentation.result import SegResult
+from paddlex.inference.models.semantic_segmentation.result import SegResult
 from paddlex.modules.semantic_segmentation.model_list import MODELS
+from paddlex.utils import logging
 
 from paddlex_hpi.models.base import CVPredictor, HPIParams
 
@@ -32,15 +33,17 @@ class SegPredictor(CVPredictor):
         model_dir: Union[str, os.PathLike],
         config: Optional[Dict[str, Any]] = None,
         device: Optional[str] = None,
+        batch_size: int = 1,
         hpi_params: Optional[HPIParams] = None,
         target_size: Union[int, Tuple[int], None] = None,
     ) -> None:
         if target_size:
-            raise TypeError("`target_size` is not supported in PaddleX HPI.")
+            logging.warning("`target_size` is not supported in PaddleX HPI.")
         super().__init__(
             model_dir=model_dir,
             config=config,
             device=device,
+            batch_size=batch_size,
             hpi_params=hpi_params,
         )
 
@@ -65,9 +68,9 @@ class SegPredictor(CVPredictor):
         self, batch_data: List[Any], target_size: Union[int, Tuple[int], None] = None
     ) -> Dict[str, List[Any]]:
         if target_size:
-            raise TypeError("`target_size` is not supported in PaddleX HPI.")
+            logging.warning("`target_size` is not supported in PaddleX HPI.")
 
-        batch_raw_imgs = self._data_reader(imgs=batch_data)
+        batch_raw_imgs = self._data_reader(imgs=batch_data.instances)
         imgs = [np.ascontiguousarray(img) for img in batch_raw_imgs]
         ui_results = self._ui_model.batch_predict(imgs)
 
@@ -80,7 +83,8 @@ class SegPredictor(CVPredictor):
             batch_preds.append(pred)
 
         return {
-            "input_path": batch_data,
+            "input_path": batch_data.input_paths,
+            "page_index": batch_data.page_indexes,
             "input_img": batch_raw_imgs,
             "pred": batch_preds,
         }

+ 4 - 3
libs/paddlex-hpi/src/paddlex_hpi/models/table_recognition.py

@@ -18,7 +18,7 @@ from typing import Any, Dict, List
 import ultra_infer as ui
 import numpy as np
 from paddlex.inference.common.batch_sampler import ImageBatchSampler
-from paddlex.inference.models_new.table_structure_recognition.result import (
+from paddlex.inference.models.table_structure_recognition.result import (
     TableRecResult,
 )
 from paddlex.modules.table_recognition.model_list import MODELS
@@ -59,7 +59,7 @@ class TablePredictor(CVPredictor):
         return TableRecResult
 
     def process(self, batch_data: List[Any]) -> Dict[str, List[Any]]:
-        batch_raw_imgs = self._data_reader(imgs=batch_data)
+        batch_raw_imgs = self._data_reader(imgs=batch_data.instances)
         imgs = [np.ascontiguousarray(img) for img in batch_raw_imgs]
         ui_results = self._ui_model.batch_predict(imgs)
 
@@ -72,7 +72,8 @@ class TablePredictor(CVPredictor):
             structure_score_list.append(0.0)
 
         return {
-            "input_path": batch_data,
+            "input_path": batch_data.input_paths,
+            "page_index": batch_data.page_indexes,
             "input_img": batch_raw_imgs,
             "bbox": bbox_list,
             "structure": structure_list,

+ 12 - 8
libs/paddlex-hpi/src/paddlex_hpi/models/text_detection.py

@@ -18,8 +18,9 @@ from typing import Any, Dict, List, Optional, Union
 import ultra_infer as ui
 import numpy as np
 from paddlex.inference.common.batch_sampler import ImageBatchSampler
-from paddlex.inference.models_new.text_detection.result import TextDetResult
+from paddlex.inference.models.text_detection.result import TextDetResult
 from paddlex.modules.text_detection.model_list import CURVE_MODELS, MODELS
+from paddlex.utils import logging
 
 from paddlex_hpi._utils.misc import parse_scale
 from paddlex_hpi.models.base import CVPredictor, HPIParams
@@ -33,6 +34,7 @@ class TextDetPredictor(CVPredictor):
         model_dir: Union[str, os.PathLike],
         config: Optional[Dict[str, Any]] = None,
         device: Optional[str] = None,
+        batch_size: int = 1,
         hpi_params: Optional[HPIParams] = None,
         limit_side_len: Union[int, None] = None,
         limit_type: Union[str, None] = None,
@@ -43,17 +45,18 @@ class TextDetPredictor(CVPredictor):
         use_dilation: Union[bool, None] = None,
     ) -> None:
         if limit_type is not None:
-            raise TypeError(
+            logging.warning(
                 "The default value for `limit_type` is max, and cannot be set in PaddleX HPI."
             )
         if max_candidates is not None:
-            raise TypeError(
+            logging.warning(
                 "The default value for `max_candidates` is 1000, and cannot be set in PaddleX HPI."
             )
         super().__init__(
             model_dir=model_dir,
             config=config,
             device=device,
+            batch_size=batch_size,
             hpi_params=hpi_params,
         )
         self._limit_side_len = limit_side_len or self._max_side_len
@@ -104,11 +107,11 @@ class TextDetPredictor(CVPredictor):
         use_dilation: Union[bool, None] = None,
     ) -> Dict[str, List[Any]]:
         if limit_type is not None:
-            raise TypeError(
+            logging.warning(
                 "The default value for `limit_type` is max, and cannot be set in PaddleX HPI."
             )
         if max_candidates is not None:
-            raise TypeError(
+            logging.warning(
                 "The default value for `max_candidates` is 1000, and cannot be set in PaddleX HPI."
             )
         self._ui_model.preprocessor.set_normalize(self._mean, self._std, True)
@@ -129,14 +132,14 @@ class TextDetPredictor(CVPredictor):
             else:
                 postprocessor.det_db_box_type = "poly"
 
-        batch_raw_imgs = self._data_reader(imgs=batch_data)
+        batch_raw_imgs = self._data_reader(imgs=batch_data.instances)
         imgs = [np.ascontiguousarray(img) for img in batch_raw_imgs]
         ui_results = self._ui_model.batch_predict(imgs)
 
         dt_polys_list = []
         dt_scores_list = []
         for ui_result in ui_results:
-            polys = [list(zip(*([iter(box)] * 2))) for box in ui_result.boxes]
+            polys = [np.array(list(zip(*([iter(box)] * 2)))) for box in ui_result.boxes]
             dt_polys_list.append(polys)
             # XXX: Currently, we cannot get scores from `ui_result`, so we
             # temporarily use dummy scores here.
@@ -144,7 +147,8 @@ class TextDetPredictor(CVPredictor):
             dt_scores_list.append(dummy_scores)
         # breakpoint()
         return {
-            "input_path": batch_data,
+            "input_path": batch_data.input_paths,
+            "page_index": batch_data.page_indexes,
             "input_img": batch_raw_imgs,
             "dt_polys": dt_polys_list,
             "dt_scores": dt_scores_list,

+ 4 - 3
libs/paddlex-hpi/src/paddlex_hpi/models/text_recognition.py

@@ -18,7 +18,7 @@ from typing import Any, Dict, List
 import ultra_infer as ui
 import numpy as np
 from paddlex.inference.common.batch_sampler import ImageBatchSampler
-from paddlex.inference.models_new.text_recognition.result import TextRecResult
+from paddlex.inference.models.text_recognition.result import TextRecResult
 from paddlex.modules.text_recognition.model_list import MODELS
 
 from paddlex_hpi.models.base import CVPredictor
@@ -49,7 +49,7 @@ class TextRecPredictor(CVPredictor):
         return model
 
     def process(self, batch_data: List[Any]) -> Dict[str, List[Any]]:
-        batch_raw_imgs = self._data_reader(imgs=batch_data)
+        batch_raw_imgs = self._data_reader(imgs=batch_data.instances)
         imgs = [np.ascontiguousarray(img) for img in batch_raw_imgs]
         ui_results = self._ui_model.batch_predict(imgs)
 
@@ -57,7 +57,8 @@ class TextRecPredictor(CVPredictor):
         rec_score_list = ui_results.rec_scores
 
         return {
-            "input_path": batch_data,
+            "input_path": batch_data.input_paths,
+            "page_index": batch_data.page_indexes,
             "input_img": batch_raw_imgs,
             "rec_text": texts_list,
             "rec_score": rec_score_list,

+ 1 - 1
libs/paddlex-hpi/src/paddlex_hpi/models/ts_ad.py

@@ -17,7 +17,7 @@ from typing import Any, Dict, List, Union
 import ultra_infer as ui
 import pandas as pd
 from paddlex.inference.common.batch_sampler import TSBatchSampler
-from paddlex.inference.models_new.ts_anomaly_detection.result import TSAdResult
+from paddlex.inference.models.ts_anomaly_detection.result import TSAdResult
 from paddlex.modules.ts_anomaly_detection.model_list import MODELS
 
 from paddlex_hpi.models.base import TSPredictor

+ 1 - 1
libs/paddlex-hpi/src/paddlex_hpi/models/ts_cls.py

@@ -17,7 +17,7 @@ from typing import Any, Dict, List, Union
 import ultra_infer as ui
 import pandas as pd
 from paddlex.inference.common.batch_sampler import TSBatchSampler
-from paddlex.inference.models_new.ts_classification.result import TSClsResult
+from paddlex.inference.models.ts_classification.result import TSClsResult
 from paddlex.modules.ts_classification.model_list import MODELS
 
 from paddlex_hpi.models.base import TSPredictor

+ 1 - 1
libs/paddlex-hpi/src/paddlex_hpi/models/ts_fc.py

@@ -17,7 +17,7 @@ from typing import Any, Dict, List, Union
 import ultra_infer as ui
 import pandas as pd
 from paddlex.inference.common.batch_sampler import TSBatchSampler
-from paddlex.inference.models_new.ts_forecasting.result import TSFcResult
+from paddlex.inference.models.ts_forecasting.result import TSFcResult
 from paddlex.modules.ts_forecast.model_list import MODELS
 
 from paddlex_hpi.models.base import TSPredictor

+ 0 - 7
libs/ultra-infer/python/ultra_infer/__init__.py

@@ -140,13 +140,6 @@ except:
     pass
 
 
-os.environ["FLAGS_enable_pir_api"] = "0"
-logging.warning(
-    "Please note that we have set the environment variable \
-'FLAGS_enable_pir_api' to 'False' to ensure the correct operation of the Paddle backend."
-)
-
-
 from .c_lib_wrap import (
     ModelFormat,
     Backend,

+ 0 - 10
libs/ultra-infer/ultra_infer/runtime/runtime.cc

@@ -264,16 +264,6 @@ void Runtime::CreatePaddleBackend() {
 #endif
   FDINFO << "Runtime initialized with Backend::PDINFER in " << option.device
          << "." << std::endl;
-
-  const char *pirApiFlag = "FLAGS_enable_pir_api";
-  const char *envValue = getenv(pirApiFlag);
-  if (envValue == nullptr ||
-      (std::string(envValue) != "0" && std::string(envValue) != "False")) {
-    FDWARNING
-        << "To ensure the correct operation of the Paddle backend, please set"
-           "the environment variable 'FLAGS_enable_pir_api' to 'False'."
-        << std::endl;
-  }
 }
 
 void Runtime::CreateOpenVINOBackend() {

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно