Manuscript Offprint
arXiv:2610.40954CAMEL: Cross-Architecture Masked Embedding Learning for Ultra-Lightweight Retinal Foundation Models
Abstract
Recent progress in deep learning has substantially advanced automated grading of ophthalmologic pathologies, supported by large annotated datasets and improved representation learning. However, a significant gap remains between state-of-the-art performance and clinical scalability. In particular, foundation models have reshaped image-based medical screening and diagnosis. These large-scale architectures trained on extensive datasets learn rich, generalizable feature representations that can be adapted to a wide range of downstream tasks. In ophthalmology, RETFound, one of the most relevant foundation models for retinal images, performs strongly across classification, segmentation, and risk prediction tasks. Despite their effectiveness, foundation models are often computationally prohibitive, hindering their deployment in real-world clinical environments where hardware constraints and latency are critical. To bridge this gap, we introduce CAMEL (Cross-Architecture Masked Embedding Learning), a novel cross-architecture distillation framework that uses an asymmetric masking strategy during embedding learning to effectively transfer knowledge from massive teacher foundation models to compact, lightweight student models. Our experimental evaluation across four datasets shows that CAMEL preserves accuracy while drastically reducing computational complexity, enabling lightweight yet highly accurate models suitable for resource-limited clinical settings.
CCS Concepts
• Computing methodologies → Machine learning; Transfer learning; • Applied computing → Health informatics.
1 Introduction
Recent progress in deep learning has substantially advanced automated grading of ophthalmologic pathologies, supported by large annotated datasets and improved representation learning [16]. However, a significant gap remains between state-of-the-art performance and clinical scalability [19]. In particular, foundation models have reshaped the medical imaging landscape. These large-scale architectures trained on extensive datasets learn rich, generalizable feature representations that easily adapt to a wide range of downstream tasks [1]. In ophthalmology, RETFound [22], a prominent foundation model trained on vast retinal image repositories,

Figure 1: Comparison of parameter count, computational cost, and AUROC between RETFound, a large Transformer-based foundation model, and a series of lightweight models for the dataset IDRID. The suffix “D” represents models distilled from RETFound.
has demonstrated exceptional performance across classification, segmentation, and risk prediction tasks.
Despite their effectiveness, foundation models are computationally restrictive, severely hindering their deployment in real-world clinical environments where hardware constraints, energy consumption, and latency are critical. Model distillation [8] has emerged as a promising strategy for transferring knowledge from a massive teacher model to a compact student model. This approach is particularly valuable in medical applications, enabling real-time screening on diverse instruments, including mobile devices [12]. However, conventional distillation approaches often struggle to bridge structurally different architectures.
To address these limitations, we introduce CAMEL (Cross-Architecture Masked Embedding Learning), a novel feature-distillation framework that transfers representations across heterogeneous architectures using masked distillation. To demonstrate the versatility of CAMEL, we evaluate its performance across a broad spectrum of lightweight student backbones, including Convolutional Neural Networks (MobileNet [9], EfficientNet [18], and a standard U-Net [15] encoder), a Vision Transformer (TinyViT [20]), and a State-Space Model (Vision Mamba - Vim [23]).
To assess model performance, we evaluate four publicly available benchmark datasets for Diabetic Retinopathy (DR) grading:
IDRiD [14], APTOS 2019 [10], mBRSET [12], and MESSIDOR-2 [4]. Including mBRSET is particularly meaningful, as its images are captured via mobile devices, reflecting the unconstrained, low-resource clinical conditions our lightweight models target. Together, these benchmarks present significant heterogeneity in image quality, illumination, hardware, and patient demographics, serving as a rigorous testbed for cross-domain generalization.
As illustrated in Fig. 1, our empirical results show that distilled student models consistently outperform their counterparts trained from scratch across all evaluated architectures. Furthermore, we show that masked feature distillation [21] provides greater robustness under domain shifts than unmasked distillation. By benchmarking a wide range of architectures within CAMEL, we offer a comprehensive spectrum of operational choices, enabling practitioners to select the optimal trade-off between computational cost and diagnostic precision according to their deployment constraints. Finally, our code and implementation details are publicly available¹.
In summary, our main contributions are threefold:
- We propose the Cross-Architecture Masked Embedding Learning (CAMEL) framework, a novel feature-distillation framework that leverages asymmetric masked embedding alignment to transfer knowledge from large-scale foundation models (such as RETFound) into compact, lightweight student backbones across heterogeneous architectural paradigms.
- We comprehensively evaluate CAMEL across diverse vision backbones, demonstrating that distilled models usually outperform their counterparts trained from scratch and providing a flexible spectrum of accuracy-efficiency trade-offs.
- We make our complete implementation codebase, model configurations, and pre-processing pipeline publicly available to foster further research into resource-constrained medical imaging deployment.
2 Related Work
The transition from high-performance research models to practical clinical tools requires navigating several technical bottlenecks. This section reviews three complementary research directions that motivate our approach: general self-supervised learning and foundation models, their adaptation to ophthalmology, and RETFound, a specific, recent, yet widely used foundation model for retinal images.
2.1 Foundation Models and Self-Supervised Learning
Foundation models have fundamentally influenced modern machine learning by acting as versatile “base” systems that learn general-purpose features. As defined by Bommasani et al. [1], these models are trained on massive datasets and can be adapted to a wide variety of downstream tasks. Their success is largely driven by self-supervised learning (SSL), which enables networks to learn deep semantic representations without exhaustive human labeling.
Among SSL methods, DINO [2] demonstrated that Vision Transformers (ViTs) could learn object-centric representations through self-supervision by having a “student” network predict the outputs
of a “teacher” model. This teacher-student paradigm is central to our proposal; however, while DINO typically employs homogeneous architectures, we explore a heterogeneous distillation strategy, transferring knowledge from a massive Transformer-based teacher to a State Space Model-based student or Convolutional Neural Networks (CNNs).
2.2 Foundation Models in Ophthalmology
Inspired by their success on natural images, foundation models have been specialized for several application domains, including retinal imaging (e.g., Figure 2), where they are designed to handle the distinctive textures and structures of the eye. The most significant milestone in this domain is RETFound, introduced by Zhou et al. [22]. Pretraining a large Vision Transformer (ViT) on 1.6 million unlabeled fundus images using Masked Autoencoder (MAE), RETFound established a new state-of-the-art for ophthalmic tasks, acting as a robust feature extractor from retinal images. However, this power comes at a high computational price: 303M parameters and 119.29 GFLOPs per forward pass.
Other ophthalmic foundation models explore different modalities and training strategies. RetCLIP [5] aligns retinal images with clinical text reports through contrastive language, enabling zero-shot inference and cross-modal retrieval. EyeFounder [17] further extends foundation models to broader ocular datasets and three-dimensional imaging modalities. Despite their expanded scope, such models remain computationally expensive, motivating the need for efficient distilled alternatives.
3 CAMEL: Cross-Architecture Masked Embedding Learning
The primary challenge in deploying models like RETFound is the Transformer bottleneck. Although Transformers dominate current benchmarks [5, 17, 22], their quadratic complexity [7] in sequence length limits scalability for high-resolution medical images and their use in resource-constrained environments. To address this, we move from heavy, attention-based foundation models to highly efficient, lightweight architectures.
One strategy to achieve this computational reduction is transferring the representation capabilities of the large foundation model into diverse lightweight student architectures. Rather than being restricted to homogeneous distillation, our framework supports a wide spectrum of compact backbones, from structurally similar, lightweight Vision Transformers (such as TinyViT [20]) to heterogeneous paradigms including Convolutional Neural Networks (CNNs) and selective State-Space Models (SSMs, such as Vision Mamba - Vim [23]). This flexible cross-architecture alignment enables student models to inherit the teacher's spatial and semantic representations while leveraging their respective architectural efficiencies for linear-time inference or reduced operational footprints.
To capture RETFound's representational strengths in a computationally efficient architecture, we propose distilling the knowledge comprised in its feature embeddings into a lightweight model. As illustrated in Figure 3, our approach uses a teacher-student paradigm in which the RETFound teacher remains frozen throughout the process. This ensures that the teacher acts as a static source of high-quality retinal features, while the lightweight student is
¹https://anonymous.4open.science/r/CAMELL/

