[Python] PaddleOCR PP-StructureV3 - give ValueError when running inference multiple times with...

Discussão em 'Python' iniciado por Stack, Junho 17, 2025.

  1. Stack

    Stack Membro Participativo

    I'm using PaddleOCR's PPStructureV3 to parse documents like invoices and receipts. I'm running inference multiple times with different images without reinitializing the pipeline. Here's a simplified version of my code:

    from paddleocr import PPStructureV3

    pipeline = PPStructureV3(
    use_doc_orientation_classify=False,
    use_doc_unwarping=False
    )

    # First inference — works fine
    output = pipeline.predict(input="image1.png")
    for res in output:
    res.save_to_markdown(save_path="output/coba4")

    ---

    # Second inference — returns empty markdown output
    output = pipeline.predict(input="image2.png")
    for res in output:
    res.save_to_markdown(save_path="output")

    ---

    # Third inference — throws ValueError
    output = pipeline.predict(input="image3.png")
    for res in output:
    res.save_to_markdown(save_path="output")



    here's how my second ouput looks like:

    <div style="text-align: center;"><html><body><table border="1"><tbody><tr><td colspan="5"></td></tr><tr><td colspan="4"></td><td></td></tr><tr><td colspan="4"></td><td></td></tr><tr><td colspan="5"></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td colspan="2"></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td colspan="4"></td><td></td></tr><tr><td colspan="4"></td><td></td></tr><tr><td colspan="4"></td><td></td></tr><tr><td colspan="4"></td><td></td></tr></tbody></table></body></html></div>


    and this my third inference error message:

    ValueError: all the input array dimensions except for the concatenation axis must match exactly, but along dimension 1, the array at index 0 has size 0 and the array at index 1 has size 4

    What I've tried:

    1. Each image I used has a different size (dimensions vary).
    2. I ran the code on Google Colab (CPU-only).
    3. Each image contains one table with multiple items, and each image has a different number of items.
    My Questions:

    1. Does the input image size cause this issue?
    2. What is the correct way to reuse the pipeline without re-downloading or reloading the model every time?
    3. Is there a clean way to reset the internal state before each prediction?
    4. Is this a bug in PPStructureV3, or am I using it incorrectly?

    Continue reading...

Compartilhe esta Página