Manuscript Offprint
arXiv:2610.22437CF-NODE: Counterfactual Spatial Node Intervention for Test-Time Adaptation Under Domain Shift, Evaluated Across Five Diabetic Retinopathy Datasets
Sabarish G and Deepak Parashar, Senior Member, IEEE
Abstract—Automated fundus-based diabetic retinopathy (DR) grading can substantially expand screening capacity, but source-trained models degrade sharply across different cameras, clinics, and patient populations. Existing test-time adaptation methods depend on entropy minimization or target information accumulated from image batches and streams. These mechanisms can reinforce confidently incorrect predictions and break down when clinical images arrive independently. We introduce CF-NODE, a novel counterfactual test-time adaptation framework for cross-domain DR grading. Instead of trusting prediction confidence or estimating a target distribution, CF-NODE asks how each prediction responds under a controlled intervention on the evidence supporting it. CF-NODE ranks internal spatial nodes using model-derived attention, feature magnitude, and node-set similarity, progressively attenuates the highest-ranked nodes, and uses the stability of the resulting expected-grade response to apply a bounded calibration of the predicted grade distribution. The framework is fully frozen and adapts every image independently using only geometric views and a fixed source-derived prior, requiring no target-derived information or model updates. We evaluate CF-NODE on five external DR datasets under repeated-seed evaluation against TENT, EATA, SAR, and T3A. CF-NODE outperforms all four methods with statistically significant improvements over the second-best method, improves AUC on every target domain, and attains the highest average AUC and macro-F1, delivering stronger grade discrimination together with more balanced recognition across DR severity levels. These results demonstrate that counterfactual intervention sensitivity provides consistent and deployment-ready domain robustness for single-image clinical inference. Code is available at https://github.com/sabarishknight/CF-Node.
Index Terms— Diabetic Retinopathy Grading, Test-time Adaptation, Domain Generalization, Counterfactual Intervention, Retinal Fundus Imaging.
I. INTRODUCTION
DIABETIC Retinopathy (DR) is one of the major causes of preventable vision loss, and accurate grading of retinal fundus images is important for timely referral and treatment [1], [2]. Deep neural networks have achieved strong performance in automated DR screening and severity grading [3], [4], [5]. However, their reliability often deteriorates when they are applied outside the training domain. Differences in retinal cameras, illumination, field of view, acquisition protocols, image quality, and patient populations can alter the appearance of fundus images and lead to confident but incorrect grades [6], [7]. This limits the safe use of a model across clinics and screening programs, even when it performs well on its original test set.
Clinical deployment also creates a difficult inference setting. Fundus images may arrive individually, on demand, and from different cameras or clinical sites. A model may not have access to a homogeneous batch of target images, and it may be unrealistic to assume that consecutive patients belong to the same target distribution. Entropy-based TTA methods [8], [9], [10] can also be risky in this setting. Low entropy indicates confidence rather than correctness, so entropy minimization may reinforce a confident but incorrect grade under domain shift. We therefore consider the following problem: how can a source-trained DR grader improve its prediction for one unlabeled image from an unseen domain without entropy minimization, parameter updates, target labels, target-domain statistics, a target batch, or an adaptation stream?
Test-time adaptation (TTA) attempts to improve model performance using unlabeled images observed during inference. A common approach is entropy minimization. TENT adapts batch-normalization parameters by reducing prediction entropy [8], while EATA combines reliable-sample filtering with anti-forgetting regularization, whereas SAR uses reliable-sample filtering and sharpness-aware updates [9], [10]. These methods can be effective, but entropy is not a direct measure of prediction correctness. A shifted model may assign high confidence to an incorrect grade and therefore produce low entropy. In this case, entropy provides little warning that correction is needed and minimizing it can make the incorrect prediction even more confident [11]. Online parameter updates may also allow an unreliable image or an unstable target batch to influence predictions for later patients.
Another group of TTA methods uses target features, class supports, prototypes, memory banks, or estimated target statistics. T3A updates class supports using incoming target features [12], while FunOTTA maintains a target-feature memory bank and uses prototype-based adaptation for fundus images [11]. Such methods can benefit from repeated observations from a stable target domain. However, their behavior can depend on pseudo-label quality, batch composition, stream order, and previously observed images [11], [12]. These assumptions may not hold when clinical images arrive independently or originate from different devices and sites. Estimating a target-class distribution or target feature structure from a single image is also unreliable. These constraints motivate a single-image method that does not rely on target-derived statistics or adaptation state carried across patients.
We introduce Counterfactual Spatial Node Intervention (CF-NODE), a frozen-model approach that obtains an adaptation signal directly from the current image. Instead of updating model parameters from entropy or estimating a target distribution, CF-NODE asks a different question: how does the predicted DR grade change when the spatial representation selected by the model is deliberately weakened? The final convolutional feature map is represented as a set of spatial nodes. CF-NODE ranks these nodes using learned attention, feature magnitude, and similarity to the complete node set, then progressively attenuates the highest-ranked nodes across four intervention levels. The magnitude and consistency of the expected-grade decrease across intervention levels define a per-image counterfactual sensitivity score. This score measures dependence within the trained model.
CF-NODE uses intervention sensitivity to control bounded, image-specific probability calibration. A small intervention response keeps the calibrated distribution close to the source prediction, while a stronger and more stable response produces a larger but bounded change in its concentration. Geometric views of the same image are then aggregated, and a fixed source-derived class prior is applied without estimating statistics from the target dataset. The complete model remains frozen, and each image is processed independently without target labels, target batches, gradients, optimization, or information from previous patients. This avoids cross-patient state and prevents an unreliable test image from changing the model used for subsequent cases.
The key distinction from existing TTA methods is the source of the adaptation signal. Entropy-based methods adapt from prediction confidence, while prototype and memory methods adapt from accumulated target features. CF-NODE instead creates a controlled intervention inside the spatial representation and uses the measured response to control the strength of bounded probability calibration. The main contributions are:
-
We introduce CF-NODE, a novel counterfactual test-time adaptation method for cross-domain DR grading. It refines each image-specific prediction through interventions on ranked internal spatial nodes.
-
We develop a model-guided framework that first ranks internal spatial nodes using attention, feature magnitude, and global node-set similarity, then applies graded counterfactual interventions to the highest-ranked nodes and converts the stability-normalized expected-grade response into a bounded probability correction.
-
CF-NODE enables fully frozen, independent-image deployment. Each prediction uses only the frozen source model, geometric views of the current image, and a fixed source-derived prior, requiring no target labels, cross-image target batches or statistics, memory banks, pseudo-labels, gradients, model updates, or persistent adaptation state.
-
Across five external DR datasets, CF-NODE improves AUC on every target and achieves the highest mean AUC and macro-F1 among the evaluated methods. Relative to source-only inference, it gains 2.1 and 6.2 percentage points on average, demonstrating stronger grade discrimination and class-balanced recognition under domain shift.
Deep learning has been widely studied for automated DR screening and grading. Gulshan et al. [3] and Ting et al. [4] demonstrated strong diagnostic performance across large and diverse fundus image collections, while Krause et al. [13] highlighted the importance of expert reference-label quality. Zoom-in networks [14] and class-attention modules [15] further improve grading by emphasizing lesion-related regions. However, these approaches mainly improve feature extraction and do not directly address unseen domain shifts during deployment.
DR models often degrade across cameras, illumination conditions, acquisition protocols, and patient populations [7], [16]. Domain adaptation and transfer learning can reduce these differences [17] but generally require target samples and an additional adaptation stage. CF-NODE considers the stricter setting in which target images arrive independently and the target distribution is unavailable.
Test-time adaptation modifies model behavior during inference without target labels. TENT [8] minimizes entropy by updating batch-normalization parameters, EATA [9] adds reliable-sample filtering and anti-forgetting regularization, and SAR [10] uses sharpness-aware adaptation. These methods rely on confidence-based optimization and parameter updates, through which an unreliable update may affect subsequent predictions. T3A [12], LAME [18], and FunOTTA [11] instead use target supports, batch relationships, prototypes, or memory banks. Their behavior can therefore depend on multiple target samples, stream order, or accumulated information. In contrast, CF-NODE derives its adaptation signal from the current image while keeping the model frozen, requiring no target batch, accumulated features, statistics, or cross-image state.
Counterfactual reasoning examines how an outcome changes under an intervention [19], [20], [21]. Attribution methods such as Grad-CAM [22] and integrated gradients [23], together with attention-based multiple-instance learning [24], identify image regions that influence a prediction but are mainly used for interpretation or localization. CF-NODE instead uses the response to controlled intervention on ranked internal spatial nodes to refine predictions under domain shift. This model-level intervention measures dependence within the trained network and does not identify clinical lesions or establish clinical causality. The recent FACTOR preprint [25] uses counterfactual input perturbations for open-vocabulary object detection, whereas CF-NODE performs representation-level intervention for image-level DR grading.
Class prevalence can also affect predictions. Logit adjustment incorporates class-frequency information into classifier outputs [26], but estimating a target prior requires multiple target samples and is unreliable for independent-image inference. Because the balanced EyePACS training subset removes the original source proportions, CF-NODE applies a weighted source-derived log-prior after multi-view aggregation. It uses only stored source frequencies and does not estimate or claim to recover the target-class prevalence.
III. METHOD
Fig. 1 provides an overview of CF-NODE. Given an unlabeled image from an unseen domain, the frozen source model produces a class distribution and a set of spatial feature nodes. CF-NODE ranks these nodes and attenuates the highest-ranked subset at several intervention levels. The changes in the model output are summarized as a per-image intervention-sensitivity score. This score controls a sensitivity-dependent temperature that calibrates the class distribution. The calibrated distributions are then aggregated across geometric views and adjusted using a fixed source-derived class prior. No target labels, target-domain statistics, gradients, or parameter updates are used.

Fig. 1. Block diagram of the proposed CF-NODE framework.
A. Source Model and Spatial Representation
CF-NODE requires a source model that exposes spatial feature vectors in addition to its class prediction. For an image , the encoder produces a feature map . Let denote the feature vector at the -th spatial position, where . The spatial features are projected into -dimensional node embeddings:
Here, , , and . The projection parameters are learned during source training and frozen during test-time inference. The resulting node set is
Each represents the encoder features associated with one receptive-field region of the image. A node is an internal representation and is not assumed to correspond directly to a pathological structure.
A learned attention module assigns an unnormalized scalar score to each node, where is the attention-scoring module. The module is learned during source training and frozen during inference. The scores are normalized into attention weights:
The attention-weighted nodes form a node-level descriptor :
A second branch obtains a global descriptor through generalized mean pooling and a learned global projection. The global descriptor is fused with the node-level descriptor:
Here, is the learned global projection, denotes feature concatenation, and is the learned fusion block. The GeM exponent is initialized to 3.0, learned during source training, and frozen during test-time inference.
The fused representation is passed to a K-class prediction head to obtain the class logits and baseline class probabilities :
Here, is the fixed default temperature selected using only the EyePACS validation split. All source-model components remain frozen during test-time inference. The source architecture and training procedure are described in Section IV. For the present DR application, K = 5.
B. Counterfactual Spatial Node Intervention
- Node Ranking: Before intervention, CF-NODE assigns each node a score using three model-derived signals: attention weight, feature magnitude, and similarity to the complete node set. The latter two are normalized within each image. The normalized feature magnitude is
The mean cosine similarity of node to the complete node set is
The similarity values are normalized within the image:
The final node-importance score is
Here, and prevent division by zero. We use the fixed weights and , selected using only the EyePACS validation split. The score measures similarity to all nodes in the image rather than only spatial neighbors. Nodes are ranked in descending order of . This ranking selects the representations to be intervened on and does not determine whether they contain pathological or domain-specific information.
- Multi-Level Intervention:
Let
denote intervention levels, where is the selected node fraction and is the retained magnitude. We use with . If contains the highest-ranked nodes, the intervened node representation is
The resulting node set is V^{(m)} = v_i^{(m)}_{i=1}^N. For each level, the attention pooling, fusion block, and classifier are reevaluated using , while the global descriptor remains fixed. Attention weights are recomputed, allowing the frozen attention module to respond to the modified node set.
Let p be the original class distribution in (6). After intervention level m, let denote the reevaluated class logits. The corresponding distribution is
where is the same default temperature used for the original and intervened distributions. The expected grade is
The one-sided response at intervention level (m) is
The stable intervention-sensitivity score is
where prevents instability when the responses have low variance. A high indicates that the mean one-sided reduction is large relative to its variation across intervention levels. Because the intervention modifies only selected nodes while the image, model parameters, global descriptor, and remaining nodes stay fixed, measures directional sensitivity to the selected representation. It does not establish lesion importance or clinical causality.
C. Sensitivity-Dependent Calibration:
The stable intervention-sensitivity score determines a bounded temperature for the class distribution of the current view:
The calibrated per-view distribution is
Here, and . When the intervention response is small, remains close to the default temperature . A larger stable response lowers and increases the concentration of the class distribution within fixed bounds. All constants are selected using only the EyePACS validation split. The procedure uses only the current image and frozen source model, without target labels, target-domain statistics, gradients, parameter updates, or cross-image adaptation state. The resulting is passed to multi-view aggregation.
D. Multi-View Inference and Source-Prior Adjustment
The complete procedure is applied independently to a set A of label-preserving geometric views of the same image. For each transformation , denotes the corresponding view of image x. The calibrated distributions are averaged:
Here, is the number of geometric views. A fixed source-prior adjustment is then applied:
Here, , and , where is the number of Grade (k) images in the full EyePACS training set before balanced subsampling. We use and . Both logarithms are applied elementwise. The source prior is fixed before external evaluation and is not estimated from target images. The final grade prediction is
For the present DR application, CF-NODE uses five geometric views: the original image, horizontal flip, vertical flip, 90° rotation, and 270° rotation. Each view is processed independently through the frozen model and intervention procedure before probability averaging.
For computational efficiency, the four intervention sets for each view are concatenated and evaluated together through the attention, fusion, and classification blocks. All operations remain sample-wise, so this temporary batching introduces no target-domain statistics or cross-image adaptation state. The source model remains in evaluation mode throughout inference.
IV. EXPERIMENT SETUP

Fig. 2. Fundus images and RGB foreground pixel-intensity distributions across the source and target datasets
We test CF-NODE in a cross-domain setting. A source model is trained on EyePACS and evaluated on five external DR datasets collected using different acquisition systems. No target-domain image or label is used during source training, hyperparameter selection, or test-time correction.
A. Datasets
The source domain is the labeled EyePACS training set [27], which contains 35,126 fundus images graded from 0 to 4. Following the source-training protocol used by FunOTTA [11], we select a balanced subset of 3,540 images, with 708 images per grade. This subset is divided into 2,832 training and 708 validation images using an 80/20 split. Cross-domain evaluation is conducted on five target datasets: IDRiD [28], containing 516 images; MESSIDOR-2 [29] containing 1,748 images, of which 1,744 gradable images are used; OIA-DDR [30], containing 13,673 images, of which 12,522 images labeled from Grade 0 to Grade 4 are used; DeepDRiD [6], containing 2,000 images, from which the official validation set of 400 images is used; and SUSTech-SYSU [31], containing 1,219 images, of which 1,151 images labeled from Grade 0 to Grade 4 are used after excluding 68 images with laser spots or scars. Representative images across Grades 0 to 4 and the foreground RGB intensity distributions of the source and target datasets are shown in Fig. 2. These datasets cover different clinical sites and image-acquisition systems. Every target image is processed independently, without target batches or previously accumulated target information. Target labels are not used during adaptation and are accessed only after inference to calculate the evaluation metrics.
B. Evaluation Metrics
The target datasets have different class distributions, with substantially fewer examples of severe DR grades. We therefore report macro-averaged one-vs-rest AUC and macro-F1. AUC is calculated from the normalized five-class probabilities, with classes absent from a target dataset excluded from its macro average. Macro-F1 is calculated from the discrete argmax predictions. Results are reported for each target dataset and as the mean across all five datasets. All values are presented as mean ( ) standard deviation over five random seeds.
C. Implementation Details
The source model uses an ImageNet-initialized ResNet-50 backbone [32] with inputs. Its final feature map provides 100 spatial nodes, each projected to a 128-dimensional embedding. The nodes are aggregated using an attention-based DeepSets module [33], while a learnable generalized mean-pooling layer [34] produces a global descriptor. The node and global descriptors are fused and passed to a five-class classification head.
The training objective combines cross-entropy with label smoothing and focal loss with . Only the task-specific layers above the backbone are trained during the first four epochs, followed by the fourth ResNet stage from epochs 5 to 14 and the complete network from epoch 15 onward. We use AdamW, cosine-annealing warm restarts, weight decay of , gradient clipping at 1.0, and an exponential moving average with decay 0.999. Training uses a batch size of 16 for at most 40 epochs, with early stopping on the EyePACS validation set using a patience of 15 epochs. The best exponential-moving-average checkpoint is used for all target-domain experiments.
Training augmentation consists of random resized cropping, horizontal flipping, mild rotation, light color jitter, and occasional Gaussian blur. Validation and base test images are resized to and normalized using ImageNet statistics. Experiments are implemented in PyTorch and run using two NVIDIA Tesla T4 GPUs.
D. Baselines
We compare CF-NODE with the source-only model, TENT [8], EATA [9], SAR [10], and T3A [12]. For each training seed, all methods use the same source checkpoint, input preprocessing, target-image order, and evaluation code. Method-specific hyperparameters are selected using only the EyePACS validation split and fixed before external evaluation. A fresh copy of the corresponding source checkpoint is loaded for every method, target dataset, and training-seed run. Target images are processed in their original order without shuffling. For methods that maintain an online adaptation state, the state is reset at the beginning of each target dataset.
In our study, TENT, EATA, and SAR are slightly modified because of the high sensitivity of the DR grading model to parameter changes. When reproduced with their original update rules, these methods show unstable and degraded performance in our setting. By updating only the classifier weights, we obtain a clear improvement, and we therefore report this stronger configuration, marked by in Tables II and III. The same reproduction strategy is used for these baselines in FunOTTA [11].
For CF-NODE, the source model remains in evaluation mode, and inference is performed without gradients or parameter updates. Five geometric views are generated for each image: the original image, horizontal flip, vertical flip, 90° rotation, and 270° rotation. Each view is processed independently through the complete CF-NODE pipeline.
Node importance is computed as a weighted combination of attention, feature magnitude, and representation consistency, with weights of 0.50, 0.25, and 0.25, respectively. We use four intervention configurations: 0.02, 0.75, 0.05, 0.40, 0.10, 0.20, and 0.15, 0.10. In each pair, the first value specifies the proportion of top-ranked nodes selected for intervention, and the second specifies their multiplicative attenuation factor. All CF-NODE settings, including the intervention configurations, node-ranking weights, temperature parameters, and source-prior strength, are selected using only the EyePACS validation split. The intervention-sensitivity score determines the sensitivity-dependent temperature according to the calibration rule defined in Section III.
The calibrated class distributions from the five geometric views are averaged. We then apply a fixed source-prior adjustment with strength 0.18 using the stored source-derived prior.
V. RESULTS AND DISCUSSION
Tables II and III compare CF-NODE with the source-only ResNet-50 and four TTA methods, TENT [8], EATA [9], SAR [10], and T3A [12], across IDRiD, MESSIDOR-2, OIA-DDR, DeepDRiD, and SUSTech-SYSU. All methods use the same source checkpoints, preprocessing, target-image order, and evaluation pipeline. Method-specific hyperparameters are selected using only the EyePACS validation split and are applied unchanged to all five target domains.
CF-NODE achieves the highest average AUC of 80.3% and macro-F1 of 42.1%. Compared with the source-only model, this corresponds to improvements of 2.1 percentage points in AUC and 6.2 percentage points in macro-F1. Its AUC gains are 2.9, 1.2, 1.6, 2.1, and 2.4 percentage points on IDRiD, MESSIDOR-2, OIA-DDR, DeepDRiD, and SUSTech-SYSU, respectively. CF-NODE obtains the highest AUC on all five datasets and the highest macro-F1 on IDRiD, MESSIDOR-2, and OIA-DDR. Its average improvement over the second-best method is statistically significant for both AUC and macro-F1 .
The baseline methods show different behavior across the two metrics. TENT maintains the same average AUC as the source model at 78.2%, while improving macro-F1 from 35.9% to 38.7%. EATA produces a similar result, with an average AUC of 78.1% and macro-F1 of 37.4%. SAR improves macro-F1 to 37.5% but reduces average AUC to 77.6%, while T3A obtains the second-highest average AUC of 79.1% but a macro-F1 of 36.1%. Because AUC measures class-probability ranking and macro-F1 measures discrete grade assignments, improvements in one metric do not necessarily produce comparable improvements in the other. Fig. 3 shows these per-domain differences, where the mean ± SD interval of CF-NODE lies entirely above zero for AUC, while TENT, EATA, and SAR span both sides of zero.
CF-NODE provides the strongest average performance across both metrics. The simultaneous improvement in AUC and macro-F1 is important for cross-domain DR grading because AUC measures ranking performance, while macro-F1 gives equal importance to each grade and reduces the influence of the dominant Grade 0 class. On DeepDRiD, CF-NODE improves macro-F1 over the source model from 37.9% to 39.5% and achieves the highest AUC of 77.0%, although TENT obtains a higher macro-F1 of 41.2%. On SUSTech-SYSU, CF-NODE achieves the highest AUC of 82.4% and the highest macro-F1 among the adaptation methods at 37.3% but remains 1.1 percentage points below the source model's macro-F1 of 38.4%. This result is consistent with the strongly imbalanced grade distribution of SUSTech-SYSU [31], which makes macro-F1 sensitive to a small number of errors in minority grades. As Fig. 3 shows, every evaluated method loses macro-F1 on this domain, and CF-NODE loses the least. Since CF-NODE does not estimate target-specific class frequencies, improved probability ranking may not always translate into the target-specific grade boundaries that maximize macro-F1. Nevertheless, its highest AUC on every target dataset and its highest average performance across both metrics support more consistent domain robustness, while the DeepDRiD and SUSTech-SYSU results show that dataset-specific discrete grade decisions remain challenging.
To isolate the contribution of counterfactual node selection, we keep the geometric views, fixed source prior, source checkpoints, and evaluation protocol unchanged. Tables IV and V compare the fixed scaffold without node intervention, random-node intervention, and full CF-NODE with ranked node selection. Results are averaged over five seeds across all five target domains. All variants operate without target labels, target-domain statistics, gradients, or parameter updates. The fixed scaffold achieves 79.7% average AUC and 40.7% macro-F1, while random-node intervention gives nearly identical results of 79.8% and 40.7%, showing that arbitrary intervention provides little benefit. Full CF-NODE improves these averages to 80.3% and 42.1%, gains of 0.6 AUC and 1.4 macro-F1 points. It improves AUC on all five domains and macro-F1 on four, with the largest macro-F1 gains on MESSIDOR-2 and IDRiD. Although random selection gives marginally higher AUC on DeepDRiD and SUSTech-SYSU, and SUSTech-SYSU macro-F1 remains nearly unchanged, these differences do not improve average performance. Overall, the results confirm that the gains come from ranked counterfactual node selection rather than arbitrary node attenuation.
VI. Conclusion
In this paper, we introduced CF-NODE, a counterfactual node-based test-time adaptation framework for robust diabetic retinopathy grading under domain shift. Unlike methods that rely mainly on prediction confidence or accumulated target statistics, CF-NODE examines how predictions respond when ranked disease-related spatial nodes are progressively attenuated. This counterfactual evidence is combined with a fixed source prior to adapt each target image independently, without target labels, target-domain statistics, gradients, parameter updates, or cross-patient adaptation state.
We validated CF-NODE across five diverse fundus image datasets: IDRiD, MESSIDOR-2, OIA-DDR, DeepDRiD, and SUSTech-SYSU. CF-NODE achieved the best average performance among all evaluated methods, reaching 80.3% AUC and 42.1% macro-F1, with improvements of 2.1 and 6.2 percentage points over the source-only model. It obtained the highest AUC on all five target domains and the highest macro-F1 on three, with statistically significant improvements over the second-best method. The ablation results further confirm that the gains come from ranked counterfactual node selection rather than arbitrary node intervention. Overall, these findings demonstrate the effectiveness and consistency of CF-NODE for single-image adaptation across different acquisition settings.
The current evaluation focuses on closed-set diabetic retinopathy grading using fundus images. Future work will investigate the applicability of CF-NODE to other retinal conditions, such as glaucoma and age-related macular degeneration, and to broader medical imaging tasks under domain shift. We hope that this work supports further development of reliable counterfactual test-time adaptation methods for medical image analysis.

