|
|
3 tuần trước cách đây | |
|---|---|---|
| .. | ||
| adapters | 1 tháng trước cách đây | |
| my_config | 3 tuần trước cách đây | |
| sample_data | 3 tháng trước cách đây | |
| shell | 3 tháng trước cách đây | |
| table_structure_recognition | 3 tháng trước cách đây | |
| unified_pytorch_models | 3 tuần trước cách đây | |
| utils | 3 tuần trước cách đây | |
| 评估算法说明 | 2 tháng trước cách đây | |
| OCR-zhch.yaml | 1 tháng trước cách đây | |
| OmniDocBench-说明.md | 3 tháng trước cách đây | |
| PP-StructureV3-说明.md | 3 tháng trước cách đây | |
| PPStructureV3-OmniDocBench.md | 3 tháng trước cách đây | |
| PaddleOCR-VL-说明.md | 1 tháng trước cách đây | |
| README.md | 1 tháng trước cách đây | |
| omnidocbench_eval.py | 3 tháng trước cách đây | |
| omnidocbench_parallel_eval.py | 3 tháng trước cách đây | |
| paddle_vllm_daemon.sh | 1 tháng trước cách đây | |
| paddleocr_vl_single_process.py | 1 tháng trước cách đây | |
| pdf2md.py | 4 tháng trước cách đây | |
| ppstructure_v3_daemon.sh | 1 tháng trước cách đây | |
| ppstructurev3_scheduler.py | 2 tháng trước cách đây | |
| ppstructurev3_single_client.py | 1 tháng trước cách đây | |
| ppstructurev3_single_process.py | 1 tháng trước cách đây | |
| ppstructurev3_utils.py | 1 tháng trước cách đây | |
| serve方式如何启用表格增强适配器.md | 1 tháng trước cách đây | |
| sitecustomize.start_error.py | 1 tháng trước cách đây | |
| start_paddlex_with_adapter.py | 1 tháng trước cách đây | |
| table_mode_selector.py | 3 tháng trước cách đây | |
| table_recognition_post_processing_V2 bugfix.md | 1 tháng trước cách đây | |
| table_recognition_v2-说明.md | 1 tháng trước cách đây | |
| table_recognition_v2_single_process.py | 1 tháng trước cách đây | |
| test_api_call.py | 1 tháng trước cách đây | |
| test_evaluator.py | 3 tháng trước cách đây | |
| test_general_ocr.py | 1 tháng trước cách đây | |
| test_paddleocr_vl_genai-client.py | 1 tháng trước cách đây | |
| test_ppstructure_v3.py | 3 tháng trước cách đây | |
| test_ppstructure_v3_client.py | 1 tháng trước cách đây | |
| test_single_model.py | 1 tháng trước cách đây | |
| test_table_recognition_v2.py | 1 tháng trước cách đây | |
| test_whister.py | 4 tháng trước cách đây | |
| 智能表格识别模式选择.md | 3 tháng trước cách đây | |
| 表格识别后处理-get_table_recognition_res.md | 1 tháng trước cách đây | |
git clone https://gitee.com/zhch158_admin/PaddleX.git
git config --local user.name "zhch158_admin"
git config --local user.email "zhch158@sina.com"
# 自定义缓存时间(如7200秒)
git config --global credential.helper 'cache --timeout=7200'
cd PaddleX
# 安装python环境
uv venv paddle_env --python 3.11
#激活环境
source paddle_env/bin/activate
uv pip install pytest PyMuPDF
uv pip install paddlepaddle==3.2.0 -i https://www.paddlepaddle.org.cn/packages/stable/cpu/
uv pip install -e .
paddlex --install PaddleOCR PaddleDetection PaddleClas # 例如PaddleOCR
# uv pip install paddleocr==3.2.0
# 首先检查NVIDIA驱动版本
nvidia-smi
# 确保驱动版本 ≥ 570.169
# 如果需要更新驱动
sudo apt update
sudo apt install nvidia-driver-570 # 或更新版本
# 安装匹配的CUDA版本(推荐12.6以匹配您的驱动)
wget https://developer.download.nvidia.com/compute/cuda/12.6.0/local_installers/cuda_12.6.0_560.28.03_linux.run
sudo sh cuda_12.6.0_560.28.03_linux.run
# 安装PaddlePaddle GPU版本
uv pip install -U --reinstall paddlepaddle-gpu==3.2.0 -i https://www.paddlepaddle.org.cn/packages/stable/cu126/
uv pip install -e .
paddlex --install PaddleOCR PaddleDetection PaddleClas
# 验证安装
python -c "import paddle; print(f'CUDA available: {paddle.device.is_compiled_with_cuda()}'); print(f'GPU count: {paddle.device.cuda.device_count()}')"
PaddleX 支持通过环境变量 PADDLE_PDX_MODEL_SOURCE 来指定模型下载源。根据 official_models.py 中的实现,支持以下下载源:
支持的下载源 huggingface - HuggingFace(默认优先级) modelscope - ModelScope bos - 百度云存储 aistudio - AI Studio
# 使用百度云存储源
export PADDLE_PDX_MODEL_SOURCE="bos"
python ppstructurev3_single_process.py --input_file "file.pdf" --output_dir "./output"
# 使用 ModelScope 源
export PADDLE_PDX_MODEL_SOURCE="modelscope"
python ppstructurev3_single_process.py --input_file "file.pdf" --output_dir "./output"
"configurations": [
{
"name": "Python Debugger: Current File",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"cwd": "${fileDirname}",
"env": {"PYTHONPATH":"${workspaceFolder};${env:PYTHONPATH}"},
"envFile": "${workspaceFolder}/.env",
"justMyCode": false
},
{
"name": "pipline ppstructurev3",
"type": "debugpy",
"request": "launch",
"module": "paddlex.__main__",
// "program": "${workspaceFolder}/paddlex/paddlex_cli.py",
"console": "integratedTerminal",
"cwd": "${workspaceFolder}/zhch",
"env": {"PYTHONPATH":"${workspaceFolder};${env:PYTHONPATH}"},
"envFile": "${workspaceFolder}/.env",
"args": [
// "-m", "paddlex.paddlex_cli",
// "--get_pipeline_config", "${workspaceFolder}/zhch/PP-StructureV3-zhch.yaml"
"--pipeline", "PP-StructureV3",
"--use_doc_orientation_classify=True",
"--use_doc_unwarping=True",
"--input", "sample_data/300674-母公司现金流量表-扫描.png",
"--save_path", "sample_data/output",
"--device", "gpu",
],
"justMyCode": false
}
]
paddleocr ocr -i zhch/sample_data/600916_中国黄金_2002年报_83_94_2.png --save_path zhch/sample_data/output --enable_mkldnn=False --device=cpu
# 版面分析
paddleocr layout_detection -i zhch/sample_data/600916_中国黄金_2002年报_83_94_2.png --save_path zhch/sample_data/output --model_name="PP-DocLayout_plus-L" --enable_mkldnn=False --device=cpu
# 表格解析
paddleocr table_recognition_v2 -i zhch/sample_data/600916_中国黄金_2002年报_83_94_2.png --save_path zhch/sample_data/output --device=cpu --enable_mkldnn=False
paddleocr pp_structurev3 \
-i zhch/sample_data/600916_中国黄金_2002年报_83_94_2.png --save_path zhch/sample_data/output \
--enable_mkldnn=False --device=cpu
paddlex --pipeline table_recognition_v2 --use_doc_orientation_classify=False --use_doc_unwarping=False --input zhch/sample_data/600916_中国黄金_2002年报_83_94_2.png --save_path zhch/sample_data/output --device cpu
paddlex --pipeline table_recognition_v2 --use_doc_orientation_classify=True --use_doc_unwarping=True --input zhch/sample_data/600916_中国黄金_2002年报_83_94_2.png --save_path zhch/sample_data/output --device cpu
# 输入是PDF
paddlex --pipeline table_recognition_v2 --use_doc_orientation_classify=True --use_doc_unwarping=True --input zhch/sample_data/至远彩色印刷工业有限公司-2022年母公司.pdf --save_path zhch/sample_data/output --device cpu
# 使用 system_profiler 命令查看 GPU 信息
system_profiler SPDisplaysDataType
zhch/my_config/PP-StructureV3.yaml中需要所有OCR的参数设定limit_type,limit_side_len
SubModules:
TextDetection:
module_name: text_detection
model_name: PP-OCRv5_server_det
model_dir: null
limit_side_len: 2560
limit_type: max
max_side_limit: 4000
配置文件中印章识别是关闭的:
PP-StructureV3.yaml 中,use_seal_recognition: False命令行参数冲突:
--use_seal_recognition True 参数试图启用印章识别模型检查失败:
_LayoutParsingPipelineV2.check_model_settings_valid 方法中检测到模型未初始化如果您主要需要印章识别功能,可以使用专门的印章识别管道:
paddlex --pipeline seal_recognition \
--input sample_data/300674-母公司现金流量表-扫描.png \
--device gpu:0 \
--use_doc_orientation_classify False \
--use_doc_unwarping False
获取 PP-StructureV3 配置文件:
paddlex --get_pipeline_config PP-StructureV3 --save_path ./my_config
修改配置文件:
# 在 my_config/PP-StructureV3.yaml 中修改:
use_seal_recognition: True # 改为 True
使用修改后的配置文件:
paddlex --pipeline ./my_config/PP-StructureV3.yaml \
--input sample_data/300674-母公司现金流量表-扫描.png \
--device gpu:0
虽然您在目录中看到了 PP-OCRv4_server_seal_det 模型文件,但问题不在于模型文件是否存在,而在于:
use_seal_recognition: False,管道没有初始化印章识别相关的子管道use_seal_recognition=True 时,系统检查发现相关模型未初始化,因此报错这是 PaddleX 的设计机制,确保只有在配置文件中明确启用的功能才会被初始化和使用。
- 只能单进程,
cd ~/zhch/PaddleX/zhch
conda activate paddle
# export PADDLE_PDX_MODEL_SOURCE="modelscope"
export PADDLE_PDX_MODEL_SOURCE="bos"
python ppstructurev3_single_process.py
python ppstructurev3_single_process.py --input_file "/home/ubuntu/zhch/data/至远彩色印刷工业有限公司/2023年度报告母公司.pdf" --output_dir "./data_PPStructureV3_Results" --pipeline "./my_config/PP-StructureV3.yaml" --device "gpu:0"
# macOS
python ppstructurev3_single_process.py --input_file "/Users/zhch158/workspace/data/至远彩色印刷工业有限公司/2023年度报告母公司.pdf" --output_dir "/Users/zhch158/workspace/data/至远彩色印刷工业有限公司/data_PPStructureV3_Results" --pipeline "./my_config/PP-StructureV3.yaml" --device "cpu"
# 安装服务
paddlex --install serving
# macOS
paddlex --serve --pipeline zhch/PP-StructureV3-zhch.yaml
# linux 10.192.72.11
# 启动ppstructure_v3增强自定义adapter服务
zhch/ppstructure_v3_daemon.sh start
# client
python ppstructurev3_single_client.py --input_file "/Users/zhch158/workspace/data/至远彩色印刷工业有限公司/2023年度报告母公司.pdf" --output_dir "/Users/zhch158/workspace/data/至远彩色印刷工业有限公司/data_PPStructureV3_Results" --api_url "http://10.192.72.11:8111/layout-parsing" --timeout 300
# client 流水分析
python ppstructurev3_single_client.py --input_file "/Users/zhch158/workspace/data/流水分析/A用户_单元格扫描流水.pdf" --output_dir "/Users/zhch158/workspace/data/流水分析/A用户_单元格扫描流水/data_PPStructureV3_Results" --api_url "http://10.192.72.11:8111/layout-parsing" --timeout 300
python ppstructurev3_single_client.py --input_file "/Users/zhch158/workspace/data/流水分析/A用户_单元格图片合成.pdf" --output_dir "/Users/zhch158/workspace/data/流水分析/A用户_单元格图片合成/data_PPStructureV3_Results" --api_url "http://10.192.72.11:8111/layout-parsing" --timeout 300
python ppstructurev3_single_client.py --input_file "/Users/zhch158/workspace/data/流水分析/B用户_扫描流水.pdf" --output_dir "/Users/zhch158/workspace/data/流水分析/B用户_扫描流水/data_PPStructureV3_Results" --api_url "http://10.192.72.11:8111/layout-parsing" --timeout 300
python ppstructurev3_single_client.py --input_file "/Users/zhch158/workspace/data/流水分析/B用户_图片合成流水.pdf" --output_dir "/Users/zhch158/workspace/data/流水分析/B用户_图片合成流水/data_PPStructureV3_Results" --api_url "http://10.192.72.11:8111/layout-parsing" --timeout 300
python ppstructurev3_single_client.py --input_file "/Users/zhch158/workspace/data/流水分析/对公_招商银行图.pdf" --output_dir "/Users/zhch158/workspace/data/流水分析/对公_招商银行图/data_PPStructureV3_Results" --api_url "http://10.192.72.11:8111/layout-parsing" --timeout 300
python ppstructurev3_single_client.py --input_file "//Users/zhch158/workspace/data/流水分析/德_内蒙古银行照.pdf" --output_dir "/Users/zhch158/workspace/data/流水分析/德_内蒙古银行照/data_PPStructureV3_Results" --api_url "http://10.192.72.11:8111/layout-parsing" --timeout 300