back to top
Home NHSJS Deep Learning Classification of Public Fundus Image Labels with Similarity Risk Controlled...

Deep Learning Classification of Public Fundus Image Labels with Similarity Risk Controlled Evaluation and On Device Inference

0
6

Abstract

Background/Objective: Public fundus image collections can support deep learning development, however they lack documentation regarding their labelling, likeliness, and domain shift. This study aimed to evaluate four pre-trained deep learning architectures to determine their efficacy for classifying supplied Myopia and Normal fundus image labels following exact file deduplication and similarity risk controlled partitioning. Subsequent evaluations characterized model robustness, external transfer performance, and on device deployment.
Methods: Of 124,794 images, 8,795 byte identical files were removed, leaving 115,999 images. Relationships between images were identified using 64-bit difference hashing, DINOv2 embeddings, and blinded human review to block relationships within a locked training, validation, and test split. YOLOv8s-cls, ResNet-50, EfficientNet-B0, and ConvNeXt-Tiny were compared using only the validation dataset for architecture choice and threshold selection. The chosen architecture was evaluated using the locked training set, three transformations applied after locking, stress tested on PALM, and deployed to Core ML.
Results: EfficientNet-B0 achieved the highest ROC-AUC during validation. At the fixed threshold, internal test accuracy was 0.999, sensitivity was 1.000, specificity was 0.998, and ROC-AUC was 1.000. When converted to grayscale, sensitivity fell to 0.918. On PALM, which used a different pathologic myopia definition, ROC-AUC remained 0.985, but sensitivity decreased to 0.554 and the Brier score increased to 0.200. The median end to end inference time on an iPhone 16 was 1.410 ms.
Conclusions: The supplied labels were very distinct however without the knowledge of the clinical ground truth and unavailable patient and eye identifiers prevent interpretation as refractive myopia diagnostic accuracy. PALM highlighted poor threshold and calibration transfer. The device results show quick classification of imported fundus photographs, however the smartphone acquisition and screening process has not been validated.

Keywords: deep learning, fundus photography, image classification, myopia, domain shift, on device inference

Introduction

Background and Clinical Context

Myopia, commonly known as nearsightedness, is one of the most prevalent visual disorders worldwide and has become an increasing public health concern over the past several decades. Myopia is a refractive state in which light is focused in front of the retina when accommodation is relaxed. The International Myopia Institute recommends defining myopia as spherical-equivalent refractive error less than or equal to -0.500 diopters and high myopia as less than or equal to -6.000 diopters1. Although myopia is often corrected with glasses, contact lenses, or refractive surgery, progressive myopia is associated with an increased risk of serious ocular complications including retinal detachment, myopic maculopathy, glaucoma, and irreversible vision loss2. Global projections estimate that nearly half of the world’s population may be affected by myopia by 20503, highlighting the growing need for accessible methods of early detection and monitoring. These refractive definitions must be distinguished from pathologic myopia, which refers to structural complications such as myopic maculopathy rather than to refractive error alone1,4.

Recent advances in artificial intelligence and computer vision have demonstrated remarkable success in medical image analysis. Deep learning models, particularly convolutional neural networks, have achieved strong performance in detecting retinal diseases from fundus photographs, including diabetic retinopathy5,6. Other work has estimated spherical-equivalent refractive error directly from fundus images linked to refraction measurements7. These results establish the potential of fundus-image analysis, but they do not make every image label clinically interchangeable. The meaning of a model’s output remains determined by the ground-truth definition and population used to train and evaluate it.

Literature Review

Prior myopia-related fundus studies generally used more explicit clinical targets than an undocumented folder label. Varadarajan and colleagues trained a model on 226,870 images linked to measured refractive error and externally evaluated continuous spherical-equivalent prediction7. Tan and colleagues developed algorithms for high myopia and myopic macular degeneration across 226,686 retinal images from multiple cohorts and countries8. Other studies focused on pathologic myopia or myopic-maculopathy categories defined through the META-PM framework. Du and colleagues evaluated lesion-specific and pathologic-myopia models in highly myopic eyes9; Lu and colleagues used expert-graded clinical images with external validation10; Li and colleagues developed a dual-stream EfficientNet approach using images from six hospitals11; and Wang and colleagues externally evaluated a four-category myopic-maculopathy classifier12. Reported areas under the receiver operating characteristic curve were often high, but the tasks, class definitions, image sources, and reference standards differed substantially. Direct numerical comparison is therefore inappropriate unless the target label and evaluation setting are also comparable.

Public resources have also shaped this field. The PALM dataset provides pathologic-myopia labels and anatomical annotations for fundus photographs13. It is useful for testing transfer to pathologic-myopia recognition, but its target is not equivalent to a general Myopia folder label. More recently, retinal foundation models such as RETFound have used large-scale self-supervised pretraining to learn transferable retinal representations across multiple downstream tasks14. General vision-transformer approaches offer alternatives to convolutional networks by modeling images as sequences of patches15. These developments motivate broader architectural comparison, but they do not remove the need for label provenance, independent partitioning, calibration assessment, and external testing.

Simultaneously, improvements in smartphone hardware and mobile machine learning frameworks have enabled increasingly sophisticated models to run directly on consumer devices. Smartphone-linked fundus cameras with offline algorithms have been evaluated for diabetic-retinopathy screening against specialist grading16,17, and a dedicated smartphone retinal adapter has been compared with a conventional fundus camera for image acquisition and remote grading18. Those studies combined a defined optical acquisition system, gradability assessment, and a clinical reference standard. By contrast, executing a model on already-decoded fundus images demonstrates on device inference only; it does not validate smartphone image acquisition or a complete screening workflow.

