feat: Layout-driven OCR pipeline with configurable OCR modes and refactoring of the OCR GT dir structures#3710
Open
nikos-livathinos wants to merge 60 commits into
Open
feat: Layout-driven OCR pipeline with configurable OCR modes and refactoring of the OCR GT dir structures#3710nikos-livathinos wants to merge 60 commits into
nikos-livathinos wants to merge 60 commits into
Conversation
Signed-off-by: Nikos Livathinos <nli@zurich.ibm.com>
…re into the BaseOcrModel Signed-off-by: Nikos Livathinos <nli@zurich.ibm.com>
Contributor
|
✅ DCO Check Passed Thanks @nikos-livathinos, all your commits are properly signed off. 🎉 |
Contributor
Merge Protections🔴 1 of 2 protections blocking · waiting on 👀 reviews
🔴 Require two reviewer for test updatesWaiting for
This rule is failing.When test data is updated, we require two reviewers
Show 1 satisfied protection🟢 Enforce conventional commitMake sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
|
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
… separate model LayoutPostProcessingModel that runs as a separate pipeline stage Signed-off-by: Nikos Livathinos <nli@zurich.ibm.com>
…ore the OCR and the layout post-processing after the OCR Signed-off-by: Nikos Livathinos <nli@zurich.ibm.com>
Signed-off-by: Nikos Livathinos <nli@zurich.ibm.com>
Signed-off-by: Nikos Livathinos <nli@zurich.ibm.com>
57ab040 to
092ef5a
Compare
Signed-off-by: Nikos Livathinos <nli@zurich.ibm.com>
Signed-off-by: Nikos Livathinos <nli@zurich.ibm.com>
…map cells in green Signed-off-by: Nikos Livathinos <nli@zurich.ibm.com>
…f cells Signed-off-by: Nikos Livathinos <nli@zurich.ibm.com>
…df cells for generating OCR input Signed-off-by: Nikos Livathinos <nli@zurich.ibm.com>
Signed-off-by: Nikos Livathinos <nli@zurich.ibm.com>
Signed-off-by: Nikos Livathinos <nli@zurich.ibm.com>
…n for each OCR mode Signed-off-by: Nikos Livathinos <nli@zurich.ibm.com>
Signed-off-by: Nikos Livathinos <nli@zurich.ibm.com>
- PDF_BITMAPS_ONLY: Only bitmaps embedded inside a programmatic PDF
- LAYOUT_DETECTIONS: Layout detections which can bear text
- LAYOUT_DETECTIONS_WITHOUT_PDF_TEXT: Layout detections, without the ones that overlap with
text-bearing pdf cells
Signed-off-by: Nikos Livathinos <nli@zurich.ibm.com>
Signed-off-by: Nikos Livathinos <nli@zurich.ibm.com>
…t clusters Signed-off-by: Nikos Livathinos <nli@zurich.ibm.com>
Signed-off-by: Nikos Livathinos <nli@zurich.ibm.com>
…de the CODE and FORMULA labels Make the FILTER_OUT_OVERLAPPING_CLUSTERS a constant in the class rather than an option Signed-off-by: Nikos Livathinos <nli@zurich.ibm.com>
…eter and replace it with the `OcrOptions.mode == OcrMode.FORCE_FULL_PAGE` Signed-off-by: Nikos Livathinos <nli@zurich.ibm.com>
Signed-off-by: Nikos Livathinos <nli@zurich.ibm.com>
…S_ONLY Signed-off-by: Nikos Livathinos <nli@zurich.ibm.com>
c897627 to
a515f28
Compare
Signed-off-by: Nikos Livathinos <nli@zurich.ibm.com>
…undtruth_paths.py and test_e2e_nemotron_ocr_conversion.py Signed-off-by: Nikos Livathinos <nli@zurich.ibm.com>
….py and the actual tests to use it Signed-off-by: Nikos Livathinos <nli@zurich.ibm.com>
Signed-off-by: Nikos Livathinos <nli@zurich.ibm.com>
Signed-off-by: Nikos Livathinos <nli@zurich.ibm.com>
Signed-off-by: Nikos Livathinos <nli@zurich.ibm.com>
…R mode Signed-off-by: Nikos Livathinos <nli@zurich.ibm.com>
Signed-off-by: Nikos Livathinos <nli@zurich.ibm.com>
Signed-off-by: Nikos Livathinos <nli@zurich.ibm.com>
Signed-off-by: Nikos Livathinos <nli@zurich.ibm.com>
Signed-off-by: Nikos Livathinos <nli@zurich.ibm.com>
Signed-off-by: Nikos Livathinos <nli@zurich.ibm.com>
…ly not exposed in API. WIP Signed-off-by: Nikos Livathinos <nli@zurich.ibm.com>
6f6a059 to
cae07ea
Compare
…. Rename code elements. Signed-off-by: Nikos Livathinos <nli@zurich.ibm.com>
Signed-off-by: Nikos Livathinos <nli@zurich.ibm.com>
Signed-off-by: Nikos Livathinos <nli@zurich.ibm.com>
Signed-off-by: Nikos Livathinos <nli@zurich.ibm.com>
…EGIONS OcrMode Signed-off-by: Nikos Livathinos <nli@zurich.ibm.com>
…g in test_cli.py Signed-off-by: Nikos Livathinos <nli@zurich.ibm.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reorders the standard PDF pipeline to be layout-driven and introduces a configurable
OcrModethat controls which document regions are fed to the OCR engine. Layout prediction now runs before OCR, so OCR can be targeted at the clusters that actually need it, and layout post-processing is split out into its own pipeline stage.StandardPdfPipelineto run:Preprocess -> Layout -> OCR -> Layout post-processing -> Table -> Assembly.OcrModewith the options:FULL_PAGE: Run OCR on the full page. No layout clusters or PDF cells are taken into account.LAYOUT_REGIONS: All detected bounding boxes from the layout model are fed as input to the OCR. No PDF cells are taken into account.PDF_AWARE_LAYOUT_REGIONS: Start with all layout detections and eliminate the ones that overlap with PDF cells that contain exclusively text. If there is any non-text overlapping PDF cell, the layout bbox is not eliminated. Non-overlapping layout bboxes are kept. All non eliminated bboxes are fed as input to the OCR.DEFAULT: Placeholder value. Currently hard-wired toPDF_AWARE_LAYOUT_REGIONS.BaseOcrModel.post_process_cells()to introduce the optional parameterprioritythat controls how the detected OCR cells and the pre-existing PDF cells are merged into the final page cells:PDF_FIRST: PDF_FIRST: The OCR cells are used only if they do not overlap with any PDF cell.OCR_FIRST: The opposite. The PDF cells are used only if they do not overlap with any OCR cell.None), it is auto-selected from theOcrMode:OCR_FIRSTforLAYOUT_REGIONS, andPDF_FIRSTforPDF_AWARE_LAYOUT_REGIONS.priorityparameter is NOT exposed to theOcrOptions.OcrOptions.bitmap_area_thresholdOcrOptions.force_full_page_ocrparameter. Now it is superseded byOcrMode.FULL_PAGEOcrModeto the CLI via the--ocr-modeparameter:--force-ocris still supported but deprecated.--ocr-modeand--force-ocrare set,--force-ocrwins.Additionally the OCR ground-truth files were reorganized from a flat, loosely-tagged layout into a structured per-engine / per-mode hierarchy:
tests/data/scanned/astests/data/ocr/.groundtruth/<engine>/<mode>/and are named<doc>.<engine>.<mode>.<suffix>(e.g.ocr_test.tesseract.full_page.json), for each of the four artifacts:.json, .md, .doctags.txt, .pages.meta.json.Update documentation.
Checklist: