Download PROJECT/tools/readme_builder.py from Dhruv1000/TSRDA: direct link, hf CLI and curl.
- Browser
- Download file 31.9 kB
-
https://huggingface.co/Dhruv1000/TSRDA/resolve/main/PROJECT/tools/readme_builder.py
- Command line
-
hf download hf://Dhruv1000/TSRDA/PROJECT/tools/readme_builder.py
-
curl -L -o readme_builder.py https://huggingface.co/Dhruv1000/TSRDA/resolve/main/PROJECT/tools/readme_builder.py
31.9 kB
| """Builds the repository front page (README.md). Called by make_reports.root_readme(). | |
| Rules this file follows (same as the rest of the pipeline): | |
| * every measured number is read from a result file through the readers passed in as `MR` | |
| (make_reports) or make_figures; no score is typed here; | |
| * the interpretation text is written to say only what those numbers support; | |
| * unfinished work is labelled, never estimated. | |
| """ | |
| import numpy as np | |
| HEADER = """--- | |
| tags: | |
| - pytorch | |
| - remote-sensing | |
| - satellite-time-series | |
| - crop-mapping | |
| - semantic-segmentation | |
| - sentinel-2 | |
| - self-supervised-learning | |
| - pastis | |
| - mtlcc | |
| - planteur | |
| metrics: | |
| - mIoU | |
| - f1 | |
| - accuracy | |
| - kappa | |
| --- | |
| """ | |
| def build(MR, F, tail_md): | |
| fmt = MR.fmt | |
| main = MR.mtlcc_main() | |
| seeds = MR.mtlcc_seeds() | |
| sv = [seeds[s]["ema"]["mIoU"] for s in seeds if seeds[s].get("ema")] | |
| sv_m, sv_sd = (float(np.mean(sv)), float(np.std(sv, ddof=1))) if len(sv) > 1 else (None, None) | |
| abl = {a["name"]: a for a in MR.mtlcc_ablations() if a["test"].get("ema")} | |
| ab = {k: v["test"]["ema"]["mIoU"] for k, v in abl.items()} | |
| ref = main.get("test_ema", {}).get("stcln", {}).get("mIoU") if main else None | |
| bl = MR.jload(MR.B / "results/mtlcc/summary.json", []) or [] | |
| stw = next((r for r in bl if r["key"] == "stcln_wp"), None) | |
| stn = next((r for r in bl if r["key"] == "stcln"), None) | |
| rows = MR.curve() | |
| plan, pend = MR.planteur_pending() | |
| m4 = MR.mask04_progress() | |
| pb = (MR.jload(MR.B / "results/planteur/summary.json", {}) or {}).get("baselines", []) | |
| pr = F.pastis_rows() | |
| _fdm = MR.foundation() if hasattr(MR, "foundation") else None | |
| FS = _fdm.summary() if _fdm else {} | |
| _busy = bool(MR.running()) or any(not b["done"] for b in (_fdm.branch_state() if _fdm else [])) | |
| _state = ("Experiments are still running." if _busy else | |
| "**All queued experiments have finished** — nothing is running; what has not been started is listed in " | |
| "[`REPORTS/07_STATUS.md`](REPORTS/07_STATUS.md).") | |
| L = [HEADER, | |
| "# T-SRDA — crop mapping on satellite image time series", "", | |
| "**T**emporal **S**patial-**R**eduction **D**ual **A**ttention: a spatio-temporal network for Sentinel-2 time " | |
| "series, pre-trained without labels and fine-tuned on few. Evaluated against the nine methods of the STCLN " | |
| "paper on **MTLCC**, **PLANTEUR** and **PASTIS**.", "", | |
| f"*Snapshot {MR.NOW}. {_state} Every number on this page is read from a result file in " | |
| "this repository by [`TOOLS/make_reports.py`](TOOLS/make_reports.py); unfinished work is labelled, never " | |
| "estimated.*", "", | |
| "| | |", "|---|---|", | |
| "| 📖 **One-page project summary** | [`REPORTS/00_OVERVIEW.md`](REPORTS/00_OVERVIEW.md) |", | |
| "| 🔴 **What is running / queued / not started** | [`REPORTS/07_STATUS.md`](REPORTS/07_STATUS.md) |", | |
| "| 📄 **The manuscript (working draft)** | [`PAPER/main.pdf`](PAPER/main.pdf) |", | |
| "| 🛟 **Lost the VM? Rebuild it** | [`RESTORE/RESTORE.md`](RESTORE/RESTORE.md) — one script restores code, checkpoints and context |", | |
| "| 🤖 **Brief for Claude Code** | [`CLAUDE.md`](CLAUDE.md) · chat history in [`HISTORY/`](HISTORY) |", ""] | |
| # ------------------------------------------------------------------ verdict | |
| L += ["## The short answer", ""] | |
| if ref and sv_m is not None and stw: | |
| gap = sv_m - stw["mIoU"] | |
| L += [f"**On the evidence in this repository, T-SRDA does not decisively surpass the strongest baseline.** " | |
| f"On MTLCC it scores **{sv_m:.4f} ± {sv_sd:.4f}** (3 fine-tuning seeds) against STCLN_wp's " | |
| f"**{stw['mIoU']:.4f}** — a lead of {gap:+.4f}, about {gap / sv_sd:.1f} seed standard deviations from one " | |
| "baseline run — and the lead disappears when T-SRDA is trained with STCLN's own loss " | |
| f"({fmt(ab.get('plain_ce'))}). What T-SRDA clearly does is turn masked pre-training into a very large " | |
| f"gain: removing it costs **{fmt(ref - ab['scratch_R4'])} mIoU**." if "scratch_R4" in ab else "", | |
| "", "| Claim | Verdict | Where |", "|---|---|---|", | |
| "| Pre-training is what makes the model strong | ✅ **Supported** — the largest effect measured | [MTLCC ablations](#ablations-mtlcc) |", | |
| "| T-SRDA beats the nine STCLN-paper methods on MTLCC | ⚠️ **Level with STCLN_wp, ahead of the rest** — but most of the lead over un-pre-trained baselines is the pre-training | [MTLCC](#mtlcc) |", | |
| "| The temporal-reduction block is the reason it works | ❓ **Not yet tested** — the swap against window / full attention with the pre-trained encoder in place has not been run | [Open work](#honest-limits) |", | |
| "| The temporal reduction is free | ❌ **Not supported** — at an equal from-scratch budget R = 1 beats R = 4 | [MTLCC ablations](#ablations-mtlcc) |", | |
| ("| T-SRDA is label-efficient on PLANTEUR | ⏳ **Partly measured** — curve done up to " + max((f"{r['frac']:.0%}" for r in rows), key=lambda x: int(x[:-1])) + " of the labels, the 100 % point pending; baselines only at 100 % | [PLANTEUR](#planteur) |" | |
| if MR.planteur_full() is None else | |
| "| T-SRDA leads the reproduced baselines on PLANTEUR at equal labels | ⚠️ **One seed** — at 100 % labels T-SRDA scores " | |
| f"{MR.planteur_full():.4f} vs {(max(pb, key=lambda x: x['mIoU'])['mIoU'] if pb else float('nan')):.4f} for the best reproduced baseline ({(max(pb, key=lambda x: x['mIoU'])['model'] if pb else '?')}); the curve (2–100 %) is complete | [PLANTEUR](#planteur) |"), | |
| "| T-SRDA beats STCLN on PASTIS | ❌ **Cannot be claimed** — the numbers are ensembles with external weights and a re-inspected test fold | [PASTIS](#pastis) |"] | |
| if FS.get("mtlcc"): | |
| _m = FS["mtlcc"] | |
| L.append(f"| The PASTIS enhancements (frozen TESSERA readout, branches, nested ensembles) transfer to MTLCC / PLANTEUR | " | |
| f"⚠️ **The TESSERA readout does; the PASTIS branches do not** — MTLCC {_m['core']:.4f} → {_m['best']['test']:.4f} " | |
| f"with TESSERA (val-selected), {_m['ens3']:.4f} without; the gain is the external encoder's, not T-SRDA's | " | |
| "[Enhancement track](#enhancement-track-pastis-components-on-mtlcc-and-planteur) |") | |
| L += [""] | |
| # ------------------------------------------------------------------ architecture | |
| L += ["## The architecture", "", | |
| "", "", | |
| "T-SRDA has two separable halves. **A spatial encoder** turns every acquisition into a feature map. " | |
| "**A temporal encoder** then mixes those maps across time, independently at every pixel. Pre-training and " | |
| "fine-tuning reuse both halves; only the heads differ.", "", | |
| "### 1 · Spatial encoder (per acquisition)", "", | |
| "A dilated-convolution stem followed by an **atrous spatial pyramid (ASPP, dilation rates 1, 2, 4)** and a " | |
| "squeeze-and-excitation gate. Atrous convolutions widen the receptive field without down-sampling, so the " | |
| "output keeps full spatial resolution — important for small parcels. Each acquisition becomes a " | |
| "256-channel map.", "", | |
| "### 2 · Temporal SRDA encoder (per pixel, across time)", "", | |
| "Plain self-attention over T acquisitions costs O(T²·D) per pixel sequence. The SRDA block gets a *global* " | |
| "temporal receptive field for a fraction of that:", "", | |
| "1. **Add the acquisition-date encoding first.** Irregular acquisition dates carry meaning; they must exist " | |
| "before anything is grouped.", | |
| "2. **Reduce the key/value path.** A point-wise linear layer shrinks each step from d to d/R; then R " | |
| "consecutive steps are concatenated back to width d, giving **T/R tokens**.", | |
| "3. **Self-attend on the T/R tokens** (the keys \"check themselves\").", | |
| "4. **Cross-attend from all T queries** to the T/R keys and values. The attention matrix is T × T/R, so " | |
| "every acquisition still reaches every other one — a global receptive field in one block — at cost " | |
| "**O(T²·D / R)**.", | |
| "5. A **convolution-augmented MLP** (FC → GELU with a parallel depth-wise Conv1d over time → FC) mixes " | |
| "channels and smooths locally in time.", "", | |
| "Three such blocks are stacked (R = 4, 8 heads, d = 256; **6.02 M parameters** in total). The block adapts " | |
| "the spatial-reduction dual attention of PDAViT to the time axis; the reference is still to be verified " | |
| "(see [open work](#honest-limits)).", "", | |
| "", "", | |
| "| Attention variant | Attention matrix | Entries at T = 12 | Global in one block? |", "|---|---|---|---|", | |
| "| Full self-attention | T × T | 144 | yes |", | |
| "| Window attention | T × w, stacked and shifted | – | only after several layers |", | |
| "| **SRDA, R = 4** | **T × T/R** | **36** | **yes** |", "", | |
| "### 3 · Pre-training (no labels)", "", | |
| "Masked reconstruction: acquisitions are hidden and the network reconstructs them. The mask is gated by NDVI " | |
| "**per frame**, which is what the released STCLN code does (a per-pixel gate would hide 18 % of values " | |
| "instead of 4 %). A deep-supervision head reconstructs from the intermediate features as well.", "", | |
| "### 4 · Fine-tuning (few labels)", "", | |
| "An attention pool collapses the time axis (STA), then **two decoders** predict class logits and a " | |
| "field-edge map; a **gated refinement** step lets the edge evidence sharpen the class map. Objective: " | |
| "cross-entropy + 0.75 Lovász + 0.5 boundary BCE with label smoothing 0.05; AdamW (weight decay 0.02), " | |
| "encoder learning rate × 0.5, 3 warm-up epochs then cosine decay, EMA of the weights (0.999).", "", | |
| "> **Honest note on the loss.** The ablations below show that part of T-SRDA's score comes from this " | |
| "fine-tuning recipe, not the architecture: with STCLN's plain cross-entropy the score drops. That is a " | |
| "recipe effect and is reported as one.", ""] | |
| # ------------------------------------------------------------------ results | |
| L += ["## Results on the three datasets", "", | |
| "| Dataset | Task | Labelled data | Metric reported |", "|---|---|---|---|", | |
| "| **MTLCC** | 18 crop classes, 48 × 48 tiles, 13 bands | 78 tiles | mIoU, OA, mF1 (STCLN protocol) |", | |
| "| **PLANTEUR** | 8 tropical crop classes, 128 × 128, 10 bands | 2 % – 100 % of 1,896 patches | mIoU-8 |", | |
| "| **PASTIS** | 18 crop classes, 128 × 128, 10 bands | 76 training entries (STCLN config) | mIoU |", "", | |
| "### MTLCC", ""] | |
| if bl: | |
| L += ["", "", | |
| "| Order | Method | Params | val mIoU | test OA | **test mIoU** | test mF1 |", "|---|---|---|---|---|---|---|"] | |
| rowsb = [] | |
| for r in bl: | |
| v = r.get("mIoU") | |
| if r["key"] == "tsrda" and sv_m is not None: | |
| rowsb.append((sv_m, f"**T-SRDA** (3-seed mean ± sd)", r)) | |
| else: | |
| rowsb.append((v, r["model"], r)) | |
| rowsb.sort(key=lambda x: -(x[0] or 0)) | |
| for i, (v, name, r) in enumerate(rowsb, 1): | |
| if r["key"] == "tsrda" and sv_m is not None: | |
| L.append(f"| {i} | {name} | {fmt(r.get('params_M'), 2)} M | {fmt(r.get('val_mIoU'))} | {fmt(r.get('OA'))} | " | |
| f"**{sv_m:.4f} ± {sv_sd:.4f}** | {fmt(r.get('mF1'))} |") | |
| else: | |
| L.append(f"| {i} | {name} | {fmt(r.get('params_M'), 2)} M | {fmt(r.get('val_mIoU'))} | {fmt(r.get('OA'))} | " | |
| f"{fmt(v)} | {fmt(r.get('mF1'))} |") | |
| L += ["", "*Order is by test mIoU; it is not a ranking of significance — T-SRDA's lead over STCLN_wp is inside the noise " | |
| "(see [the short answer](#the-short-answer)).*", "", "T-SRDA's OA / mF1 / val columns are the seed-3407 run; its mIoU is the 3-seed mean. Baselines are our " | |
| "runs at the learning rate chosen on validation, one seed each. Seed-by-seed numbers: " | |
| "[`REPORTS/01_MTLCC.md`](REPORTS/01_MTLCC.md). Reproduction of the paper's own table: " | |
| "[`REPORTS/03_BASELINE_REPRODUCTION.md`](REPORTS/03_BASELINE_REPRODUCTION.md) — for STCLN_wp our harness " | |
| "reproduces the published 0.6953 exactly at the paper's learning rate.", ""] | |
| L += ["### PLANTEUR", "", | |
| "", "", | |
| "| Labelled patches | Seeds | val mIoU-8 | **test mIoU-8** | test OA | test mF1 |", "|---|---|---|---|---|---|"] | |
| for r in rows: | |
| L.append(f"| {r['frac']:.0%} ({r['n_patches']}) | {r['n']} | {r['val']} | **{r['test']}** | {r['oa']} | {r['mf1']} |") | |
| short = [f"{r['frac']:.0%}: {r['n']} of 3 seeds" for r in rows if r["frac"] <= 0.25 and r["n"] < 3] | |
| if short: | |
| L += ["", "*Still running — " + "; ".join(short) + " (mean ± sd over the seeds finished so far).*"] | |
| _have = {round(r["frac"], 2) for r in rows} | |
| _miss = [f"{int(f * 100)} %" for f in (0.5, 1.0) if round(f, 2) not in _have] | |
| L += ["", f"{len(plan) - len(pend)} of {len(plan)} planned fine-tunes are complete" | |
| + (f"; the {' and '.join(_miss)} point{'s are' if len(_miss) > 1 else ' is'} pending and absent from the table, not estimated." if _miss else "."), "", | |
| "**Baselines on PLANTEUR (100 % of the labels, our runs):**", "", | |
| "| Method | Params | val mIoU-8 | test OA | **test mIoU-8** | test mF1 |", "|---|---|---|---|---|---|"] | |
| for b in sorted(pb, key=lambda x: -x["mIoU"]): | |
| L.append(f"| {b['model']} | {fmt(b.get('params_M'), 2)} M | {fmt(b.get('val'))} | {fmt(b.get('OA'))} | " | |
| f"**{fmt(b['mIoU'])}** | {fmt(b.get('mF1'))} |") | |
| _full = MR.planteur_full() | |
| if _full is None: | |
| L += ["", "> T-SRDA and the baselines are **not** compared at the same label budget: the baselines have only a " | |
| "100 % run, and T-SRDA's 100 % run is pending. The same-budget comparison is queued. Read the curve as " | |
| "label-efficiency evidence for T-SRDA alone. Details: [`REPORTS/02_PLANTEUR.md`](REPORTS/02_PLANTEUR.md).", ""] | |
| else: | |
| _bb = max(pb, key=lambda x: x["mIoU"]) if pb else None | |
| L += ["", f"> **Same-budget row:** at 100 % of the labels T-SRDA scores **{_full:.4f}** test mIoU-8" | |
| + (f", {_full - _bb['mIoU']:+.4f} against the best reproduced baseline ({_bb['model']}, {_bb['mIoU']:.4f})" if _bb else "") | |
| + ". T-SRDA is self-supervised pre-trained on the training-fold imagery and the baselines are not, so the row compares two recipes, not two architectures. It is also a **single seed** (the 2–25 % points have three): a lead in one run, not an established ranking. " | |
| "The lower-budget points are still not ranked against baselines trained on all labels. " | |
| "Details: [`REPORTS/02_PLANTEUR.md`](REPORTS/02_PLANTEUR.md).", ""] | |
| L += [ | |
| "### PASTIS", "", | |
| "", "", | |
| "| Method | val mIoU | test mIoU | Status |", "|---|---|---|---|", | |
| "| STCLN (published) | – | 0.4501 | paper, Table 6 |", | |
| "| STCLN_wp (published) | – | 0.4843 | paper, Table 6 |"] | |
| lab = {"Original SAM optimizer network": ("T-SRDA, earlier single network", "historical; test fold inspected repeatedly"), | |
| "Historical foundation ensemble": ("T-SRDA, ensemble + external encoder, validation-selected", "ensemble; external weights; test fold inspected"), | |
| "5×5 feature mean + standard deviation, blended": ("T-SRDA, ensemble + external encoder, best test score seen", "ensemble; external weights; **not a validation-selected result**")} | |
| for k, (n, st) in lab.items(): | |
| v, t = pr.get(k, (None, None)) | |
| if t: | |
| L.append(f"| {n} | {v:.4f} | {t:.4f} | {st} |") | |
| L += ["", "The PASTIS work predates the other two studies and is kept unchanged in [`PASTIS/`](PASTIS). Its best figures " | |
| "are ensembles that include a frozen, externally pre-trained component whose geographic overlap with the test " | |
| "region is uncertified, and the test fold was inspected repeatedly while variants were explored. **They cannot " | |
| "carry an architecture claim.** The one number that is a single network — the earlier single-network row — " | |
| "sits slightly *below* the published STCLN_wp. Full account: [`REPORTS/04_PASTIS.md`](REPORTS/04_PASTIS.md).", ""] | |
| # ------------------------------------------------------------------ enhancement (foundation) track | |
| if FS.get("mtlcc"): | |
| _m = FS["mtlcc"]; _p = FS.get("planteur"); _pl = FS.get("planteur_ladder") | |
| L += ["## Enhancement track: PASTIS components on MTLCC and PLANTEUR", "", | |
| "The components that lifted T-SRDA on PASTIS — a **frozen, externally pre-trained TESSERA v2** temporal " | |
| "Transformer read out by a **shrinkage-covariance Gaussian** on a 768-D 5×5 local-moment descriptor, SAM / " | |
| "refinement / structured-SSL / temporal-CNN branches, cosine-cluster and original-Gaussian readouts, " | |
| "three-pass feature-affinity diffusion, entropy-weighted and nested ensembles — were ported to the other two " | |
| "datasets, reusing the PASTIS code. Every weight, temperature and member was chosen on **validation**; test " | |
| "was scored once per system. **Ext** = uses the external TESSERA encoder (not available to any baseline).", "", | |
| "| System | Ext | MTLCC val | MTLCC test | Δ core | Δ STCLN_wp (official lr, 0.6953) |", "|---|---|---|---|---|---|"] | |
| _rows = [("core T-SRDA (one network)", "no", _m["core_val"], _m["core"]), | |
| ("TESSERA Gaussian alone (no T-SRDA)", "yes", _m["v_tess"], _m["tess_alone"]), | |
| ("core + TESSERA Gaussian", "yes", _m["v_net_g"], _m["net_g"]), | |
| ("3-seed T-SRDA ensemble (fixed average)", "no", _m["v_ens3"], _m["ens3"]), | |
| ("3-seed ensemble + TESSERA Gaussian", "yes", _m["v_ens3_g"], _m["ens3_g"]), | |
| ("best without external features by validation (greedy; over-fits the 78 val entries)", "no", _m["best_noext"]["val"], _m["best_noext"]["test"]), | |
| ("**best overall, val-selected** (" + _m["best"]["system"] + ")", "yes", _m["best"]["val"], _m["best"]["test"])] | |
| for n, e, v, t in _rows: | |
| L.append(f"| {n} | {e} | {fmt(v)} | {t:.4f} | {t - _m['core']:+.4f} | {t - _m['base']:+.4f} |") | |
| if _p and _p.get("frac"): | |
| L += ["", "| PLANTEUR labels | Seeds | T-SRDA alone | TESSERA Gaussian alone | Blend (val-selected) |", "|---|---|---|---|---|"] | |
| for fr, a, g, b, n in _p["frac"]: | |
| L.append(f"| {fr:.0%} | {n} | {a:.4f} | {g:.4f} | **{b:.4f}** |") | |
| if _p.get("base"): | |
| L += ["", f"*Strongest reproduced PLANTEUR baseline at 100 % labels: {_p['base']['model']} {_p['base']['mIoU']:.4f}. " | |
| "The published fine-tuned OlmoEarth v1.2 (40.82, transcribed) stays above every row here.*"] | |
| if _pl and not _pl.get("_partial"): | |
| _R = {r["system"]: r for r in _pl["rows"]}; _sb = _pl["strongest_baseline"] | |
| _first = lambda pre: next(r for k, r in _R.items() if k.startswith(pre)) | |
| _sel = [("core T-SRDA", "no", _R["core T-SRDA"]), | |
| ("core + SAM net", "no", next(r for r in _pl["rows"] if r["system"] == "core + sam")), | |
| ("core + structured-SSL net", "no", next(r for r in _pl["rows"] if r["system"] == "core + structured")), | |
| ("core + cosine-cluster readout", "no", next(r for r in _pl["rows"] if r["system"] == "core + cluster")), | |
| ("4-network T-SRDA ensemble (core, refinement, SAM, structured)", "no", _first("4-network T-SRDA ensemble (")), | |
| ("best T-SRDA-only ensemble (greedy on validation)", "no", _first("best T-SRDA-only")), | |
| ("TESSERA 768-D moments LDA alone", "yes", _R["tess768_lda alone"]), | |
| ("core + TESSERA moments LDA (50/50, τ on val)", "yes", _first("core 50/50 TESSERA 768-D")), | |
| ("entropy-weighted 7-branch ensemble (PASTIS rule)", "yes", _first("entropy-weighted")), | |
| ("PASTIS historical 58.63 recipe, core-rooted (fixed weights)", "yes", _first("core-rooted historical")), | |
| ("greedy over all components (val-selected)", "yes", _first("greedy ensemble over ALL")), | |
| ("**greedy + diffusion** (best on validation)", "yes", _first("greedy ensemble + diffusion"))] | |
| _c = _R["core T-SRDA"]["test"] | |
| L += ["", f"### PLANTEUR enhancement ladder (100 % labels, one seed) — {len(_pl['rows'])} systems evaluated", "", | |
| "| System | Ext | Val | Test | Δ core | Δ " + _sb["name"].split(",")[0] + " |", "|---|---|---|---|---|---|"] | |
| for n, e, r in _sel: | |
| L.append(f"| {n} | {e} | {r['val']:.4f} | {r['test']:.4f} | {r['test'] - _c:+.4f} | {r['test'] - _sb['test']:+.4f} |") | |
| L += ["", "", ""] | |
| L += ["", "**Reading.** On MTLCC the TESSERA readout *alone* is level with the fine-tuned T-SRDA, and the blend of the two " | |
| "is clearly better than either: the gain over the baselines comes from the **external encoder**, not from the " | |
| "T-SRDA architecture. Without external features the best reliable number is the plain 3-seed ensemble; the " | |
| "PASTIS branches (SAM, refinement, structured SSL, CNNs, cluster readout) add nothing measurable on MTLCC and the " | |
| "fixed PASTIS ensemble weights lower the score. On PLANTEUR the TESSERA readout dominates at small label " | |
| "budgets and complements T-SRDA at 50–100 %. " | |
| + (("On the complete PLANTEUR ladder the T-SRDA-only ensemble adds about +0.012 over the core network, the TESSERA " | |
| "readout adds +0.015 to +0.023 on top, and the PASTIS fixed-weight recipes score *below* the core " | |
| "(0.31–0.35): the branch networks are individually no better than the core, and the diverse, " | |
| "externally pre-trained readouts are what help. Both greedy rows are selected on a small one-seed " | |
| "validation set and are upper estimates. The published OlmoEarth result (0.4082) remains higher." if not _pl.get("_partial") else | |
| "A partial PLANTEUR ladder (without the structured-SSL branch) is in the report; the full one follows when that branch finishes.") if _pl else | |
| "The PLANTEUR ports of the branch networks are still training; the PLANTEUR ladder runs when they finish.") | |
| + f" Full tables ({_m['n_rows']}-row MTLCC ladder, per-run PLANTEUR selections, branch status): " | |
| "[`REPORTS/08_FOUNDATION_TRACK.md`](REPORTS/08_FOUNDATION_TRACK.md); code and results in [`FOUNDATION/`](FOUNDATION).", ""] | |
| # ------------------------------------------------------------------ ablations | |
| L += ["## Ablations (MTLCC)", "", | |
| "", "", | |
| "", ""] | |
| if ref and ab: | |
| L += ["| Run | What changes | test mIoU (EMA) | Δ vs reference | Reading |", "|---|---|---|---|---|", | |
| f"| **full recipe** | reference (pre-trained encoder, R = 4, loss as described above) | **{fmt(ref)}** | – | 3-seed mean {sv_m:.4f} ± {sv_sd:.4f} |"] | |
| notes = {"scratch_R4": ("no pre-training (random encoder)", "**The largest effect measured.** Self-supervised pre-training carries most of the accuracy."), | |
| "scratch_R1": ("no pre-training **and** R = 1 (full-resolution keys/values)", "Read against `scratch_R4`: R = 1 is *better* by " | |
| + (f"{ab['scratch_R1'] - ab['scratch_R4']:+.4f}" if "scratch_R4" in ab else "–") + " from scratch — the reduction is a cost–accuracy trade, not free. R = 1 is also the larger net."), | |
| "plain_ce": ("plain cross-entropy instead of CE + Lovász + boundary + smoothing", "Our loss is worth this much; with STCLN's objective T-SRDA falls below STCLN_wp."), | |
| "no_boundary": ("boundary-loss weight 0", "Null result — inside the seed spread; the signs disagree across raw / EMA / validation.")} | |
| for k in ("scratch_R4", "scratch_R1", "plain_ce", "no_boundary"): | |
| if k in ab: | |
| base = ab["scratch_R4"] if k == "scratch_R1" and "scratch_R4" in ab else ref | |
| L.append(f"| `{k}` | {notes[k][0]} | {fmt(ab[k])} | {ab[k] - ref:+.4f} | {notes[k][1]} |") | |
| L += ["", f"One seed per ablation row; the seed spread of the reference is ±{sv_sd:.4f}. " | |
| "No ablation attributes accuracy to the T-SRDA *temporal encoder itself*: pre-training and architecture " | |
| "still vary together. Full table, validation scores and caveats: [`REPORTS/01_MTLCC.md`](REPORTS/01_MTLCC.md).", ""] | |
| # ------------------------------------------------------------------ evidence | |
| L += ["## What the evidence supports — and what it does not", "", | |
| "**Supported by measurement**", "", | |
| "* T-SRDA with masked pre-training is a strong model: it is level with the strongest baseline on MTLCC and ahead " | |
| "of the other methods run here.", | |
| "* The pre-training is responsible for most of that strength (largest ablation).", | |
| "* Label efficiency on PLANTEUR: mIoU-8 rises steadily with the label share, with small seed spread."] | |
| if stn and "scratch_R4" in ab: | |
| L.append(f"* **Without pre-training T-SRDA is not better than the baselines**: trained from scratch it reaches " | |
| f"{fmt(ab['scratch_R4'])} (R = 4) / {fmt(ab.get('scratch_R1'))} (R = 1), against {fmt(stn['mIoU'])} " | |
| "for STCLN trained from scratch (recipes differ, so this is indicative, not a clean comparison).") | |
| L += ["", "**Not supported (yet)**", "", | |
| "* That the T-SRDA temporal block is what makes it work — the controlled swap has not been run.", | |
| "* A large margin over the state of the art. On MTLCC the margin over STCLN_wp is inside noise and disappears " | |
| "under STCLN's loss; on PASTIS the strong numbers are not clean; on PLANTEUR the budgets do not yet match.", | |
| "* That the spatial reduction is free.", "", | |
| "The manuscript states these limits in the same words; see [`PAPER/`](PAPER).", ""] | |
| # ------------------------------------------------------------------ reports index | |
| L += ["## All reports", "", | |
| "| Report | What it answers |", "|---|---|", | |
| "| [`00_OVERVIEW`](REPORTS/00_OVERVIEW.md) | The whole project on one page |", | |
| "| [`01_MTLCC`](REPORTS/01_MTLCC.md) | Protocol, headline run, seed variance, ablations, mask-ratio check, nine-method table |", | |
| "| [`02_PLANTEUR`](REPORTS/02_PLANTEUR.md) | Label-efficiency curve, baselines, per-class scores |", | |
| "| [`03_BASELINE_REPRODUCTION`](REPORTS/03_BASELINE_REPRODUCTION.md) | Why our baseline numbers differ from the published table |", | |
| "| [`04_PASTIS`](REPORTS/04_PASTIS.md) | What the stored PASTIS numbers actually are |", | |
| "| [`05_RUN_INVENTORY`](REPORTS/05_RUN_INVENTORY.md) | Every run: seed, epochs, scores, log |", | |
| "| [`06_REPRODUCIBILITY`](REPORTS/06_REPRODUCIBILITY.md) | Environment, commits, how to rerun |", | |
| "| [`07_STATUS`](REPORTS/07_STATUS.md) | What is running, what is queued, what is not started |", | |
| "| [`08_FOUNDATION_TRACK`](REPORTS/08_FOUNDATION_TRACK.md) | PASTIS enhancements + frozen TESSERA on MTLCC and PLANTEUR: ladder, attribution, status |", | |
| "| [`MTLCC/REPORT.md`](MTLCC/REPORT.md) | The original MTLCC write-up |", ""] | |
| # ------------------------------------------------------------------ layout etc. | |
| L += ["## Repository layout", "", "| Folder | Contents |", "|---|---|", | |
| "| [`MTLCC/`](MTLCC) | Everything MTLCC: code, checkpoints, results, logs, figures, notebooks, and `enhancement/` (TESSERA readouts and the 54-system ladder) |", | |
| f"| [`PLANTEUR/`](PLANTEUR) | Everything PLANTEUR ({len(plan) - len(pend)} of {len(plan)} fine-tunes complete): code, checkpoints, results, logs, and `enhancement/` (PASTIS branches, TESSERA readout curve, 49-system ladder) |", | |
| "| [`PASTIS/`](PASTIS) | Everything PASTIS, with its own README below |", | |
| "| [`BASELINES/`](BASELINES) | The nine-method comparison shared by the datasets: adapters, every learning-rate trial, logs, weights, [`ADAPTATIONS.md`](BASELINES/ADAPTATIONS.md) |", | |
| "| [`PAPER/`](PAPER) | The manuscript (`main.pdf`, source, tables, figures) and [`reports/`](PAPER/reports), the written reports listed above |", | |
| "| [`PROJECT/`](PROJECT) | Not results: `CLAUDE.md`, the restore kit, chat history, assistant notes, the generator scripts and the queue logs |", "", | |
| "## Honest limits", "", | |
| "1. The **central architectural claim is only partly isolated.** A from-scratch pair (R = 4 vs R = 1) bounds what the " | |
| "reduction costs, but swapping the whole temporal block for window or full self-attention *with the pre-trained " | |
| "encoder in place* has not been run — it needs two new pre-trainings.", | |
| "2. On **MTLCC the margin over STCLN_wp is inside seed noise, and the loss-family ablation removes it.** We do not claim T-SRDA beats STCLN_wp there.", | |
| ("3. On **PLANTEUR, T-SRDA and the baselines are measured at different label budgets**; the same-budget row is queued." | |
| if MR.planteur_full() is None else | |
| "3. On **PLANTEUR the only same-budget row (100 % labels) is a single seed**; the lead over STCLN needs more seeds before it can be called a ranking."), | |
| "4. **Seven of the nine baselines cannot be reproduced exactly** — the STCLN repository ships only STCLN " | |
| "([`REPORTS/03_BASELINE_REPRODUCTION.md`](REPORTS/03_BASELINE_REPRODUCTION.md)).", | |
| "5. The **PASTIS figures are an ensemble** with an externally pre-trained component and a history of test inspection. " | |
| "The same holds for the TESSERA-assisted MTLCC / PLANTEUR rows in the enhancement track: they are validation-selected, " | |
| "but they use an external encoder the baselines do not get.", | |
| "6. The released STCLN pre-training script masks 15 % of pixels while the paper says 40 %; our MTLCC encoder followed the script, and a 0.4 re-run is " | |
| + (f"in progress (epoch {m4['done']}/100)." if m4["done"] < 100 else "complete — see the report."), | |
| "7. One seed per ablation row; the manuscript's reference to the PDAViT block (`zhou2026pdavit`) and to the PLANTEUR paper still has to be verified.", "", | |
| "## Licence and attribution", "", | |
| "Third-party baseline code is cloned unmodified from each method's own repository; sources, commits and licence " | |
| "files are in [`BASELINES/README.md`](BASELINES/README.md). The MTLCC and PLANTEUR datasets stay with their " | |
| "original licences and are not redistributed here.", "", "---", ""] | |
| return "\n".join(x for x in L) + "\n" + tail_md | |