Training-Free Medical Image Segmentation vs Trained Networks

A multi-domain data-efficiency study — frozen-foundation-model assembly (an LLM polygon drawer in the deployed path on 1/6 domains, else SAM / op_sam / SegGPT) + a numpy genome, zero gradient training on the target task.

6 modalitiesmeasured, from scratch GT-free at inferenceLLM-agnostic skills updated · 2026-07-16

Data-efficiency

The crossover — one panel per domain

Frozen assembly vs the strongest compatible, complete three-seed trained NN at each K, selected from U-Net, SegFormer and nnU-Net only. Filled comparator dot + whisker = exactly seeds 0/1/2 and a 95% df=2 t interval; absent dot = no eligible comparator. The tuned SAM decoder GT-box oracle is kept separate in the expanded figure below.

▬ pipeline (strict first-K curve; Spleen and Prostate updated to NN-assisted SkillOpt) · □/■ strongest trained NN

ISIC 2018 · dermoscopyassembly ahead
0.750.800.850.9051025501000.8800.854
Kvasir · endoscopy polypnear-tie
0.500.600.700.800.9051025501000.8650.864
MSD Spleen · CTNN-assisted pipeline · strict first-K
0.20.50.81.051025501000.9260.912
MSD Prostate · MRINN-assisted pipeline · strict first-K
0.20.40.60.851025501000.7920.846
Chest X-ray · lungnear-tie
0.800.850.900.951.0051025501000.9500.946

Strict leakage-free Spleen data efficiency

K Training supportsK+24 adaptation labelsNN-assisted pipeline Dice [95% volume CI]Strongest compatible trained NN Dice [95% df=2 t CI]
5290.759 [0.682, 0.828]U-Net 0.380 [0.219, 0.541]
10340.856 [0.784, 0.913]U-Net 0.577 [0.530, 0.623]
25490.874 [0.801, 0.921]SegFormer 0.772 [0.687, 0.856]
50740.922 [0.887, 0.942]U-Net 0.855 [0.717, 0.992]
1001240.926 [0.897, 0.945]U-Net 0.912 [0.864, 0.959]

The green Spleen curve is the fresh NN-assisted pipeline at every K. It uses three training seeds and its NN-specific crop scales, routing, agreement gates, morphology, margins and selectors were independently tuned at every K; baseline intervals are across exact seeds 0/1/2. Resize-224 nnU-Net and historical cached-mask SAM scores are excluded.

Strict leakage-free Prostate data efficiency

K Training supportsK+20 adaptation labelsNN-assisted pipeline Dice [95% volume CI]Strongest compatible trained NN Dice [95% df=2 t CI]
5250.321 [0.184, 0.472]U-Net 0.596 [0.533, 0.658]
10300.505 [0.341, 0.672]U-Net 0.700 [0.599, 0.800]
25450.687 [0.584, 0.789]nnU-Net 0.791 [0.783, 0.799]
50700.789 [0.711, 0.860]nnU-Net 0.795 [0.780, 0.810]
1001200.792 [0.728, 0.860]nnU-Net 0.846 [0.834, 0.858]

The green Prostate curve uses fresh masks from three NN seeds. Its NN-specific preprocessing, localization, crop-zoom, gates, margins and selectors were independently tuned at every K. Green intervals bootstrap the six complete Test volumes; baseline intervals use exact seeds 0/1/2.

The green ISIC, Kvasir and CXR pipeline curves carry 95% image-level bootstrap intervals (10,000 iterations, fixed seed) over the matched per-image few-shot Dice at N=5/10/25/50. The deployed N=100 anchor has no matched per-image list, so that single point is shown without a whisker.

The green Spleen pipeline curve strictly uses the first K Training supports. Its selector was calibrated with 24 separate Validation labels, so the disclosed total is K+24 adaptation labels. Green error bars are 95% complete-volume bootstrap intervals over the seven held-out Test volumes.

The green Prostate pipeline curve also strictly uses the first K Training supports. Its selector used 20 separate Validation labels, so the disclosed total is K+20 adaptation labels. Green error bars bootstrap the six held-out Test volumes.

Coverage is intentionally incomplete. No uncertainty bar is synthesized for one/two-seed cells or the single-run tuned-decoder oracle. The expanded figure below shows every cached method curve and makes the missing-seed cells explicit.

HC18 FetalHead remains withheld pending its leakage-free rerun; these updates do not restore any prior FetalHead result.

