---
title: 'Grad-CL: Source-Free Adaptation for Fundus Segmentation'
url: https://www.emergentmind.com/topics/grad-cl
type: topic
---

# Grad-CL: Source-Free Adaptation for Fundus Segmentation

Searching arXiv for the specified Grad-CL paper and closely related SFDA/optic disc-cup segmentation work for corroborating citations.
Grad-CL is a source-free domain adaptation framework for optic cup and optic disc segmentation in fundus images. It addresses the setting in which a pretrained source model $f^s$ is available but the original source images are not, so adaptation must be performed using only unlabeled target images under cross-domain shifts caused by different scanners, image quality, and patient populations. The method combines a gradient-guided pseudolabel refinement module with a cosine similarity-based contrastive learning strategy: the first stage uses Grad-CAM-derived class-specific saliency features for uncertainty quantification and prototype estimation, and the second stage explicitly enforces inter-class separability between optic cup and optic disc features in latent space [2509.10134].

## 1. Problem formulation and motivation

Grad-CL is situated in source-free domain adaptation (SFDA) for medical image segmentation, specifically optic cup/disc segmentation for glaucoma-related fundus analysis. The motivating observation is that deep CNNs, including DeepLabv3+ with a MobileNet-v2 backbone, achieve high accuracy when trained and tested on the same fundus dataset but suffer large performance drops under cross-domain shifts. In many clinical settings, the original source images cannot be shared because of privacy or proprietary constraints, which rules out standard unsupervised domain adaptation methods that require joint access to source and target data. SFDA therefore assumes a pretrained source model $f^s$ and only unlabeled target images [2509.10134].

The framework is presented against limitations in prior SFDA segmentation methods. Existing approaches are described as typically relying on pseudo-labeling with simple thresholding plus prototype denoising, exemplified by DPL, or on contrastive learning via historical source hypotheses or neighbourhood statistics, exemplified by HCID and UC-SFDA. The paper identifies three specific deficiencies: naïve thresholds produce many noisy labels around object boundaries; prototypes that fuse optic cup and disc features can misassign pixels; and no method explicitly enforces inter-class separation of the two anatomically distinct structures [2509.10134].

A common misconception in this setting is that “source-free” means training without source-side knowledge. In Grad-CL, source-free adaptation still depends on a pretrained source model; what is absent is access to the original source images during target-domain adaptation. Another misconception is that thresholded pseudolabeling alone is sufficient for boundary-sensitive structures. Grad-CL is explicitly designed around the opposite premise: boundary noise and class overlap remain central failure modes and require dedicated filtering and feature-separation mechanisms [2509.10134].

## 2. Framework composition and network design

Grad-CL has a two-stage structure. The first stage is a gradient-guided pseudolabel refinement module. The second stage is a cosine similarity-based contrastive loss that “disaligns” optic cup and optic disc features using gradient-informed representations. In the paper’s formulation, these stages work together to sharpen pseudolabel quality and explicitly enforce disc–cup separability in feature space [2509.10134].

The network is DeepLabv3+ with a MobileNet-v2 backbone. During target adaptation, the backbone’s BatchNorm statistics are frozen, while all convolutional weights are fine-tuned on the target domain. Grad-CAM uses gradients from the final convolutional layer to form $e_{GC}$, per-pixel feature vectors $e_v$ are extracted from the penultimate layer before atrous spatial pooling, and the contrastive module operates pixel-wise on $\tilde e_v^{cup}$ and $\tilde e_v^{disc}$ [2509.10134].

Operationally, the per-minibatch procedure is: forward propagation to obtain probability maps and logits; generation of raw pseudolabels by thresholding; Monte Carlo dropout to estimate uncertainty; computation of class-specific Grad-CAM weights and heatmaps; construction of enhanced features; prototype estimation and distance-based agreement filtering; computation of the segmentation loss on retained pixels; construction of gradient-informed cup/disc features for the contrastive term; and backpropagation of the combined objective. This suggests that Grad-CL is organized as a refinement-and-separation pipeline rather than as a single loss added to standard self-training [2509.10134].

## 3. Gradient-guided pseudolabel refinement

For an unlabeled target image $x^t$, the source model $f^s$ produces per-pixel probability maps $p_v$ for cup, disc, and background. Initial binary pseudolabels are formed by thresholding:
$$
\widehat y_v^t = 1[p_v \ge \gamma], \qquad \gamma = 0.75.
$$
Because domain shift induces noisy predictions near object boundaries, Grad-CL refines these labels through uncertainty quantification and gradient-guided prototype estimation [2509.10134].

