from __future__ import annotations import argparse import json import subprocess import sys from pathlib import Path def main() -> int: parser = argparse.ArgumentParser(description="Generate benchmark-like HighlightBench synthetic tables.") parser.add_argument("--out-dir", default="benchmark_like_demo") parser.add_argument("--count", type=int, default=1) parser.add_argument("--seed", type=int, default=7) args = parser.parse_args() here = Path(__file__).resolve().parent cmd = [ sys.executable, str(here / "paper_table.py"), "--out-dir", args.out_dir, "--count", str(args.count), "--seed", str(args.seed), "--canvas-width", "1600", "--canvas-height", "900", "--table-shape-mode", "mixed", "--top-levels", "random", "--left-levels", "random", "--line-style", "sparse-grid", "--block-sep", "--highlight", "--highlight-mode", "multi", "--highlight-rate", "0.16", "--underline-image-prob", "0.7", "--underline-rate", "0.08", "--bold-image-prob", "0.7", "--bold-rate", "0.06", "--missing-prob", "0.05", "--metric-arrow-prob", "0.35", "--qa-cell-lookup", "--qa-col-argmax-item", "--qa-topk", "--qa-topk-cols", "1", "--qa-highlight-neighbor", "--qa-same-color", "--qa-underline", "--qa-bold", "--qa-missing-list", "--qa-filter-highlight-threshold", "--qa-filter-samples", "1", "--gt-format", "jsonl", ] subprocess.check_call(cmd) out = Path(args.out_dir) qa_path = out / "qa.jsonl" compact_path = out / "qa_compact.jsonl" if qa_path.exists(): with qa_path.open(encoding="utf-8") as src, compact_path.open("w", encoding="utf-8") as dst: for line in src: if not line.strip(): continue row = json.loads(line) compact = { "qid": row.get("qid"), "image_path": row.get("image_path"), "question": row.get("question"), "answer": row.get("answer"), } dst.write(json.dumps(compact, ensure_ascii=False, separators=(",", ":")) + "\n") print(out / "images" / "img_00001.png") print(compact_path) print(out / "gt.jsonl") return 0 if __name__ == "__main__": raise SystemExit(main())