A practical guide to table detection — finding where tables are in documents and images.
Whether you're building a document processing pipeline, extracting data from PDFs, or working with photos of tables, this repo helps you understand the landscape and pick the right tools.
Table detection answers one question: "Where are the tables on this page?"
| Input | Output |
|---|---|
| A document page (PDF, scan, photo) | Bounding boxes or polygons around each table |
That's it. Table detection finds the regions — it doesn't extract the data inside (that's table structure recognition + OCR, which comes after).
Tables are everywhere: invoices, reports, scientific papers, forms, receipts. Before you can extract data from a table, you need to know where it is. Good detection is the foundation of any table extraction pipeline.
| Document tables | Tables in the wild |
|---|---|
| PDFs, scans, reports, papers | Photos, screenshots, whiteboards |
| Usually axis-aligned | Often rotated, curved, perspective-distorted |
| Consistent layouts | Varied lighting, occlusions, noise |
| Easier to detect | Harder to detect |
flowchart TD
A[What's your input?] --> B{PDF with<br>selectable text?}
B -->|Yes| C[Try heuristic tools first]
C --> C1[Tabula / Camelot]
C1 --> C2{Works well?}
C2 -->|Yes| DONE[Done!]
C2 -->|No| D
B -->|No| D{Scans or<br>document images?}
D -->|Yes| E{Want to train<br>your own?}
E -->|No| E1[Use pretrained models]
E1 --> E1a[Table Transformer]
E1 --> E1b[Docling]
E1 --> E1c[Surya]
E -->|Yes| E2[Train custom detector]
E2 --> E2a[YOLO + DocLayNet/PubTables]
E2 --> E2b[Detectron2 / MMDetection]
E2 --> E2c[Fine-tune TATR]
D -->|No| F{Photos or<br>screenshots?}
F -->|Yes| G[Use wild-trained models]
G --> G1[Fine-tune on TabRecSet/WTW]
G --> G2[Consider polygon detectors]
A --> H{No labeled<br>data?}
H -->|Yes| I[Bootstrap with VLMs]
I --> I1[Grounding DINO]
I --> I2[Florence-2 Table Detection]
I --> I3[Then train a dedicated detector]
| Your situation | Recommended approach | Tools |
|---|---|---|
| Clean PDFs (selectable text) | Heuristic extraction | Tabula, Camelot |
| Scans / images (use pretrained) | Ready-to-use models | Table Transformer, Docling, Surya |
| Scans / images (train your own) | Custom training | YOLO, Detectron2, MMDetection |
| Photos / wild tables | Domain-specific models | Train on TabRecSet or WTW |
| No labeled data | VLM bootstrapping | Grounding DINO, Florence-2 |
For detailed guidance, see Choosing a solution
| Dataset | Size | Best for | Link |
|---|---|---|---|
| PubTables-1M | 575k pages | Scientific PDFs | HuggingFace |
| DocLayNet | 80k pages | Business documents | GitHub |
| PubLayNet | 360k pages | Layout detection | GitHub |
| TableBank | 417k tables | Pretraining | GitHub |
| Dataset | Size | Best for | Link |
|---|---|---|---|
| TabRecSet | 32k images | Real-world scans | GitHub |
| WTW | 14k images | Distortions, occlusions | GitHub |
| Dataset | Size | Best for | Link |
|---|---|---|---|
| STDW | 7k images | Diverse document layouts | GitHub |
Full dataset catalog: Datasets documentation
| Model | Type | Speed | Best for | Link |
|---|---|---|---|---|
| Table Transformer (TATR) | DETR | Medium | Document tables | HuggingFace |
| YOLO fine-tunes | One-stage | Fast | Production, high volume | Ultralytics |
| CascadeTabNet | Mask R-CNN | Slower | High accuracy | GitHub |
| Grounding DINO | Open-vocab | Medium | Zero-shot, weak labeling | GitHub |
Full model guide: Model families
If you want a complete solution (not just detection):
| Tool | What it does | Link |
|---|---|---|
| Docling | PDF → structured data (tables, text, figures) | GitHub |
| Unstructured | Document ETL for LLMs | GitHub |
| Marker | PDF → Markdown | GitHub |
| deepdoctection | Configurable DocAI pipelines | GitHub |
docs/ # Start here — narrative guides
├── 00-scope-and-definitions.md # What is table detection?
├── 01-history-timeline.md # How we got here
├── 02-problem-decomposition.md # Breaking down the problem
├── 03-datasets.md # All the datasets
├── 04-model-families.md # Types of detectors
├── 05-evaluation-and-benchmarks.md # How to measure success
├── 06-open-source-solutions.md # Free tools
├── 07-commercial-solutions.md # Cloud APIs
├── 08-vlms-and-weak-labeling.md # Using VLMs for detection
└── 09-choosing-a-solution.md # Decision guide
model-zoo/ # Curated model cards
├── document-layout-detectors.md
├── table-only-detectors.md
├── vlm-grounded-detectors.md
└── yolo-recipes.md
datasets/ # Dataset quick-reference
├── documents.md # PDF/scan datasets
└── in-the-wild.md # Photo/camera datasets
evaluation/ # Metrics and protocols
├── metrics.md # AP, IoU, F1 explained
└── protocols.md # Standardized evaluation
resources/ # Links and references
├── papers-and-surveys.md # Key papers
├── github-and-hf-links.md # Quick links
└── communities.md # Where to get help
| If you want to... | Go to... |
|---|---|
| Understand the basics | Scope and definitions |
| Pick a solution quickly | Choosing a solution |
| Find a dataset | Datasets |
| Compare models | Model families |
| Evaluate fairly | Evaluation |
| Use VLMs for labeling | VLMs and weak labeling |
| Find papers | Papers and surveys |
| Get quick links | GitHub and HF links |
- Table detection ≠ table extraction — detection finds regions, extraction gets the data
- Domain matters more than architecture — a model trained on your document type beats a "better" model trained on different data
- Start simple — heuristic tools work great on clean PDFs; don't over-engineer
- Preprocessing is critical — PDF rasterization DPI, resize policy, and augmentations often matter more than model choice
- VLMs are enablers, not replacements — use them to bootstrap labels, not as your production detector
Found a missing dataset? Know a better model? See CONTRIBUTING.md.
See LICENSE.