Pixel-level filtering is performed with Monte Carlo Dropout, using dropout rate $0.5$ and $K=10$ stochastic passes. The pixel-wise standard deviation is
$$
u_v = \sqrt{\frac{1}{K}\sum_{k=1}^K \left(p_v^{(k)} - \bar p_v\right)^2},
\qquad
\bar p_v = \frac{1}{K}\sum p_v^{(k)},
$$
and the binary uncertainty mask is
$$
m_v^u = 1[u_v < \eta], \qquad \eta = 0.05.
$$
Only low-uncertainty pixels are considered reliable for later prototype construction and supervision [2509.10134].

Class-level filtering is based on Grad-CAM. If $A^k \in \mathbb{R}^{W \times H}$ denotes the $k$-th feature map at the final convolutional layer and $y^{cup}, y^{disc}$ are the corresponding logits, the class-specific Grad-CAM weights are
$$
\alpha_k^{cup} = \frac{1}{W \cdot H}\sum_{w,h}\frac{\partial y^{cup}}{\partial A^k_{wh}},
\qquad
\alpha_k^{disc} = \frac{1}{W \cdot H}\sum_{w,h}\frac{\partial y^{disc}}{\partial A^k_{wh}}.
$$
These define coarse heatmaps
$$
e_{GC}^{cup} = \mathrm{ReLU}\left(\sum_k \alpha_k^{cup} A^k\right),
\qquad
e_{GC}^{disc} = \mathrm{ReLU}\left(\sum_k \alpha_k^{disc} A^k\right).
$$
Per-pixel feature vectors $e_v \in \mathbb{R}^D$ from the penultimate layer are then enriched by the gradient activation:
$$
e_v' = e_v \cdot e_{GC,v}.
$$
The paper’s rationale is that salient class-specific features yield more accurate uncertainty quantification and more robust prototype estimation [2509.10134].

Reliable object and background masks are defined as
$$
b_v^{ob} = 1[\widehat y_v^t=1]\cdot 1[u_v<\eta],
\qquad
b_v^{bg} = 1[\widehat y_v^t=0]\cdot 1[u_v<\eta].
$$
Using the enhanced features, the class prototypes are
$$
z^{ob} = \frac{\sum_v e_v' \cdot b_v^{ob} \cdot p_v}{\sum_v b_v^{ob}\cdot p_v},
\qquad
z^{bg} = \frac{\sum_v e_v' \cdot b_v^{bg} \cdot (1-p_v)}{\sum_v b_v^{bg}\cdot (1-p_v)}.
$$
Distances to these prototypes are computed by
$$
d_v^{ob} = \|e_v' - z^{ob}\|_2,
\qquad
d_v^{bg} = \|e_v' - z^{bg}\|_2.
$$
A pixel is retained only when its prototype assignment agrees with the initial prediction:
$$
m_v =
\bigl[1[u_v<\eta]\cdot 1[\widehat y_v^t=1]\cdot 1[d_v^{ob}<d_v^{bg}]\bigr]
+
\bigl[1[u_v<\eta]\cdot 1[\widehat y_v^t=0]\cdot 1[d_v^{ob}>d_v^{bg}]\bigr].
$$
The segmentation loss is then evaluated only on filtered pixels:
$$
L_{seg} = \sum_v m_v \cdot CE(p_v,\widehat y_v^t).
$$
In the paper’s framing, this procedure addresses both boundary noise and pixel misassignment caused by mixed cup/disc prototypes [2509.10134].

## 4. Cosine-similarity feature disalignment

After pseudolabel refinement, Grad-CL adds an explicit inter-class separation term. The paper argues that optic cup and optic disc features can still overlap in latent space, producing residual confusion. To counter this, it constructs gradient-informed representations for each pixel:
$$
\tilde e_v^{cup} = e_v + e_{GC,v}^{cup},
\qquad
\tilde e_v^{disc} = e_v + e_{GC,v}^{disc}.
$$
These features combine the baseline pixel embedding with class-specific gradient activations [2509.10134].

The contrastive term penalizes cosine similarity between the two representations:
$$
L_{sim}(v) =
\frac{\tilde e_v^{cup}\cdot \tilde e_v^{disc}}
{\max(\|\tilde e_v^{cup}\|_2 \, \|\tilde e_v^{disc}\|_2,\epsilon)},
$$
where $\epsilon$ prevents division by zero. Minimizing this term “disaligns” cup and disc features, that is, it pushes them apart in feature space. The total objective is
$$
L_{total} = L_{seg} + \lambda L_{sim},
\qquad
\lambda = 0.1.
$$
The weight $\lambda$ is reported as tuned on a small validation subset [2509.10134].

This contrastive construction is notable because it does not operate through historical source hypotheses or neighbourhood statistics. Instead, it uses gradient-informed class representations defined at pixel level. A plausible implication is that the method targets anatomically local confusion more directly than global alignment objectives. The paper’s own claim is narrower: the loss explicitly enforces inter-class separability between the gradient-informed features of the optic cup and disc [2509.10134].

## 5. Training protocol, data, and reported results

The reported source dataset is REFUGE, with 400 annotated fundus images cropped to a $512 \times 512$ ROI. The target datasets are Drishti-GS, with 99 training images and 60 test images, and RIM-ONE-r3, with 50 training images and 51 test images. Preprocessing extracts a $512 \times 512$ ROI around the optic nerve head, normalizes intensities, and applies weak augmentations: random erasing, contrast jitter, and Gaussian noise. Evaluation uses Dice coefficient (%) and Average Surface Distance (ASD in pixels) [2509.10134].

Training uses Adam with learning rate $2\times 10^{-3}$, $\beta_1=0.9$, $\beta_2=0.99$, batch size $8$, and $20$ epochs. The hyperparameters are $\gamma=0.75$, $\eta=0.05$, dropout rate $0.5$, $K=10$, and $\lambda=0.1$ [2509.10134].

The paper reports the following quantitative comparison for no adaptation, UDA, and SFDA baselines [2509.10134]:

| Method | Drishti-GS (OD Dice/ASD; OC Dice/ASD) | RIM-ONE-r3 (OD Dice/ASD; OC Dice/ASD) |
|---|---|---|
| No adaptation | 83.18 / 24.15; 74.51 / 14.44 | 93.84 / 9.05; 83.36 / 11.39 |
| BEAL (UDA) | 89.80 / –; 81.00 / – | 96.10 / –; 86.20 / – |
| DPL (SFDA) | 90.13 / 9.43; 79.78 / 9.01 | 96.39 / 4.08; 83.53 / 11.39 |
| PLPB (SFDA) | 92.89 / 6.52; 77.94 / 10.07 | 96.51 / 4.01; 83.56 / 11.11 |
| Grad-CL | 96.58 / 4.05; 84.53 / 10.38 | 94.99 / 5.02; 80.51 / 9.50 |

The paper’s key observations state that Grad-CL outperforms both UDA methods such as BEAL and AdvEnt and SFDA methods such as DPL and PLPB by $2$–$4\,\%$ Dice on OC/OD, and that boundaries are tighter, with ASD reduction of $2$–$5$ pixels [2509.10134]. Qualitative results in Figures 4 and 5 are described as showing sharper cup/disc boundaries with fewer oversegmentations or undersegmentations near the neuroretinal rim when compared with DPL, CPR, and BEAL [2509.10134].

An ablation study on divergence metrics tested alternative ways to measure dissimilarity between cup/disc gradient-feature maps. The paper reports that using KL or JS divergence produces higher Dice scores and lower ASD than Euclidean distance or MMD, and interprets this as evidence that enforcing feature-distribution divergence is more effective than simple distance minimization [2509.10134].

## 6. Interpretation, limitations, and extensions

The method’s principal strengths are presented as source-free adaptation without access to original source images, a two-stage design that combines gradient-guided pseudo-label refinement with explicit inter-class feature disalignment, and consistent gains of $+2$–$4\,\%$ Dice and $-2$–$5$ px ASD versus prior SFDA methods [2509.10134]. Within the paper’s problem framing, these strengths directly address the two identified bottlenecks of SFDA fundus segmentation: unstable pseudolabels near boundaries and insufficient separation between anatomically distinct target structures.

The reported limitations are equally specific. Grad-CL depends on the quality of Grad-CAM saliency maps; if Grad-CAM mislocalizes, the prototypes may degrade. It also introduces additional compute because Monte Carlo dropout requires $K$ stochastic passes and Grad-CAM requires gradient extraction. Finally, the hyperparameters $\eta$, $\gamma$, and $\lambda$ require tuning on a small held-out set [2509.10134]. These constraints matter because the framework couples uncertainty estimation, attribution, prototype formation, and contrastive separation; failure in one stage can propagate to later stages.

The paper identifies several possible extensions: replacing Grad-CAM with richer attribution methods such as Grad-CAM++ or Score-CAM; extending the method to multi-class segmentation, including vessels or lesion regions, or to 3D modalities such as OCT; incorporating a memory bank of target features for global contrastive learning via historical hypotheses; and using adaptive thresholding or uncertainty-aware $\lambda$ scheduling to reduce hyperparameter sensitivity [2509.10134]. This suggests that Grad-CL is less a closed recipe than a modular SFDA template centered on gradient-informed label denoising and feature separation.

In summary, Grad-CL defines SFDA for optic cup/disc segmentation as a combination of uncertainty-aware pseudolabel filtering, gradient-guided prototype estimation, and explicit cup–disc feature disalignment. Its central claim is that leveraging gradient-based saliency for pseudolabel refinement, together with an explicit cosine-similarity contrastive term, leads to state-of-the-art source-free adaptation on challenging fundus segmentation benchmarks [2509.10134].

Source: https://www.emergentmind.com/topics/grad-cl