Detailed data-efficiency figure — five settled domains with updated Spleen and Prostate NN-assisted pipelines
Data-efficiency curves with strict first-K Spleen and Prostate pipelines updated to independently tuned NN-assisted SkillOpt
Five settled domains, five K budgets; FetalHead remains withheld. Green is the strict first-K pipeline curve. Spleen and Prostate use fresh NN-assisted pipelines with independently tuned NN-specific SkillOpt at every K; their green whiskers bootstrap seven and six complete Test volumes. The separate Validation selector labels remain disclosed as K+24 and K+20 total adaptation labels. U-Net, SegFormer and nnU-Net use protocol-compatible cached score artifacts; filled squares and whiskers appear only for exact seeds 0/1/2 and show 95% df=2 t intervals. Resize-224 Spleen nnU-Net and historical cached-mask SAM scores are excluded. Exact values, label counts, seed counts and source paths are in dataeff_grid.json.

Results — best trained NN across N vs the frozen-assembly pipeline

Strongest trained NN per cell — max of SegFormer (mit_b2), pretrained U-Net (resnet34), and nnU-Net using every currently cached seed — at matched budgets N = 10 / 25 / 50 / 100, against the frozen assembly. The point estimates below are current; seed coverage is not uniform. The data-efficiency figure above draws 95% seed intervals only for exact three-seed cells and marks one/two-seed cells as incomplete. Amber denotes a close point estimate, not a significance claim.

Domainbest NN N=10N=25N=50N=100training-free LLMfew-shot decoder
N=100 (oracle)
ISIC 2018 (derm)0.8320.8330.8500.8540.8800.911
MSD Spleen (CT)0.6330.7750.8690.9130.9200.953
Kvasir-SEG (endo)0.7090.8180.8540.8640.86460.944
ChestXray (X-ray)0.9380.9480.9520.95350.9497
SegGPT in-context; fs-deploy 0.9488
0.9556
HC18 Fetal-Head (US)0.9230.9580.9650.96540.9667
retrieval SegGPT; zero gradient
0.9603
single-run GT-box oracle
MSD Prostate (MRI)0.7000.7910.7950.84630.7877
deployed K=8 SegGPT⊕op_sam
0.9377
Comparator scope: the tuned-decoder column is a single-run GT-box oracle, not a deployable or three-seed benchmark. The trained-NN columns use cached seed means and now include the completed nnU-Net cells; this raises the strongest prostate N=100 comparator from the older 0.8152 reference to 0.8463. Exact seed coverage and provenance are exposed in dataeff_grid.json.
Point-estimate outcome at N=100: the frozen assembly leads ISIC (+0.026) and Spleen (+0.007), is within 0.004 on Kvasir/CXR/FetalHead, and trails prostate by 0.059. These are descriptive margins; significance depends on the cell-specific seed coverage shown above.

Latest Prostate experiments — Codex feedback + SegGPT K sweep / SkillOpt

These are sealed follow-up experiments, kept separate from the deployed six-domain table above. The NN-free Codex pilot uses 15 fixed slices; the frozen SegGPT⊕op_sam lane and K sweep use the 30-case prostate benchmark. Results from different protocols are not subtracted from one another.

Codex crop-zoom + SkillOpt feedback loop

Protocolnvariantmean DiceΔpaired 95% CIstatus
NN-free LLM polygon lane15frozen baseline0.6188reference
NN-free LLM polygon lane15Codex REPAIR + independent JUDGE0.6524+0.0336[+0.0097, +0.0612]positive pilot
Frozen SegGPT⊕op_sam lane30sealed base cache0.7843reference
Frozen SegGPT⊕op_sam lane30crop-zoom SkillOpt + Codex judge0.7840−0.00027[−0.00080, 0.00000]null; default-off
Frozen SegGPT⊕op_sam lane30full skill-family GT oracle0.8302+0.0459headroom only
Trained benchmark30nnU-Net, N=100 (3-seed mean)0.8463+0.0620 vs sealed basecurrent strongest NN
Feedback-loop verdict: crop-zoom and SkillOpt help the weaker NN-free lane, but they do not improve the already-tight frozen SegGPT⊕op_sam masks. The all-candidate oracle is +0.0459 over its base, so candidate headroom exists, but it still trails the newly completed N=100 nnU-Net mean by 0.0161. The GT-free diagnosis/selection stage cannot harvest even the available within-lane headroom, so the NN-assisted feedback edit remains disabled.

Uncapping SegGPT K

We removed the implicit K=min(8,N) ceiling and reran the same full frozen pipeline on the same 30 held-out slices. K is the number of query-retrieved in-context support pairs, not gradient-training set size. Every run reads from the same pool of 100 leak-free TRAIN pairs, stored at 224×224. Raw joint inference fits through K=10 on a 12 GB TITAN Xp; raw K=12 and K=16 OOM. K>10 therefore uses a memory-safe approximation: feature-ensemble chunks of at most 8, followed by a support-count-weighted pixel vote. Two GPUs ran separate values/shards concurrently; they reduced wall time but did not combine VRAM.

