| --- |
| license: mit |
| task_categories: |
| - image-to-text |
| language: |
| - en |
| - hi |
| - te |
| - ta |
| - or |
| - ur |
| - ml |
| - zh |
| - pa |
| - gu |
| - bn |
| - as |
| - kn |
| tags: |
| - table |
| - table-structure-recognition |
| - TSR |
| - multilingual |
| - OTSL |
| - historical-documents |
| size_categories: |
| - 1K<n<10K |
| configs: |
| - config_name: default |
| data_splits: |
| - test |
| --- |
| |
| # MUSTARD |
|
|
| A structured repackaging of [badrivishalk/MUSTARD](https://huggingface.co/datasets/badrivishalk/MUSTARD) that surfaces the OTSL annotations and language metadata as proper dataset columns. |
|
|
| **MUSTARD** (Multilingual Scanned and Scene Table Structure Recognition Dataset) contains 1,429 table images across 13 languages, annotated with OTSL (Optimized Table Structure Language) sequences for table structure recognition. Introduced by the SPRINT paper (ICDAR 2024). |
|
|
| This is an **evaluation-only benchmark** (test split only, no train). |
|
|
| ## Why this version |
|
|
| The original upload uses `imagefolder` format, which means the OTSL annotations in `merged.txt` are not exposed as columns in the dataset viewer or via `load_dataset`. Loading it returns only `{"image": ...}` with no annotation access. |
|
|
| This version gives you: |
|
|
| ```python |
| { |
| "image_id": "indic/assamese/1", # stable identifier |
| "image": <PIL Image>, |
| "width": 2210, |
| "height": 1394, |
| "language": "assamese", # 13 values |
| "script_type": "indic", # "indic" or "scenetext" |
| "has_lines": True, # scenetext: whether grid lines visible |
| "otsl": "FFFLFFFNUUFFUUUN...", |
| "n_rows": 10, |
| "n_cols": 7, |
| } |
| ``` |
|
|
| ## Schema |
|
|
| | Field | Type | Description | |
| |-------|------|-------------| |
| | `image_id` | string | Stable path-derived identifier (e.g. `indic/assamese/1`, `scenetext/chinese_lines/1`) | |
| | `image` | Image | Table image (PNG) | |
| | `width` | int32 | Image width in pixels | |
| | `height` | int32 | Image height in pixels | |
| | `language` | string | One of 13 languages (see table below) | |
| | `script_type` | string | `"indic"` for printed/scanned Indic-script tables; `"scenetext"` for scene-text tables | |
| | `has_lines` | bool | For `scenetext`: whether the table has visible grid lines. Always `True` for `indic`. | |
| | `otsl` | string | OTSL annotation sequence (see format below) | |
| | `n_rows` | int32 | Number of table rows decoded from OTSL | |
| | `n_cols` | int32 | Number of table columns decoded from OTSL (max row width) | |
|
|
| ## Language distribution |
|
|
| | Language | Script type | Count | |
| |----------|-------------|-------| |
| | assamese | indic | 101 | |
| | bengali | indic | 100 | |
| | chinese | indic + scenetext | 207 | |
| | english | scenetext | 109 | |
| | gujarati | indic | 101 | |
| | hindi | indic | 101 | |
| | kannada | indic | 101 | |
| | malayalam | indic | 102 | |
| | oriya | indic | 101 | |
| | punjabi | indic | 102 | |
| | tamil | indic | 100 | |
| | telugu | indic | 102 | |
| | urdu | indic | 102 | |
| | **Total** | | **1,429** | |
|
|
| Scenetext subset: 111 with visible grid lines (`has_lines=True`), 103 without (`has_lines=False`). |
|
|
| ## OTSL format |
|
|
| OTSL (Optimized Table Structure Language) encodes table structure as a flat token sequence. Rows are delimited by `N`; within each row, each character is one cell: |
|
|
| | Token | Meaning | |
| |-------|---------| |
| | `F` | Regular cell (no span) | |
| | `L` | Cell spanning left (continuation of the cell immediately to its left) | |
| | `U` | Cell spanning up (continuation of the cell directly above) | |
| | `E` | Cell spanning both left and up (interior merge corner) | |
| | `X` | Empty/non-data cell | |
|
|
| Example: `FFLNFFN` = a 2-row, 3-column table where row 1 has a merged cell in columns 2-3 (`F F L`) and row 2 is all regular cells (`F F`). |
|
|
| ### Decode OTSL to an HTML table |
|
|
| ```python |
| def otsl_to_html(otsl: str) -> str: |
| rows = [r for r in otsl.split("N") if r] |
| n_cols = max(len(r) for r in rows) |
| |
| # First pass: compute colspan/rowspan |
| grid = [[None] * n_cols for _ in range(len(rows))] |
| spans = {} |
| |
| for r, row in enumerate(rows): |
| for c, tok in enumerate(row): |
| if tok == "F": |
| spans[(r, c)] = [1, 1] |
| grid[r][c] = (r, c) |
| elif tok == "L": |
| origin = grid[r][c - 1] |
| spans[origin][1] += 1 |
| grid[r][c] = origin |
| elif tok == "U": |
| origin = grid[r - 1][c] |
| spans[origin][0] += 1 |
| grid[r][c] = origin |
| elif tok == "E": |
| origin = grid[r - 1][c - 1] |
| grid[r][c] = origin |
| |
| # Second pass: emit HTML |
| html = ["<table>"] |
| for r, row in enumerate(rows): |
| html.append(" <tr>") |
| for c in range(len(row)): |
| if grid[r][c] == (r, c): |
| rs, cs = spans[(r, c)] |
| attrs = "" |
| if rs > 1: |
| attrs += f' rowspan="{rs}"' |
| if cs > 1: |
| attrs += f' colspan="{cs}"' |
| html.append(f" <td{attrs}></td>") |
| html.append(" </tr>") |
| html.append("</table>") |
| return "\n".join(html) |
| ``` |
|
|
| ## Usage |
|
|
| ```python |
| from datasets import load_dataset |
| |
| ds = load_dataset("rootsautomation/MUSTARD", split="test") |
| |
| # Filter to a single language |
| hindi = ds.filter(lambda x: x["language"] == "hindi") |
| |
| # Filter to scenetext with lines |
| scene_lines = ds.filter(lambda x: x["script_type"] == "scenetext" and x["has_lines"]) |
| |
| # Access a sample |
| row = ds[0] |
| print(row["language"], row["n_rows"], "x", row["n_cols"]) |
| row["image"].show() |
| ``` |
|
|
| ## License |
|
|
| MIT. Source data curated by the IIT Bombay LEAP OCR Team. See [badrivishalk/MUSTARD](https://huggingface.co/datasets/badrivishalk/MUSTARD) for the original release. |
|
|
| ## Citation |
|
|
| ```bibtex |
| @inproceedings{sprint2024, |
| title = {SPRINT: Script-agnostic Structure Recognition in Tables}, |
| booktitle = {Document Analysis and Recognition -- ICDAR 2024}, |
| year = {2024}, |
| note = {arXiv:2503.11932} |
| } |
| ``` |
|
|