Skip to content

[models] Assemble table grids from cells and page words, add TablePredictor.predict_regions and new TableCenterNet checkpoint - #2222

Merged
felixdittrich92 merged 8 commits into
mindee:mainfrom
felixdittrich92:table-imp
Nov 11, 2026
Merged

felixdittrich92 merged 8 commits into
mindee:mainfrom
felixdittrich92:table-imp

Conversation

@felixdittrich92

@felixdittrich92 felixdittrich92 commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Tables are now assembled from the predicted cells and the words of the page, so the grid follows the text: missed cells, header rows and totals outside the predicted cells are added, rows the model split are merged, and rows it merged are split along their text lines.

Changes

Table assembly

  • New doctr/models/table_structure/grid.py:
    • fill_table_grid: assigns every word of a table to a cell, completes the grid with the words lying in no cell, merges split rows / columns, removes the ones without text and splits merged rows along their text lines
    • assemble_page_table: applies it to a table given in page coordinates (straight or rotated)
  • New TablePredictor.predict_regions(pages, regions, word_boxes, class_name): crops the table regions of a layout prediction, drops the cells centered in the context margin, indexes rows / columns from the cell edges and returns the tables in page coordinates, each cell listing its word indices in reading order. It replaces OCRPredictor._tables_from_regions.
  • DocumentBuilder._build_tables delegates to assemble_page_table; the word-assignment helpers of the builder are removed.

TableCenterNet

  • New checkpoint tablecenternet-b0d6f603.pt
  • _vote_line_indices is replaced by _index_lines: grid lines are indexed from the geometry only; the model logic gives the axis direction and the absolute offset
  • The post-processor only removes duplicate cells when geometric_logic=True; the geometric re-indexing moved to TablePredictor.predict_regions

Reading order

  • A title and its authors above two columns no longer count as crossing the gutter
  • The columns after the gutter are read after the ones before it, even when they start higher

Docs & tests

  • Benchmark updated; predict_regions added to the API reference and the user guide
  • New tests for the grid assembly, predict_regions, _index_lines and the two reading-order cases

Behaviour changes

  • TableCell.objectness_score is None for a cell made from words; Table.confidence is the mean over the scored cells
  • A table can hold more cells than the model predicted, and rows / columns without text are removed when the page has words
  • The standalone TablePredictor returns the logical coordinates of the model (no geometric re-indexing)
  • Removed private API: OCRPredictor._tables_from_regions and the DocumentBuilder table helpers (_assign_cell_words, _table_grids, _localize_logic, ...); _build_tables takes a page_shape

@codecov

codecov Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.56691% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 98.16%. Comparing base (ca06a62) to head (3ecdb04).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
doctr/models/table_structure/grid.py 97.88% 6 Missing ⚠️
doctr/models/table_structure/predictor/pytorch.py 94.82% 3 Missing ⚠️
...octr/models/table_structure/tablecenternet/base.py 94.44% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2222      +/-   ##
==========================================
+ Coverage   97.86%   98.16%   +0.29%     
==========================================
  Files         171      172       +1     
  Lines       11774    11974     +200     
==========================================
+ Hits        11523    11754     +231     
+ Misses        251      220      -31     
Flag Coverage Δ
unittests 98.16% <97.56%> (+0.29%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@felixdittrich92 felixdittrich92 changed the title DRAFT [models] Assemble table grids from cells and page words, add TablePredictor.predict_regions and new TableCenterNet checkpoint Nov 11, 2026
@felixdittrich92 felixdittrich92 self-assigned this Nov 11, 2026
@felixdittrich92 felixdittrich92 added this to the 1.2.0 milestone Nov 11, 2026
@felixdittrich92 felixdittrich92 added topic: documentation Improvements or additions to documentation type: enhancement Improvement module: models Related to doctr.models ext: tests Related to tests folder benchmark This issue reports a benchmark topic: table comprehension Related to table comprehension ext: docs Related to docs folder topic: reading order Related to the task of reading order labels Nov 11, 2026
@felixdittrich92
felixdittrich92 marked this pull request as ready for review November 11, 2026 11:56
@felixdittrich92
felixdittrich92 merged commit f16cda9 into mindee:main Nov 11, 2026
55 of 57 checks passed
@felixdittrich92
felixdittrich92 deleted the table-imp branch November 11, 2026 12:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

benchmark This issue reports a benchmark ext: docs Related to docs folder ext: tests Related to tests folder module: models Related to doctr.models topic: documentation Improvements or additions to documentation topic: reading order Related to the task of reading order topic: table comprehension Related to table comprehension type: enhancement Improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant