zhouchangda commited on
Commit
a11a125
·
1 Parent(s): 8a8ce98

Add leaderboard space support

Browse files
.gitignore ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ leaderboard/data/
2
+ hf_eval_results/generated/
hf_eval_results/README.md ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Hugging Face Eval Results Support
2
+
3
+ This directory prepares Real5-OmniDocBench for Hugging Face's model-side
4
+ `.eval_results/*.yaml` mechanism.
5
+
6
+ ## Current Support Status
7
+
8
+ Not fully enabled on the Hub yet.
9
+
10
+ Hugging Face Evaluation Results require:
11
+
12
+ 1. The dataset repo to have a root `eval.yaml`.
13
+ 2. The `evaluation_framework` in that file to be one of Hugging Face's supported framework identifiers.
14
+ 3. The benchmark dataset to be accepted by the beta allow-list.
15
+ 4. Model repos to submit `.eval_results/*.yaml` files that reference this dataset and task IDs.
16
+
17
+ As of July 11, 2026, Hugging Face documents this feature as work in progress and benchmark registration as beta / allow-listed. The supported framework enum currently includes document-related frameworks such as `olmocr-bench`, `mdpbench`, and `parsebench`, but not a dedicated `real5-omnidocbench` or `omnidocbench` framework.
18
+
19
+ For that reason, `eval.yaml.candidate` is intentionally not placed at the repository root yet. Move or copy it to `eval.yaml` only after Hugging Face confirms the framework choice and allow-list registration.
20
+
21
+ ## Dataset-Side Candidate
22
+
23
+ `eval.yaml.candidate` defines six Hub leaderboard tasks:
24
+
25
+ - `overall`
26
+ - `scanning`
27
+ - `warping`
28
+ - `screen_photography`
29
+ - `illumination`
30
+ - `skew`
31
+
32
+ These correspond to the six score columns in the README Overall table. All six are "higher is better" scores in the current benchmark presentation.
33
+
34
+ ## Model-Side Submission Format
35
+
36
+ Model repositories should add a file like:
37
+
38
+ ```text
39
+ .eval_results/real5_omnidocbench.yaml
40
+ ```
41
+
42
+ Use `examples/model_eval_results.yaml` as the template.
43
+
44
+ Each YAML list item reports one task:
45
+
46
+ ```yaml
47
+ - dataset:
48
+ id: PaddlePaddle/Real5-OmniDocBench
49
+ task_id: overall
50
+ value: 93.19
51
+ date: "2026-05-28"
52
+ source:
53
+ url: https://huggingface.co/datasets/PaddlePaddle/Real5-OmniDocBench
54
+ name: Real5-OmniDocBench README
55
+ org: PaddlePaddle
56
+ notes: "PaddleOCR-VL-1.6; official reported result"
57
+ ```
58
+
59
+ ## Generate Files From Current README Data
60
+
61
+ The static leaderboard data must already be generated from the external source file:
62
+
63
+ ```bash
64
+ python leaderboard/scripts/build_from_source_data.py
65
+ ```
66
+
67
+ Generate one YAML file per method:
68
+
69
+ ```bash
70
+ python hf_eval_results/scripts/generate_model_eval_results.py
71
+ ```
72
+
73
+ Generate only one method:
74
+
75
+ ```bash
76
+ python hf_eval_results/scripts/generate_model_eval_results.py --method "PaddleOCR-VL-1.6"
77
+ ```
78
+
79
+ Validate generated or submitted YAML:
80
+
81
+ ```bash
82
+ python hf_eval_results/scripts/validate_eval_results.py hf_eval_results/generated
83
+ ```
84
+
85
+ ## Important Limitation
86
+
87
+ The Hub `.eval_results` schema stores one numeric `value` per dataset task. It does not directly encode the full multi-metric rows from the README tables. This support therefore maps the Hub-native leaderboard to the six primary Overall-table scores. The richer scenario-level metrics such as `TextEdit`, `FormulaCDM`, `TableTEDS`, and `Reading OrderEdit` remain available in the Static Space leaderboard.
hf_eval_results/eval.yaml.candidate ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Real5-OmniDocBench
2
+ description: >
3
+ Real5-OmniDocBench is a real-world document parsing robustness benchmark
4
+ covering five physical acquisition scenarios: Scanning, Warping,
5
+ Screen-Photography, Illumination, and Skew.
6
+ evaluation_framework: olmocr-bench
7
+
8
+ tasks:
9
+ - id: overall
10
+ config: default
11
+ split: test
12
+ - id: scanning
13
+ config: default
14
+ split: test
15
+ - id: warping
16
+ config: default
17
+ split: test
18
+ - id: screen_photography
19
+ config: default
20
+ split: test
21
+ - id: illumination
22
+ config: default
23
+ split: test
24
+ - id: skew
25
+ config: default
26
+ split: test
hf_eval_results/examples/model_eval_results.yaml ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copy this file into a model repository as:
2
+ # .eval_results/real5_omnidocbench.yaml
3
+ #
4
+ # Each entry reports one leaderboard task. The value is the score shown in the
5
+ # Real5-OmniDocBench README / leaderboard data. Higher is better for these
6
+ # six tasks.
7
+
8
+ - dataset:
9
+ id: PaddlePaddle/Real5-OmniDocBench
10
+ task_id: overall
11
+ value: 93.19
12
+ date: "2026-05-28"
13
+ source:
14
+ url: https://huggingface.co/datasets/PaddlePaddle/Real5-OmniDocBench
15
+ name: Real5-OmniDocBench README
16
+ org: PaddlePaddle
17
+ notes: "PaddleOCR-VL-1.6; official reported result"
18
+
19
+ - dataset:
20
+ id: PaddlePaddle/Real5-OmniDocBench
21
+ task_id: scanning
22
+ value: 94.74
23
+ date: "2026-05-28"
24
+ source:
25
+ url: https://huggingface.co/datasets/PaddlePaddle/Real5-OmniDocBench
26
+ name: Real5-OmniDocBench README
27
+ org: PaddlePaddle
28
+ notes: "PaddleOCR-VL-1.6; official reported result"
29
+
30
+ - dataset:
31
+ id: PaddlePaddle/Real5-OmniDocBench
32
+ task_id: warping
33
+ value: 92.48
34
+ date: "2026-05-28"
35
+ source:
36
+ url: https://huggingface.co/datasets/PaddlePaddle/Real5-OmniDocBench
37
+ name: Real5-OmniDocBench README
38
+ org: PaddlePaddle
39
+ notes: "PaddleOCR-VL-1.6; official reported result"
40
+
41
+ - dataset:
42
+ id: PaddlePaddle/Real5-OmniDocBench
43
+ task_id: screen_photography
44
+ value: 92.78
45
+ date: "2026-05-28"
46
+ source:
47
+ url: https://huggingface.co/datasets/PaddlePaddle/Real5-OmniDocBench
48
+ name: Real5-OmniDocBench README
49
+ org: PaddlePaddle
50
+ notes: "PaddleOCR-VL-1.6; official reported result"
51
+
52
+ - dataset:
53
+ id: PaddlePaddle/Real5-OmniDocBench
54
+ task_id: illumination
55
+ value: 93.28
56
+ date: "2026-05-28"
57
+ source:
58
+ url: https://huggingface.co/datasets/PaddlePaddle/Real5-OmniDocBench
59
+ name: Real5-OmniDocBench README
60
+ org: PaddlePaddle
61
+ notes: "PaddleOCR-VL-1.6; official reported result"
62
+
63
+ - dataset:
64
+ id: PaddlePaddle/Real5-OmniDocBench
65
+ task_id: skew
66
+ value: 92.66
67
+ date: "2026-05-28"
68
+ source:
69
+ url: https://huggingface.co/datasets/PaddlePaddle/Real5-OmniDocBench
70
+ name: Real5-OmniDocBench README
71
+ org: PaddlePaddle
72
+ notes: "PaddleOCR-VL-1.6; official reported result"
hf_eval_results/scripts/generate_model_eval_results.py ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Generate model-side .eval_results YAML files from Space leaderboard data."""
3
+
4
+ from __future__ import annotations
5
+
6
+ import argparse
7
+ import re
8
+ from pathlib import Path
9
+
10
+ import yaml
11
+
12
+
13
+ DEFAULT_DATA = Path(__file__).resolve().parents[2] / "leaderboard" / "data" / "leaderboard_data.json"
14
+ DEFAULT_OUT_DIR = Path(__file__).resolve().parents[1] / "generated"
15
+ DEFAULT_DATASET_ID = "PaddlePaddle/Real5-OmniDocBench"
16
+ DEFAULT_SOURCE_URL = "https://huggingface.co/datasets/PaddlePaddle/Real5-OmniDocBench"
17
+
18
+ TASK_COLUMNS = {
19
+ "overall": "overall",
20
+ "scanning": "scanning",
21
+ "warping": "warping",
22
+ "screen_photography": "screen_photography",
23
+ "illumination": "illumination",
24
+ "skew": "skew",
25
+ }
26
+
27
+
28
+ def slugify(value: str) -> str:
29
+ value = value.strip().lower()
30
+ value = re.sub(r"[^a-z0-9]+", "-", value)
31
+ return value.strip("-") or "model"
32
+
33
+
34
+ def load_overall_rows(path: Path) -> list[dict[str, object]]:
35
+ import json
36
+
37
+ payload = json.loads(path.read_text(encoding="utf-8"))
38
+ for table in payload["tables"]:
39
+ if table["name"] == "Overall":
40
+ return table["rows"]
41
+ raise ValueError("Overall table not found")
42
+
43
+
44
+ def make_entries(row: dict[str, object], args: argparse.Namespace) -> list[dict[str, object]]:
45
+ method = str(row["method"])
46
+ entries: list[dict[str, object]] = []
47
+ for task_id, column in TASK_COLUMNS.items():
48
+ value = row.get(column)
49
+ if not isinstance(value, (int, float)):
50
+ continue
51
+ entry: dict[str, object] = {
52
+ "dataset": {
53
+ "id": args.dataset_id,
54
+ "task_id": task_id,
55
+ },
56
+ "value": round(float(value), 6),
57
+ }
58
+ if args.date:
59
+ entry["date"] = args.date
60
+ if args.source_url:
61
+ entry["source"] = {
62
+ "url": args.source_url,
63
+ "name": args.source_name,
64
+ "org": args.source_org,
65
+ }
66
+ entry["notes"] = f"{method}; generated from Real5-OmniDocBench README"
67
+ entries.append(entry)
68
+ return entries
69
+
70
+
71
+ def main() -> None:
72
+ parser = argparse.ArgumentParser(description=__doc__)
73
+ parser.add_argument("--data", type=Path, default=DEFAULT_DATA)
74
+ parser.add_argument("--out-dir", type=Path, default=DEFAULT_OUT_DIR)
75
+ parser.add_argument("--method", help="Generate only one method by exact name.")
76
+ parser.add_argument("--dataset-id", default=DEFAULT_DATASET_ID)
77
+ parser.add_argument("--date", help="Optional ISO-8601 evaluation date.")
78
+ parser.add_argument("--source-url", default=DEFAULT_SOURCE_URL)
79
+ parser.add_argument("--source-name", default="Real5-OmniDocBench README")
80
+ parser.add_argument("--source-org", default="PaddlePaddle")
81
+ args = parser.parse_args()
82
+
83
+ rows = load_overall_rows(args.data)
84
+ if args.method:
85
+ rows = [row for row in rows if row["method"] == args.method]
86
+ if not rows:
87
+ raise SystemExit(f"Method not found: {args.method}")
88
+
89
+ args.out_dir.mkdir(parents=True, exist_ok=True)
90
+ for row in rows:
91
+ method = str(row["method"])
92
+ entries = make_entries(row, args)
93
+ out_file = args.out_dir / f"{slugify(method)}.yaml"
94
+ out_file.write_text(
95
+ yaml.safe_dump(entries, sort_keys=False, allow_unicode=False),
96
+ encoding="utf-8",
97
+ )
98
+ print(f"Wrote {out_file}")
99
+
100
+
101
+ if __name__ == "__main__":
102
+ main()
hf_eval_results/scripts/validate_eval_results.py ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Validate Real5-OmniDocBench model-side .eval_results YAML files."""
3
+
4
+ from __future__ import annotations
5
+
6
+ import argparse
7
+ from pathlib import Path
8
+
9
+ import yaml
10
+
11
+
12
+ DEFAULT_DATASET_ID = "PaddlePaddle/Real5-OmniDocBench"
13
+ VALID_TASK_IDS = {
14
+ "overall",
15
+ "scanning",
16
+ "warping",
17
+ "screen_photography",
18
+ "illumination",
19
+ "skew",
20
+ }
21
+
22
+
23
+ def validate_file(path: Path, dataset_id: str) -> list[str]:
24
+ errors: list[str] = []
25
+ payload = yaml.safe_load(path.read_text(encoding="utf-8"))
26
+ if not isinstance(payload, list):
27
+ return [f"{path}: top-level YAML must be a list"]
28
+
29
+ seen: set[str] = set()
30
+ for index, entry in enumerate(payload, start=1):
31
+ prefix = f"{path}: entry {index}"
32
+ if not isinstance(entry, dict):
33
+ errors.append(f"{prefix}: must be a mapping")
34
+ continue
35
+
36
+ dataset = entry.get("dataset")
37
+ if not isinstance(dataset, dict):
38
+ errors.append(f"{prefix}: missing dataset mapping")
39
+ continue
40
+
41
+ if dataset.get("id") != dataset_id:
42
+ errors.append(f"{prefix}: dataset.id must be {dataset_id!r}")
43
+
44
+ task_id = dataset.get("task_id")
45
+ if task_id not in VALID_TASK_IDS:
46
+ errors.append(f"{prefix}: invalid task_id {task_id!r}")
47
+ else:
48
+ seen.add(str(task_id))
49
+
50
+ value = entry.get("value")
51
+ if not isinstance(value, (int, float)):
52
+ errors.append(f"{prefix}: value must be numeric")
53
+ elif not 0 <= float(value) <= 100:
54
+ errors.append(f"{prefix}: value should be in [0, 100]")
55
+
56
+ source = entry.get("source")
57
+ if source is not None:
58
+ if not isinstance(source, dict) or not source.get("url"):
59
+ errors.append(f"{prefix}: source.url is required when source is present")
60
+
61
+ missing = VALID_TASK_IDS - seen
62
+ if missing:
63
+ errors.append(f"{path}: missing task_id entries: {', '.join(sorted(missing))}")
64
+ return errors
65
+
66
+
67
+ def main() -> None:
68
+ parser = argparse.ArgumentParser(description=__doc__)
69
+ parser.add_argument("paths", nargs="+", type=Path)
70
+ parser.add_argument("--dataset-id", default=DEFAULT_DATASET_ID)
71
+ args = parser.parse_args()
72
+
73
+ all_errors: list[str] = []
74
+ files: list[Path] = []
75
+ for path in args.paths:
76
+ if path.is_dir():
77
+ files.extend(sorted(path.glob("*.yaml")))
78
+ files.extend(sorted(path.glob("*.yml")))
79
+ else:
80
+ files.append(path)
81
+
82
+ if not files:
83
+ raise SystemExit("No YAML files found")
84
+
85
+ for path in files:
86
+ all_errors.extend(validate_file(path, args.dataset_id))
87
+
88
+ if all_errors:
89
+ print("\n".join(all_errors))
90
+ raise SystemExit(1)
91
+
92
+ print(f"Validated {len(files)} file(s)")
93
+
94
+
95
+ if __name__ == "__main__":
96
+ main()
leaderboard/DEPLOY.md ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Deploying the Leaderboard on Hugging Face
2
+
3
+ Hugging Face supports benchmark leaderboards in two practical ways.
4
+
5
+ ## Recommended: Static Space
6
+
7
+ Use this for the current Real5-OmniDocBench README tables. It is simple, keeps the dataset card unchanged, and does not require backend dependencies.
8
+
9
+ 1. Create a new Hugging Face Space.
10
+ 2. Select **Static HTML** as the SDK, or keep the metadata in `leaderboard/README.md`:
11
+
12
+ ```yaml
13
+ sdk: static
14
+ app_file: index.html
15
+ ```
16
+
17
+ 3. Push the contents of the `leaderboard/` directory to the Space repository:
18
+
19
+ ```bash
20
+ cd leaderboard
21
+ git init
22
+ git remote add origin git@hf.co:spaces/<org-or-user>/Real5-OmniDocBench-Leaderboard
23
+ git add README.md index.html data scripts DEPLOY.md
24
+ git commit -m "Add Real5-OmniDocBench leaderboard"
25
+ git push -u origin main
26
+ ```
27
+
28
+ 4. When benchmark scores change in `/paddle/project/wild_omnidocbench/dataset_new/leaderboard_data.json`, regenerate the Space data:
29
+
30
+ ```bash
31
+ python leaderboard/scripts/build_from_source_data.py
32
+ ```
33
+
34
+ The dataset repository ignores `leaderboard/data/`. For a Space deployment, copy or generate `leaderboard/data/leaderboard_data.json` into the Space repository and push it there.
35
+
36
+ ## Hub Benchmark / Eval Results
37
+
38
+ Hugging Face also has a Hub-level Evaluation Results feature. In that flow:
39
+
40
+ 1. The dataset repository is registered as a benchmark with an `eval.yaml` file.
41
+ 2. Each model repository publishes scores in `.eval_results/*.yaml`.
42
+ 3. Hugging Face aggregates the model results back onto the benchmark dataset page.
43
+
44
+ This is better for decentralized community submissions, but it requires model repositories to publish result files and the benchmark feature is currently marked as work in progress / beta allow-listed in the official docs.
45
+
46
+ For this benchmark, the current README already has complete published tables, so the Static Space is the lowest-friction path.
47
+
48
+ The repository also includes `hf_eval_results/` with:
49
+
50
+ - `eval.yaml.candidate` for the dataset-side benchmark registration.
51
+ - `examples/model_eval_results.yaml` for model repositories.
52
+ - scripts to generate and validate `.eval_results/*.yaml` files from the README-derived leaderboard data.
53
+
54
+ Do not move `hf_eval_results/eval.yaml.candidate` to the dataset repository root as `eval.yaml` until Hugging Face confirms the benchmark allow-list and evaluation framework choice.
leaderboard/README.md ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Real5-OmniDocBench Leaderboard
3
+ colorFrom: indigo
4
+ colorTo: green
5
+ sdk: static
6
+ pinned: false
7
+ app_file: index.html
8
+ datasets:
9
+ - PaddlePaddle/Real5-OmniDocBench
10
+ tags:
11
+ - leaderboard
12
+ - model-benchmarking
13
+ - document-parsing
14
+ - ocr
15
+ ---
16
+
17
+ # Real5-OmniDocBench Leaderboard
18
+
19
+ This Space renders Real5-OmniDocBench benchmark results as a searchable, sortable leaderboard.
20
+
21
+ Update workflow:
22
+
23
+ 1. Keep the latest source data at `/paddle/project/wild_omnidocbench/dataset_new/leaderboard_data.json`.
24
+ 2. Run `python leaderboard/scripts/build_from_source_data.py`.
25
+ 3. Push the `leaderboard/` directory to a Hugging Face Space.
26
+
27
+ The generated `leaderboard/data/` directory is ignored by the dataset repository. Include it only as a Space deployment artifact.
28
+
29
+ Hugging Face supports leaderboard-style presentation in two relevant ways:
30
+
31
+ - Community managed leaderboards live on Spaces and are appropriate for benchmark pages with custom tables and filters.
32
+ - Evaluation Results are a Hub-level benchmark feature where a dataset repo defines `eval.yaml` and model repos publish `.eval_results/*.yaml`; this is currently marked as work in progress and beta allow-listed.
leaderboard/index.html ADDED
@@ -0,0 +1,740 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
6
+ <title>Real5-OmniDocBench Leaderboard</title>
7
+ <style>
8
+ :root {
9
+ color-scheme: light;
10
+ --bg: #f7f8fb;
11
+ --panel: #ffffff;
12
+ --panel-subtle: #f1f4f8;
13
+ --line: #d9e0e8;
14
+ --line-strong: #b8c2cc;
15
+ --text: #172033;
16
+ --muted: #647084;
17
+ --accent: #1d7a68;
18
+ --accent-strong: #145b50;
19
+ --accent-soft: #e0f3ee;
20
+ --blue: #245ca8;
21
+ --gold: #946200;
22
+ --danger: #a73b37;
23
+ --shadow: 0 10px 30px rgba(23, 32, 51, 0.08);
24
+ }
25
+
26
+ * {
27
+ box-sizing: border-box;
28
+ }
29
+
30
+ body {
31
+ margin: 0;
32
+ background: var(--bg);
33
+ color: var(--text);
34
+ font-family:
35
+ Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
36
+ "Segoe UI", sans-serif;
37
+ line-height: 1.5;
38
+ }
39
+
40
+ a {
41
+ color: var(--accent-strong);
42
+ }
43
+
44
+ .page {
45
+ max-width: 1440px;
46
+ margin: 0 auto;
47
+ padding: 24px;
48
+ }
49
+
50
+ .topbar {
51
+ display: flex;
52
+ flex-wrap: wrap;
53
+ gap: 16px;
54
+ align-items: flex-end;
55
+ justify-content: space-between;
56
+ margin-bottom: 18px;
57
+ }
58
+
59
+ .title-block {
60
+ max-width: 820px;
61
+ }
62
+
63
+ h1 {
64
+ margin: 0 0 8px;
65
+ font-size: clamp(28px, 4vw, 44px);
66
+ line-height: 1.08;
67
+ letter-spacing: 0;
68
+ }
69
+
70
+ .subtitle {
71
+ margin: 0;
72
+ color: var(--muted);
73
+ font-size: 16px;
74
+ }
75
+
76
+ .links {
77
+ display: flex;
78
+ flex-wrap: wrap;
79
+ gap: 8px;
80
+ }
81
+
82
+ .link-button {
83
+ display: inline-flex;
84
+ min-height: 36px;
85
+ align-items: center;
86
+ justify-content: center;
87
+ gap: 8px;
88
+ border: 1px solid var(--line);
89
+ border-radius: 8px;
90
+ background: var(--panel);
91
+ color: var(--text);
92
+ padding: 7px 12px;
93
+ text-decoration: none;
94
+ font-weight: 650;
95
+ font-size: 14px;
96
+ }
97
+
98
+ .summary {
99
+ display: grid;
100
+ grid-template-columns: repeat(4, minmax(0, 1fr));
101
+ gap: 12px;
102
+ margin-bottom: 18px;
103
+ }
104
+
105
+ .stat {
106
+ border: 1px solid var(--line);
107
+ border-radius: 8px;
108
+ background: var(--panel);
109
+ padding: 14px 16px;
110
+ box-shadow: var(--shadow);
111
+ }
112
+
113
+ .stat-label {
114
+ display: block;
115
+ color: var(--muted);
116
+ font-size: 13px;
117
+ }
118
+
119
+ .stat-value {
120
+ display: block;
121
+ margin-top: 4px;
122
+ font-size: 24px;
123
+ line-height: 1.1;
124
+ font-weight: 760;
125
+ }
126
+
127
+ .controls {
128
+ display: grid;
129
+ grid-template-columns: minmax(220px, 1.4fr) minmax(180px, 0.8fr) minmax(180px, 0.8fr);
130
+ gap: 12px;
131
+ align-items: end;
132
+ border: 1px solid var(--line);
133
+ border-radius: 8px;
134
+ background: var(--panel);
135
+ padding: 14px;
136
+ margin-bottom: 14px;
137
+ box-shadow: var(--shadow);
138
+ }
139
+
140
+ .field {
141
+ display: flex;
142
+ min-width: 0;
143
+ flex-direction: column;
144
+ gap: 6px;
145
+ }
146
+
147
+ label {
148
+ color: var(--muted);
149
+ font-size: 12px;
150
+ font-weight: 700;
151
+ text-transform: uppercase;
152
+ }
153
+
154
+ input,
155
+ select {
156
+ min-height: 40px;
157
+ width: 100%;
158
+ border: 1px solid var(--line-strong);
159
+ border-radius: 8px;
160
+ background: #fff;
161
+ color: var(--text);
162
+ padding: 8px 10px;
163
+ font: inherit;
164
+ }
165
+
166
+ input:focus,
167
+ select:focus {
168
+ outline: 2px solid var(--accent-soft);
169
+ border-color: var(--accent);
170
+ }
171
+
172
+ .tabs {
173
+ display: flex;
174
+ gap: 6px;
175
+ overflow-x: auto;
176
+ border-bottom: 1px solid var(--line);
177
+ margin-bottom: 0;
178
+ }
179
+
180
+ .tab {
181
+ flex: 0 0 auto;
182
+ border: 1px solid transparent;
183
+ border-bottom: 0;
184
+ border-radius: 8px 8px 0 0;
185
+ background: transparent;
186
+ color: var(--muted);
187
+ padding: 10px 14px;
188
+ font: inherit;
189
+ font-weight: 750;
190
+ cursor: pointer;
191
+ }
192
+
193
+ .tab.active {
194
+ background: var(--panel);
195
+ color: var(--accent-strong);
196
+ border-color: var(--line);
197
+ }
198
+
199
+ .table-panel {
200
+ border: 1px solid var(--line);
201
+ border-top: 0;
202
+ border-radius: 0 0 8px 8px;
203
+ background: var(--panel);
204
+ box-shadow: var(--shadow);
205
+ overflow: hidden;
206
+ }
207
+
208
+ .table-meta {
209
+ display: flex;
210
+ flex-wrap: wrap;
211
+ gap: 10px;
212
+ justify-content: space-between;
213
+ align-items: center;
214
+ padding: 12px 14px;
215
+ border-bottom: 1px solid var(--line);
216
+ background: var(--panel-subtle);
217
+ }
218
+
219
+ .meta-text {
220
+ color: var(--muted);
221
+ font-size: 14px;
222
+ }
223
+
224
+ .hint {
225
+ display: flex;
226
+ flex-wrap: wrap;
227
+ gap: 6px;
228
+ }
229
+
230
+ .chip {
231
+ display: inline-flex;
232
+ align-items: center;
233
+ min-height: 24px;
234
+ border-radius: 999px;
235
+ background: var(--accent-soft);
236
+ color: var(--accent-strong);
237
+ padding: 2px 8px;
238
+ font-size: 12px;
239
+ font-weight: 760;
240
+ }
241
+
242
+ .table-wrap {
243
+ overflow: auto;
244
+ max-height: 72vh;
245
+ }
246
+
247
+ table {
248
+ width: 100%;
249
+ min-width: 980px;
250
+ border-collapse: separate;
251
+ border-spacing: 0;
252
+ }
253
+
254
+ th,
255
+ td {
256
+ border-bottom: 1px solid var(--line);
257
+ padding: 10px 12px;
258
+ text-align: right;
259
+ white-space: nowrap;
260
+ font-variant-numeric: tabular-nums;
261
+ }
262
+
263
+ th {
264
+ position: sticky;
265
+ top: 0;
266
+ z-index: 2;
267
+ background: #eef3f7;
268
+ color: #334054;
269
+ font-size: 12px;
270
+ text-transform: uppercase;
271
+ cursor: pointer;
272
+ user-select: none;
273
+ }
274
+
275
+ th:first-child,
276
+ td:first-child {
277
+ position: sticky;
278
+ left: 0;
279
+ z-index: 1;
280
+ background: inherit;
281
+ }
282
+
283
+ th:first-child {
284
+ z-index: 3;
285
+ background: #eef3f7;
286
+ }
287
+
288
+ td {
289
+ background: var(--panel);
290
+ }
291
+
292
+ tr:nth-child(even) td {
293
+ background: #fbfcfd;
294
+ }
295
+
296
+ th.text,
297
+ td.text {
298
+ text-align: left;
299
+ }
300
+
301
+ .rank {
302
+ color: var(--muted);
303
+ font-weight: 750;
304
+ }
305
+
306
+ .method {
307
+ font-weight: 760;
308
+ }
309
+
310
+ .best {
311
+ color: var(--accent-strong);
312
+ font-weight: 820;
313
+ }
314
+
315
+ .second {
316
+ color: var(--gold);
317
+ font-weight: 780;
318
+ }
319
+
320
+ .model-type {
321
+ display: inline-flex;
322
+ align-items: center;
323
+ border-radius: 6px;
324
+ background: #e9edf5;
325
+ color: #34415a;
326
+ padding: 2px 7px;
327
+ font-size: 12px;
328
+ font-weight: 760;
329
+ }
330
+
331
+ .empty {
332
+ padding: 32px;
333
+ color: var(--muted);
334
+ text-align: center;
335
+ }
336
+
337
+ .footer {
338
+ margin: 18px 0 0;
339
+ color: var(--muted);
340
+ font-size: 13px;
341
+ }
342
+
343
+ .error {
344
+ border: 1px solid #efb8b2;
345
+ border-radius: 8px;
346
+ background: #fff4f2;
347
+ color: var(--danger);
348
+ padding: 16px;
349
+ font-weight: 650;
350
+ }
351
+
352
+ @media (max-width: 900px) {
353
+ .page {
354
+ padding: 18px;
355
+ }
356
+
357
+ .summary {
358
+ grid-template-columns: repeat(2, minmax(0, 1fr));
359
+ }
360
+
361
+ .controls {
362
+ grid-template-columns: 1fr;
363
+ }
364
+ }
365
+
366
+ @media (max-width: 560px) {
367
+ .page {
368
+ padding: 14px;
369
+ }
370
+
371
+ .summary {
372
+ grid-template-columns: 1fr;
373
+ }
374
+
375
+ .link-button {
376
+ width: 100%;
377
+ }
378
+ }
379
+ </style>
380
+ </head>
381
+ <body>
382
+ <main class="page">
383
+ <div class="topbar">
384
+ <div class="title-block">
385
+ <h1>Real5-OmniDocBench Leaderboard</h1>
386
+ <p class="subtitle">
387
+ Searchable benchmark results for real-world document parsing across Scanning,
388
+ Warping, Screen-Photography, Illumination, and Skew scenarios.
389
+ </p>
390
+ </div>
391
+ <nav class="links" aria-label="Resources">
392
+ <a class="link-button" href="https://huggingface.co/datasets/PaddlePaddle/Real5-OmniDocBench">Dataset</a>
393
+ <a class="link-button" href="https://arxiv.org/abs/2603.04205">Paper</a>
394
+ <a class="link-button" href="https://github.com/opendatalab/OmniDocBench">Eval Protocol</a>
395
+ </nav>
396
+ </div>
397
+
398
+ <section class="summary" aria-label="Summary">
399
+ <div class="stat">
400
+ <span class="stat-label">Best Overall</span>
401
+ <span class="stat-value" id="best-overall">-</span>
402
+ </div>
403
+ <div class="stat">
404
+ <span class="stat-label">Best Method</span>
405
+ <span class="stat-value" id="best-method">-</span>
406
+ </div>
407
+ <div class="stat">
408
+ <span class="stat-label">Methods</span>
409
+ <span class="stat-value" id="method-count">-</span>
410
+ </div>
411
+ <div class="stat">
412
+ <span class="stat-label">Tables</span>
413
+ <span class="stat-value" id="table-count">-</span>
414
+ </div>
415
+ </section>
416
+
417
+ <section class="controls" aria-label="Filters">
418
+ <div class="field">
419
+ <label for="search">Search</label>
420
+ <input id="search" type="search" placeholder="Filter by method, type, or parameter size" />
421
+ </div>
422
+ <div class="field">
423
+ <label for="model-type">Model Type</label>
424
+ <select id="model-type">
425
+ <option value="">All model types</option>
426
+ </select>
427
+ </div>
428
+ <div class="field">
429
+ <label for="sort-by">Sort By</label>
430
+ <select id="sort-by"></select>
431
+ </div>
432
+ </section>
433
+
434
+ <section>
435
+ <div class="tabs" id="tabs" role="tablist" aria-label="Benchmark tables"></div>
436
+ <div class="table-panel">
437
+ <div class="table-meta">
438
+ <div class="meta-text" id="table-title"></div>
439
+ <div class="hint">
440
+ <span class="chip">Click headers to sort</span>
441
+ <span class="chip">higher is better</span>
442
+ <span class="chip">lower is better</span>
443
+ </div>
444
+ </div>
445
+ <div class="table-wrap" id="table-wrap"></div>
446
+ </div>
447
+ </section>
448
+
449
+ <p class="footer">
450
+ Data is built from the external leaderboard source JSON.
451
+ To update this Space data locally, run <code>python leaderboard/scripts/build_from_source_data.py</code>.
452
+ </p>
453
+ </main>
454
+
455
+ <script>
456
+ const STATE = {
457
+ data: null,
458
+ activeTable: "Overall",
459
+ query: "",
460
+ modelType: "",
461
+ sortKey: "overall",
462
+ sortDirection: "desc",
463
+ };
464
+
465
+ const TEXT_COLUMNS = new Set(["model_type", "method", "parameters"]);
466
+ const CORE_COLUMNS = ["rank", "model_type", "method", "parameters"];
467
+ const LABELS = {
468
+ model_type: "Model Type",
469
+ method: "Methods",
470
+ parameters: "Parameters",
471
+ overall: "Overall",
472
+ scanning: "Scanning",
473
+ warping: "Warping",
474
+ screen_photography: "Screen-Photography",
475
+ illumination: "Illumination",
476
+ skew: "Skew",
477
+ text_edit: "TextEdit",
478
+ formula_cdm: "FormulaCDM",
479
+ table_teds: "TableTEDS",
480
+ reading_order_edit: "Reading OrderEdit",
481
+ };
482
+
483
+ const $ = (id) => document.getElementById(id);
484
+
485
+ function formatValue(value) {
486
+ if (typeof value === "number") {
487
+ return value < 1 ? value.toFixed(3) : value.toFixed(2);
488
+ }
489
+ return value ?? "";
490
+ }
491
+
492
+ function metricDirection(key) {
493
+ return STATE.data?.metrics?.[key]?.direction || "higher";
494
+ }
495
+
496
+ function defaultSortDirection(key) {
497
+ return metricDirection(key) === "lower" ? "asc" : "desc";
498
+ }
499
+
500
+ function currentTable() {
501
+ return STATE.data.tables.find((table) => table.name === STATE.activeTable);
502
+ }
503
+
504
+ function numericColumns(table) {
505
+ return table.headers.filter((key) => !TEXT_COLUMNS.has(key));
506
+ }
507
+
508
+ function buildSummary() {
509
+ const overall = STATE.data.tables.find((table) => table.name === "Overall");
510
+ const rows = overall.rows.slice().sort((a, b) => Number(b.overall) - Number(a.overall));
511
+ const best = rows[0];
512
+ $("best-overall").textContent = formatValue(best.overall);
513
+ $("best-method").textContent = best.method;
514
+ $("method-count").textContent = String(overall.rows.length);
515
+ $("table-count").textContent = String(STATE.data.tables.length);
516
+ }
517
+
518
+ function buildTabs() {
519
+ const tabs = $("tabs");
520
+ tabs.innerHTML = "";
521
+ STATE.data.tables.forEach((table) => {
522
+ const button = document.createElement("button");
523
+ button.className = `tab${table.name === STATE.activeTable ? " active" : ""}`;
524
+ button.type = "button";
525
+ button.role = "tab";
526
+ button.textContent = table.name;
527
+ button.setAttribute("aria-selected", table.name === STATE.activeTable ? "true" : "false");
528
+ button.addEventListener("click", () => {
529
+ STATE.activeTable = table.name;
530
+ const defaultKey = table.headers.includes("overall") ? "overall" : numericColumns(table)[0];
531
+ STATE.sortKey = defaultKey;
532
+ STATE.sortDirection = defaultSortDirection(defaultKey);
533
+ buildTabs();
534
+ buildSortOptions();
535
+ render();
536
+ });
537
+ tabs.appendChild(button);
538
+ });
539
+ }
540
+
541
+ function buildFilters() {
542
+ const allTypes = new Set();
543
+ STATE.data.tables.forEach((table) => {
544
+ table.rows.forEach((row) => allTypes.add(row.model_type));
545
+ });
546
+
547
+ const select = $("model-type");
548
+ [...allTypes].sort().forEach((type) => {
549
+ const option = document.createElement("option");
550
+ option.value = type;
551
+ option.textContent = type;
552
+ select.appendChild(option);
553
+ });
554
+ }
555
+
556
+ function buildSortOptions() {
557
+ const table = currentTable();
558
+ const select = $("sort-by");
559
+ select.innerHTML = "";
560
+ table.headers.forEach((key) => {
561
+ const option = document.createElement("option");
562
+ option.value = key;
563
+ option.textContent = LABELS[key] || key;
564
+ select.appendChild(option);
565
+ });
566
+ select.value = STATE.sortKey;
567
+ }
568
+
569
+ function sortRows(rows) {
570
+ const key = STATE.sortKey;
571
+ const direction = STATE.sortDirection === "asc" ? 1 : -1;
572
+ return rows.slice().sort((a, b) => {
573
+ const left = a[key];
574
+ const right = b[key];
575
+ if (typeof left === "number" && typeof right === "number") {
576
+ return (left - right) * direction;
577
+ }
578
+ return String(left).localeCompare(String(right)) * direction;
579
+ });
580
+ }
581
+
582
+ function filterRows(rows) {
583
+ const query = STATE.query.trim().toLowerCase();
584
+ return rows.filter((row) => {
585
+ if (STATE.modelType && row.model_type !== STATE.modelType) {
586
+ return false;
587
+ }
588
+ if (!query) {
589
+ return true;
590
+ }
591
+ return [row.model_type, row.method, row.parameters].some((value) =>
592
+ String(value).toLowerCase().includes(query),
593
+ );
594
+ });
595
+ }
596
+
597
+ function bestValues(rows, headers) {
598
+ const values = {};
599
+ headers.forEach((key) => {
600
+ if (TEXT_COLUMNS.has(key)) {
601
+ return;
602
+ }
603
+ const nums = rows.map((row) => row[key]).filter((value) => typeof value === "number");
604
+ const unique = [...new Set(nums)].sort((a, b) =>
605
+ metricDirection(key) === "lower" ? a - b : b - a,
606
+ );
607
+ values[key] = {
608
+ best: unique[0],
609
+ second: unique[1],
610
+ };
611
+ });
612
+ return values;
613
+ }
614
+
615
+ function cellClass(row, key, values) {
616
+ if (key === "method") {
617
+ return "text method";
618
+ }
619
+ if (TEXT_COLUMNS.has(key)) {
620
+ return "text";
621
+ }
622
+ const cls = [];
623
+ if (row[key] === values[key]?.best) {
624
+ cls.push("best");
625
+ } else if (row[key] === values[key]?.second) {
626
+ cls.push("second");
627
+ }
628
+ return cls.join(" ");
629
+ }
630
+
631
+ function headerLabel(key) {
632
+ if (key === STATE.sortKey) {
633
+ return `${LABELS[key] || key} ${STATE.sortDirection === "asc" ? "asc" : "desc"}`;
634
+ }
635
+ const direction = metricDirection(key);
636
+ if (!TEXT_COLUMNS.has(key)) {
637
+ return `${LABELS[key] || key} (${direction === "lower" ? "lower" : "higher"})`;
638
+ }
639
+ return LABELS[key] || key;
640
+ }
641
+
642
+ function render() {
643
+ const table = currentTable();
644
+ const filtered = filterRows(table.rows);
645
+ const rows = sortRows(filtered);
646
+ const values = bestValues(table.rows, table.headers);
647
+ $("table-title").textContent = `${table.name}: ${rows.length} of ${table.rows.length} methods shown`;
648
+
649
+ const wrap = $("table-wrap");
650
+ if (!rows.length) {
651
+ wrap.innerHTML = '<div class="empty">No matching results.</div>';
652
+ return;
653
+ }
654
+
655
+ const columns = ["rank", ...table.headers];
656
+ const html = [
657
+ "<table>",
658
+ "<thead><tr>",
659
+ ...columns.map((key) => {
660
+ const cls = key === "rank" || TEXT_COLUMNS.has(key) ? ' class="text"' : "";
661
+ const label = key === "rank" ? "Rank" : headerLabel(key);
662
+ return `<th${cls} data-key="${key}">${label}</th>`;
663
+ }),
664
+ "</tr></thead><tbody>",
665
+ ...rows.map((row, index) => {
666
+ const rank = `<td class="text rank">${index + 1}</td>`;
667
+ const cells = table.headers
668
+ .map((key) => {
669
+ if (key === "model_type") {
670
+ return `<td class="text"><span class="model-type">${row[key]}</span></td>`;
671
+ }
672
+ const cls = cellClass(row, key, values);
673
+ const classAttr = cls ? ` class="${cls}"` : "";
674
+ return `<td${classAttr}>${formatValue(row[key])}</td>`;
675
+ })
676
+ .join("");
677
+ return `<tr>${rank}${cells}</tr>`;
678
+ }),
679
+ "</tbody></table>",
680
+ ].join("");
681
+ wrap.innerHTML = html;
682
+
683
+ wrap.querySelectorAll("th[data-key]").forEach((th) => {
684
+ th.addEventListener("click", () => {
685
+ const key = th.dataset.key;
686
+ if (key === "rank") {
687
+ return;
688
+ }
689
+ if (STATE.sortKey === key) {
690
+ STATE.sortDirection = STATE.sortDirection === "asc" ? "desc" : "asc";
691
+ } else {
692
+ STATE.sortKey = key;
693
+ STATE.sortDirection = defaultSortDirection(key);
694
+ $("sort-by").value = key;
695
+ }
696
+ render();
697
+ });
698
+ });
699
+ }
700
+
701
+ async function init() {
702
+ try {
703
+ const response = await fetch("data/leaderboard_data.json", { cache: "no-store" });
704
+ if (!response.ok) {
705
+ throw new Error(`Failed to load data/leaderboard_data.json: ${response.status}`);
706
+ }
707
+ STATE.data = await response.json();
708
+ STATE.activeTable = "Overall";
709
+ STATE.sortKey = "overall";
710
+ STATE.sortDirection = defaultSortDirection("overall");
711
+
712
+ buildSummary();
713
+ buildTabs();
714
+ buildFilters();
715
+ buildSortOptions();
716
+ render();
717
+
718
+ $("search").addEventListener("input", (event) => {
719
+ STATE.query = event.target.value;
720
+ render();
721
+ });
722
+ $("model-type").addEventListener("change", (event) => {
723
+ STATE.modelType = event.target.value;
724
+ render();
725
+ });
726
+ $("sort-by").addEventListener("change", (event) => {
727
+ STATE.sortKey = event.target.value;
728
+ STATE.sortDirection = defaultSortDirection(STATE.sortKey);
729
+ render();
730
+ });
731
+ } catch (error) {
732
+ document.querySelector(".page").innerHTML =
733
+ `<div class="error">${error.message}</div>`;
734
+ }
735
+ }
736
+
737
+ init();
738
+ </script>
739
+ </body>
740
+ </html>
leaderboard/scripts/build_from_source_data.py ADDED
@@ -0,0 +1,184 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Build Space leaderboard data from the external source JSON."""
3
+
4
+ from __future__ import annotations
5
+
6
+ import argparse
7
+ import json
8
+ from pathlib import Path
9
+
10
+
11
+ DEFAULT_SOURCE = Path("/paddle/project/wild_omnidocbench/dataset_new/leaderboard_data.json")
12
+ DEFAULT_OUT_DIR = Path(__file__).resolve().parents[1] / "data"
13
+
14
+ TABLE_ORDER = [
15
+ ("overall", "Overall"),
16
+ ("scanning", "Scanning"),
17
+ ("warping", "Warping"),
18
+ ("screen-photography", "Screen-Photography"),
19
+ ("illumination", "Illumination"),
20
+ ("skew", "Skew"),
21
+ ]
22
+
23
+ SCENARIO_KEY_MAP = {
24
+ "screen-photography": "screen_photography",
25
+ }
26
+
27
+ MODEL_TYPE_LABELS = {
28
+ "pipeline": "Pipeline Tools",
29
+ "general": "General VLMs",
30
+ "specialized": "Specialized VLMs",
31
+ }
32
+
33
+ METRIC_DIRECTIONS = {
34
+ "overall": "higher",
35
+ "scanning": "higher",
36
+ "warping": "higher",
37
+ "screen_photography": "higher",
38
+ "illumination": "higher",
39
+ "skew": "higher",
40
+ "text": "higher",
41
+ "formula": "higher",
42
+ "table": "higher",
43
+ "read_order": "higher",
44
+ }
45
+
46
+ METRIC_LABELS = {
47
+ "overall": "Overall",
48
+ "scanning": "Scanning",
49
+ "warping": "Warping",
50
+ "screen_photography": "Screen-Photography",
51
+ "illumination": "Illumination",
52
+ "skew": "Skew",
53
+ "text": "Text",
54
+ "formula": "Formula",
55
+ "table": "Table",
56
+ "read_order": "ReadOrder",
57
+ }
58
+
59
+
60
+ def normalize_key(key: str) -> str:
61
+ key = SCENARIO_KEY_MAP.get(key, key)
62
+ return key.replace("-", "_")
63
+
64
+
65
+ def model_type_label(value: object) -> str:
66
+ text = str(value or "-").strip()
67
+ return MODEL_TYPE_LABELS.get(text.lower(), text)
68
+
69
+
70
+ def normalize_overall_row(row: dict[str, object]) -> dict[str, object]:
71
+ return {
72
+ "model_type": model_type_label(row.get("type")),
73
+ "method": row.get("model", ""),
74
+ "parameters": row.get("params", "-"),
75
+ "overall": row.get("overall", ""),
76
+ "scanning": row.get("scanning", ""),
77
+ "warping": row.get("warping", ""),
78
+ "screen_photography": row.get("screen-photography", ""),
79
+ "illumination": row.get("illumination", ""),
80
+ "skew": row.get("skew", ""),
81
+ }
82
+
83
+
84
+ def normalize_scenario_row(
85
+ row: dict[str, object],
86
+ overall_lookup: dict[str, dict[str, object]],
87
+ ) -> dict[str, object]:
88
+ method = str(row.get("model", ""))
89
+ metadata = overall_lookup.get(method, {})
90
+ return {
91
+ "model_type": model_type_label(metadata.get("type")),
92
+ "method": method,
93
+ "parameters": metadata.get("params", "-"),
94
+ "overall": row.get("overall", ""),
95
+ "text": row.get("Text", ""),
96
+ "formula": row.get("Formula", ""),
97
+ "table": row.get("Table", ""),
98
+ "read_order": row.get("ReadOrder", ""),
99
+ }
100
+
101
+
102
+ def build_payload(source: dict[str, object]) -> dict[str, object]:
103
+ overall_rows = source.get("overall")
104
+ if not isinstance(overall_rows, list):
105
+ raise ValueError("Source JSON must contain an 'overall' list")
106
+ overall_lookup = {str(row.get("model", "")): row for row in overall_rows if isinstance(row, dict)}
107
+
108
+ tables: list[dict[str, object]] = []
109
+ for source_key, title in TABLE_ORDER:
110
+ rows = source.get(source_key)
111
+ if not isinstance(rows, list):
112
+ raise ValueError(f"Source JSON must contain a {source_key!r} list")
113
+
114
+ if source_key == "overall":
115
+ headers = [
116
+ "model_type",
117
+ "method",
118
+ "parameters",
119
+ "overall",
120
+ "scanning",
121
+ "warping",
122
+ "screen_photography",
123
+ "illumination",
124
+ "skew",
125
+ ]
126
+ normalized_rows = [normalize_overall_row(row) for row in rows if isinstance(row, dict)]
127
+ else:
128
+ headers = [
129
+ "model_type",
130
+ "method",
131
+ "parameters",
132
+ "overall",
133
+ "text",
134
+ "formula",
135
+ "table",
136
+ "read_order",
137
+ ]
138
+ normalized_rows = [
139
+ normalize_scenario_row(row, overall_lookup) for row in rows if isinstance(row, dict)
140
+ ]
141
+
142
+ tables.append(
143
+ {
144
+ "name": title,
145
+ "slug": normalize_key(source_key),
146
+ "headers": headers,
147
+ "rows": normalized_rows,
148
+ }
149
+ )
150
+
151
+ return {
152
+ "benchmark": "Real5-OmniDocBench",
153
+ "source": str(DEFAULT_SOURCE),
154
+ "tables": tables,
155
+ "metrics": {
156
+ key: {"label": METRIC_LABELS[key], "direction": direction}
157
+ for key, direction in METRIC_DIRECTIONS.items()
158
+ },
159
+ }
160
+
161
+
162
+ def main() -> None:
163
+ parser = argparse.ArgumentParser(description=__doc__)
164
+ parser.add_argument("--source", type=Path, default=DEFAULT_SOURCE)
165
+ parser.add_argument("--out-dir", type=Path, default=DEFAULT_OUT_DIR)
166
+ args = parser.parse_args()
167
+
168
+ source = json.loads(args.source.read_text(encoding="utf-8"))
169
+ payload = build_payload(source)
170
+
171
+ args.out_dir.mkdir(parents=True, exist_ok=True)
172
+ out_file = args.out_dir / "leaderboard_data.json"
173
+ out_file.write_text(
174
+ json.dumps(payload, ensure_ascii=False, indent=2) + "\n",
175
+ encoding="utf-8",
176
+ )
177
+
178
+ tables = payload["tables"]
179
+ total_rows = sum(len(table["rows"]) for table in tables if isinstance(table, dict))
180
+ print(f"Wrote {len(tables)} tables and {total_rows} rows to {out_file}")
181
+
182
+
183
+ if __name__ == "__main__":
184
+ main()