• myhloli's avatar
    refactor(pdf_parse_union): integrate LayoutLMv3 for block orderingReplace the... · 1efebe42
    myhloli authored
    refactor(pdf_parse_union): integrate LayoutLMv3 for block orderingReplace the heuristic-based block ordering algorithm with LayoutLMv3 model predictions toimprove the accuracy of block ordering on PDF pages. Additionally, refactor the span
    handling during block filling to ensure spans are correctly assigned.
    
    - Introduce LayoutLMv3ForTokenClassification from 'hantian/layoutreader' to predict block
      order.
    - Implement span replacement strategy to use pymu spans for non-OCR content.
    - Enhance cleanup process to free GPU memory more effectively after model use.
    - Adjust block ordering logic to use median line index for text, title, and interline equation blocks.
    - Refactor page parsing core logic for better maintainability.
    
    BREAKING CHANGE: The integration of LayoutLMv3 changes the internal block handling and
    ordering mechanism, which may affect downstream systems relying on the previous
    implementation. Ensure to test thoroughly before deployment.
    1efebe42
pdf_parse_union_core_v2.py 12.3 KB