The literature also shows why high internal discrimination is insufficient by itself. Medical-image models can lose performance across institutions when patient populations and imaging systems differ19. Models may also exploit shortcuts correlated with labels rather than the intended biological signal20. Modern neural networks can be poorly calibrated, and predictive calibration can deteriorate further under dataset shift21,22. Saliency maps can support qualitative inspection, but methodological work has shown that some saliency methods may be insensitive to model or data randomization and therefore require sanity checks23. These concerns are especially important when source labels and patient identifiers are unavailable.

Research Gap and Purpose

The evidence gap addressed here is greater than clinical myopia diagnosis. The available Kaggle collection is substantial, but it supplies only Myopia and Normal folders without documented patient identifiers or a verified clinical labeling protocol. Now, the central questions include the following. Can the supplied labels continue to be classified after removing exact duplicate files and better similarity risk controls? How will the chosen model perform under controlled image transformations and an external pathologic myopia stress test? Finally, will the frozen classifier execute fully on an iPhone?

Accordingly, this study doesn’t claim to validate refractive-myopia screening. Its contribution is an auditable image-label classification pipeline that considers the dataset’s clinical limits and separates factors including architecture selection, threshold selection, frozen internal evaluation, external stress testing, and on device interference.

Research Questions

RQ1: How accurately can pretrained deep-learning architectures classify the supplied Myopia/Normal labels after similarity-risk-controlled partitioning?

RQ2: Which of YOLOv8s-cls, ResNet-50, EfficientNet-B0, and ConvNeXt-Tiny ranks highest under a predeclared validation-only selection hierarchy?

RQ3: How robust is the selected model to grayscale conversion, CLAHE enhancement, and circular border masking?

RQ4: How well do the selected model’s ranking and locked operating point transfer to PALM under a non-equivalent label/domain definition?

RQ5: Can the selected classifier be exported and executed efficiently for fully on device iPhone inference?

Methods

Study Design and Scope

This study evaluated deep-learning models for binary classification of the supplied Myopia and Normal folder labels in a public Kaggle fundus-image collection. The labels were treated as just dataset labels, therefore the study measured image-label classification instead of refractive-myopia diagnostic accuracy or a complete screening workflow.

The empirical workflow was fixed before final test evaluation (Figure 1). It consisted of exact-file deduplication, similarity-risk auditing and partition blocking, a frozen train/validation/test split, validation-only architecture and threshold selection, one primary evaluation on the frozen internal test set, secondary post-lock robustness analyses, an external stress test using PALM, and export of the selected classifier for on device inference. The training set was used for parameter optimization and the validation set was used for model selection. The test set, however, remained completely unseen until final evaluation.

Dataset and Supplied Labels

The dataset contained color retinal fundus photographs organized into Myopia and Normal. Note that the ground truth is based purely on the dataset’s binary folder labels, so results should be interpreted with this limitation in mind. The original Kaggle collection contained 124,794 fundus images with 63,294 in the Myopia folder and 61,500 in the Normal folder. MD5 hashes were calculated to identify byte-identical files. This procedure removed 8,795 redundant images from the Myopia folder. No Normal images were removed, and no MD5-identical files had conflicting class labels. The final eligible dataset contained 115,999 MD5-unique images, with 54,499 labeled Myopia and 61,500 labeled Normal.

Many large publicly available image datasets (many available from Kaggle) are often compiled from various sources and may contain duplicate or near-duplicate images. If these images are spread across training and testing subsets, model performance can be artificially inflated due to data leakage. Duplicates were only deleted if they were confirmed by their MD5 hash to be exact duplicates. Perceptual hash and feature similarity signals were kept for any risk of leakage auditing and partition blocking since human review revealed that a difference-hash Hamming distance of zero could occur for distinct photographs.

Blinded Similarity Audit and Risk Grouping

A 64-bit difference hash was computed by resizing each image to 9 × 8 grayscale using PIL Lanczos interpolation and encoding the 64 horizontal pixel-intensity comparisons as a uint64. Pairwise Hamming distance was calculated with vectorized exclusive OR and population count operations. DINOv2 features were extracted at 224 × 224 input resolution using the published ViT-S/14 architecture24, implemented through timm as vit_small_patch14_dinov2. The resulting 384-dimensional feature vectors were L2-normalized before cosine similarity was calculated.

Similarity-risk groups were constructed as connected components of the blocking relationships. All members of the original difference-hash Hamming-distance-zero groups were constrained to the same partition. Additional blocking edges were added for global image pairs with DINO cosine similarity greater than or equal to 0.990 and for pairs satisfying both a difference-hash Hamming distance less than or equal to 1 and DINO cosine similarity greater than or equal to 0.970. Human-confirmed Category-1 relationships were also added as blocking edges. Images connected by any blocking path were assigned to the same partition.

A total of 100 image pairs underwent blinded human review. Category 1 required clear evidence that both images derived from the same underlying retinal photograph. Reviewers assessed matching retinal vessel geometry, optic-disc relationships, and retinal lesions or textures, while allowing differences attributable to cropping, resizing, exposure, compression, or minor rotation. Category 2 indicated that the images were likely related but that the evidence was insufficient to establish the same source photograph; Category 3 indicated uncertainty; and Category 4 indicated that the images were confidently unrelated for same-source leakage control. Categories 2 through 4 were not treated as confirmed same-source relationships. All accepted category assignments were human decisions.

Detected quantitative and Category-1 relationships were blocked across partitions. Because patient and eye identifiers were unavailable, this procedure could not establish patient- or eye-level independence.

Frozen Train, Validation, and Test Split

After exact-file deduplication and similarity-risk grouping, the 115,999 eligible images were divided into training, validation, and testing subsets. Random sampling and partitioning used a fixed seed value of 42 to ensure reproducibility. The training set contained 81,199 images, and the validation and test sets each contained 17,400 images (Table 1). The split was recorded in a frozen manifest with SHA-256 hash 963f23288fb1b45160aeb31ebb37ef77bd35d58ca4cbea5ffbec6010a56e86a2.

SplitMyopiaNormalTotal
Training38,14943,05081,199
Validation8,1759,22517,400
Test8,1759,22517,400
Total54,49961,500115,999
Table 1 | Frozen dataset split after MD5 exact-file deduplication and similarity-risk-controlled partitioning.
Figure 1 | Study workflow from exact-file deduplication and similarity-risk-controlled partitioning through validation-only selection, locked internal evaluation, post-lock robustness analysis, PALM external stress testing, and on device inference.

Candidate Architectures and Training

Four pretrained architectures were trained on the same frozen split: YOLOv8s-cls, ResNet-5025, EfficientNet-B026, and ConvNeXt-Tiny27. All images were resized to 224 x 224 pixels, and all runs used seed 42, deterministic mode, and batch size 64. Table 2 reports parameter counts and training configurations.

YOLOv8s-cls was optimized with stochastic gradient descent using an initial learning rate of 0.010, weight decay of 5 x 10-4, linear learning-rate decay, three warmup epochs, a maximum of 30 epochs, and early-stopping patience of 10 epochs. Its augmentation pipeline included horizontal flipping with probability 0.500, rotation within ±5°, scale augmentation of 0.100, translation of 0.100, and HSV augmentation. The retained checkpoint was the epoch with the highest validation top-1 accuracy.

The three torchvision architectures used AdamW, weight decay of 0.010, cosine annealing, two warmup epochs, a maximum of 25 epochs, and early-stopping patience of seven epochs. ResNet-50 and ConvNeXt-Tiny used an initial learning rate of 1 x 10-4, whereas EfficientNet-B0 used 2 x 10-4. Their shared augmentation pipeline included horizontal flipping with probability 0.500, rotation within ±5°, and color jitter with brightness, contrast, and saturation set to 0.200 and hue set to 0.020. For each model, the checkpoint with the lowest validation cross-entropy loss was retained. Table 2 summarizes the training configurations.

ArchitectureOptimizationSchedule and stoppingCheckpoint rule
YOLOv8s-clsSGD; LR 0.010; weight decay 5 x 10-4Linear decay; 3 warmup epochs; maximum 30 epochs; patience 10Highest validation top-1 accuracy
ResNet-50AdamW; LR 1 x 10-4; weight decay 0.010Cosine annealing; 2 warmup epochs; maximum 25 epochs; patience 7Lowest validation cross-entropy loss
EfficientNet-B0AdamW; LR 2 x 10-4; weight decay 0.010Cosine annealing; 2 warmup epochs; maximum 25 epochs; patience 7Lowest validation cross-entropy loss
ConvNeXt-TinyAdamW; LR 1 x 10-4; weight decay 0.010Cosine annealing; 2 warmup epochs; maximum 25 epochs; patience 7Lowest validation cross-entropy loss
Table 2 | Final training configurations for the four candidate architectures.

Validation-Only Architecture Selection

Architecture selection followed a predeclared validation-only hierarchy. Models were ranked first by validation receiver operating characteristic area under the curve (ROC-AUC). An exact tie would be resolved by precision-recall area under the curve (PR-AUC), then by balanced accuracy at a probability threshold of 0.500, and finally by lower model complexity. No ROC-AUC tolerance band was applied. Only the highest-ranked architecture advanced to threshold selection, frozen test evaluation, robustness characterization, PALM stress testing, and deployment.

Validation-Only Threshold Selection

After architecture selection, a single operating threshold was chosen using the validation set alone. The selected threshold maximized Youden’s statistic,

(1)   \begin{equation*}J = \text{sensitivity} + \text{specificity} - 1.\end{equation*}

Then, the resulting probability threshold, 0.752, was fixed before the test set was evaluated. The traditional threshold of 0.500 was kept only as a secondary reference point.

Internal Test Evaluation and Uncertainty

The selected model was evaluated once on the frozen internal test set at the locked threshold. Myopia was designated as the positive class for all binary classification metrics. Threshold-dependent measures included accuracy, sensitivity, specificity, balanced accuracy, positive predictive value (PPV), negative predictive value (NPV), F1 score, and the confusion matrix. Threshold-independent and probabilistic measures included ROC-AUC, PR-AUC, Brier score, and log loss.

Confidence intervals used 2,000 cluster-bootstrap replicates with seed 42 and the 13,289 frozen similarity-risk groups as resampling units. They describe uncertainty under this grouping scheme, not at the patient level. Ten-bin expected calibration error was also calculated; no calibration mapping was fitted to the test set.

Secondary Robustness and Interpretability Analyses

Using the selected model and locked threshold, RGB images were converted to replicated-channel grayscale with the BT.601 equation. CLAHE was applied to the LAB L channel with clipLimit = 2.000 and tileGridSize = (8, 8). The predeclared border mask retained the largest contour, multiplied its enclosing-circle radius by 0.950, and zeroed pixels outside the disk; no radius sweep was performed.

Grad-CAM28 was used only for qualitative visualization and not as evidence of pathology-specific learning or as a test excluding acquisition, color, illumination, or texture shortcuts.

PALM External Stress Test

External transfer was characterized using the 400-image PALM training set. PALM contained 213 images labeled pathologic myopia (P), 26 high-myopia images labeled non-pathologic myopia (H), and 161 normal/non-pathologic-myopia images (N). For the primary PALM mapping, P was treated as positive, and H and N were combined as negative/non-pathologic myopia. This PM-versus-non-PM task is not the same as the Kaggle Myopia-versus-Normal label definition.