Full frozen pipelineKexecutionmean DicemedianΔ vs K=8gap to NN
SegGPT gate5joint0.78320.8433−0.0044−0.0631
SegGPT gate · deployed8joint0.78770.8483reference−0.0587
Uncapped SegGPT gate10joint0.78560.8560−0.0021−0.0608
Uncapped SegGPT gate25chunk 8 + weighted vote0.78450.8433−0.0032−0.0619
Uncapped SegGPT gate · exploratory50chunk 8 + weighted vote0.79880.8499+0.0112−0.0475
Uncapped SegGPT gate100 (all)chunk 8 + weighted vote0.77980.8433−0.0079−0.0666
Per-image best K · GT oracle5/8/10/25/50/100not deployable0.8090+0.0213−0.0374
nnU-Net, N=1003-seed mean0.8463+0.0587reference
K-sweep verdict: more supports do not yield a monotonic gain. K=50 has the best exploratory point estimate (0.7988), but its paired improvement over K=8 has a bootstrap 95% CI crossing zero (−0.0091 to +0.0411), and one rescued slice supplies most of the lift; remove it and the other 29 average −0.0012. K=100/all regresses to 0.7798, and even the test-GT per-image K oracle (0.8090) trails the current N=100 nnU-Net mean (0.8463). K=8 stays deployed. K=50 is a validation hypothesis, not a claimed improvement.

Sealed K-router SkillOpt transfer test

The K sweep also has a GT-isolated router experiment (seggpt_k_skillopt.py, driven by experiments/seggpt_k_feedback.py). It fits on four validation volumes using leave-one-volume-out SkillOpt, freezes the resulting GT-free router, and then opens the six-volume test labels once for scoring.

Split / protocolnK=8 fallbackfrozen SkillOptΔuncertainty / decisionsverdict
Validation · volume-LOO20 / 4 volumes0.8340940.840757+0.006662enable threshold +0.005fit enabled
Frozen test · volume-cluster bootstrap30 / 6 volumes0.7876720.769596−0.01807695% CI [−0.040310, −0.003187]
2↑ / 4↓ / 24=; P(Δ≤0)=0.9988
fails transfer
SkillOpt verdict — do not deploy. The router crossed its preregistered +0.005 validation threshold, then transferred negatively to the untouched test volumes. The volume-cluster bootstrap excludes zero in the harmful direction. This is a gate-bound result despite the per-image K oracle: validation-fit K routing did not generalize. The router stays disabled and fixed K=8 remains deployed.

Segmentation galleries

Per-case GT-vs-prediction overlays for the deployed pipeline on every test image (all 465, sorted worst-Dice first) — open the 6-domain gallery hub → (ISIC · Kvasir · Spleen · Prostate · CXR · FetalHead). Green = ground truth, red = deployed prediction; overlays rendered from the committed mask_cache/.

Where is the wall — the decoder, or localization? A fair few-shot probe

Is the residual to the trained NN a decoder limit or a localization limit? MedSAM (SAM fine-tuned on ~1M medical masks) beats box-prompted SAM — but it is data-leaky (its training set likely includes these test distributions), so it is really "import a trained medical net." The fair, leak-free counterpart of the same operation: init from the generic SAM (no medical data), freeze the image + prompt encoders, and fine-tune only the ~4M-param mask decoder on our own N-label train split — GT never touches test. Given a good box (the GT-box oracle, which isolates the decoder), this few-shot-tuned decoder beats the from-scratch NN at every budget on 4 of 6 domains (ISIC/Spleen/Kvasir/Prostate — Prostate by +0.12) and ties on the other two (CXR, HC18 — both near-ceiling NNs at ~0.95–0.96), and it saturates at N=10 (pretrained features + a tiny adapted head), so its curve is flat-high while the NN climbs:

Domain (tuned decoder, oracle)N=10N=25N=50N=100best NN N=100
ISIC 2018 (derm)0.90470.90440.90710.91100.8544
MSD Spleen (CT)0.95740.96020.95990.95280.9132
Kvasir-SEG (endo)0.93600.93400.93720.94390.8643
ChestXray (X-ray)0.93250.94620.95450.95560.9535
HC18 Fetal-Head (US)0.91830.95400.95660.96030.9654
MSD Prostate (MRI)0.90650.93110.93150.93770.8463
Oracle scope: these tuned-decoder values are cached single point runs with a GT test box; they isolate decoder capacity but are neither deployable nor three-seed estimates. They exceed the current strongest trained-NN point estimate on ISIC, Spleen, Kvasir and Prostate, nearly tie CXR, and trail FetalHead. The gap from this oracle to the deployed frozen assembly mostly measures localization/prompting, not a fair end-to-end model comparison.

Is the medical pretraining (MedSAM) worth it? — a leaky benchmark

