文件最后提交记录最后更新时间
fix PaddleOCR-VL-1.5, PP-DocLayoutV2, PP-DocLayoutV3 Co-authored-by: wangzihan-zzz<1780093255@qq.com> # message auto-generated for no-merge-commit merge: !7594 merge master into master fix PaddleOCR-VL-1.5, PP-DocLayoutV2, PP-DocLayoutV3 Created-by: wangzihan-zzz Commit-by: wangzihan-zzz Merged-by: ascend-robot Description: ## Motivation fix PaddleOCR-VL-1.5, PP-DocLayoutV2, PP-DocLayoutV3 docs ## Modification fix PaddleOCR-VL-1.5 README contents,update PP-DocLayoutV2 README、infer.py,fix PP-DocLayoutV3 README ## Checklist **Before PR**: - [ ] The new code needs to comply with the Clean Code specification. - [ ] The PR content is self-checked, and the expression can be clear and the writing standardized **After PR**: - [ ] CLA has been signed and all committers have signed the CLA in this PR. - [ ] The ci-pipeline is passed, Code Check is passed. See merge request: Ascend/ModelZoo-PyTorch!75944 天前
add PP-DocLayoutV3 model Co-authored-by: wangzihan-zzz<1780093255@qq.com> # message auto-generated for no-merge-commit merge: !7575 merge PP-DocLayoutV3 into master add PP-DocLayoutV3 model Created-by: wangzihan-zzz Commit-by: wangzihan-zzz Merged-by: ascend-robot Description: ## Motivation add PP-DocLayoutV3 model ## Modification add README、infer.py ## Checklist **Before PR**: - [ ] The new code needs to comply with the Clean Code specification. - [ ] The PR content is self-checked, and the expression can be clear and the writing standardized **After PR**: - [ ] CLA has been signed and all committers have signed the CLA in this PR. - [ ] The ci-pipeline is passed, Code Check is passed. See merge request: Ascend/ModelZoo-PyTorch!75754 天前
add PP-DocLayoutV3 model Co-authored-by: wangzihan-zzz<1780093255@qq.com> # message auto-generated for no-merge-commit merge: !7575 merge PP-DocLayoutV3 into master add PP-DocLayoutV3 model Created-by: wangzihan-zzz Commit-by: wangzihan-zzz Merged-by: ascend-robot Description: ## Motivation add PP-DocLayoutV3 model ## Modification add README、infer.py ## Checklist **Before PR**: - [ ] The new code needs to comply with the Clean Code specification. - [ ] The PR content is self-checked, and the expression can be clear and the writing standardized **After PR**: - [ ] CLA has been signed and all committers have signed the CLA in this PR. - [ ] The ci-pipeline is passed, Code Check is passed. See merge request: Ascend/ModelZoo-PyTorch!75754 天前
add PP-DocLayoutV3 model Co-authored-by: wangzihan-zzz<1780093255@qq.com> # message auto-generated for no-merge-commit merge: !7575 merge PP-DocLayoutV3 into master add PP-DocLayoutV3 model Created-by: wangzihan-zzz Commit-by: wangzihan-zzz Merged-by: ascend-robot Description: ## Motivation add PP-DocLayoutV3 model ## Modification add README、infer.py ## Checklist **Before PR**: - [ ] The new code needs to comply with the Clean Code specification. - [ ] The PR content is self-checked, and the expression can be clear and the writing standardized **After PR**: - [ ] CLA has been signed and all committers have signed the CLA in this PR. - [ ] The ci-pipeline is passed, Code Check is passed. See merge request: Ascend/ModelZoo-PyTorch!75754 天前
add PP-DocLayoutV3 model Co-authored-by: wangzihan-zzz<1780093255@qq.com> # message auto-generated for no-merge-commit merge: !7575 merge PP-DocLayoutV3 into master add PP-DocLayoutV3 model Created-by: wangzihan-zzz Commit-by: wangzihan-zzz Merged-by: ascend-robot Description: ## Motivation add PP-DocLayoutV3 model ## Modification add README、infer.py ## Checklist **Before PR**: - [ ] The new code needs to comply with the Clean Code specification. - [ ] The PR content is self-checked, and the expression can be clear and the writing standardized **After PR**: - [ ] CLA has been signed and all committers have signed the CLA in this PR. - [ ] The ci-pipeline is passed, Code Check is passed. See merge request: Ascend/ModelZoo-PyTorch!75754 天前
README.md