Physical-device tests were performed using the different compute configurations on an iPhone 16 using three compute configurations (all compute units, CPU plus Apple Neural Engine, and CPU only). End-to-end timing measured VNImageRequestHandler.perform([VNCoreMLRequest]) using an already-decoded CGImage, which captured both Vision preprocessing and Core ML inference. Image acquisition, decoding, model loading, interface rendering, and the complete screening workflow were all outside this measurement. The model only benchmarks were also recorded separately. All processing was done locally.

Core ML Export and iPhone Timing

The selected model was exported as a Float16 Core ML ML Program accepting 224 × 224 RGB input. Numerical parity was evaluated on 100 validation images by comparing the original and Core ML Myopia probabilities and their classifications at the locked threshold.

Deployment performance was evaluated separately from classification performance to determine whether the system could operate effectively on consumer smartphone hardware. Physical-device timing was measured on an iPhone 16 under three compute configurations including all compute units, CPU plus Apple Neural Engine (ANE), and CPU only. End-to-end timing was defined as VNImageRequestHandler.perform([VNCoreMLRequest]) on an already-decoded CGImage. It therefore included Vision resizing and preprocessing together with Core ML inference, but excluded camera capture, photo selection, image decoding, user-interface rendering, model loading, and the duration of a complete screening workflow. Model-only timing was also recorded separately. All computations occurred locally on the device, and no external servers participated in image analysis.

Ethical Considerations

This study used public retinal-image datasets with no personally identifiable information and did not recruit participants. Because the datasets lacked patient and eye identifiers, patient or eye independent partitioning could not be verified which limits the clinical claims that can be made. Deployment testing used only imported fundus photographs.

Results

Exact-File Deduplication and Similarity Audit

MD5 hashing removed 8,795 byte-identical Myopia images from the 124,794-image collection. No Normal images or cross-class conflicts were found. This left us with a dataset with 115,999 unique images (54,499 Myopia and 61,500 Normal).

Global enumeration was able to identify 144,133 image pairs with DINO cosine similarity greater than or equal to 0.990 and 26,335 pairs satisfying the combined difference-hash Hamming distance and DINO criterion. Among the 100 blinded image pair reviews, 52 pairs were confirmed near-duplicates or exact copies of the same base photograph, 21 were likely to be related retinal images, 15 were uncertain, and 12 were unrelated to prevent leakage. After separating into groups based on similarity risk criteria, zero cross partition relationships were detected. However, this result does not establish patient independence or eye independence because corresponding identifiers were unavailable.

Training Outcomes and Validation-Based Architecture Selection

Training ended after 18 epochs for YOLOv8s-cls, 20 for ResNet-50, 25 for EfficientNet-B0, and 17 for ConvNeXt-Tiny. Respectively, the retained checkpoints occurred at epochs 8, 13, 21, and 10.

All four architectures achieved almost perfect scores on the 17,400 image validation set (Table 3; Figure 2). EfficientNet-B0 had the highest ROC-AUC, 1.000, and advanced under the predeclared hierarchy. Minor differences were observed between models with no clear architectural advantages observed.

ArchitectureROC-AUCPR-AUCBalanced accuracy at 0.50Accuracy
YOLOv8s-cls0.9999900.9999880.9990.999
ResNet-500.9999930.9999920.9990.999
EfficientNet-B00.9999980.9999981.0000.999
ConvNeXt-Tiny0.9999960.9999960.9990.999
Table 3 | Validation performance used for architecture selection (N = 17,400).
Figure 2 | Validation comparison of the four candidate architectures. Bars show the distance of ROC-AUC and PR-AUC from 1.000 in parts per million. Lower values are better. EfficientNet-B0 ranked first by the predeclared ROC-AUC criterion. All models achieved almost perfect scores.

Locked Validation Threshold

The locked threshold was determined by maximizing Youden’s statistic using only the validation data. This resulted in a threshold of 0.752. The validation confusion matrix consisted of 8,174 true positives, 6 false positives, 9,219 true negatives, and 1 false negative. No test observations were used in the selection of the threshold.

Frozen Internal Test Performance

With the locked threshold, EfficientNet-B0 correctly classified 17,384 of 17,400 test images (accuracy 0.999). The confusion matrix consisted of 8,173 true positives, 14 false positives, 9,211 true negatives, and 2 false negatives. Remaining threshold dependent measures are reported in Table 4.

ROC-AUC was 1.000, PR-AUC 1.000, Brier score 0.001, log loss 0.008, and 10-bin ECE 0.001. No calibration mapping was fitted on the test set.

MetricEstimateCluster-bootstrap 95% CI
Accuracy0.9990.999–1.000
Sensitivity1.0000.999–1.000
Specificity0.9980.998–0.999
Balanced accuracy0.9990.999–1.000
PPV0.9980.997–0.999
NPV1.0000.999–1.000
F10.9990.998–1.000
ROC-AUC1.0000.999–1.000
PR-AUC1.0000.999–1.000
Brier score0.0010.000–0.001
Table 4 | Frozen internal test performance at the validation-locked threshold (N = 17,400).
Note: Confidence intervals used the 13,289 frozen similarity-risk groups and are not patient-level clinical intervals. TP = 8,173, FP = 14, TN = 9,211, FN = 2.

Post-Lock Robustness Analyses

The greatest change to the operating point occurred between the grayscale conversion (Table 5; Figure 3). Sensitivity fell from 1.000 to 0.918, causing 671 false negatives, however ROC-AUC remained 1.000. The result indicates color dependence but does not explain if it was due to retinal biology or through acquisition or processing effects.

CLAHE had a sensitivity of 0.997, specificity of 0.996, and ROC-AUC of 1.000. The fixed circular mask had a sensitivity of 0.999, specificity of 0.999, and ROC-AUC of 1.000. However, this mask result was specific to our predefined definition and does not rule out other shortcuts.

