Skip to content

The official example of PPStructureV3 cannot be run successfully #16687

Description

@yongtenglei

🔎 Search before asking

  • I have searched the PaddleOCR Docs and found no similar bug report.
  • I have searched the PaddleOCR Issues and found no similar bug report.
  • I have searched the PaddleOCR Discussions and found no similar bug report.

🐛 Bug (问题描述)

官方案例多页PDF跑不通。

🏃‍♂️ Environment (运行环境)

python --version
Python 3.10.16

uv pip list | grep paddle
paddleocr                                3.3.0
paddlepaddle                             3.2.0
paddlex                                  3.3.3

OS:
cat /etc/*release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=24.04
DISTRIB_CODENAME=noble
DISTRIB_DESCRIPTION="Ubuntu 24.04.1 LTS"
PRETTY_NAME="Ubuntu 24.04.1 LTS"
NAME="Ubuntu"
VERSION_ID="24.04"
VERSION="24.04.1 LTS (Noble Numbat)"
VERSION_CODENAME=noble
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=noble
LOGO=ubuntu-logo

🌰 Minimal Reproducible Example (最小可复现问题的Demo)

from pathlib import Path
from paddleocr import PPStructureV3

input_file = "./your_pdf_file.pdf"
output_path = Path("./output")

pipeline = PPStructureV3()
output = pipeline.predict(input=input_file)

markdown_list = []
markdown_images = []

for res in output:
    md_info = res.markdown
    markdown_list.append(md_info)
    markdown_images.append(md_info.get("markdown_images", {}))

markdown_texts = pipeline.concatenate_markdown_pages(markdown_list)

mkd_file_path = output_path / f"{Path(input_file).stem}.md"
mkd_file_path.parent.mkdir(parents=True, exist_ok=True)

with open(mkd_file_path, "w", encoding="utf-8") as f:
    f.write(markdown_texts)

for item in markdown_images:
    if item:
        for path, image in item.items():
            file_path = output_path / path
            file_path.parent.mkdir(parents=True, exist_ok=True)
            image.save(file_path)

ERROR:

Creating model: ('PP-LCNet_x1_0_doc_ori', None)
Model files already exist. Using cached files. To redownload, please delete the directory manually: `/home/xxx/.paddlex/official_models/PP-LCNet_x1_0_doc_ori`.
Creating model: ('UVDoc', None)
Model files already exist. Using cached files. To redownload, please delete the directory manually: `/home/xxx/.paddlex/official_models/UVDoc`.
Creating model: ('PP-DocBlockLayout', None)
Model files already exist. Using cached files. To redownload, please delete the directory manually: `/home/xxx/.paddlex/official_models/PP-DocBlockLayout`.
Creating model: ('PP-DocLayout_plus-L', None)
Model files already exist. Using cached files. To redownload, please delete the directory manually: `/home/xxx/.paddlex/official_models/PP-DocLayout_plus-L`.
Creating model: ('PP-LCNet_x1_0_textline_ori', None)
Model files already exist. Using cached files. To redownload, please delete the directory manually: `/home/xxx/.paddlex/official_models/PP-LCNet_x1_0_textline_ori`.
Creating model: ('PP-OCRv5_server_det', None)
Model files already exist. Using cached files. To redownload, please delete the directory manually: `/home/xxx/.paddlex/official_models/PP-OCRv5_server_det`.
Traceback (most recent call last):
  File "/home/xxx/workspace/myproject/test.py", line 8, in <module>
    pipeline = PPStructureV3()
  File "/home/xxx/workspace/myproject/.venv/lib/python3.10/site-packages/paddleocr/_pipelines/pp_structurev3.py", line 137, in __init__
    super().__init__(**kwargs)
  File "/home/xxx/workspace/myproject/.venv/lib/python3.10/site-packages/paddleocr/_pipelines/base.py", line 67, in __init__
    self.paddlex_pipeline = self._create_paddlex_pipeline()
  File "/home/xxx/workspace/myproject/.venv/lib/python3.10/site-packages/paddleocr/_pipelines/base.py", line 105, in _create_paddlex_pipeline
    return create_pipeline(config=self._merged_paddlex_config, **kwargs)
  File "/home/xxx/workspace/myproject/.venv/lib/python3.10/site-packages/paddlex/inference/pipelines/__init__.py", line 167, in create_pipeline
    pipeline = BasePipeline.get(pipeline_name)(
  File "/home/xxx/workspace/myproject/.venv/lib/python3.10/site-packages/paddlex/utils/deps.py", line 206, in _wrapper
    return old_init_func(self, *args, **kwargs)
  File "/home/xxx/workspace/myproject/.venv/lib/python3.10/site-packages/paddlex/inference/pipelines/_parallel.py", line 103, in __init__
    self._pipeline = self._create_internal_pipeline(config, self.device)
  File "/home/xxx/workspace/myproject/.venv/lib/python3.10/site-packages/paddlex/inference/pipelines/_parallel.py", line 158, in _create_internal_pipeline
    return self._pipeline_cls(
  File "/home/xxx/workspace/myproject/.venv/lib/python3.10/site-packages/paddlex/inference/pipelines/layout_parsing/pipeline_v2.py", line 84, in __init__
    self.inintial_predictor(config)
  File "/home/xxx/workspace/myproject/.venv/lib/python3.10/site-packages/paddlex/inference/pipelines/layout_parsing/pipeline_v2.py", line 173, in inintial_predictor
    self.general_ocr_pipeline = self.create_pipeline(
  File "/home/xxx/workspace/myproject/.venv/lib/python3.10/site-packages/paddlex/inference/pipelines/base.py", line 140, in create_pipeline
    pipeline = create_pipeline(
  File "/home/xxx/workspace/myproject/.venv/lib/python3.10/site-packages/paddlex/inference/pipelines/__init__.py", line 167, in create_pipeline
    pipeline = BasePipeline.get(pipeline_name)(
  File "/home/xxx/workspace/myproject/.venv/lib/python3.10/site-packages/paddlex/utils/deps.py", line 206, in _wrapper
    return old_init_func(self, *args, **kwargs)
  File "/home/xxx/workspace/myproject/.venv/lib/python3.10/site-packages/paddlex/inference/pipelines/_parallel.py", line 103, in __init__
    self._pipeline = self._create_internal_pipeline(config, self.device)
  File "/home/xxx/workspace/myproject/.venv/lib/python3.10/site-packages/paddlex/inference/pipelines/_parallel.py", line 158, in _create_internal_pipeline
    return self._pipeline_cls(
  File "/home/xxx/workspace/myproject/.venv/lib/python3.10/site-packages/paddlex/inference/pipelines/ocr/pipeline.py", line 117, in __init__
    self.text_det_model = self.create_model(
  File "/home/xxx/workspace/myproject/.venv/lib/python3.10/site-packages/paddlex/inference/pipelines/base.py", line 106, in create_model
    model = create_predictor(
  File "/home/xxx/workspace/myproject/.venv/lib/python3.10/site-packages/paddlex/inference/models/__init__.py", line 87, in create_predictor
    return BasePredictor.get(model_name)(
  File "/home/xxx/workspace/myproject/.venv/lib/python3.10/site-packages/paddlex/inference/models/text_detection/predictor.py", line 57, in __init__
    self.pre_tfs, self.infer, self.post_op = self._build()
  File "/home/xxx/workspace/myproject/.venv/lib/python3.10/site-packages/paddlex/inference/models/text_detection/predictor.py", line 77, in _build
    infer = self.create_static_infer()
  File "/home/xxx/workspace/myproject/.venv/lib/python3.10/site-packages/paddlex/inference/models/base/predictor/base_predictor.py", line 302, in create_static_infer
    self.model_name, self.model_dir, self.MODEL_FILE_PREFIX, self._pp_option
AttributeError: 'TextDetPredictor' object has no attribute '_pp_option'. Did you mean: 'pp_option'?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions