Automated segmentation is routinely used as the first step in quantitative image-based clinical workflows, where predicted masks are subsequently reviewed and corrected by human operators. Automated correction of the residual structural errors is currently addressed one anatomy at a time, so the number of trained correctors scales with the number of segmentation targets. We present GRACE, a retrieval-augmented refiner that edits an input mask under context drawn from a shared knowledge base of verified prior cases. The refiner is trained once on a multi-organ corpus spanning compact organs, cavities, branching vessels, and tumour lesions. In the held-out dataset-transfer evaluation, three held-out datasets query a fixed knowledge base built from training data only. A separate leave-one-anatomy-out experiment tests parameter-free index extension: verified cases of an unseen solid organ enter the knowledge base, and the refiner stays frozen. A light shape-aware projection head on a frozen multimodal encoder maps embedding similarity to the shape agreement of the masks, so the knowledge base returns cases that the refiner can use as a shape prior. We evaluate GRACE on 18 public datasets spanning CT, MRI and ultrasound, using nine refinement configurations and seven upstream segmentors that span weak, mid, and strong operating regimes. We report each change with the DSC of its input mask. On the weak tier, the input DSC is 0.386 and GRACE adds up to +0.35 DSC. On a strong segmentor, the input DSC is 0.932 and the mean change is small. Transfer to an imaging modality that is absent from training and from the index is partial and depends on the anatomy, and remains an open research direction. Our results suggest retrieval-conditioned refinement is a practical alternative to anatomy-specific correction models. Code: https://github.com/robustml-eurecom/grace
Figures & tables
Figure 1: Overview of GRACE. (a) The knowledge base stores multimodal embeddings of verified cases together with their corresponding masks. (b) At inference, the query (corrupted mask Y∗ and image X ) is embedded, and the top- k same-class neighbours are retrieved from a FAISS index. The top-1 mask Yr is used as an exemplar. (c) The refiner produces the corrected mask Y^∗ from the query and retrieved context using either a pixel-space or a latent-space instantiation. Figure elements that depict a compact latent representation illustrate the latent variant; the pixel-space variant follows the same retrieval interface without an encoder–decoder pair. The multimodal encoder P is frozen, and the projection head ϕψ (Sec. 3.3 ) is not drawn. In (c), z∗=E(Y∗) .
Figure 2: Semantic topology and latent anatomical hierarchy of the anatomy-aware knowledge base K . (Left) Similarity graph: A 3-nearest neighbour connectivity graph where edges denote a cosine similarity ≥0.9 , illustrating strong intra-class cohesion. (Middle) Embedding space projected on a t-SNE vector space. (Right) Semantic hierarchical clustering: A dendrogram of class centroids computed via average linkage and cosine distance. The topological structure demonstrates that K intrinsically captures underlying anatomical relationships and modality-specific groupings (e.g., abdominal CT and neurological MR clusters).
Weak
Mid
Strong
Refiner
U-Net@30
MedSAM2
TotalSeg
SegResNet
U-Net@150
Block A — DSC ( ↑ )
Raw upstream
0.386
0.727
0.932
0.793
0.775
Morphological
+0.005±0.019
+0.003±0.021
−0.005±0.011
−0.002±0.014
−0.003±0.015
TTAug
+0.018±0.024
—
+0.002±0.008
+0.007±0.013
+0.008±0.014
PostDAE
−0.108±0.117
−0.330±0.140
−0.487±0.152
−0.294±0.148
−0.221±0.144
Table 1: GRACE as a universal refiner across upstream operating regimes. Weak, mid, and strong upstream segmentors are evaluated using DSC ( ↑ ) and HD95 ( ↓ ). Raw upstream rows report absolute scores. Refinement methods report signed changes ( Δ ) relative to the corresponding upstream prediction (mean ± standard deviation). † denotes statistical significance against the raw upstream (paired Wilcoxon, p<0.05 ). Bold indicates the best refinement change per column; “–” denotes configurations that are not applicable. The latent flow-matching variant GRACE-M-D is reported alongside the two deterministic variants so that all three instantiations can be compared directly; its inference cost is about seven times higher (Table 6 ).
Figure 3: Refiner performance across corruption severities. Bars show mean DSC (a) and mean HD95 (b) across seven anatomy–dataset pairs (Liver, Pancreas, Spleen from MSD; Liver, Pancreas, Spleen from AbdomenCT1K; Spleen from AMOS22); error bars show the sample standard deviation across those seven pair-level values. Seven refiners are compared per severity group: raw upstream (grey), morphological (dark grey), PostDAE (red), RAM (purple), U-Net w/o RAG (amber), GRACE-U (blue-green), and GRACE-M (yellow-green). TTAug requires repeated upstream inference and is therefore not defined for the precomputed synthetic-corruption inputs in this figure.
Raw
+ GRACE-U
+ GRACE-M
Dataset
Segmentor
DSC
HD95
Δ DSC
Δ HD95
Δ DSC
Δ HD95
ProstateX
ScribblePrompt
0.753±0.078
8.1±2.6
+0.041±0.034
−2.4±1.5
+0.036±0.036
−2.0±1.6
CHAOS
TotalSeg (fast)
0.921±0.041
3.2±1.1
+0.006±0.017
−0.4±0.6
+0.009±0.019
−0.5±0.7
SwinUNETR-BTCV
0.874±0.052
4.7±1.7
+0.019±0.024
−1.0±0.9
+0.017±0.025
−0.9±1.0
LUMIERE
ScribblePrompt
0.716±0.084
11.5±3.4
+0.062±0.041
−3.6±1.9
+0.079±0.044
−4.2±2.1
Table 2: Held-out dataset transfer to three datasets. Raw upstream and refined DSC and HD95 (mm) for three upstream segmentors (one or two per dataset) . No case from a held-out dataset is inserted into K ; every query retrieves only from the fixed training-corpus index. Δ denotes refined − raw performance (positive is better for DSC, negative for HD95). Best refiner per row is shown in bold .
Held-out
Query
Index
Input DSC
GRACE-U Δ DSC
GRACE-M Δ DSC
Control Δ
Shape ret.
Block A — Leave-one-anatomy-out (parameter-free index extension)
Pancreas
U-Net@30
+241
0.013±0.019
+0.164±0.078
+0.181±0.081
–
–
Spleen
U-Net@30
+273
0.033±0.025
+0.238±0.091
+0.246±0.088
–
–
Liver
U-Net@30
+302
0.130±0.056
+0.317±0.094
+0.301±0.096
–
–
Prostate PZ
U-Net@30
+118
0.421±0.113
+0.088±0.061
+0.082±0.064
–
–
Mean
0.149
+0.202
+0.203
–
–
Table 3: Transfer to a held-out anatomy or modality. In both blocks, we remove the held-out anatomy or modality from the training data and from the retrieval index, and we retrain the refiner from scratch. Block A: we add the stated number of verified support cases of the held-out organ to K and do not update the refiner. The support cases are disjoint from the queries. Block B: no case of the held-out modality enters the index, and one GRACE-U refiner is evaluated per modality. The control is the refiner trained with that modality, on the same queries. Shape ret. is the query–pool shape agreement without the modality, relative to the agreement with it. Δ is refined − input. “–” denotes configurations that are not applicable or not evaluated.
Retrieval strategy
DSC ↑
HD95 (voxels) ↓
Corrupted input (no refinement, baseline)
0.660±0.104
10.42±4.31
Random same-class peer
0.755±0.087
8.16±3.62
K-NN same-class peer ( ours )
0.815±0.068
6.71±2.98
Oracle (retrieve GT) [upper bound]
0.881±0.052
4.94±2.11
Table 4: Retrieval-strategy assessment. All rows are evaluated on the strong synthetic-corruption preset. The first row is the corrupted input without refinement (baseline). The other three rows use the same trained GRACE-M refiner and differ only in the same-class mask provided as the spatial exemplar channel. The oracle row retrieves the ground-truth mask and provides an upper bound on the contribution of retrieval to refinement.
Figure 4: Retrieval-module quality. ( a, left) Downstream Δ DSC when varying knowledge-base density ( d ) and retrieval fan-out ( k ). ( b, right) Diagnostic class purity@ k for the 15 most frequent classes when the usual same-class filter is disabled, one curve per class.
Encoder source
Similarity space
Dim
DSC (base)
DSC (full model)
Δfull vs. raw cosine
MedGemma-multimodal
unprojected cosine (control)
2560
0.708±0.082
0.741±0.076
—
MedGemma-multimodal
shape-proj. (ours)
256
0.727±0.079
0.771±0.072
+0.030
Mask-domain (VAE + pool + PCA)
unprojected cosine (control)
256
0.718±0.084
0.752±0.075
—
Mask-domain (VAE + pool + PCA)
shape-proj. (ours)
256
0.739±0.078
0.782±0.071
+0.030
Table 5: Shape-aware retrieval projector. Performance on the strong synthetic-corruption preset using two embedding sources: MedGemma multimodal embeddings and a mask-domain baseline derived from the frozen VAE encoder. Base and full model denote two fixed GRACE-M-D refiner configurations (we report one variant for simplicity) ; within each column, only the encoder source and similarity space change. Shape-proj. denotes the learned shape-aware projection.
Figure 5: Qualitative overview of GRACE refinements. Rows correspond to Liver, Pancreas, Spleen, Heart LA, and Prostate PZ. Columns show the ground truth; one representative synthetic corruption from the training schedule and its GRACE-U refinement; and three upstream segmentors (U-Net@150, MedSAM2, and TotalSegmentator, with SegResNet used where TotalSegmentator is unavailable) together with their corresponding GRACE-U refinements. Colours identify the source of each mask. DSC and HD95 with respect to the ground truth are overlaid on every panel.
Appendix figures & tables7 assets
Supplementary material from the paper’s appendix.
Appendix
Method
NFE
Time / case (s)
DSC ↑
GRACE-U (feedforward)
1
0.31±0.02
0.803±0.071
GRACE-M (deterministic latent)
1
0.58±0.03
0.815±0.068
GRACE-M-D (FM, 10 steps)
10
1.4±0.1
0.788±0.073
GRACE-M-D (FM, 20 steps)
20
2.8±0.1
0.801±0.070
GRACE-M-D (FM, 30 steps)
30
4.2±0.1
0.810±0.069
GRACE-M-D (FM, 50 steps)
50
7.0±0.2
0.813±0.068
Appendix
Table 6: Performance versus inference runtime. Wall-clock time per case (mean ± sample standard deviation across five benchmark runs, each covering ten organs) and DSC (mean ± sample standard deviation across cases) under the strong synthetic-corruption preset. PostDAE requires 10 separately trained models (one per anatomy). The number of function evaluations (NFE) is also reported.
Fusion module
GRACE-U DSC ↑
GRACE-M DSC ↑
Concat (default)
0.803±0.071
0.815±0.068
FiLM
0.786±0.074
0.797±0.072
Cross-attention
0.750±0.086
0.799±0.071
Appendix
Table 7: Fusion-module ablation. Refined DSC (mean ± sample standard deviation across cases) for the three exemplar-fusion interfaces, evaluated on both refiner variants under the strong synthetic-corruption preset. All rows share the training data, corruption schedule, and retrieval pipeline; only the module that injects the retrieved exemplar changes. Concat gives the highest displayed score for both variants and is retained as the default.
Configuration
DSC ↑
Δ DSC
Params (M)
Baseline
0.706±0.082
0.000±0.000
53.2
Dice-aux only ( w=0.5 , 60-ep warmup)
0.721±0.079
+0.015±0.021
53.2
K-NN exemplar only
0.717±0.081
+0.011±0.020
53.2
Dice-aux + K-NN exemplar
0.732±0.076
+0.026±0.024
53.2
Both + wider U-Net ( ×2 channels)
0.744±0.073
+0.038±0.026
118.6
Appendix
Table 8: Training ablation for GRACE-M-D. Rows compare controlled combinations against a common baseline on the strong synthetic-corruption preset; Δ DSC is measured relative to that baseline. Params report only the U-Net velocity network.
Input DSC
n
Mean Δ DSC
Harmed ( >0.01 drop)
Harmed ( >0.05 drop)
<0.2
214
+0.271
1.4% (3)
0.5% (1)
0.2 to 0.5
187
+0.168
3.7% (7)
1.1% (2)
0.5 to 0.8
243
+0.061
6.6% (16)
1.2% (3)
>0.8
156
+0.007
11.5% (18)
3.8% (6)
Appendix
Table 9: Case-level failure analysis. Evaluated cases grouped by the DSC of their input mask. A case is harmed when refinement lowers its DSC by more than the stated margin; case counts in brackets. Mean Δ DSC is the mean change of DSC within each band.
KB encoder
Encoder dim.
DSC (strong synthetic preset) ↑
HD95 ↓
DINOv2 (natural)
1024
0.746±0.081
8.44±3.42
BiomedCLIP
512
0.789±0.074
7.32±3.10
MedSigLIP
1152
0.796±0.072
7.05±2.98
MedGemma multimodal ( main encoder )
2560
0.812±0.069
6.78±2.86
MAISI-pure (raw)
864
0.764±0.078
7.94±3.25
MAISI-pure → PCA-256
256
0.779±0.075
7.51±3.14
Appendix
Table 10: Retrieval encoder ablation. Performance on the strong synthetic-corruption preset with different retrieval encoders while keeping the GRACE-M refiner, knowledge-base size, and corruption schedule fixed. The mask-domain variants construct retrieval embeddings from the frozen MAISI VAE encoder: the first uses adaptive pooling alone, the second adds PCA reduction, and the third replaces PCA with a learned two-layer MLP. This comparison assesses how far anatomical shape alone can approach multimodal retrieval. “Encoder dim.” reports the dimensionality emitted by the listed encoder or reduction, rather than the 256-dimensional shape-aware index used by the main pipeline. Unlike the main experiments ( k=5 ), all rows in this ablation use top- k retrieval with k=3 and spatial-exemplar conditioning.
Organ
Input DSC
Correct class
Random wrong class
No exemplar
Exemplar share
Liver
0.183
+0.512
+0.361
+0.208
59%
Kidneys
0.110
+0.449
+0.372
+0.171
62%
Spleen
0.201
+0.430
+0.338
+0.163
62%
Pancreas
0.308
+0.194
+0.101
+0.119
39%
Appendix
Table 11: Robustness to the class query. Mean DSC gain over the input at the evaluation-only extreme preset, with the trained refiner held fixed. Correct class is the protocol used everywhere else in the paper. Random wrong class retrieves the exemplar from a randomly chosen other class. No exemplar sets the retrieval channel to zero. The exemplar share is (correct class − no exemplar) / correct class.
Dataset
Modality
Cases
Classes
Notes
Training corpus
Task01_BrainTumour
MRI
484
3
edema, non-enhancing tumour, enhancing tumour
Task02_Heart
MRI
20
1
left atrium
Task03_Liver
CT
117
2
liver, cancer
Task04_Hippocampus
MRI
260
2
anterior, posterior
Task05_Prostate
MRI
28
2
PZ, TZ
Appendix
Table 12: Dataset scope. GRACE is trained on 15 public datasets spanning CT, MRI and ultrasound, covering 38 anatomical structures across the abdomen, thorax, pelvis, brain and cardiac chambers. Three further datasets are held out entirely from training. For the held-out dataset-transfer evaluation in Sec. 4.3 , none of their cases is inserted into K ; the optional longitudinal-memory analysis is reported separately in Appendix G . The columns report dataset, modality, case count, class count, and covered anatomy. After decomposing the multi-class labels, the training splits contain 11,900 non-empty binary-mask instances, of which K indexes N=3,913 .
Medical image segmentation delineates organs, lesions, and other structures in scans to support measurement, diagnosis, treatment planning, and research.