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:
|
device |
Device for inference - "cpu", "cuda", "mps", or "auto"
TYPE:
|
num_threads |
Number of CPU threads for inference
TYPE:
|
do_cell_matching |
Whether to match predicted cells with OCR text cells
TYPE:
|
artifacts_path |
Path to pre-downloaded model artifacts
TYPE:
|
repo_id |
HuggingFace model repository
TYPE:
|
revision |
Model revision/tag
TYPE:
|
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,
)
)