Figure 2: Classification task, IDRiD sample images illustrating diabetic retinopathy severity levels (DR0–DR4). Diabetic retinopathy is a diabetes complication that progressively damages retinal blood vessels and can lead to vision loss
optimized to minimize the discrepancy between their respective embedding spaces.

Figure 3: CAMEL framework: distillation process for training the student backbone using RETFound as the teacher model. In this configuration, the ViM student processes a masked version of the input image, whereas the teacher receives the full, unmasked image; an MLP projection layer approximates the student's and teacher's feature embeddings.
To evaluate feature reconstruction under varying spatial constraints, we explore both unmasked and masked distillation strategies. In the unmasked setting, both the student and teacher process identical inputs, using complete fundus images. Conversely, in the masked configuration, we apply an MAE-style random masking strategy [6] to the student's input. Specifically, we randomly mask 75% of the image patches using a uniform distribution without replacement, while the frozen RETFound teacher receives the full, unmasked image. This forces the student model to learn rich spatial dependencies and infer missing structural details by aligning its projected representations with the complete teacher embeddings. Initial empirical evaluations on both the IDRiD and APTOS datasets demonstrated that this masked distillation strategy yields superior feature representations for lightweight student backbones. Consequently, we selected the masked approach as our standard distillation protocol for comparing models.
The distillation objective is to align the student's internal representations with the teacher's feature geometry. This is achieved
by minimizing the cosine distance between the projected student features and the teacher's embeddings, defined by the following loss function:
where and denote the projected student features and the corresponding teacher features for the -th sample, respectively, in a batch of size .
After the distillation phase, the student backbone is finetuned to better adapt the distilled retinal knowledge. We then perform a supervised downstream finetuning phase to adapt the model for Diabetic Retinopathy (DR) grading. For this purpose, we attach a classification head inspired by the DINO framework [2], consisting of two fully connected layers with Batch Normalization, GELU activations, and dropout, followed by a final linear layer that produces the class logits. This two-stage pipeline allows CAMEL to achieve foundation-level diagnostic accuracy while remaining light enough for real-time inference on mobile devices.
The remainder of this section details the backbone architecture illustrated in Fig. 3.
3.1 Projection layer
To align the representation spaces of the teacher and student models, we introduce a lightweight projection module that maps the student embedding dimension to the teacher's feature dimension. The projector is implemented as a two-layer MLP with a GELU activation, consisting of a first linear layer with 128 neurons (expanding the 64-dimensional student embedding) followed by a second linear layer with 1024 neurons corresponding to the teacher embedding dimension. This component contains 468K parameters, adding negligible computational overhead while proving essential for stable distillation.
3.2 Optimizer
Based on the optimization strategy used in RETFound, we adopt the AdamW optimizer for both the distillation stage and the subsequent downstream task. As our experiments confirm (cf. Section 5), this choice provides stable convergence and effective regularization, which are particularly important for models derived from sequence-processing architectures such as Vim. Training stability is further enhanced by a learning rate schedule that combines a warmup phase with cosine annealing: the learning rate increases linearly over the first 10 epochs and then decays smoothly toward a small final value as training progresses.
Across all experiments, we maintain a consistent configuration of hyperparameters. The base learning rate is set to , gradually reduced to a final value of by the end of training. Weight decay is fixed at to provide additional regularization throughout optimization.
3.3 Metrics and Callbacks
During the distillation phase, the objective is to align the features between the RETFound teacher and the lightweight student. Thus, we monitor the distillation loss, computed as the cosine distance between the projected student features and the teacher features.
To ensure stable convergence and avoid overfitting to noisy feature alignments, we employ two key callbacks. The first one is Early Stopping, triggered when the validation distillation loss stops improving for 15 consecutive epochs. We also employ Model Checkpointing, saving only the checkpoint with the lowest validation distillation loss.
After distillation, a second training phase is performed where the distilled backbone and a lightweight classification head are trained using supervised labels. In this stage, different metrics are tracked, such as accuracy, macro-F1, AUROC, and AUPR, together with early stopping and checkpointing based on the validation F1 score, ensuring optimal downstream classification performance.
3.4 Image Preprocessing and Data Augmentation
In order to improve feature extraction and mitigate inherent variations in fundus image quality (e.g., uneven illumination and camera artifacts), we apply a preprocessing pipeline prior to network ingestion.
First, extraneous black backgrounds are removed using contour-based bounding box cropping. We then isolate the green color channel, which empirically yields the highest contrast for critical retinal structures such as blood vessels and lesions. To correct uneven illumination across the fundus, we apply Ben Graham's luminance normalization method, combining the original green channel with a Gaussian-blurred version to equalize lighting. This is followed by Contrast Limited Adaptive Histogram Equalization (CLAHE) [13] to enhance local structural details. Finally, a central circular mask is applied to eliminate artificial corner artifacts, and the enhanced grayscale image is converted back to a 3-channel RGB format for compatibility with the pretrained feature spaces.
During the downstream fine-tuning phase, we employ an augmentation strategy to improve generalization. This regime begins with standard geometric variations, including random horizontal and vertical flips and random rotations up to . To make the model anatomically robust against variations in eye positioning and lens geometry, we incorporate elastic deformations (). Finally, we apply RandAugment [3] to optimize the augmentation policy space, then apply standard ImageNet normalization before passing the tensors to the network.
4 Experimental Setup
We evaluate the CAMEL framework using four retinal fundus datasets: IDRid, APTOS, mBRSET, and MESSIDOR-2. These datasets vary substantially in size, image quality, acquisition hardware, and patient demographics, providing an environment to assess the model's adaptability and performance consistency.
To build a comprehensive benchmark, we compare it against a variety of vision models. Our lightweight convolutional baselines include MobileNet [9], EfficientNet-B0 [18], and a standard U-Net encoder [15]. For Vision Transformers, we employ TinyViT-5M-224 [20] and, as a State Space Model, we use Vim [23]. To assess the impact of our approach, we train each student backbone from scratch as a baseline and compare it directly with its distilled counterpart. This paired configuration allows us to isolate the performance gains from knowledge distillation within each evaluated architectural family. Finally, we benchmark all compact models against the full-scale RETFound teacher to establish a speculative performance upper bound and measure the diagnostic capacity retained post-distillation. Table 1 details the computational complexity and parameter counts for all evaluated architectures, as well as estimated energy and carbon dioxide usage.
Table 1: Computational complexity, inference efficiency, and environmental footprint across evaluated base architectures using a NVIDIA RTX A5000 GPU. Latency is measured per image at batch size 1, while throughput represents images processed per second at batch size 32. Energy and CO metrics are scaled by for readability. Results are aggregated across all runs (mean std).
| Model | Params (M) | GFLOPs | Latency (ms) | Throughput (img/s) | Energy (10 kWh) | CO (10 kg) |
|---|---|---|---|---|---|---|
| MobileNet | 1.52 | 0.111 | 1.18 0.02 | 11611.9 82.5 | 0.95 1.95 | 0.09 0.19 |
| EfficientNet | 4.01 | 0.769 | 1.83 0.04 | 2649.6 3.2 | 8.50 2.10 | 0.84 0.21 |
| UNet | 4.85 | 6.561 | 0.71 0.00 | 2348.2 30.9 | 8.60 1.85 | 0.84 0.18 |
| Vim | 5.02 | 0.476 | 17.46 0.75 | 1691.2 77.8 | 18.15 1.70 | 1.78 0.17 |
| TinyViT | 5.07 | 2.510 | 1.92 0.03 | 1695.6 7.4 | 14.40 2.20 | 1.41 0.21 |
| Foundation Teacher | ||||||
| RETFound | 303.31 | 119.292 | 14.79 0.12 | 93.2 0.9 | 278.50 2.90 | 27.38 0.28 |
The Indian Diabetic Retinopathy Image Dataset (IDRid) [14] serves as our primary benchmark for both feature distillation and downstream classification. After standardizing the preprocessing and split construction, we obtained training and validation sets composed of 413 and 103 images, respectively. Despite its relatively small size, IDRid's high-quality annotations make it an essential baseline for evaluating the precision of distilled ophthalmic features.
To examine scalability, we further train and evaluate the models on the APTOS 2019 Blindness Detection dataset [10]. This dataset contains 3,662 labeled retinal images, from which we allocated 2,930 for training and 366 for validation. Its larger scale and distinct distributional characteristics relative to IDRid let us assess how well models adapt to diverse clinical imaging conditions and varying grading protocols across populations.
We employ the mBRSET [12] dataset to assess the robustness under realistic acquisition conditions. mBRSET consists of fundus images captured with handheld portable cameras in community screening settings, exhibiting significant variations in illumination, focus, and field-of-view compared to the high-end desktop cameras used in IDRiD and APTOS. Notably, we first evaluate mBRSET without additional fine-tuning to assess the viability of masked and unmasked variants. Afterward, this dataset is fine-tuned for in-domain testing of all architectures. We acknowledge that this dataset is highly imbalanced, with a predominant majority of healthy (DR0) samples and only 1.68% representing severe (DR3) cases, posing a significant challenge for robust automated grading.
Furthermore, we incorporate the MESSIDOR-2 dataset [4], a widely recognized standard for diabetic retinopathy assessment. It comprises 1,748 macula-centered fundus images collected across 874 patient examinations. Including MESSIDOR-2 allows us to validate the framework's learning capacity on an established international benchmark.
To comprehensively evaluate the effectiveness of each approach, we structured our experimental protocol to directly train and evaluate the model independently on all four datasets. In this approach, both feature distillation and downstream classification training are conducted using the respective training split of each individual source dataset, then evaluated on the evaluation split. This enables us to establish robust in-domain performance metrics across diverse clinical settings, ranging from high-end desktop imaging to unconstrained portable community screenings. To ensure the reliability of our findings, all experiments are conducted across five random seeds, and statistical significance is determined using a non-parametric Friedman test followed by a Nemenyi post-hoc analysis to compare the performance of the lightweight models.
5 Results & Discussion
In this section, we first analyze the effectiveness of the masked and unmasked variants of the CAMEL framework by testing them on Vim models and comparing them with the RETFound teacher for in-domain and cross-domain evaluation, as well as a Zero-Shot test on mBRSET. Once we establish the best alternative across datasets, we use it in all subsequent experiments for UNet, EfficientNet, Mobilenet, and TinyVIT. We trained and evaluated all models on IDRiD, APTOS, mBRSET, and MESSIDOR.
5.1 Distillation Masking Analysis
To investigate how distillation strategy shapes representation learning, Figure 4 illustrates the trajectory of the cosine distance loss between the RETFound teacher and student configurations throughout training. For this analysis, we select the Vision Mamba (Vim) backbone as our representative student, as its linear-time state-space mechanisms offer a compelling non-Transformer paradigm to probe how distinct inductive biases reconstruct teacher representations under spatial constraints. While the unmasked student aligns more closely with the teacher's representation, the masked variant maintains a slightly higher yet remarkably stable distance. This behavior indicates that asymmetric masking forces the student model to learn a distinct, structurally robust feature space. From a practical standpoint, this suggests that masking the input acts as a regularizer once the model no longer closely mimics the teacher's representation.

