SLICE is a patient-level multimodal deep-learning framework for simultaneous grading of cortical cataract (CC), nuclear cataract (NC), and posterior subcapsular cataract (PSC) from slit-lamp images.
This repository provides the source code, configuration files, evaluation scripts, aggregate results, and source data supporting the SLICE manuscript.
- Dataset: 8,943 slit-lamp images from 2,981 eyes with three imaging modes.
- Development cohort: 2,731 eyes with dual labels from two experienced ophthalmologists.
- Independent clinical validation cohort: 250 eyes graded by ophthalmologists with 1, 4, 7, and 10 years of experience.
- Tasks: CC grades 0-5, NC grades 0-6, and PSC grades 0-5 plus Px handling.
- Model: modality-specific ConvNeXt-Tiny experts followed by frozen-expert feature addition and three subtype-specific ordinal heads.
| Modality | Accuracy (%) | F1 (%) | QWK | MAE |
|---|---|---|---|---|
| CC | 81.97 | 80.88 | 0.95 | 0.18 |
| NC | 80.33 | 74.28 | 0.96 | 0.20 |
| PSC | 77.87 | 70.74 | 0.88 | 0.35 |
| Average | 80.05 | 75.30 | 0.93 | 0.24 |
In the independent clinical validation cohort, SLICE showed the highest agreement with the Y10 ophthalmologist, with QWK values of 0.91 for CC, 0.92 for NC, and 0.63 for PSC.
git clone https://github.com/ZJUMAI/SLICE.git
cd SLICE
conda create -n slice python=3.8 -y
conda activate slice
pip install -r requirements.txtGPU execution is recommended for training and full evaluation.
Dependency details for full training and the lightweight example inference are
summarized in docs/dependencies.md.
The training and evaluation scripts expect the following local layout:
data/
├── dataset/
│ └── labels.xlsx
├── data_crop/
│ └── dataset/
└── external_validation/
The spreadsheet should contain train/validation/test sheets, three image-path
columns, dual labels for CC/NC/PSC, ROI bounding-box columns, and optional
LabelMe JSON paths for lesion-preserving augmentation. See
configs/default.yaml and utils/datasets.py for the field usage.
Train the final two-stage SLICE model:
python scripts/train_slice.py \
--data_excel data/dataset/labels.xlsx \
--data_root data/data_crop/dataset \
--output_dir checkpoints/slice \
--gpu 0The training wrapper first learns modality-specific ConvNeXt-Tiny experts with dual-label supervision and lesion-preserving augmentation, then freezes the expert backbones and trains the final feature-addition fusion model.
Evaluate a trained SLICE checkpoint:
python evaluate.py \
--model fusion \
--checkpoint checkpoints/slice/stage2_fusion/stage2_fusion_best.pth \
--data_excel data/dataset/labels.xlsx \
--data_root data/data_crop/datasetScripts for the baseline comparisons, ablation analyses, clinical validation,
and figure generation are included under scripts/.
The repository includes five de-identified slit-lamp ROI sample triplets and a split FP16 SLICE checkpoint. Reassemble the checkpoint and run inference on the included samples with:
python scripts/prepare_example_checkpoint.py
python scripts/run_example_inference.pyThe script prints the ground-truth labels and model predictions for CC, NC, and PSC for each included sample.
The full evaluate.py --data_excel ... --data_root ... command is intended for
test-set evaluation when the corresponding local dataset is available.
Table source data are provided in results/source_data/tables/:
table1_model_performance.csvsupplementary_table_s1_ablation.csvsupplementary_table_s2_fusion_strategies.csv
Aggregate figure exports are provided in results/figures/. Case-level
visualization panels can be regenerated with the scripts in
scripts/evaluation/ when the corresponding local data and checkpoints are
available.
SLICE/
├── configs/ # Default experiment configuration
├── docs/ # Dependency, figure-caption, and reproducibility notes
├── models/ # Backbones, baseline models, and fusion models
├── examples/ # De-identified sample ROIs and split checkpoint
├── results/ # Aggregate figures and source data
├── scripts/ # Training, evaluation, and validation scripts
│ └── train_slice.py # Main SLICE training entry point
├── scripts_yolo/ # YOLO ROI extraction wrappers
├── utils/ # Datasets, losses, metrics, config helpers
├── evaluate.py # Evaluation entry point
└── requirements.txt
The source code is available at https://github.com/ZJUMAI/SLICE.
Additional study data are available from the corresponding author on reasonable request, subject to institutional approval and applicable privacy restrictions.
Please cite the accompanying SLICE manuscript when using this repository.