Front page: model card of version-3.0.0
Browse files
README.md
CHANGED
|
@@ -1,10 +1,130 @@
|
|
| 1 |
---
|
|
|
|
|
|
|
|
|
|
| 2 |
tags:
|
| 3 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
- pytorch_model_hub_mixin
|
|
|
|
| 5 |
---
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
base_model: timm/convnext_tiny.in12k_ft_in1k
|
| 3 |
+
library_name: pytorch
|
| 4 |
+
pipeline_tag: image-segmentation
|
| 5 |
tags:
|
| 6 |
+
- medical-imaging
|
| 7 |
+
- ophthalmology
|
| 8 |
+
- oct
|
| 9 |
+
- choroid
|
| 10 |
+
- segmentation
|
| 11 |
+
- upernet
|
| 12 |
+
- convnext
|
| 13 |
+
- segmentation-models-pytorch
|
| 14 |
- pytorch_model_hub_mixin
|
| 15 |
+
- model_hub_mixin
|
| 16 |
---
|
| 17 |
|
| 18 |
+
# Choroid segmentation in OCT B-scans (version 3.0.0)
|
| 19 |
+
|
| 20 |
+
A binary segmentation model for the **choroid** in OCT B-scans: it labels the
|
| 21 |
+
region between Bruch's membrane and the choroid-sclera interface (CSI). It is the
|
| 22 |
+
first stage of the OcularRigidity pipeline (choroid segmentation, then video
|
| 23 |
+
registration, then pulsation analysis). Its frozen encoder is also the feature
|
| 24 |
+
extractor of the registration model `ClementP/OCTVideoRegistration`.
|
| 25 |
+
|
| 26 |
+
| | |
|
| 27 |
+
|---|---|
|
| 28 |
+
| Architecture | UPerNet decoder, ConvNeXt-Tiny encoder (`tu-convnext_tiny`, ImageNet init), from `segmentation_models_pytorch` |
|
| 29 |
+
| Parameters | 37.0 M |
|
| 30 |
+
| Input | 1 channel (grayscale B-scan) at the **PLEX Elite pixel size: 1.95 µm axial × 5.9 µm lateral** |
|
| 31 |
+
| Output | 1 channel of logits; choroid = `logit > 0` |
|
| 32 |
+
| Revision | `version-3.0.0` |
|
| 33 |
+
|
| 34 |
+
## Usage
|
| 35 |
+
|
| 36 |
+
The weights load with the `ChoroidSegmentationModule` class from the
|
| 37 |
+
OcularRigidity package (`ocularrigidity.segmentation.trainer.pl_module`):
|
| 38 |
+
|
| 39 |
+
```python
|
| 40 |
+
import torch
|
| 41 |
+
from ocularrigidity.segmentation.trainer.pl_module import ChoroidSegmentationModule
|
| 42 |
+
|
| 43 |
+
model = ChoroidSegmentationModule.from_pretrained(
|
| 44 |
+
"ClementP/ChoroidSegmentationModule", revision="version-3.0.0"
|
| 45 |
+
).eval().cuda()
|
| 46 |
+
|
| 47 |
+
# bscan: uint8 array (H, W), already at 1.95 µm/px axially and 5.9 µm/px laterally,
|
| 48 |
+
# H and W padded to multiples of 32
|
| 49 |
+
x = torch.from_numpy(bscan).float().div(255).sub(0.5).div(0.5)[None, None].cuda()
|
| 50 |
+
with torch.no_grad():
|
| 51 |
+
mask = model(x)[0, 0] > 0 # (H, W) bool
|
| 52 |
+
```
|
| 53 |
+
|
| 54 |
+
**Preprocessing**
|
| 55 |
+
- **Pixel size:** resample images from other devices to the PLEX pixel size first.
|
| 56 |
+
Training used only small scale jitter (±10%), so the model expects that scale.
|
| 57 |
+
- **Normalisation:** `(x / 255 - 0.5) / 0.5`.
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
## Training data
|
| 61 |
+
|
| 62 |
+
All images were resampled to the PLEX pixel size. The splits are made at the patient level.
|
| 63 |
+
|
| 64 |
+
| Source | Device | Train | Val | Test |
|
| 65 |
+
|---|---|---|---|---|
|
| 66 |
+
| In-house, annotated (Didascalie) | Zeiss PLEX Elite 9000 | 1,769 | 118 | 329 |
|
| 67 |
+
| In-house, annotated (Didascalie) | Heidelberg Spectralis (videos) | 327 | 24 | 77 |
|
| 68 |
+
| In-house, annotated (Didascalie) | Heidelberg Spectralis | 81 | 10 | 18 |
|
| 69 |
+
| [OIMHS](https://www.nature.com/articles/s41597-023-02675-1) (choroid label) | Spectralis | 125 patients, 3,859 B-scans in total, split 0.8 / 0.05 / 0.15 by patient (seed 42) | | |
|
| 70 |
+
|
| 71 |
+
The in-house annotations are not public.
|
| 72 |
+
|
| 73 |
+
## Training procedure
|
| 74 |
+
|
| 75 |
+
**Setup**
|
| 76 |
+
- **Loss:** Dice + cross-entropy, plus a thickness-smoothness term (weight 0.1)
|
| 77 |
+
and a gap-detection term (weight 0.05) that penalise jagged or broken choroid masks.
|
| 78 |
+
- **Optimiser:** AdamW, learning rate 1e-4, weight decay 1e-5. Cosine schedule
|
| 79 |
+
with 2 warm-up epochs, 60 epochs, no early stopping.
|
| 80 |
+
- **Batches:** batch size 8, random 1024 × 768 crops, bf16 mixed precision, one GPU.
|
| 81 |
+
|
| 82 |
+
**Model selection:** the architecture was chosen in a W&B sweep over SegFormer,
|
| 83 |
+
UPerNet, U-Net, U-Net++ and FPN variants trained with the same recipe. UPerNet
|
| 84 |
+
ConvNeXt-T gave the best trade-off between Dice and boundary errors.
|
| 85 |
+
|
| 86 |
+
**Checkpoint:** this release is the **final-epoch** checkpoint, not the best-Dice
|
| 87 |
+
one. The final checkpoint has a clearly lower thickness error for almost the same Dice.
|
| 88 |
+
|
| 89 |
+
## Evaluation
|
| 90 |
+
|
| 91 |
+
Validation split (in-house plus OIMHS), final checkpoint:
|
| 92 |
+
|
| 93 |
+
| Metric | Value |
|
| 94 |
+
|---|---|
|
| 95 |
+
| Dice | 0.958 |
|
| 96 |
+
| Choroid thickness MAE (per A-scan) | 12.8 µm |
|
| 97 |
+
| CSI position MAE (per A-scan) | 19.5 µm |
|
| 98 |
+
|
| 99 |
+
**How the errors are computed**
|
| 100 |
+
- Errors are per column, over the columns where the ground truth has choroid, at 1.95 µm/px.
|
| 101 |
+
- The CSI is the deepest choroid pixel of each column.
|
| 102 |
+
|
| 103 |
+
## Limitations
|
| 104 |
+
|
| 105 |
+
- **Single frames:** the model segments each B-scan independently, with no
|
| 106 |
+
temporal consistency across video frames. In the pipeline, consistency comes
|
| 107 |
+
from the registration stage.
|
| 108 |
+
- **Training domain:** trained on PLEX Elite and Spectralis only, with mostly
|
| 109 |
+
macular and some optic nerve head scans. Other devices, or scans with
|
| 110 |
+
pathologies that change choroid appearance, may need validation.
|
| 111 |
+
- **CSI:** the choroid-sclera interface is the hardest boundary, and its error is
|
| 112 |
+
larger than the thickness error.
|
| 113 |
+
- **Research use only.** This is not a medical device.
|
| 114 |
+
|
| 115 |
+
## Version history
|
| 116 |
+
|
| 117 |
+
- `version-3.0.0`:
|
| 118 |
+
- UPerNet ConvNeXt-T;
|
| 119 |
+
- new annotated set plus OIMHS, everything at the PLEX pixel size;
|
| 120 |
+
- final-epoch checkpoint.
|
| 121 |
+
- `version-2.0.0`: previous model, kept on its branch.
|
| 122 |
+
|
| 123 |
+
## Citation
|
| 124 |
+
|
| 125 |
+
If you use this model, please cite the OcularRigidity work (reference to come)
|
| 126 |
+
and the OIMHS dataset:
|
| 127 |
+
|
| 128 |
+
```
|
| 129 |
+
Ye, X., He, S., Zhong, X. et al. OIMHS: An Optical Coherence Tomography Image Dataset Based on Macular Hole Manual Segmentation. Sci Data 10, 769 (2023). https://doi.org/10.1038/s41597-023-02675-1
|
| 130 |
+
```
|