| """Render measured metrics into the §4 protocol-template tables. |
| |
| Per the design's integrity note, only the MapGS column is filled (with your |
| measured values); baseline columns are emitted as ``TBD`` and must be produced |
| by re-running each baseline — never pasted across datasets. |
| """ |
|
|
| from __future__ import annotations |
|
|
| from typing import Dict |
|
|
| FF_BASELINES = ["STORM", "DGGT", "PointForward", "TokenGS"] |
|
|
|
|
| def _fmt(x, nd=3): |
| if x != x: |
| return "n/a" |
| return f"{x:.{nd}f}" |
|
|
|
|
| def interpolation_table(by_dataset: Dict[str, Dict[str, float]]) -> str: |
| lines = ["### 4.2 Interpolation (held-out frames) — measured MapGS\n", |
| "| Dataset | PSNR↑ | SSIM↑ | LPIPS↓ | D-RMSE↓ (m) |", |
| "|---|---|---|---|---|"] |
| for ds, m in by_dataset.items(): |
| lines.append(f"| {ds} | {_fmt(m['PSNR'],2)} | {_fmt(m['SSIM'])} | " |
| f"{_fmt(m['LPIPS'])} | {_fmt(m['D-RMSE'])} |") |
| lines.append("\n_Baselines (STORM/DGGT/PointForward/TokenGS): TBD — re-run with verified provenance._") |
| return "\n".join(lines) |
|
|
|
|
| def extrapolation_table(sweep: Dict[float, Dict[str, float]], metric: str = "FID") -> str: |
| shifts = sorted(sweep.keys()) |
| direction = "higher is better" if metric in ("PSNR", "SSIM") else "lower is better" |
| header = "| Lateral shift (m) | " + " | ".join(FF_BASELINES) + " | MapGS | MapGS+TT |" |
| sep = "|" + "---|" * (len(FF_BASELINES) + 3) |
| lines = [f"### 4.3 Out-of-trajectory extrapolation — {metric} ({direction}), measured MapGS\n", |
| header, sep] |
| for sh in shifts: |
| base = " | ".join(["TBD"] * len(FF_BASELINES)) |
| val = _fmt(sweep[sh].get(metric, float("nan")), 2) |
| lines.append(f"| {sh:g} | {base} | {val} | TBD |") |
| lines.append("\n_Also reports PSNR/SSIM per shift; baseline + MapGS+TT columns: TBD._") |
| return "\n".join(lines) |
|
|
|
|
| def lane_table(m: Dict[str, float]) -> str: |
| return ("### 4.4 Semantic consistency — measured MapGS\n\n" |
| f"| Metric | MapGS |\n|---|---|\n" |
| f"| lane mIoU↑ (vs projected map) | {_fmt(m['lane_mIoU'])} |\n" |
| f"| rendered-lane reprojection (px)↓ | {_fmt(m['lane_chamfer_px'],2)} |\n\n" |
| "_CondLaneNet-based lane mIoU on real data: TBD._") |
|
|
|
|
| def write_report(path: str, interpolation=None, extrapolation=None, lane=None, header: str = ""): |
| parts = ["# MapGS evaluation report", |
| "", |
| "> All numbers are **measured on this run's data**. Baseline columns are TBD: " |
| "reproduce or cite-with-verified-provenance; never paste numbers across dataset columns.", |
| ""] |
| if header: |
| parts += [header, ""] |
| if interpolation is not None: |
| parts += [interpolation_table(interpolation), ""] |
| if extrapolation is not None: |
| parts += [extrapolation_table(extrapolation, "FID"), "", |
| extrapolation_table(extrapolation, "PSNR"), ""] |
| if lane is not None: |
| parts += [lane_table(lane), ""] |
| text = "\n".join(parts) |
| with open(path, "w") as fh: |
| fh.write(text) |
| return text |
|
|