ConditionAccuracySensitivitySpecificityROC-AUCBrier scoreFP / FN
Original RGB0.9991.0000.9981.0000.00114 / 2
Grayscale0.9610.9181.0001.0000.0302 / 671
CLAHE0.9960.9970.9961.0000.00338 / 26
Circular/border mask0.9990.9990.9991.000Not reported10 / 11
Table 5 | Secondary post-lock robustness results on the frozen internal test set.
Note: Not reported indicates that no frozen value was available. None was imputed.

Grad-CAM visualizations were retained as qualitative inspection aids only. They did not assume that the model had learned pathology specific features or to exclude possible shortcuts.

PALM External Stress Test

At the unchanged threshold, PALM accuracy was 0.763 and sensitivity 0.554, with 118 true positives and 95 false negatives. No false positives occurred among 187 negative images (specificity and PPV 1.000); NPV was 0.663 and F1 was 0.713 (Table 6).

MetricValue
Accuracy0.763
Sensitivity0.554
Specificity1.000
Balanced accuracy0.777
PPV1.000
NPV0.663
F10.713
ROC-AUC0.985
PR-AUC0.990
Brier score0.200
Log loss1.760
Table 6 | PALM external stress-test performance using the unchanged validation-locked threshold (N = 400).
Note: Confusion matrix: TP = 118, FP = 0, TN = 187, FN = 95. Positive class: PALM P. Negative class: PALM H and N.
Figure 3 | Sensitivity, specificity, ROC-AUC, and reported Brier scores for internal transformations and the non-equivalent PALM stress test at the unchanged threshold.

Core ML Parity and iPhone Performance

EfficientNet-B0 was exported as a 7.748 MB Float16 Core ML program. The maximum difference between probabilities in the 100 validation images was 1.192 x 10-7, and the mean and median differences were 2.384 x 10-9 and 0 respectively. No locked threshold classifications changed.

The median end-to-end processing times were 1.410 ms with all compute units, 1.380 ms with CPU plus ANE, and 4.430 ms with CPU only (Table 7; Figure 4). Corresponding median model only processing times were 0.600, 0.770, and 3.570 ms. All recorded thermal states were nominal.

Compute configurationEnd-to-end median (ms)End-to-end mean ± SD (ms)End-to-end p95 (ms)Model-only median (ms)Thermal state
All compute units1.4101.700 ± 0.7703.7700.600Not reported
CPU + ANE1.3801.480 ± 0.3402.0800.770Nominal
CPU only4.4304.450 ± 0.1404.6803.570Nominal
Table 7 | EfficientNet-B0 timing on an iPhone 16.
Note: End-to-end timing covers VNImageRequestHandler.perform([VNCoreMLRequest]) on an already-decoded CGImage. This includes Vision resizing/preprocessing and Core ML inference.
Figure 4 | Core ML pathway and median iPhone 16 timing for decoded-image preprocessing and inference. Time taken for capture and interaction were excluded.

Discussion

Principal Findings and Connection to the Research Questions

The selected EfficientNet-B0 separated the supplied labels with test accuracy 0.999 and ROC-AUC 1.000 after controlled partitioning (RQ1), but undocumented clinical ground truth prevents interpretation as screening accuracy. EfficientNet-B0 ranked first among four near-ceiling models under validation-only selection (RQ2). Grayscale caused the largest robustness loss, indicating color dependence without establishing its mechanism (RQ3). PALM retained high ranking performance but weak locked-threshold sensitivity under combined label and domain shift (RQ4). Core ML export preserved numerical parity and enabled rapid inference on decoded images, not validated smartphone acquisition (RQ5).

Internal Performance and Architecture Selection

Dataset quality strongly affected the model performance. The model learned a boundary that separated the given folders within the partitioning framework of the study. This boundary could have included features relating to how the images were acquired, their source, preprocessing, severity, or other characteristics which could be correlated with the folder labels. The internal metrics are reflective of how well the model can separate the dataset based on its labels. This highlights the importance of dataset auditing and suggests that image duplication checks should be carried out as part of standard practice in medical AI development.

The four model comparison addresses the lack of a baseline because EfficientNet-B0 had the highest validation ROC-AUC and fewest parameters. Due to the tight clustering of values, having one seed and one final configuration for each architecture shows that we have a reproducible model choice for this workflow.

The model architecture and threshold selection were chosen based on validation data only. Once these were decided upon, the test set was opened. Cluster bootstrap intervals reflect the risk of similarity between groups, however it does not reflect the uncertainty for clinically identified patients.

Color Dependence Robustness and Shortcut Risk

Grayscale conversion increased the amount of false negatives from 2 to 671, while specificity and ROC-AUC remained at 1.000. The model still maintains that the majority of positives are ranked higher than negatives but the probability values are skewed enough to affect sensitivity at the locked threshold.

CLAHE produced 26 false negatives and 38 false positives. The fixed circular mask produced 11 and 10, respectively. Both models also maintained an almost perfect ROC-AUC. The mask result does not necessarily rule out the possibility of shortcuts in other areas of the fundus or using another crop.

Grad-CAM cannot determine that the model has learnt pathologies or any shortcuts such as color lighting, texture, camera processing, and source. The analyses show robustness across selected transformations without establishing a biological classification mechanism.

PALM Domain Label and Threshold Shift

PALM was consistent with respect to ranking (ROC-AUC 0.985; PR-AUC 0.990), but not probability quality or the internal operating point (Brier score 0.200; log loss 1.760; sensitivity 0.554).

The model produced no PALM false positives but failed to detect 95 of 213 pathologic myopia images. This sensitivity is poor and would be unacceptable for a validated screening threshold. It shows why an operating point cannot be assumed to transfer across domains or target definitions.

The study cannot determine whether poor performance was due to PALM label mismatching, or changes in imaging protocol, camera, preprocessing, population, or severity. The resulting poor sensitivity despite good ranking indicates that there are challenges in generalizing thresholds and calibrations.

Classification Errors and Ethical Implications

