Run this model with HF Jobs
Run zeromodels/table-transformer-detection on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/zeromodels/table-transformer-detection. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/zeromodels/table-transformer-detection on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use zeromodels/table-transformer-detection with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- ZeroModels
How to use zeromodels/table-transformer-detection with ZeroModels:
# pip install -U zeromodels # ZeroModels is pure Keras 3, so pick a backend: "jax", "torch" or "tensorflow". import os os.environ["KERAS_BACKEND"] = "jax" from zeromodels import AutoZModel # AutoZModel reads the repo's model_type and loads the matching class. # For a task head use the matching loader, e.g. AutoZMImageClassify / AutoZMDetect / # AutoZMSemanticSegment / AutoZMTextGenerate (see zeromodels.auto). model = AutoZModel.from_weights("zeromodels/table-transformer-detection") - Keras
How to use zeromodels/table-transformer-detection with Keras:
# !pip install -U keras tensorflow huggingface_hub # Keras needs TensorFlow installed to read "hf://" paths, so the tensorflow backend is selected here; # "jax" and "torch" also work for computation once TensorFlow is installed. import os os.environ["KERAS_BACKEND"] = "tensorflow" import keras model = keras.saving.load_model("hf://zeromodels/table-transformer-detection") - Notebooks
- Google Colab
- Kaggle
Upload folder using huggingface_hub
Browse filesFiles changed (4)
- README.mdAdded+92
- model.weights.h5Added+3
- zm_config.jsonAdded+21
- zm_preprocessor.jsonAdded+27
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192---
pipeline_tag: object-detection
license: apache-2.0
base_model: microsoft/table-transformer-detection
library_name: zeromodels
tags:
- keras
- zeromodels
- table-transformer
- detr
- object-detection
- arxiv:2110.00061
- pytorch
- jax
- tf
---
## ***See [our collection](https://huggingface.co/collections/zeromodels/table-transformer-6a928f000a88c73a41f9411e) for all versions of Table Transformer.***
# Run Table Transformer with Keras 3: JAX, PyTorch, or TensorFlow
[](https://github.com/IMvision12/ZeroModels) [](https://imvision12.github.io/ZeroModels/table_transformer/) [](https://huggingface.co/collections/zeromodels/table-transformer-6a928f000a88c73a41f9411e)
# zeromodels/table-transformer-detection
Paper: [PubTables-1M: Towards comprehensive table extraction from unstructured documents (arXiv:2110.00061)](https://arxiv.org/abs/2110.00061) · [HF Papers](https://huggingface.co/papers/2110.00061)
Table Transformer (TATR) applies the DETR detection recipe to tables. A ResNet-18 backbone produces a feature map, a transformer encoder-decoder attends over it with a fixed set of learned object queries, and each query emits one class and one box, with no anchors and no NMS. This detection checkpoint locates tables in a page image.
For more details on the model, please go to Microsoft's original [model card](https://huggingface.co/microsoft/table-transformer-detection).
Pure-**Keras 3** conversion of [`microsoft/table-transformer-detection`](https://huggingface.co/microsoft/table-transformer-detection) for [zeromodels](https://github.com/IMvision12/ZeroModels). One implementation runs unmodified on **TensorFlow / Torch / JAX**.
This is a **table detection** checkpoint (`TableTransformerDetect`): each query predicts a table region (classes: table, table rotated).
## ✨ Quick start
```python
import os
os.environ["KERAS_BACKEND"] = "torch" # or "jax" / "tensorflow"
from PIL import Image
from zeromodels.models.table_transformer import (
TableTransformerDetect,
TableTransformerImageProcessor,
)
from zeromodels.models.table_transformer.table_transformer_image_processor import (
TABLE_DETECTION_LABELS,
)
model = TableTransformerDetect.from_weights("zeromodels/table-transformer-detection")
processor = TableTransformerImageProcessor.from_weights("zeromodels/table-transformer-detection")
image = Image.open("your_image.jpg").convert("RGB")
inputs = processor(image)
output = model(inputs["pixel_values"], training=False)
results = processor.post_process_object_detection(
output,
threshold=0.9,
target_sizes=[(image.height, image.width)],
label_names=TABLE_DETECTION_LABELS,
)[0]
for score, name, box in zip(
results["scores"], results["label_names"], results["boxes"]
):
print(f"{name}: {float(score):.3f} {box}")
```
Load any Table Transformer variant the same way with `from_weights("zeromodels/<variant>")`:
| Variant | Hub | Task |
|---|---|---|
| `table-transformer-detection` | [`zeromodels/table-transformer-detection`](https://huggingface.co/zeromodels/table-transformer-detection) | table detection |
| `table-transformer-structure-recognition` | [`zeromodels/table-transformer-structure-recognition`](https://huggingface.co/zeromodels/table-transformer-structure-recognition) | table-structure recognition |
| `table-transformer-structure-recognition-v1.1-all` | [`zeromodels/table-transformer-structure-recognition-v1.1-all`](https://huggingface.co/zeromodels/table-transformer-structure-recognition-v1.1-all) | table-structure recognition |
| `table-transformer-structure-recognition-v1.1-fin` | [`zeromodels/table-transformer-structure-recognition-v1.1-fin`](https://huggingface.co/zeromodels/table-transformer-structure-recognition-v1.1-fin) | table-structure recognition |
| `table-transformer-structure-recognition-v1.1-pub` | [`zeromodels/table-transformer-structure-recognition-v1.1-pub`](https://huggingface.co/zeromodels/table-transformer-structure-recognition-v1.1-pub) | table-structure recognition |
## Tips
- Set `KERAS_BACKEND` **before** importing Keras / zeromodels.
- Detection finds tables in a page image; structure recognition decomposes a cropped table into rows, columns, and header / spanning cells.
- Both tasks use `TableTransformerDetect` + `post_process_object_detection`; only the checkpoint and the class set differ.
- Pass `label_names=TABLE_DETECTION_LABELS` for the detection checkpoint and `label_names=TABLE_STRUCTURE_LABELS` for structure recognition (both live in `zeromodels.models.table_transformer.table_transformer_image_processor`).
- See [Table Transformer docs](https://imvision12.github.io/ZeroModels/table_transformer/) and [Loading Weights](https://imvision12.github.io/ZeroModels/loading_weights/).
- Community / upstream safetensors still work via the `hf:` prefix, e.g. `TableTransformerDetect.from_weights("hf:microsoft/table-transformer-detection")`.
## Special Thanks
A huge thank you to the Microsoft Table Transformer authors for creating and releasing these models.
License: Apache 2.0.123version https://git-lfs.github.com/spec/v1oid sha256:3c4e1090b653fe063b700927a0cb9500b35e89f040e35d1a7a7a5cc242d48a88size 116082616123456789101112131415161718192021{
"library_name": "zeromodels",
"zeromodels_version": "1.2.7",
"model_module": "zeromodels.models.table_transformer",
"model_class": "TableTransformerDetect",
"variant": "table-transformer-detection",
"weights": "model.weights.h5",
"schema_version": 2,
"model_type": "table-transformer",
"vision_config": {
"hidden_dim": 256,
"num_heads": 8,
"num_encoder_layers": 6,
"num_decoder_layers": 6,
"dim_feedforward": 2048,
"dropout_rate": 0.1,
"num_queries": 15,
"num_classes": 3,
"image_size": 800
}
}123456789101112131415161718192021222324252627{
"library_name": "zeromodels",
"zeromodels_version": "1.2.7",
"preprocessor_module": "zeromodels.models.table_transformer",
"preprocessor_class": "TableTransformerImageProcessor",
"variant": "table-transformer-detection",
"size": {
"height": 800,
"width": 800
},
"resample": "bilinear",
"do_rescale": true,
"rescale_factor": 0.00392156862745098,
"do_normalize": true,
"image_mean": [
0.485,
0.456,
0.406
],
"image_std": [
0.229,
0.224,
0.225
],
"return_tensor": true,
"data_format": null
}README.mdAdded+92
model.weights.h5Added+3
zm_config.jsonAdded+21
zm_preprocessor.jsonAdded+27