Figure 4: Average loss during the distillation of the RETFound teacher and the masked/unmasked Vim-based students.
To determine the best configuration, Table 2 consolidates the in-domain and cross-dataset generalization results across the IDRiD, APTOS, and mBRSET datasets. In-domain evaluations demonstrate that while RETFound achieves the highest overall performance, both student variants remain highly competitive. However, the cross-dataset evaluations reveal a critical distinction. Under severe domain shifts (e.g., training on APTOS and evaluating on IDRiD), the masked student demonstrates superior generalization capability, notably outperforming its unmasked counterpart in accuracy and ranking metrics.
Table 2: Masked vs. unmasked variants across validation and cross-dataset evaluations (mean ± std). The best results in each column per dataset are bolded, and the second best are underlined.
| Model | Acc | F1 | AUROC | AUPR |
|---|---|---|---|---|
| In-Domain IDRiD | ||||
| Vim (Masked) | 0.412 ± 0.033 | 0.318 ± 0.023 | 0.610 ± 0.020 | 0.350 ± 0.008 |
| Vim (Unmasked) | 0.454 ± 0.021 | 0.330 ± 0.011 | 0.626 ± 0.027 | 0.356 ± 0.020 |
| RETFound (Teacher) | 0.516 ± 0.047 | 0.390 ± 0.024 | 0.665 ± 0.029 | 0.393 ± 0.020 |
| Cross: Train APTOS → Eval IDRiD | ||||
| Vim (Masked) | 0.213 ± 0.051 | 0.146 ± 0.029 | 0.554 ± 0.021 | 0.240 ± 0.009 |
| Vim (Unmasked) | 0.193 ± 0.038 | 0.129 ± 0.016 | 0.530 ± 0.013 | 0.236 ± 0.009 |
| RETFound (Teacher) | 0.317 ± 0.045 | 0.255 ± 0.038 | 0.664 ± 0.015 | 0.319 ± 0.015 |
| In-Domain APTOS | ||||
| Vim (Masked) | 0.750 ± 0.020 | 0.569 ± 0.011 | 0.872 ± 0.019 | 0.574 ± 0.015 |
| Vim (Unmasked) | 0.762 ± 0.006 | 0.559 ± 0.011 | 0.879 ± 0.005 | 0.571 ± 0.009 |
| RETFound (Teacher) | 0.812 ± 0.010 | 0.663 ± 0.021 | 0.922 ± 0.007 | 0.665 ± 0.015 |
| Cross: Train IDRiD → Eval APTOS | ||||
| Vim (Masked) | 0.290 ± 0.132 | 0.173 ± 0.044 | 0.558 ± 0.033 | 0.238 ± 0.025 |
| Vim (Unmasked) | 0.214 ± 0.114 | 0.148 ± 0.068 | 0.575 ± 0.051 | 0.253 ± 0.035 |
| RETFound (Teacher) | 0.439 ± 0.095 | 0.268 ± 0.033 | 0.603 ± 0.040 | 0.271 ± 0.026 |
| Zero-Shot: Train APTOS → Eval mBRSET | ||||
| Vim (Masked) | 0.590 ± 0.190 | 0.180 ± 0.009 | 0.498 ± 0.016 | 0.201 ± 0.004 |
| Vim (Unmasked) | 0.755 ± 0.016 | 0.180 ± 0.009 | 0.544 ± 0.020 | 0.210 ± 0.005 |
| RETFound (Teacher) | 0.725 ± 0.028 | 0.236 ± 0.025 | 0.626 ± 0.017 | 0.249 ± 0.006 |
| Zero-Shot: Train IDRiD → Eval mBRSET | ||||
| Vim (Masked) | 0.637 ± 0.051 | 0.193 ± 0.006 | 0.492 ± 0.022 | 0.204 ± 0.007 |
| Vim (Unmasked) | 0.486 ± 0.313 | 0.145 ± 0.061 | 0.493 ± 0.025 | 0.204 ± 0.009 |
| RETFound (Teacher) | 0.674 ± 0.096 | 0.216 ± 0.016 | 0.587 ± 0.035 | 0.230 ± 0.013 |
5.2 Benchmark Evaluations
With the masked student established as our primary approach, we present an expanded evaluation against the wider range of competitive baseline architectures. We name each distilled version using the CAMEL framework by the backbone name followed by the identifier “D”: TinyVit-D, Vim-D, MobileNet-D, EfficientNet-D, and UNet-D. Table 3 summarizes performance across IDRiD, APTOS, mBRSET, and MESSIDOR, while Figure 5 visually shows these results.
On the IDRiD dataset, the CAMEL framework’s impact is notably apparent. TinyVit-D achieves the best overall results across F1 (0.471 ± 0.019) and AUPR (0.477 ± 0.037), improving over the baseline TinyVit. Similarly, UNet-D achieves the highest AUROC (0.782 ± 0.089) on the dataset, substantially improving upon the standard UNet. While RETFound shows the advantages of large-scale foundation pretraining with a slightly better accuracy, the CAMEL-based ViT shows that our knowledge distillation successfully imbues lightweight architectures with diagnostic capabilities, surpassing the foundation model on all other metrics.
On the APTOS dataset, which generally yields higher baseline scores due to more uniform image quality, the CAMEL framework’s advantage becomes even more pronounced. Every single distilled variant, MobileNet-D, EfficientNet-D, UNet-D, and TinyVit-D yields strict improvements over its respective baseline in nearly all metrics. Notably, TinyVit-D reaches the highest Accuracy (0.849 ± 0.008) and F1 (0.736 ± 0.013), even surpassing the RETFound teacher. Vim-D also shows surprisingly large gains over the base Vim architecture, raising AUROC from 0.787 to 0.867, showing that the distilled backbone retains strong diagnostic discriminability if compared to training from scratch.
On the highly imbalanced mBRSET dataset, real-world handheld device image acquisition, EfficientNet-D shows a remarkable AU-ROC jump to 0.874 ± 0.008 compared to the standard EfficientNet’s 0.754 ± 0.116. While the standard UNet baseline performs exceptionally well on this specific distribution, TinyVit-D continues to show consistent, broad upgrades over TinyVit across all metrics. Furthermore, Vim-D generalizes well in this challenging environment, outperforming the raw Vim baseline in F1 and showing robustness comparable to standard convolutional networks, yet within a much more structurally efficient framework.
Finally, on the MESSIDOR dataset, TinyVit-D and EfficientNet-D capture the highest scores across F1, AUROC, and AUPR, improving upon their standard versions. Furthermore, Vim-D achieves an accuracy peak (0.849 ± 0.003), outperforming heavier conventional architectures like EfficientNet and MobileNet.
This systematic uplift across diverse architectures confirms that the spatial mapping mechanisms and structural regularization enforced by the CAMEL framework’s masking and distillation process may be well-suited to identifying specific lesion structures characteristic of diabetic retinopathy, regardless of the base model topology.
The core justification for CAMEL is that its masking mechanism acts as a strong regularizer while balancing classification power with strict constraints on parameters, FLOPs, and inference time. While massive models like RETFound or heavier CNN architectures maximize diagnostic scores, they are fundamentally unsuited for mobile, resource-limited deployments. By asymmetrically distilling RETFound’s robust capabilities into a compact masked model, CAMEL minimizes the classification decay often associated with
Table 3: Comprehensive Benchmark Performance on validation across IDRiD, APTOS, mBRSET, and MESSIDOR datasets (mean ± std). The best results in each column per dataset are bolded, and the second best are underlined.
| Model | Acc | F1 | AUROC | AUPR |
|---|---|---|---|---|
| IDRID | ||||
| Vim | 0.254 ± 0.056 | 0.203 ± 0.027 | 0.569 ± 0.026 | 0.296 ± 0.021 |
| MobileNet | 0.208 ± 0.059 | 0.168 ± 0.055 | 0.580 ± 0.015 | 0.317 ± 0.031 |
| MobileNet-D | 0.204 ± 0.027 | 0.190 ± 0.026 | 0.623 ± 0.035 | 0.347 ± 0.036 |
| EfficientNet | 0.235 ± 0.033 | 0.189 ± 0.040 | 0.587 ± 0.025 | 0.304 ± 0.009 |
| EfficientNet-D | 0.365 ± 0.037 | 0.322 ± 0.059 | 0.750 ± 0.065 | 0.421 ± 0.053 |
| UNet | 0.361 ± 0.123 | 0.334 ± 0.115 | 0.745 ± 0.069 | 0.406 ± 0.081 |
| UNet-D | 0.381 ± 0.121 | 0.359 ± 0.129 | 0.782 ± 0.089 | 0.493 ± 0.118 |
| Vim-D | 0.301 ± 0.028 | 0.255 ± 0.010 | 0.588 ± 0.012 | 0.314 ± 0.006 |
| TinyVit | 0.373 ± 0.064 | 0.348 ± 0.058 | 0.775 ± 0.018 | 0.435 ± 0.026 |
| TinyVit-D | 0.538 ± 0.049 | 0.471 ± 0.019 | 0.779 ± 0.020 | 0.477 ± 0.037 |
| RETFound | 0.557 ± 0.052 | 0.440 ± 0.034 | 0.740 ± 0.022 | 0.448 ± 0.028 |
| APTOS | ||||
| MobileNet | 0.803 ± 0.004 | 0.647 ± 0.017 | 0.930 ± 0.006 | 0.673 ± 0.027 |
| MobileNet-D | 0.810 ± 0.009 | 0.652 ± 0.027 | 0.940 ± 0.002 | 0.703 ± 0.008 |
| EfficientNet | 0.786 ± 0.019 | 0.619 ± 0.024 | 0.928 ± 0.006 | 0.659 ± 0.020 |
| EfficientNet-D | 0.822 ± 0.015 | 0.658 ± 0.037 | 0.941 ± 0.003 | 0.697 ± 0.014 |
| UNet | 0.805 ± 0.019 | 0.644 ± 0.037 | 0.937 ± 0.006 | 0.708 ± 0.022 |
| UNet-D | 0.845 ± 0.009 | 0.690 ± 0.030 | 0.953 ± 0.002 | 0.766 ± 0.013 |
| Vim | 0.588 ± 0.151 | 0.296 ± 0.102 | 0.787 ± 0.080 | 0.430 ± 0.060 |
| Vim-D | 0.744 ± 0.004 | 0.445 ± 0.007 | 0.867 ± 0.009 | 0.527 ± 0.014 |
| TinyVit | 0.789 ± 0.023 | 0.619 ± 0.048 | 0.928 ± 0.010 | 0.663 ± 0.041 |
| TinyVit-D | 0.849 ± 0.008 | 0.736 ± 0.013 | 0.939 ± 0.013 | 0.738 ± 0.030 |
| RETFound | 0.834 ± 0.005 | 0.703 ± 0.010 | 0.932 ± 0.003 | 0.703 ± 0.010 |
| MBRSET | ||||
| MobileNet | 0.799 ± 0.024 | 0.361 ± 0.168 | 0.641 ± 0.135 | 0.369 ± 0.149 |
| MobileNet-D | 0.803 ± 0.013 | 0.395 ± 0.072 | 0.814 ± 0.016 | 0.482 ± 0.044 |
| EfficientNet | 0.810 ± 0.015 | 0.471 ± 0.166 | 0.754 ± 0.116 | 0.483 ± 0.153 |
| EfficientNet-D | 0.834 ± 0.012 | 0.497 ± 0.028 | 0.874 ± 0.008 | 0.580 ± 0.011 |
| UNet | 0.895 ± 0.006 | 0.693 ± 0.027 | 0.939 ± 0.014 | 0.758 ± 0.014 |
| UNet-D | 0.879 ± 0.008 | 0.575 ± 0.040 | 0.951 ± 0.007 | 0.699 ± 0.055 |
| Vim | 0.759 ± 0.052 | 0.177 ± 0.003 | 0.549 ± 0.017 | 0.226 ± 0.010 |
| Vim-D | 0.741 ± 0.058 | 0.180 ± 0.007 | 0.528 ± 0.033 | 0.215 ± 0.014 |
| TinyVit | 0.809 ± 0.016 | 0.476 ± 0.034 | 0.805 ± 0.020 | 0.536 ± 0.023 |
| TinyVit-D | 0.821 ± 0.015 | 0.570 ± 0.022 | 0.824 ± 0.013 | 0.569 ± 0.015 |
| RETFound | 0.682 ± 0.096 | 0.272 ± 0.008 | 0.628 ± 0.063 | 0.275 ± 0.031 |
| MESSIDOR | ||||
| MobileNet | 0.490 ± 0.036 | 0.331 ± 0.031 | 0.728 ± 0.015 | 0.347 ± 0.026 |
| MobileNet-D | 0.479 ± 0.048 | 0.321 ± 0.065 | 0.777 ± 0.029 | 0.434 ± 0.031 |
| EfficientNet | 0.536 ± 0.023 | 0.405 ± 0.113 | 0.738 ± 0.054 | 0.412 ± 0.099 |
| EfficientNet-D | 0.559 ± 0.035 | 0.461 ± 0.112 | 0.785 ± 0.063 | 0.485 ± 0.118 |
| UNet | 0.466 ± 0.042 | 0.315 ± 0.020 | 0.726 ± 0.023 | 0.331 ± 0.021 |
| UNet-D | 0.478 ± 0.023 | 0.262 ± 0.021 | 0.754 ± 0.006 | 0.371 ± 0.012 |
| Vim | 0.441 ± 0.047 | 0.322 ± 0.030 | 0.719 ± 0.010 | 0.321 ± 0.020 |
| Vim-D | 0.849 ± 0.003 | 0.184 ± 0.000 | 0.647 ± 0.025 | 0.272 ± 0.048 |
| TinyVit | 0.526 ± 0.022 | 0.409 ± 0.034 | 0.770 ± 0.027 | 0.433 ± 0.063 |
| TinyVit-D | 0.571 ± 0.020 | 0.552 ± 0.028 | 0.805 ± 0.018 | 0.532 ± 0.017 |
| RETFound | 0.523 ± 0.042 | 0.299 ± 0.016 | 0.646 ± 0.080 | 0.358 ± 0.076 |
lightweight models. The statistical parity observed (Figure 6) further shows that computational reduction does not cause a statistically meaningful loss of diagnostic power, positioning CAMEL as a highly capable, edge-deployable alternative for diabetic retinopathy screening.
6 Conclusion
In this work, we addressed a critical barrier to deploying ophthalmic machine learning models in decentralized clinical settings: the prohibitive computational cost of Transformer-based foundation
Mean validation AUROC by model and dataset