False negative results would cause delays in clinical application due to the false confidence they provide. On the other hand, false positives could cause anxiety or unnecessary follow up. Their relative costs depend on the intended population, target condition, role of the tool, and available follow up. These factors were not established here.

There were 2 false negatives using the internal test and 95 false negatives using PALM at the same threshold. Generally missing cases would be of more importance in a screening application however it is important these are chosen based on clinically valid labels, an intended population, and a pre-set rule. If the classifier was tuned post-hoc then the generalization would be overestimated.

As there was no correlation between the training results and cycloplegic refraction, spherical equivalent error, axial length, or another clinical reference, there should not be any suggestion that this classifier can diagnose myopia. It should be described as a classifier within the device for classifying imported fundus images.

On Device Inference and Translational Scope

EfficientNet-B0 retained numerical parity after export to a compressed Float16 Core ML and had end-to-end median runtimes of 1.380-4.430 ms across compute configurations. For this device and input representation, it is unlikely that the model would act as a computational bottleneck.

The benchmark was performed on a decoded fundus photograph. This does not include imaging, decoding, model loading, interface rendering, operator variability, or clinical comparison. This means that the model is suitable to perform interface locally.

Limitations

The training dataset lacked information on image acquisition, patient demographics, diagnosis and labels. Folder labels were not indicative of cycloplegic refraction, a spherical equivalent threshold, axial length, or an independently verified diagnosis. Therefore the internal performance cannot be translated into refractive myopia sensitivity or specificity.

Patient, eye, source, device, and demographic identifiers were unavailable. Similarity risk blocking was used to reduce detected cross partition relatedness but could not prove patient or eye level independence. Only 100 pairs were audited meaning we could not cover all possible relationships. As such, no relationships were detected based on the criteria given.

The architecture comparison covered four models with one seed and one final configuration each. Small validation differences may not carry through repeated runs, other hyperparameters, or additional architectures. Additionally, uncertainty was not estimated between models.

The three perturbations did not represent the full range of acquisition variation. The mask result only relates to one radius. Grad-CAM remained a qualitative measure. Source and device metadata were not available meaning stratification or source prediction were not possible. There is also no guarantee that there wasn’t shortcut learning within the fundus.

PALM addressed pathologic myopia and therefore served as a stress test rather than a replication of the task. Factors including label definition, imaging protocol, camera, preprocessing, population, and severity effects could not be separated. The threshold remained unchanged meaning this reflects transferability instead of performance after PALM specific calibration.

All evaluations were retrospective with no gold standard clinical evaluation. Confidence intervals were calculated at the group level. Deployment used one iPhone and decoded images, without testing acquisition, gradability, operators, ambient conditions, sustained thermal behavior, or prospective outcomes.

Future Work and Recommendations

Future validation should link images to patient and eye identifiers, cycloplegic refraction or an explicit spherical equivalent threshold, and axial length when available. The dataset must be stratified at the patient level, with an external outcome definition, to test the refractive myopia classification.

Future datasets should contain metadata on where the image was collected, the camera, location, and any preprocessing. The dataset can be stratified by analyzing predeclared factors such as source prediction, occlusion, saliency sanity, color normalization, and grayscale training.

Thresholds and calibrations should be developed using a predeclared error balance on clinically labeled development data, and applied without modification to external data. Calibration, confusion matrices, and predictive values should be reported at the deployment prevalence.

Prospective deployment should document the phone, optical adapter, illumination, pupil protocol, field of view, and capture procedure. The gradability, failure rate, and predictions should be recorded across operators and deployment scenarios. Longitudinal analysis will also be conducted to determine performance over time, including temperature, memory, and power usage. Until this is complete, the Core ML model will just be a research classifier for imported images.

Conclusion

EfficientNet-B0 ranked first among four architectures, with excellent test performance when frozen after exact deduplication and similarity risk controlled partitioning. Grayscale reduced sensitivity with fixed thresholds, while PALM retained robustness with strong ranking but weaker sensitivity and calibration. Exporting models to Core ML enabled rapid iPhone inference on imported fundus photographs. These results do not validate refractive myopia diagnosis using smartphone acquisition and screening. Clinical definitions of labels are required during translation. This should also be independent of patients and externally calibrated. Shortcuts should be considered and models tested prospectively.

Acknowledgments

The author thanks UCSD Assistant Professor Imani Munyaka for guidance on optimizing models and project workflow.

