GridFormer: Towards Accurate Table Structure Recognition via Grid Prediction

Pengyuan Lyu, Weihong Ma, Hongyi Wang, Yuechen Yu, Chengquan Zhang, Kun Yao, Yang Xue, Jingdong Wang

Abstract

GridFormer is a novel, end-to-end table structure recognition (TSR) framework that models tables as flexible $M \times N$ grids. By utilizing a DETR-style transformer with a unique "two-stream" decoder to predict grid vertexes and edges, it achieves state-of-the-art accuracy across diverse scenarios, including wireless, rotated, and geometrically distorted tables.

Introduction

Table Structure Recognition (TSR) is the essential task of converting table images into machine-readable formats like HTML or structured grids. Despite its importance in document analysis, TSR remains a significant challenge due to three primary factors:

  1. Structural Variety: Tables range from "wired" (with explicit grid lines) to "wireless" (relying on whitespace) or hybrid formats.
  2. Geometric Distortion: Real-world captures, such as photographs of receipts or curved book pages, introduce rotation and perspective shifts.
  3. Complex Layouts: Merged cells and varying row/column counts often cause standard object detection approaches to fail.

Existing methods typically rely on complex multi-stage pipelines—such as splitting cells and then merging them—or depend heavily on OCR results. These approaches are prone to error propagation if the initial text recognition or cell detection fails. GridFormer addresses these issues by treating the table as a single topological entity.

Methodology

The core philosophy of GridFormer is that all tables, regardless of their visual style, can be represented as a grid. The model employs a single-shot, DETR-style (Detection Transformer) architecture to predict the underlying "skeleton" of this grid.

Two-Stream Decoder

A key innovation in GridFormer is the decoupling of row and column prediction. Predicting $x$ and $y$ coordinates simultaneously for every point can be computationally noisy. GridFormer utilizes two parallel transformer decoders:

  • Row Decoder: Specializes in $y$-coordinates and downward edges.
  • Column Decoder: Specializes in $x$-coordinates and rightward edges.

This decoupling allows the model to focus on the distinct geometric properties of rows versus columns, preventing variations in one axis (like a very wide column) from interfering with the localization of the other.

Query Selection and Loss Functions

Instead of random initialization, GridFormer uses a CNN-based query selection module to identify the best initial reference points for the transformer queries. This mechanism speeds up convergence and improves final localization accuracy. The model is trained using a hybrid loss strategy, combining Focal Loss for classification with L1 and Generalized IoU (GIoU) losses to ensure the predicted grid aligns precisely with the physical table structure.

Experimental Evaluation

The authors evaluated GridFormer across a comprehensive suite of benchmarks, including:

  • Regular Tables: PDF-based datasets such as SciTSR, PubTabNet, and FinTabNet.
  • Scene Tables: "In-the-wild" datasets like WTW (Wired Table in the Wild) and TAL.
  • Stress Tests: The authors introduced TAL_rotated and TAL_curved to specifically measure performance under extreme geometric distortions.

Key Results

GridFormer demonstrated dominant performance, particularly in challenging environments:

  • Distortion Robustness: On the TAL_rotated dataset, GridFormer achieved a 92.9% F-score. In comparison, previous top-tier methods like TableMaster saw performance plummet to 27.8%.
  • SOTA Performance: It reached a 94.1% F1-score on the WTW dataset, outperforming existing graph-based and cell-based methods.
  • Efficiency: By utilizing an end-to-end, single-shot approach, GridFormer eliminates the need for error-prone post-processing steps or heuristic merging required by traditional region-based models.

Insights and Discussion

GridFormer’s success stems from its focus on vertexes and edges rather than whole-cell detection. This approach naturally handles merged cells; a merged cell is simply a region where internal grid edges are predicted as "negative." Furthermore, because the model learns the underlying grid topology, it remains highly accurate even when the input image is tilted, blurry, or lacks explicit grid lines.

Limitations and Future Work

While highly robust, GridFormer currently utilizes a fixed $M \times N$ grid size (e.g., 100x100). While this accommodates the vast majority of practical tables, extremely large tables might require different configurations. Additionally, the use of a large number of queries to handle dense tables increases computational overhead. Future research may explore integrating text-line information more deeply into the grid prediction process to further refine results on sparse, wireless tables.

Summary updated

BibTeX
@inproceedings{lyu2023gridformer,
  author = {Pengyuan Lyu and Weihong Ma and Hongyi Wang and Yuechen Yu and Chengquan Zhang and Kun Yao and Yang Xue and Jingdong Wang},
  title = {{GridFormer: Towards Accurate Table Structure Recognition via Grid Prediction}},
  booktitle = {ACM Multimedia},
  year = {2023},
  url = {https://openreview.net/forum?id=U1c1HxIlxX},
}
Figure