Figure 5: Mean validation AUROC by model and dataset. Bar height shows the mean AUROC, and error bars show the standard deviation. Each dot is the result of a single model run.
Critical Difference Diagram - Friedman + Nemenyi (val/f1, 4 datasets, alpha=0.05)

Figure 6: Critical difference (CD) diagram for AUROC. Models connected by a horizontal bar are not significantly different according to the Friedman test with Nemenyi post-hoc correction ().
models. To bridge this gap, we introduced CAMEL. This generalizable feature-distillation framework transfers the rich ophthalmic
representations of massive foundation models (such as the 303M-parameter RETFound) into compact student backbones across heterogeneous architectural paradigms. Our findings strongly advocate for knowledge distillation as an essential strategy in this scenario, confirming that the representational power required for accurate retinal screening can be condensed into lightweight networks suitable for edge and mobile deployment without compromising diagnostic precision.
Across extensive benchmarking on four diverse datasets (IDRiD, APTOS, mBRESET, and MESSIDOR-2), CAMEL-distilled models consistently outperformed their counterparts trained from scratch. Crucially, specific distilled student variants, such as TinyViT-D and EfficientNet-D, not only closed the performance gap with the teacher but also surpassed RETFound across key diagnostic metrics, while reducing parameter counts by up to and floating operations by up to . By evaluating a broad spectrum of CNN, ViT, and State-Space Model backbones, CAMEL establishes an effective Pareto frontier of efficiency-versus-accuracy trade-offs. This enables practitioners and deployment engineers to select the optimal operational point tailored to their specific hardware, latency, and clinical constraints. Furthermore, our analysis confirms that asymmetric masked feature distillation provides crucial structural regularization, significantly boosting robustness under severe domain and acquisition shifts.
Future work will extend this framework to optimize cross-architecture feature alignment further. We plan to investigate hybrid distillation strategies that combine feature-level embedding alignment with logit-based loss and masked reconstruction objectives to make accurate task-specific models. Additionally, we aim to scale the distillation process using larger, multi-center repositories, such as PAPILA [11] and MESSIDOR [4], to assess robustness across broader clinical demographics. Beyond diabetic retinopathy grading, we will evaluate the CAMEL framework's generality across a wider spectrum of ophthalmic tasks, including glaucoma detection, retinal vessel segmentation, and microaneurysm identification.
References
[1] Rishi Bommasani et al. 2022. On the Opportunities and Risks of Foundation Models. arXiv preprint arXiv:2108.07258 abs/2108.07258, 1 (2022), 1–212. https://arxiv.org/abs/2108.07258
[2] Mathilde Caron, Hugo Touvron, Ishan Misra, Hervé Jégou, Julien Mairal, Piotr Bojanowski, and Armand Joulin. 2021. Emerging properties in self-supervised vision transformers. CoRR abs/2104.14294 (2021), 9630–9640.
[3] Ekin D. Cubuk, Barret Zoph, Jonathon Shlens, and Quoc V. Le. 2020. Randaugment: Practical automated data augmentation with a reduced search space. In 2020 IEEE/CVF Conference on Computer Vision and Pattern Recognition Workshops (CVPRW). 3008–3017. doi:10.1109/CVPRW.2020.00359
[4] Etienne Decencière, Xiwei Zhang, Guy Cazuelo, Bruno Lay, Béatrice Cochener, Caroline Trone, Philippe Gain, John-Richard Ordóñez-Varela, Pascale Massin, Ali Erginay, et al. 2014. Feedback on a publicly distributed image database: the Messidor database. Image Analysis & Stereology 33, 3 (2014), 231–234.
[5] Jiawei Du, Jia Guo, Weihang Zhang, Shengzhu Yang, Hanruo Liu, Huiqi Li, and Ningli Wang. 2024. RET-CLIP: A Retinal Image Foundation Model Pre-trained with Clinical Diagnostic Reports. In Medical Image Computing and Computer Assisted Intervention – MICCAI 2024, Marius George Linguraru, Qi Dou, Aasa Feragen, Stamatia Giannarou, Ben Glocker, Karim Lekadir, and Julia A. Schnabel (Eds.). Springer Nature Switzerland, Cham, 709–719.
[6] Kaiming He, Xinxie Chen, Saining Xie, Yanghao Li, Piotr Dollár, and Ross Girshick. 2022. Masked autoencoders are scalable vision learners. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR). IEEE, IEEE, New York, NY, USA, 15979–15988.
[7] Moein Heidari, Reza Azad, Sina Ghorbani Kohahi, René Arimond, Leon Niggemeier, Alaa Sulaiman, Afshin Bozorgpour, Ehsan Khodapanah Aghdam, Amirhossein Kazerouni, Ilker Hachaliloglu, and Dorit Merhof. 2024. Enhancing Efficiency in Vision Transformer Networks: Design Techniques and Insights. arXiv:2403.19882 [eess.IV] https://arxiv.org/abs/2403.19882
[8] Geoffrey Hinton, Oriol Vinyals, and Jeff Dean. 2015. Distilling the Knowledge in a Neural Network. CoRR abs/1503.02531 (2015), 9 pages. https://arxiv.org/abs/1503.02531
[9] Andrew Howard, Mark Sandler, Grace Chu, Liang-Chieh Chen, Bo Chen, Mingxing Tan, Weijun Wang, Yukun Zhu, Ruoming Pang, Vijay Vasudevan, Quoc V. Le, and Hartwig Adam. 2019. Searching for MobileNetV3. In Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV). IEEE, New York, NY, USA, 1314–1324.
[10] Sara Hosseinzadeh Kassani, Peyman Hosseinzadeh Kassani, Reza Khazaeinezhad, Michal J. Wesolowski, Kevin A. Schneider, and Ralph Deters. 2019. Diabetic Retinopathy Classification Using a Modified Xception Architecture. In 2019 IEEE International Symposium on Signal Processing and Information Technology (ISSPIT). IEEE, New York, NY, USA, 1–6. doi:10.1109/ISSPIT47144.2019.9001846.
[11] Oleksandr Kovalyk, Juan Morales-Sánchez, Rafael Verdú-Monedero, Inmaculada Sellés-Návorán, Ana Palazón-Cabanes, and José-Luis Sancho-Gómez. 2022. PAPILA: Dataset with fundus images and clinical data of both eyes of the same patient for glaucoma assessment. Scientific Data 9, 1 (June 2022), 291. doi:10.1038/s41597-022-01388-1
[12] Luis Filipe Nakayama, Lucas Zago Ribeiro, David Restrepo, Nathan Santos Barboza, Raul Dias Fiterman, Maria luiza Vieira Sousa, Alexandre Durao Alves Pereira, Caio Regatieri, Fernando Korn Malerbi, and Rafael Andrade. 2024. mBRSET, a Mobile Brazilian Retinal Dataset. PhysioNet, 11 pages. doi:10.13026/qxpd-1y65 Version 1.0.
[13] Stephen M. Pizer, E. Philip Amburn, John D. Austin, Robert Cromartie, Ari Geselowitz, Trey Greer, Bart ter Haar Romeny, John B. Zimmerman, and Karel Zuiderveld. 1987. Adaptive histogram equalization and its variations. Computer Vision, Graphics, and Image Processing 39, 3 (1987), 355–368. doi:10.1016/S0734-189X(87)80186-X
[14] Prasanna Porwal, Samiksha Pachade, Ravi Kamble, Manesh Kokare, Girish Deshmukh, Vivek Sahasrabuddhe, and Fabrice Meraudeau. 2018. Indian diabetic retinopathy image dataset (IDRID): a database for diabetic retinopathy screening research. Data 3, 3 (2018), 25.
[15] Olaf Ronneberger, Philipp Fischer, and Thomas Brox. 2015. U-net: Convolutional networks for biomedical image segmentation. In International Conference on Medical Image Computing and Computer-Assisted Intervention (MICCAI). Springer, Springer International Publishing, Cham, Switzerland, 234–241.
[16] Mertcan Sevgi, Eden Ruffell, Fares Antaki, Mark A Chia, and Pearse A Keane. 2024. Foundation models in ophthalmology: opportunities and challenges. Current opinion in ophthalmology 36, 1 (2024), 90.
[17] Danli Shi, Weiyi Zhang, Xiaolan Chen, Yexin Liu, Jiancheng Yang, Siyu Huang, Yih Chung Tham, Yingfeng Zheng, and Mingguang He. 2024. Eye-Found: A Multimodal Generalist Foundation Model for Ophthalmic Imaging. arXiv:2405.11338 [cs.CV] https://arxiv.org/abs/2405.11338
[18] Mingxing Tan and Quoc V. Le. 2019. EfficientNet: Rethinking Model Scaling for Convolutional Neural Networks. In Proceedings of the 36th International Conference on Machine Learning (ICML). PMLR, Long Beach, CA, USA, 6105–6114.
[19] Daniel S.W. Ting, Lily Peng, Avinash V. Varadarajan, Pearse A. Keane, Philippe M. Burlina, Michael F. Chiang, Leopold Schetterner, Louis R. Pasquale, Neil M. Bressler, Dale R. Webster, Michael Abramoff, and Tien Y. Wong. 2019. Deep learning in ophthalmology: The technical and clinical considerations. Progress in Retinal and Eye Research 72 (2019), 100759. doi:10.1016/j.preteyeres.2019.04.003
[20] Kan Wu, Jinnian Zhang, Houwen Peng, Mengchen Liu, Bin Xiao, Jianlong Fu, and Lu Yuan. 2022. TinyViT: Fast Pretraining Distillation for Small Vision Transformers. arXiv:2207.10666 [cs.CV] https://arxiv.org/abs/2207.10666
[21] Zhendong Yang, Zhe Li, Mingqi Shao, Dachuan Shi, Zehuan Yuan, and Chun Yuan. 2022. Masked Generative Distillation. arXiv:2205.01529 [cs.CV] https://arxiv.org/abs/2205.01529
[22] Y. Zhou, Mark A. Chia, Siegfried K. Wagner, Murat S. Ayhan, Dominic J. Williamson, Robbert R. Struyven, Timing Liu, Moucheng Xu, Mateo G. Lozano, Peter Woodward-Court, Yuka Kihara, UK Biobank Eye & Vision Consortium, Naomi Allen, John E. J. Gallacher, Thomas Littlejohns, Tariq Aslam, Paul Bishop, Graeme Black, Panagiotis Sergouniotis, Denize Atan, Andrew D. Dick, Cathy Williams, Sarah Barman, Jenny H. Barrett, Sarah Mackie, Tasanee Braithwaite, Roxana O. Carare, Sarah Ennis, Jane Gibson, Andrew J. Lotery, Jay Self, Usha Chakravarthy, Ruth E. Hogg, Euan Paterson, Jayne Woodside, Tunde Peto, Gareth McKay, Bernadette McGuinness, Paul J. Foster, Konstantinos Balaskas, Anthony P. Khawaja, Nikolas Pontikos, Jugnoo S. Rahi, Gerassimos Lascaratos, Praveen J. Patel, Michelle Chan, Sharon Y. L. Chua, Alexander Day, Parul Desai, Cathy Egan, Marcus Fruttiger, David F. Garway-Heath, Alison Hardcastle, Sir Peng T. Khaw, Tony Moore, Sobha Sivaprasad, Nicholas Strouthidis, Dhanes Thomas, Adnan Tufail, Ananth C. Viswanathan, Bal Dhillon, Tom Macgillivray, Cathie Sudlow, Veronique Vitart, Alexander Doney, Emanuele Trucco, Jeremy A. Guggenheim, James E. Morgan, Chris J. Hammond, Katie Williams, Pirro Hysi, Simon P. Harding, Yalin Zheng, Robert Luben, Phil Luthert, Zihan Sun, Martin McKibbin, Eoin O'Sullivan, Richard Oram, Mike Weedon, Chris G. Owen, Alicja R. Rudnicka, Naveed Sattar, David Steel, Irene Stratton, Robyn Tapp, Max M. Yates, Axel Petzold, Savita Madhusudhan, Andre Altmann, Aaron Y. Lee, Eric J. Topol, Alastair K. Denniston, Daniel C. Alexander, and Pearse A. Keane. 2023. A foundation model for generalizable disease detection from retinal images (RetFound). Nature 622, 7981 (Oct. 2023), 156–163. doi:10.1038/s41586-023-06555-x Publisher: Springer Science and Business Media LLC.
[23] Lianghui Zhu, Bencheng Liao, Qian Zhang, Xinlong Wang, Wenyu Liu, and Xinggang Wang. 2024. Vision Mamba: Efficient Visual Representation Learning with Bidirectional State Space Model. arXiv:2401.09417 [cs.CV] https://arxiv.org/abs/2401.09417