PP-DocLayoutV3(ONNX)-推理指导


概述

版面分析是文档解析系统中的重要组成环节,目标是对文档的整体布局进行解析,准确检测出其中所包含的各种元素(例如,文本段落、标题、图片、表格、公式等),并恢复这些元素正确的阅读顺序。 PP-DocLayoutV3是一个专门用于布局分析的轻量级模型,专注于元素检测、分类和读取顺序预测,是PP-DocLayoutV2的迭代版本,也是PaddleOCR-VL-1.5的核心组件。

  • 版本说明:
url=https://www.modelscope.cn/models/PaddlePaddle/PP-DocLayoutV3/
model_name=PP-DocLayoutV3

推理环境准备

  • 该模型需要以下插件与驱动

表 1 版本配套表

配套 版本 环境准备指导
固件与驱动 25.2.RC1 Pytorch框架推理环境准备
CANN 8.5.0 -
Python 3.11 -

说明:Atlas 800I A2推理卡请以CANN版本选择实际固件与驱动版本

快速上手

环境配置

  1. 拉取源码
git clone https://gitcode.com/ascend/ModelZoo-PyTorch.git
cd ModelZoo-PyTorch/ACL_PyTorch/built-in/ocr/PP-DocLayoutV3
  1. 安装依赖
# 安装paddle相关库与其他基础库
pip install -r requirements.txt
# 安装aisbench相关组件
wget https://aisbench.obs.myhuaweicloud.com/packet/ais_bench_infer/0.0.2/ait/ais_bench-0.0.2-py3-none-any.whl
wget https://aisbench.obs.myhuaweicloud.com/packet/ais_bench_infer/0.0.2/ait/aclruntime-0.0.2-cp311-cp311-linux_aarch64.whl
pip install ais_bench-0.0.2-py3-none-any.whl
pip install aclruntime-0.0.2-cp311-cp311-linux_aarch64.whl
  1. 应用patch
workdir=$(pwd)
source_path=$(pip show paddlex | grep Location | awk '{print $2}')
cd ${source_path}/
git apply ${workdir}/paddlex.patch

获取权重

下载PP-DocLayoutV3模型权重,并放置于本地目录PP-DocLayoutV3-weight

mkdir PP-DocLayoutV3-weight
modelscope download --model PaddlePaddle/PP-DocLayoutV3 --local_dir ./PP-DocLayoutV3-weight

模型转换

导出onnx模型

paddlex --paddle2onnx --paddle_model_dir ./PP-DocLayoutV3-weight --onnx_model_dir PP-DocLayoutV3_paddle2onnx
mv PP-DocLayoutV3_paddle2onnx/inference.onnx PP-DocLayoutV3-weight/PP-DocLayoutV3.onnx

onnx模型优化

使用onnxsim工具对导出的onnx进行优化

onnxsim PP-DocLayoutV3-weight/PP-DocLayoutV3.onnx PP-DocLayoutV3-weight/PP-DocLayoutV3-opt.onnx

om模型转换

参照ATC工具指导,执行npu-smi info查看芯片名称,并赋值为${soc_version},执行ATC命令,生成PP-DocLayoutV3的om模型

atc --model=PP-DocLayoutV3-weight/PP-DocLayoutV3-opt.onnx --framework=5 --output=PP-DocLayoutV3 --soc_version=Ascend${soc_version} --input_shape "im_shape:-1,2;image:-1,3,800,800;scale_factor:-1,2" --precision_mode_v2=mixed_float16

执行推理

获取示例图像,并执行推理脚本

wget https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/layout.jpg
python3 infer.py
  • 可选参数说明
    • image_dir: 待预测数据
    • model_name: 布局检测模型的名称,默认为PP-DocLayoutV3
    • model_dir: 布局检测模型的目录路径

结果展示

推理执行完成后,解析结果存放于output目录,目录包含存有各项中间结果的json文件以及可视化结果图像

示例图像推理结果