Fig. 3. Domain-wise AUC and macro-F1 differences from source-only ResNet-50. Diamonds and whiskers show the cross-domain mean ±SD; positive values favor adaptation.
TABLE II AUC COMPARISON ACROSS FIVE TARGET DOMAINS
| Dataset | IDRiD | MESSIDOR-2 | OIA-DDR | DeepDRiD | SUSTech-SYSU | Avg |
|---|---|---|---|---|---|---|
| Metric | AUC | AUC | AUC | AUC | AUC | AUC |
| ResNet50 | ||||||
| TENT† [8] | ||||||
| EATA† [9] | ||||||
| SAR† [10] | ||||||
| T3A [12] | ||||||
| CF-NODE (ours) |
TABLE III MACRO-F1 COMPARISON ACROSS FIVE TARGET DOMAINS
| Dataset | IDRiD | MESSIDOR-2 | OIA-DDR | DeepDRiD | SUSTech-SYSU | Avg |
|---|---|---|---|---|---|---|
| Metric | F1 | F1 | F1 | F1 | F1 | F1 |
| ResNet50 | ||||||
| TENT† [8] | ||||||
| EATA† [9] | ||||||
| SAR† [10] | ||||||
| T3A [12] | ||||||
| CF-NODE (ours) |
Note (table II & III): Values are reported as mean over five seeds, with SD shown as a subscript. Bold and underlined means indicate the best and second-best results, respectively. The dagger symbol ( ) indicates that the method was adapted to our setting by fine-tuning only the classifier weights. * and ** indicate significance against the second-best method using a paired t-test on matched seed-level results ( ) and ( ).
TABLE IV AUC ABLATION OF COUNTERFACTUAL NODE SELECTION ACROSS TARGET DOMAINS
| Configuration | Node selection | MESSIDOR-2 | IDRiD | DeepDRiD | OIA-DDR | SUSTech-SYSU | Avg. |
|---|---|---|---|---|---|---|---|
| Metric | AUC | AUC | AUC | AUC | AUC | AUC | |
| Fixed scaffold | None | 79.24 | 82.35 | 76.79 | 77.50 | 82.37 | 79.7 |
| Random-node CF | Random | 79.23 | 82.40 | 77.14 | 77.57 | 82.48 | 79.8 |
| Full CF-NODE | Ranked | 79.91 | 83.75 | 77.01 | 78.31 | 82.41 | 80.3 |
TABLE V MACRO-F1 ABLATION OF COUNTERFACTUAL NODE SELECTION ACROSS TARGET DOMAINS
| Configuration | Node selection | MESSIDOR-2 | IDRiD | DeepDRiD | OIA-DDR | SUSTech-SYSU | Avg. |
|---|---|---|---|---|---|---|---|
| Metric | F1 | F1 | F1 | F1 | F1 | F1 | |
| Fixed scaffold | None | 44.18 | 46.09 | 38.07 | 37.99 | 37.36 | 40.7 |
| Random-node CF | Random | 44.18 | 46.03 | 38.23 | 37.81 | 37.24 | 40.7 |
| Full CF-NODE | Ranked | 46.83 | 48.08 | 39.55 | 38.85 | 37.35 | 42.1 |
VII. REFERENCES
[1] H. Li et al., "Current research and future strategies for the management of vision-threatening diabetic retinopathy," Asia-Pac. J. Ophthalmol., vol. 13, no. 5, Sep./Oct. 2024, Art. no. 100109, doi: 10.1016/j.apjo.2024.100109.
[2] Z. L. Teo et al., "Global prevalence of diabetic retinopathy and projection of burden through 2045: Systematic review and meta-analysis," Ophthalmology, vol. 128, no. 11, pp. 1580–1591, Nov. 2021, doi: 10.1016/j.ophtha.2021.04.027.
[3] V. Gulshan et al., "Development and validation of a deep learning algorithm for detection of diabetic retinopathy in retinal fundus photographs," JAMA, vol. 316, no. 22, pp. 2402–2410, Dec. 2016, doi: 10.1001/jama.2016.17216.
[4] D. S. W. Ting et al., "Development and validation of a deep learning system for diabetic retinopathy and related eye diseases using retinal images from multiethnic populations with diabetes," JAMA, vol. 318, no. 22, pp. 2211–2223, Dec. 2017, doi: 10.1001/jama.2017.18152.
[5] R. Sayres et al., "Using a deep learning algorithm and integrated gradients explanation to assist grading for diabetic retinopathy," Ophthalmology, vol. 126, no. 4, pp. 552–564, Apr. 2019, doi: 10.1016/j.ophtha.2018.11.016.
[6] R. Liu et al., "DeepDRiD: Diabetic retinopathy—Grading and image quality estimation challenge," Patterns, vol. 3, no. 6, Jun. 2022, Art. no. 100512, doi: 10.1016/j.patter.2022.100512.
[7] D. C. Castro, I. Walker, and B. Glocker, "Causality matters in medical imaging," Nat. Commun., vol. 11, no. 1, Jul. 2020, Art. no. 3673, doi: 10.1038/s41467-020-17478-w.
[8] D. Wang, E. Shelhamer, S. Liu, B. Olshausen, and T. Darrell, "Tent: Fully test-time adaptation by entropy minimization," in Proc. Int. Conf. Learn. Represent. (ICLR), 2021.
[9] S. Niu et al., "Efficient test-time model adaptation without forgetting," in Proc. Int. Conf. Mach. Learn. (ICML), 2022, pp. 16888–16905.
[10] S. Niu et al., "Towards stable test-time adaptation in dynamic wild world," in Proc. Int. Conf. Learn. Represent. (ICLR), 2023.
[11] Q. Zeng, L. Zhang, Y. Liu, C. Zhu, and F. Zhang, "FunOTTA: On-the-fly adaptation on cross-domain fundus image via stable test-time training," IEEE Trans. Med. Imag., early access, doi: 10.1109/TMI.2025.3631049.
[12] Y. Iwasawa and Y. Matsuo, "Test-time classifier adjustment module for model-agnostic domain generalization," in Proc. Adv. Neural Inf. Process. Syst. (NeurIPS), vol. 34, 2021, pp. 2427–2440.
[13] J. Krause et al., "Grader variability and the importance of reference standards for evaluating machine learning models for diabetic retinopathy," Ophthalmology, vol. 125, no. 8, pp. 1264–1272, Aug. 2018, doi: 10.1016/j.ophtha.2018.01.034.
[14] Z. Wang, Y. Yin, J. Shi, W. Fang, H. Li, and X. Wang, "Zoom-in-Net: Deep mining lesions for diabetic retinopathy detection," in Proc. Med. Image Comput. Comput.-Assist. Intervent. (MICCAI), 2017, pp. 267–275, doi: 10.1007/978-3-319-66179-7_31.
[15] A. He, T. Li, N. Li, K. Wang, and H. Fu, "CABNet: Category attention block for imbalanced diabetic retinopathy grading," IEEE Trans. Med. Imag., vol. 40, no. 1, pp. 143–153, Jan. 2021, doi: 10.1109/TMI.2020.3023463.
[16] M. Wang and W. Deng, "Deep visual domain adaptation: A survey," Neurocomputing, vol. 312, pp. 135–153, Oct. 2018, doi: 10.1016/j.neucom.2018.05.083.
[17] T. Chen et al., "Cross-modality transfer learning with knowledge infusion for diabetic retinopathy grading," Front. Med., vol. 11, May 2024, Art. no. 1400137, doi: 10.3389/fmed.2024.1400137.
[18] M. Boudiaf, R. Mueller, I. Ben Ayed, and L. Bertinetto, "Parameter-free online test-time adaptation," in Proc. IEEE/CVF Conf. Comput. Vis. Pattern Recognit. (CVPR), 2022, pp. 8344–8353, doi: 10.1109/CVPR52688.2022.00816.
[19] J. Pearl, "An introduction to causal inference," Int. J. Biostat., vol. 6, no. 2, 2010, Art. no. 7, doi: 10.2202/1557-4679.1203.
[20] S. Wachter, B. Mittelstadt, and C. Russell, "Counterfactual explanations without opening the black box: Automated decisions and the GDPR," Harvard J. Law Technol., vol. 31, no. 2, pp. 841–887, 2018.
[21] Y. Goyal, Z. Wu, J. Ernst, D. Batra, D. Parikh, and S. Lee, "Counterfactual visual explanations," in Proc. Int. Conf. Mach. Learn. (ICML), 2019, pp. 2376–2384.
[22] R. R. Selvaraju, M. Cogswell, A. Das, R. Vedantam, D. Parikh, and D. Batra, "Grad-CAM: Visual explanations from deep networks via gradient-based localization," in Proc. IEEE Int. Conf. Comput. Vis. (ICCV), 2017, pp. 618–626, doi: 10.1109/ICCV.2017.74.
[23] M. Sundararajan, A. Taly, and Q. Yan, "Axiomatic attribution for deep networks," in Proc. Int. Conf. Mach. Learn. (ICML), 2017, pp. 3319–3328.
[24] M. Ilse, J. M. Tomczak, and M. Welling, "Attention-based deep multiple instance learning," in Proc. Int. Conf. Mach. Learn. (ICML), 2018, pp. 2127–2136.
[25] K. Zhao, M. Ye, L. Zhou, H. Wang, L. Ji, S. Tang, and X. Zhu, "FACTOR: Counterfactual training-free test-time adaptation for open-vocabulary object detection," 2026, arXiv:2605.03294.
[26] A. K. Menon, S. Jayasumana, A. S. Rawat, H. Jain, A. Veit, and S. Kumar, "Long-tail learning via logit adjustment," in Proc. Int. Conf. Learn. Represent. (ICLR), 2021.
[27] EyePACS, "Diabetic retinopathy detection," Kaggle, 2015. [Online]. Available: https://www.kaggle.com/c/diabetic-retinopathy-detection
[28] P. Porwal et al., "Indian Diabetic Retinopathy Image Dataset (IDRiD): A database for diabetic retinopathy screening research," Data, vol. 3, no. 3, Jul. 2018, Art. no. 25, doi: 10.3390/data3030025.
[29] E. Decencière et al., "Feedback on a publicly distributed image database: The Messidor database," Image Anal. Stereol., vol. 33, no. 3, pp. 231–234, Aug. 2014, doi: 10.5566/ias.1155.
[30] T. Li, Y. Gao, K. Wang, S. Guo, H. Liu, and H. Kang, "Diagnostic assessment of deep learning algorithms for diabetic retinopathy
screening," Inf. Sci., vol. 501, pp. 511–522, Oct. 2019, doi: 10.1016/j.ins.2019.06.011.
[31] L. Lin et al., "The SUSTech-SYSU dataset for automated exudate detection and diabetic retinopathy grading," Sci. Data, vol. 7, no. 1, Nov. 2020, Art. no. 409, doi: 10.1038/s41597-020-00755-0.
[32] K. He, X. Zhang, S. Ren, and J. Sun, "Deep residual learning for image recognition," in Proc. IEEE Conf. Comput. Vis. Pattern Recognit. (CVPR), 2016, pp. 770–778, doi: 10.1109/CVPR.2016.90.
[33] M. Zaheer, S. Kottur, S. Ravanbakhsh, B. Póczos, R. Salakhutdinov, and A. Smola, "Deep sets," in Proc. Adv. Neural Inf. Process. Syst. (NeurIPS), vol. 30, 2017, pp. 3391–3401.
[34] A. Radenović, G. Tolias, and O. Chum, "Fine-tuning CNN image retrieval with no human annotation," IEEE Trans. Pattern Anal. Mach. Intell., vol. 41, no. 7, pp. 1655–1668, Jul. 2019, doi: 10.1109/TPAMI.2018.2846566.