Skip to content

Config

Configuration for TableFormer table structure extractor.

TableFormer uses a dual-decoder transformer architecture with OTSL+ support for recognizing table structure from images.

Example
from omnidocs.tasks.table_extraction import TableFormerExtractor, TableFormerConfig

# Fast mode (default)
extractor = TableFormerExtractor(config=TableFormerConfig())

# Accurate mode with GPU
extractor = TableFormerExtractor(
    config=TableFormerConfig(
        mode="accurate",
        device="cuda",
        do_cell_matching=True,
    )
)

TableFormerMode

Bases: str, Enum

TableFormer inference mode.

TableFormerConfig

Bases: BaseModel

Configuration for TableFormer table structure extractor.

TableFormer is a transformer-based model that predicts table structure using OTSL (Optimal Table Structure Language) tags and cell bounding boxes.

ATTRIBUTE DESCRIPTION
mode

Inference mode - "fast" or "accurate"

TYPE: TableFormerMode

device

Device for inference - "cpu", "cuda", "mps", or "auto"

TYPE: Literal['cpu', 'cuda', 'mps', 'auto']

num_threads

Number of CPU threads for inference

TYPE: int

do_cell_matching

Whether to match predicted cells with OCR text cells

TYPE: bool

artifacts_path

Path to pre-downloaded model artifacts

TYPE: Optional[str]

repo_id

HuggingFace model repository

TYPE: str

revision

Model revision/tag

TYPE: str

Example
from omnidocs.tasks.table_extraction import TableFormerExtractor, TableFormerConfig

# Fast mode
extractor = TableFormerExtractor(config=TableFormerConfig(mode="fast"))

# Accurate mode with GPU
extractor = TableFormerExtractor(
    config=TableFormerConfig(
        mode="accurate",
        device="cuda",
        do_cell_matching=True,
    )
)