Przeglądaj źródła

!11 Fix assemble script (#4650)
Merge pull request !11 from zhch158/release/3.3

zhch158 3 tygodni temu
rodzic
commit
cb69cbce44

+ 1 - 1
deploy/hps/sdk/scripts/assemble.sh

@@ -8,5 +8,5 @@ docker run \
     -v "$(pwd)":/workspace \
     -w /workspace \
     --rm \
-    python:3.10@sha256:6ff000548a4fa34c1be02624836e75e212d4ead8227b4d4381c3ae998933a922 \
+    python:3.10 \
     /bin/bash scripts/_assemble.sh "$@"

+ 3 - 4
deploy/hps/server_env/Dockerfile

@@ -33,9 +33,7 @@ ENV DEBIAN_FRONTEND=noninteractive
 
 RUN mkdir /paddlex
 
-RUN apt-get update \
-    && apt-get install -y --no-install-recommends software-properties-common \
-    && add-apt-repository -y ppa:deadsnakes/ppa \
+RUN echo 'deb http://archive.ubuntu.com/ubuntu jammy main universe' > /etc/apt/sources.list.d/jammy-temp.list \
     && apt-get update \
     && apt-get install -y --no-install-recommends python3.10 python3.10-venv \
     && python3.10 -m venv /paddlex/py310 \
@@ -101,7 +99,8 @@ RUN --mount=type=bind,source=deploy/hps/server_env/requirements/${DEVICE_TYPE}.t
     python -m pip install --requirement /tmp/requirements.txt --requirement /tmp/hpi_requirements.txt \
     && if [ "${ENV_TYPE}" = 'dev' ]; then \
         python -m pip install --requirement /tmp/dev_requirements.txt; \
-    fi
+    fi \
+    && python -m pip install https://paddle-whl.bj.bcebos.com/nightly/cu126/safetensors/safetensors-0.6.2.dev0-cp38-abi3-linux_x86_64.whl
 
 RUN --mount=type=bind,source=.,target=/tmp/PaddleX,rw \
     python -m pip install --no-deps /tmp/PaddleX

+ 7 - 1
deploy/hps/server_env/requirements/cpu.txt

@@ -2,7 +2,7 @@
 # This file is autogenerated by pip-compile with Python 3.10
 # by the following command:
 #
-#    pip-compile --allow-unsafe --extra=base --extra=serving --no-emit-index-url --no-emit-trusted-host --output-file=requirements/cpu.txt --strip-extras ../../../setup.py paddlex-hps-server/pyproject.toml requirements/app.in requirements/cpu.in
+#    pip-compile --allow-unsafe --cert=None --client-cert=None --extra=base --extra=serving --index-url=None --no-emit-index-url --no-emit-trusted-host --output-file=requirements/cpu.txt --pip-args=None --strip-extras ../../../setup.py paddlex-hps-server/pyproject.toml requirements/app.in requirements/cpu.in
 #
 aiohappyeyeballs==2.4.6
     # via aiohttp
@@ -289,6 +289,8 @@ pyparsing==3.2.1
     # via matplotlib
 pypdfium2==4.30.1
     # via paddlex (../../../setup.py)
+python-bidi==0.6.6
+    # via paddlex (../../../setup.py)
 python-dateutil==2.9.0.post0
     # via
     #   matplotlib
@@ -324,6 +326,8 @@ ruamel-yaml==0.18.10
     # via paddlex (../../../setup.py)
 ruamel-yaml-clib==0.2.12
     # via ruamel-yaml
+safetensors==0.6.2
+    # via paddlex (../../../setup.py)
 scikit-image==0.24.0
     # via paddlex (../../../setup.py)
 scikit-learn==1.6.1
@@ -332,6 +336,8 @@ scipy==1.15.2
     # via
     #   scikit-image
     #   scikit-learn
+sentencepiece==0.2.1
+    # via paddlex (../../../setup.py)
 shapely==2.0.7
     # via paddlex (../../../setup.py)
 six==1.17.0

+ 1 - 1
deploy/hps/server_env/requirements/cpu_dev.txt

@@ -2,5 +2,5 @@
 # This file is autogenerated by pip-compile with Python 3.10
 # by the following command:
 #
-#    pip-compile --allow-unsafe --constraint=requirements/cpu.txt --no-emit-index-url --no-emit-trusted-host --output-file=requirements/cpu_dev.txt --strip-extras requirements/cpu_dev.in
+#    pip-compile --allow-unsafe --cert=None --client-cert=None --constraint=requirements/cpu.txt --index-url=None --no-emit-index-url --no-emit-trusted-host --output-file=requirements/cpu_dev.txt --pip-args=None --strip-extras requirements/cpu_dev.in
 #

+ 1 - 1
deploy/hps/server_env/requirements/cpu_hpi.txt

@@ -2,7 +2,7 @@
 # This file is autogenerated by pip-compile with Python 3.10
 # by the following command:
 #
-#    pip-compile --allow-unsafe --constraint=requirements/cpu.txt --no-emit-index-url --no-emit-trusted-host --output-file=requirements/cpu_hpi.txt --strip-extras requirements/cpu_hpi.in
+#    pip-compile --allow-unsafe --cert=None --client-cert=None --constraint=requirements/cpu.txt --index-url=None --no-emit-index-url --no-emit-trusted-host --output-file=requirements/cpu_hpi.txt --pip-args=None --strip-extras requirements/cpu_hpi.in
 #
 certifi==2025.1.31
     # via

+ 7 - 1
deploy/hps/server_env/requirements/gpu.txt

@@ -2,7 +2,7 @@
 # This file is autogenerated by pip-compile with Python 3.10
 # by the following command:
 #
-#    pip-compile --allow-unsafe --extra=base --extra=serving --no-emit-index-url --no-emit-trusted-host --output-file=requirements/gpu.txt --strip-extras ../../../setup.py paddlex-hps-server/pyproject.toml requirements/app.in requirements/gpu.in
+#    pip-compile --allow-unsafe --cert=None --client-cert=None --extra=base --extra=serving --index-url=None --no-emit-index-url --no-emit-trusted-host --output-file=requirements/gpu.txt --pip-args=None --strip-extras ../../../setup.py paddlex-hps-server/pyproject.toml requirements/app.in requirements/gpu.in
 #
 aiohappyeyeballs==2.4.6
     # via aiohttp
@@ -289,6 +289,8 @@ pyparsing==3.2.1
     # via matplotlib
 pypdfium2==4.30.1
     # via paddlex (../../../setup.py)
+python-bidi==0.6.6
+    # via paddlex (../../../setup.py)
 python-dateutil==2.9.0.post0
     # via
     #   matplotlib
@@ -324,6 +326,8 @@ ruamel-yaml==0.18.10
     # via paddlex (../../../setup.py)
 ruamel-yaml-clib==0.2.12
     # via ruamel-yaml
+safetensors==0.6.2
+    # via paddlex (../../../setup.py)
 scikit-image==0.24.0
     # via paddlex (../../../setup.py)
 scikit-learn==1.6.1
@@ -332,6 +336,8 @@ scipy==1.15.2
     # via
     #   scikit-image
     #   scikit-learn
+sentencepiece==0.2.1
+    # via paddlex (../../../setup.py)
 shapely==2.0.7
     # via paddlex (../../../setup.py)
 six==1.17.0

+ 1 - 1
deploy/hps/server_env/requirements/gpu_dev.txt

@@ -2,5 +2,5 @@
 # This file is autogenerated by pip-compile with Python 3.10
 # by the following command:
 #
-#    pip-compile --allow-unsafe --constraint=requirements/gpu.txt --no-emit-index-url --no-emit-trusted-host --output-file=requirements/gpu_dev.txt --strip-extras requirements/gpu_dev.in
+#    pip-compile --allow-unsafe --cert=None --client-cert=None --constraint=requirements/gpu.txt --index-url=None --no-emit-index-url --no-emit-trusted-host --output-file=requirements/gpu_dev.txt --pip-args=None --strip-extras requirements/gpu_dev.in
 #

+ 1 - 1
deploy/hps/server_env/requirements/gpu_hpi.txt

@@ -2,7 +2,7 @@
 # This file is autogenerated by pip-compile with Python 3.10
 # by the following command:
 #
-#    pip-compile --allow-unsafe --constraint=requirements/gpu.txt --no-emit-index-url --no-emit-trusted-host --output-file=requirements/gpu_hpi.txt --strip-extras requirements/gpu_hpi.in
+#    pip-compile --allow-unsafe --cert=None --client-cert=None --constraint=requirements/gpu.txt --index-url=None --no-emit-index-url --no-emit-trusted-host --output-file=requirements/gpu_hpi.txt --pip-args=None --strip-extras requirements/gpu_hpi.in
 #
 certifi==2025.1.31
     # via

+ 30 - 3
docs/pipeline_usage/tutorials/ocr_pipelines/PaddleOCR-VL.md

@@ -78,8 +78,8 @@ comments: true
 </thead>
 <tbody>
 <tr>
-<td>PP-DocLayoutV2-L</td>
-<td><a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_inference_model/paddle3.0.0/PP-DocLayoutV2-L_infer.tar">推理模型</a>/<a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_pretrained_model/PP-DocLayoutV2-L_pretrained.pdparams">训练模型</a></td>
+<td>PP-DocLayoutV2</td>
+<td><a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_inference_model/paddle3.0.0/PP-DocLayoutV2_infer.tar">推理模型</a>/<a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_pretrained_model/PP-DocLayoutV2_pretrained.pdparams">训练模型</a></td>
 <td>-</td>
 <td>- / -</td>
 <td>- / -</td>
@@ -287,6 +287,7 @@ comments: true
     * 由于我们没有收集NPU和XPU的设备内存数据,因此表中相应位置的数据标记为N/A。
 
 ## 2. 快速开始
+
 PaddleX 所提供的模型产线均可以快速体验效果,你可以在本地使用命令行或 Python 体验通用通用版面解析v3产线的效果。
 
 在本地使用通用版面解析v3产线前,请确保您已经按照[PaddleX本地安装教程](../../../installation/installation.md)完成了PaddleX的wheel包安装。如果您希望选择性安装依赖,请参考安装教程中的相关说明。该产线对应的依赖分组为 `ocr`。此外,为了使用飞桨框架读取 safetensors 格式模型,请执行如下命令安装 safetensors:
@@ -907,6 +908,20 @@ docker run \
     paddlex_genai_server --model_name PaddleOCR-VL-0.9B --host 0.0.0.0 --port 8118 --backend vllm
 ```
 
+若您使用的是  NVIDIA 50 系显卡 (Compute Capacity >= 12),需要在启动服务前安装指定版本的 FlashAttention:
+
+```
+docker run \
+    -it \
+    --rm \
+    --gpus all \
+    --network host \
+    ccr-2vdh3abv-pub.cnc.bj.baidubce.com/paddlepaddle/paddlex-genai-vllm-server \
+    /bin/bash
+python -m pip install flash-attn==2.8.3
+paddlex_genai_server --model_name PaddleOCR-VL-0.9B --backend vllm --port 8118
+```
+
 #### 3.1.2 通过 PaddleX CLI 和启动
 
 由于推理加速框架可能与飞桨框架存在依赖冲突,建议在虚拟环境中安装。示例如下:
@@ -917,13 +932,19 @@ python -m venv .venv
 # 激活环境
 source .venv/bin/activate
 # 安装 PaddleX
-python -m pip install "paddlex[ocr]"
+python -m pip install paddlex
 # 安装 vLLM 服务器插件
 paddlex --install genai-vllm-server
 # 安装 SGLang 服务器插件
 # paddlex --install genai-sglang-server
 ```
 
+若您使用的是  NVIDIA 50 系显卡 (Compute Capacity >= 12),需要在启动服务前安装指定版本的 FlashAttention:
+
+```
+python -m pip install flash-attn==2.8.3
+```
+
 安装完成后,可通过 `paddlex_genai_server` 命令启动服务:
 
 ```bash
@@ -1146,6 +1167,12 @@ PaddleX 会将来自单张或多张输入图像中的子图分组并对服务器
 <td>否</td>
 </tr>
 <tr>
+<td><code>useDocOrientationClassify</code></td>
+<td><code>boolean</code> | <code>null</code></td>
+<td>请参阅产线对象中 <code>predict</code> 方法的 <code>use_doc_orientation_classify</code> 参数相关说明。</td>
+<td>否</td>
+</tr>
+<tr>
 <td><code>useDocUnwarping</code></td>
 <td><code>boolean</code> | <code>null</code></td>
 <td>请参阅产线对象中 <code>predict</code> 方法的 <code>use_doc_unwarping</code> 参数相关说明。</td>

+ 1 - 1
paddlex/.version

@@ -1 +1 @@
-3.3.3
+3.3.4

+ 4 - 0
paddlex/inference/models/common/vlm/transformers/model_utils.py

@@ -1607,6 +1607,8 @@ class PretrainedModel(
                 except NotImplementedError:
                     if convert_from_hf:
                         raise ValueError("`convert_from_hf=True` is not supported")
+                    else:
+                        transpose_weight_keys = None
                 state_dict = load_state_dict(
                     shard_file,
                     tp_actions if pre_tensor_parallel_split else None,
@@ -1937,6 +1939,8 @@ class PretrainedModel(
                 except NotImplementedError:
                     if convert_from_hf:
                         raise ValueError("`convert_from_hf=True` is not supported")
+                    else:
+                        transpose_weight_keys = None
                 state_dict = load_state_dict(
                     resolved_archive_file,
                     convert_from_hf=convert_from_hf,

+ 27 - 0
paddlex/inference/utils/hpi_model_info_collection.json

@@ -1465,6 +1465,9 @@
       ],
       "YOWO": [
         "paddle"
+      ],
+      "PP-DocLayoutV2": [
+        "paddle"
       ]
     },
     "paddle31": {
@@ -2946,6 +2949,9 @@
       ],
       "YOWO": [
         "paddle"
+      ],
+      "PP-DocLayoutV2": [
+        "paddle"
       ]
     },
     "paddle311": {
@@ -4428,6 +4434,9 @@
       ],
       "YOWO": [
         "paddle"
+      ],
+      "PP-DocLayoutV2": [
+        "paddle"
       ]
     }
   },
@@ -5849,6 +5858,9 @@
       ],
       "YOWO": [
         "paddle"
+      ],
+      "PP-DocLayoutV2": [
+        "paddle"
       ]
     },
     "paddle31": {
@@ -7288,6 +7300,9 @@
       ],
       "YOWO": [
         "paddle"
+      ],
+      "PP-DocLayoutV2": [
+        "paddle"
       ]
     },
     "paddle311": {
@@ -8726,6 +8741,9 @@
       ],
       "YOWO": [
         "paddle"
+      ],
+      "PP-DocLayoutV2": [
+        "paddle"
       ]
     }
   },
@@ -9774,6 +9792,9 @@
       ],
       "YOWO": [
         "paddle"
+      ],
+      "PP-DocLayoutV2": [
+        "paddle"
       ]
     },
     "paddle31": {
@@ -10835,6 +10856,9 @@
       ],
       "YOWO": [
         "paddle"
+      ],
+      "PP-DocLayoutV2": [
+        "paddle"
       ]
     },
     "paddle311": {
@@ -11880,6 +11904,9 @@
       ],
       "YOWO": [
         "paddle"
+      ],
+      "PP-DocLayoutV2": [
+        "paddle"
       ]
     }
   }

+ 14 - 11
paddlex/inference/utils/official_models.py

@@ -433,11 +433,12 @@ class _BaseModelHoster(ABC):
             )
             self._download(model_name, model_dir)
 
-        return (
-            model_dir / "PaddleOCR-VL-0.9B"
-            if model_name == "PaddleOCR-VL"
-            else model_dir
-        )
+        if model_name == "PaddleOCR-VL":
+            vl_model_dir = model_dir / "PaddleOCR-VL-0.9B"
+            if vl_model_dir.exists() and vl_model_dir.is_dir():
+                return vl_model_dir
+
+        return model_dir
 
     @abstractmethod
     def _download(self):
@@ -584,17 +585,19 @@ Otherwise, only local models can be used."""
         for idx, hoster in enumerate(hosters):
             if model_name in hoster.model_list:
                 try:
-                    return hoster.get_model(model_name)
-                except Exception as e:
-                    logging.warning(
-                        f"Encounter exception when download model from {hoster.alias}: \n{e}."
+                    model_path = hoster.get_model(model_name)
+                    logging.debug(
+                        f"`{model_name}` model files has been download from model source: `{hoster.alias}`!"
                     )
+                    return model_path
+
+                except Exception as e:
                     if len(hosters) <= 1:
                         raise Exception(
-                            f"No model source is available! Please check network or use local model files!"
+                            f"Encounter exception when download model from {hoster.alias}. No model source is available! Please check network or use local model files!"
                         )
                     logging.warning(
-                        f"PaddleX would try to download from other model sources."
+                        f"Encountering exception when download model from {hoster.alias}: \n{e}, will try to download from other model sources: `hosters[idx + 1].alias`."
                     )
                     return self._download_from_hoster(hosters[idx + 1 :], model_name)
 

+ 1 - 8
paddlex/paddlex_cli.py

@@ -370,14 +370,7 @@ def install(args):
             if "vllm" in plugin_type or "sglang" in plugin_type:
                 try:
                     install_packages(["wheel"], constraints="required")
-                    if "vllm" in plugin_type:
-                        install_packages(
-                            ["flash-attn == 2.8.3"], constraints="required"
-                        )
-                    elif "sglang" in plugin_type:
-                        install_packages(
-                            ["flash-attn == 2.8.2"], constraints="required"
-                        )
+                    install_packages(["flash-attn == 2.8.2"], constraints="required")
                 except Exception:
                     logging.error("Installation failed", exc_info=True)
                     sys.exit(1)

+ 3 - 3
setup.py

@@ -38,10 +38,10 @@ BASE_DEP_SPECS = {
     "imagesize": "",
     "Jinja2": "",
     "joblib": "",
-    "langchain": ">= 0.2",
-    "langchain-community": ">= 0.2",
+    "langchain": ">= 0.2, < 1.0",
+    "langchain-community": ">= 0.2, < 1.0",
     "langchain-core": "",
-    "langchain-openai": ">= 0.1",
+    "langchain-openai": ">= 0.1, < 1.0",
     "lxml": "",
     "matplotlib": "",
     "modelscope": ">=1.28.0",