References

  1. D. I. Flitcroft, M. He, J. B. Jonas, M. Jong, K. Naidoo, K. Ohno-Matsui, J. Rahi, S. Resnikoff, S. Vitale, L. Yannuzzi. IMI – Defining and classifying myopia: A proposed set of standards for clinical and epidemiologic studies. Investigative Ophthalmology & Visual Science. Vol. 60, pg. M20-M30, 2019, https://doi.org/10.1167/iovs.18-25957. [↩] [↩]
  2. A. E. G. Haarman, C. A. Enthoven, J. W. L. Tideman, M. S. Tedja, V. J. M. Verhoeven, C. C. W. Klaver. The complications of myopia: A review and meta-analysis. Investigative Ophthalmology & Visual Science. Vol. 61, pg. 49, 2020, https://doi.org/10.1167/iovs.61.4.49. [↩]
  3. B. A. Holden, T. R. Fricke, D. A. Wilson, M. Jong, K. S. Naidoo, P. Sankaridurg, T. Y. Wong, T. J. Naduvilath, S. Resnikoff. Global prevalence of myopia and high myopia and temporal trends from 2000 through 2050. Ophthalmology. Vol. 123, pg. 1036-1042, 2016, https://doi.org/10.1016/j.ophtha.2016.01.006. [↩]
  4. K. Ohno-Matsui, R. Kawasaki, J. B. Jonas, C. M. G. Cheung, S. M. Saw, V. J. M. Verhoeven, C. C. W. Klaver, M. Moriyama, K. Shinohara, Y. Kawasaki, M. Yamazaki, S. Meuer, T. Ishibashi, M. Yasuda, H. Yamashita, A. Sugano, J. J. Wang, P. Mitchell, T. Y. Wong, META-PM Study Group. International photographic classification and grading system for myopic maculopathy. American Journal of Ophthalmology. Vol. 159, pg. 877-883.e7, 2015, https://doi.org/10.1016/j.ajo.2015.01.022. [↩]
  5. V. Gulshan, L. Peng, M. Coram, M. C. Stumpe, D. Wu, A. Narayanaswamy, S. Venugopalan, K. Widner, T. Madams, J. Cuadros, R. Kim, R. Raman, P. C. Nelson, J. L. Mega, D. R. Webster. Development and validation of a deep learning algorithm for detection of diabetic retinopathy in retinal fundus photographs. JAMA. Vol. 316, pg. 2402-2410, 2016, https://doi.org/10.1001/jama.2016.17216. [↩]
  6. D. S. W. Ting, C. Y. L. Cheung, G. Lim, G. S. W. Tan, N. D. Quang, A. Gan, H. Hamzah, R. Garcia-Franco, I. Y. S. Yeo, S. Y. Lee, E. Y. M. Wong, C. Sabanayagam, M. Baskaran, F. Ibrahim, N. C. Tan, E. A. Finkelstein, E. L. Lamoureux, I. Y. S. Wong, N. M. Bressler, S. Sivaprasad, R. Varma, J. B. Jonas, M. G. He, C. Y. Cheng, G. C. M. Cheung, T. Aung, W. Hsu, M. L. Lee, T. Y. Wong. 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, pg. 2211-2223, 2017, https://doi.org/10.1001/jama.2017.18152. [↩]
  7. A. V. Varadarajan, R. Poplin, K. Blumer, C. Angermueller, J. Ledsam, R. Chopra, P. A. Keane, G. S. Corrado, L. Peng, D. R. Webster. Deep learning for predicting refractive error from retinal fundus images. Investigative Ophthalmology & Visual Science. Vol. 59, pg. 2861-2868, 2018, https://doi.org/10.1167/iovs.18-23887. [↩] [↩]
  8. T. E. Tan, A. Anees, C. Chen, S. Li, X. Xu, Z. Li, Z. Xiao, Y. Yang, X. Lei, M. Ang, A. Chia, S. Y. Lee, E. Y. M. Wong, I. Y. S. Yeo, Y. L. Wong, Q. V. Hoang, Y. X. Wang, M. M. Bikbov, V. Nangia, J. B. Jonas, Y. P. Chen, W. C. Wu, K. Ohno-Matsui, T. H. Rim, Y. C. Tham, R. S. M. Goh, H. Lin, H. Liu, N. Wang, W. Yu, D. T. H. Tan, L. Schmetterer, C. Y. Cheng, Y. Chen, C. W. Wong, G. C. M. Cheung, S. M. Saw, T. Y. Wong, Y. Liu, D. S. W. Ting. Retinal photograph-based deep learning algorithms for myopia and a blockchain platform to facilitate artificial intelligence medical research: A retrospective multicohort study. The Lancet Digital Health. Vol. 3, pg. e317-e329, 2021, https://doi.org/10.1016/S2589-7500(21)00055-8. [↩]
  9. R. Du, S. Xie, Y. Fang, T. Igarashi-Yokoi, M. Moriyama, S. Ogata, T. Tsunoda, T. Kamatani, S. Yamamoto, C. Y. Cheng, S. M. Saw, D. Ting, T. Y. Wong, K. Ohno-Matsui. Deep learning approach for automated detection of myopic maculopathy and pathologic myopia in fundus images. Ophthalmology Retina. Vol. 5, pg. 1235-1244, 2021, https://doi.org/10.1016/j.oret.2021.02.006. [↩]
  10. L. Lu, P. Ren, X. Tang, M. Yang, M. Yuan, W. Yu, J. Huang, E. Zhou, L. Lu, Q. He, M. Zhu, G. Ke, W. Han. AI-model for identifying pathologic myopia based on deep learning algorithms of myopic maculopathy classification and plus lesion detection in fundus images. Frontiers in Cell and Developmental Biology. Vol. 9, pg. 719262, 2021, https://doi.org/10.3389/fcell.2021.719262. [↩]
  11. J. Li, L. Wang, Y. Gao, Q. Liang, L. Chen, X. Sun, H. Yang, Z. Zhao, L. Meng, S. Xue, Q. Du, Z. Zhang, C. Lv, H. Xu, Z. Guo, G. Xie, L. Xie. Automated detection of myopic maculopathy from color fundus photographs using deep convolutional neural networks. Eye and Vision. Vol. 9, pg. 13, 2022, https://doi.org/10.1186/s40662-022-00285-3. [↩]
  12. R. Wang, J. He, Q. Chen, L. Ye, D. Sun, L. Yin, H. Zhou, L. Zhao, J. Zhu, H. Zou, Q. Tan, D. Huang, B. Liang, L. He, W. Wang, Y. Fan, X. Xu. Efficacy of a deep learning system for screening myopic maculopathy based on color fundus photographs. Ophthalmology and Therapy. Vol. 12, pg. 469-484, 2023, https://doi.org/10.1007/s40123-022-00621-9. [↩]
  13. H. Fang, F. Li, J. Wu, H. Fu, X. Sun, J. I. Orlando, H. Bogunovic, X. Zhang, Y. Xu. Open fundus photograph dataset with pathologic myopia recognition and anatomical structure annotation. Scientific Data. Vol. 11, pg. 99, 2024, https://doi.org/10.1038/s41597-024-02911-2. [↩]
  14. Y. Zhou, M. A. Chia, S. K. Wagner, M. S. Ayhan, D. J. Williamson, R. R. Struyven, T. Liu, M. Xu, M. G. Lozano, P. Woodward-Court, Y. Kihara, UK Biobank Eye & Vision Consortium, A. Altmann, A. Y. Lee, E. J. Topol, A. K. Denniston, D. C. Alexander, P. A. Keane. A foundation model for generalizable disease detection from retinal images. Nature. Vol. 622, pg. 156-163, 2023, https://doi.org/10.1038/s41586-023-06555-x. [↩]
  15. A. Dosovitskiy, L. Beyer, A. Kolesnikov, D. Weissenborn, X. Zhai, T. Unterthiner, M. Dehghani, M. Minderer, G. Heigold, S. Gelly, J. Uszkoreit, N. Houlsby. An image is worth 16 × 16 words: Transformers for image recognition at scale. International Conference on Learning Representations, 2021, https://openreview.net/forum?id=YicbFdNTTy. [↩]
  16. A. Jain, R. Krishnan, A. Rogye, S. Natarajan. Use of offline artificial intelligence in a smartphone-based fundus camera for community screening of diabetic retinopathy. Indian Journal of Ophthalmology. Vol. 69, pg. 3150-3154, 2021, https://doi.org/10.4103/ijo.IJO_3808_20. [↩]
  17. B. Sosale, A. R. Sosale, H. Murthy, S. Sengupta, M. Naveenam. Medios: An offline, smartphone-based artificial intelligence algorithm for the diagnosis of diabetic retinopathy. Indian Journal of Ophthalmology. Vol. 68, pg. 391-395, 2020, https://doi.org/10.4103/ijo.IJO_1203_19. [↩]
  18. A. Bastawrous, M. E. Giardini, N. M. Bolster, T. Peto, N. Shah, I. A. T. Livingstone, H. A. Weiss, S. Hu, H. Rono, H. Kuper, M. Burton. Clinical validation of a smartphone-based adapter for optic disc imaging in Kenya. JAMA Ophthalmology. Vol. 134, pg. 151-158, 2016, https://doi.org/10.1001/jamaophthalmol.2015.4625. [↩]
  19. J. R. Zech, M. A. Badgeley, M. Liu, A. B. Costa, J. J. Titano, E. K. Oermann. Variable generalization performance of a deep learning model to detect pneumonia in chest radiographs: A cross-sectional study. PLOS Medicine. Vol. 15, pg. e1002683, 2018, https://doi.org/10.1371/journal.pmed.1002683. [↩]
  20. A. J. DeGrave, J. D. Janizek, S. I. Lee. AI for radiographic COVID-19 detection selects shortcuts over signal. Nature Machine Intelligence. Vol. 3, pg. 610-619, 2021, https://doi.org/10.1038/s42256-021-00338-7. [↩]
  21. C. Guo, G. Pleiss, Y. Sun, K. Q. Weinberger. On calibration of modern neural networks. Proceedings of the 34th International Conference on Machine Learning. Vol. 70, pg. 1321-1330, 2017, https://proceedings.mlr.press/v70/guo17a.html. [↩]
  22. Y. Ovadia, E. Fertig, J. Ren, Z. Nado, D. Sculley, S. Nowozin, J. Dillon, B. Lakshminarayanan, J. Snoek. Can you trust your model’s uncertainty? Evaluating predictive uncertainty under dataset shift. Advances in Neural Information Processing Systems. Vol. 32, 2019, https://proceedings.neurips.cc/paper/2019/hash/8558cb408c1d76621371888657d2eb1d-Abstract.html. [↩]
  23. J. Adebayo, J. Gilmer, M. Muelly, I. Goodfellow, M. Hardt, B. Kim. Sanity checks for saliency maps. Advances in Neural Information Processing Systems. Vol. 31, 2018, https://proceedings.neurips.cc/paper/2018/hash/294a8ed24b1ad22ec2e7efea049b8737-Abstract.html. [↩]
  24. M. Oquab, T. Darcet, T. Moutakanni, H. Vo, M. Szafraniec, V. Khalidov, P. Fernandez, D. Haziza, F. Massa, A. El-Nouby, M. Assran, N. Ballas, W. Galuba, R. Howes, P. Y. Huang, S. W. Li, I. Misra, M. Rabbat, V. Sharma, G. Synnaeve, H. Xu, H. Jégou, J. Mairal, P. Labatut, A. Joulin, P. Bojanowski. DINOv2: Learning robust visual features without supervision. Transactions on Machine Learning Research, 2024, https://openreview.net/forum?id=a68SUt6zFt. [↩]
  25. K. He, X. Zhang, S. Ren, J. Sun. Deep residual learning for image recognition. Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pg. 770-778, 2016, https://doi.org/10.1109/CVPR.2016.90. [↩]
  26. M. Tan, Q. V. Le. EfficientNet: Rethinking model scaling for convolutional neural networks. Proceedings of the 36th International Conference on Machine Learning. Vol. 97, pg. 6105-6114, 2019, https://proceedings.mlr.press/v97/tan19a.html. [↩]
  27. Z. Liu, H. Mao, C. Y. Wu, C. Feichtenhofer, T. Darrell, S. Xie. A ConvNet for the 2020s. Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pg. 11976-11986, 2022, https://doi.org/10.1109/CVPR52688.2022.01167. [↩]
  28. R. R. Selvaraju, M. Cogswell, A. Das, R. Vedantam, D. Parikh, D. Batra. Grad-CAM: Visual explanations from deep networks via gradient-based localization. Proceedings of the IEEE International Conference on Computer Vision, pg. 618-626, 2017, https://doi.org/10.1109/ICCV.2017.74. [↩]

LEAVE A REPLY

Please enter your comment!
Please enter your name here