MedSAM is SAM already fine-tuned on ~1M medical masks — a leaky upper reference (its training likely saw these test distributions). Arch-matched (both vit_b, GT-box oracle, N=100), few-shot tuning of the GENERIC SAM matches or beats the leaky MedSAM on 3 of 6 domains, and stays within 0.015 on the other 3. This table preserves that experiment's arch-matched NN reference; the current strongest cached-NN grid is the data-efficiency section above.

Domain (N=100 oracle, vit_b)study NN referencegeneric frozengeneric few-shot (fair)MedSAM frozen (leaky)MedSAM few-shot (leaky)
ISIC 2018 (derm)0.8680.8700.9150.9210.943
MSD Spleen (CT)0.9070.9410.9560.9090.946
Kvasir-SEG (endo)0.8890.9170.9360.8880.918
ChestXray (X-ray)0.95460.9250.9540.9350.952
HC18 Fetal-Head (US) ·new0.9700.7690.9650.9040.972
MSD Prostate (MRI) ·new0.8150.8950.9280.8070.941
Fair few-shot generic SAM vs leaky MedSAM benchmark, N=100 oracle
Fair few-shot tuning of generic SAM (dark blue) vs the leaky MedSAM (orange), each frozen + few-shot-tuned, vs the from-scratch NN (gray) — arch-matched vit_b, N=100 GT-box oracle. The fair generic few-shot ≥ leaky MedSAM few-shot on Spleen/Kvasir/ChestXray (3/6); MedSAM leads on its own pretraining distributions — derm (ISIC), US (HC18), MRI (prostate) — but by <0.015 once the generic decoder is tuned, and generic-frozen still beats MedSAM-frozen on prostate (0.895 vs 0.807). Medical pretraining helps most exactly where MedSAM saw the data, yet few-shot tuning of the generic decoder nearly erases it — decoder adaptation, not medical pretraining, is the lever.
The MedSAM attack inverts once it is prompted fairly and tested OOD (ood_medsam.md). The oracle-box column above is a leaky upper reference. Give MedSAM a fair box (learned from N GT, not the oracle) and it drops +0.16..+0.59 Dice below the deployed pipeline in-distribution; take it out-of-distribution (DRIVE retinal vessels — a distribution MedSAM never trained on) and the gap widens to +0.51 while MedSAM collapses to 0.220 even handed the ORACLE box (vs ~0.90 in-distribution). MedSAM's in-distribution edge was its decoder recognizing box-shaped targets it had trained on — memorization that does not transfer; the pipeline's few-shot-refit GT-free localization is distribution-robust.

Can it be ONE domain-agnostic pipeline? — few-shot skills + a router, SAM frozen

Each domain has a distinct setup — so can it be a single domain-agnostic pipeline that few-shot-fits per domain WITHOUT tuning SAM? We test the transferable skill — a frozen-SAM-feature localizer prototype fit from N labeled images — with identical code across all six domains, SAM never touched.

Domain-agnostic few-shot skill transfer: skills few-shot-fit, topology is routed not tuned
(A) One fixed pipeline (prototype-sim localizer): the skill few-shot-fits — saturates by ~N=10 on every domain — and scores high where the target is prototype-localizable (ISIC 0.71, CXR 0.62, HC18 US 0.72), mid where it is a central structure (Prostate MRI 0.51), low where it needs a specialized localizer (Kvasir 0.35, Spleen 0.12). (B) Routing the per-domain topology (genome / static-box / op_sam dense-correspondence / volume-prior / ellipse-snap / volume-trajectory) + the few-shot skill recovers most of the deployed number (Kvasir 0.35→0.77→0.86, HC18 0.69→0.92, Prostate 0.51→0.76, Spleen 0.14→0.66→0.83@N=50).
Yes — a domain-agnostic pipeline = frozen SAM + a GT-free router + few-shot skills. The learning (localizer prototype + gate weights + genome) is domain-agnostic, few-shot (~10 labels; ~50 for the isodense spleen), and SAM-frozen — it transfers with identical code. The per-domain "distinct setup" you'd notice is which localizer topology to route to — a GT-free routing choice (learned config, the project's route.py), not SAM tuning. So onboarding a new domain is ~10 labels + a routing decision, zero gradient training. Robust localizer skill: the deployed default is now the op_sam frozen-DINOv2 dense-correspondence localizer (kvasir/HC18/prostate) — it transfers 10-shot support masks through the full patch cross-correlation, and superseded the earlier SAM+DINOv2 AMG-ranker ensemble on Kvasir (0.655→0.8646). The lesson holds and is now stronger: the polyp/fold and faint-skull walls yield to the right frozen feature space — dense correspondence, plus feature-diverse supports — not to distractor-verification tricks. The AMG-ranker ensemble (at/near the best single feature space on all three, Kvasir 0.65 / Spleen 0.64 / ISIC 0.67, never catastrophic where SAM-alone fails the isodense spleen 0.40) remains the LLM-agnostic fallback where a support set is too small for correspondence.