Front page: repo overview and card of the legacy main model
Browse files123452 unmodified lines89101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128---base_model: timm/convnext_tiny.in12k_ft_in1klibrary_name: pytorchpipeline_tag: image-segmentationtags:2 unmodified lines- oct- choroid- segmentation- upernet- convnext- segmentation-models-pytorch- pytorch_model_hub_mixin- model_hub_mixin---# Choroid segmentation in OCT B-scans (version 3.0.0)A binary segmentation model for the **choroid** in OCT B-scans: it labels theregion between Bruch's membrane and the choroid-sclera interface (CSI). It is thefirst stage of the OcularRigidity pipeline (choroid segmentation, then videoregistration, then pulsation analysis). Its frozen encoder is also the featureextractor of the registration model `ClementP/OCTVideoRegistration`.| | ||---|---|| Architecture | UPerNet decoder, ConvNeXt-Tiny encoder (`tu-convnext_tiny`, ImageNet init), from `segmentation_models_pytorch` || Parameters | 37.0 M || Input | 1 channel (grayscale B-scan) at the **PLEX Elite pixel size: 1.95 µm axial × 5.9 µm lateral** || Output | 1 channel of logits; choroid = `logit > 0` || Revision | `version-3.0.0` |## UsageThe weights load with the `ChoroidSegmentationModule` class from theOcularRigidity package (`ocularrigidity.segmentation.trainer.pl_module`):```pythonimport torchfrom ocularrigidity.segmentation.trainer.pl_module import ChoroidSegmentationModulemodel = ChoroidSegmentationModule.from_pretrained("ClementP/ChoroidSegmentationModule", revision="version-3.0.0").eval().cuda()# bscan: uint8 array (H, W), already at 1.95 µm/px axially and 5.9 µm/px laterally,# H and W padded to multiples of 32x = torch.from_numpy(bscan).float().div(255).sub(0.5).div(0.5)[None, None].cuda()with torch.no_grad():mask = model(x)[0, 0] > 0 # (H, W) bool```**Preprocessing**- **Pixel size:** resample images from other devices to the PLEX pixel size first.Training used only small scale jitter (±10%), so the model expects that scale.- **Normalisation:** `(x / 255 - 0.5) / 0.5`.## Training dataAll images were resampled to the PLEX pixel size. The splits are made at the patient level.| Source | Device | Train | Val | Test ||---|---|---|---|---|| In-house, annotated (Didascalie) | Zeiss PLEX Elite 9000 | 1,769 | 118 | 329 || In-house, annotated (Didascalie) | Heidelberg Spectralis (videos) | 327 | 24 | 77 || In-house, annotated (Didascalie) | Heidelberg Spectralis | 81 | 10 | 18 || [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) | | |The in-house annotations are not public.## Training procedure**Setup**- **Loss:** Dice + cross-entropy, plus a thickness-smoothness term (weight 0.1)and a gap-detection term (weight 0.05) that penalise jagged or broken choroid masks.- **Optimiser:** AdamW, learning rate 1e-4, weight decay 1e-5. Cosine schedulewith 2 warm-up epochs, 60 epochs, no early stopping.- **Batches:** batch size 8, random 1024 × 768 crops, bf16 mixed precision, one GPU.**Model selection:** the architecture was chosen in a W&B sweep over SegFormer,UPerNet, U-Net, U-Net++ and FPN variants trained with the same recipe. UPerNetConvNeXt-T gave the best trade-off between Dice and boundary errors.**Checkpoint:** this release is the **final-epoch** checkpoint, not the best-Diceone. The final checkpoint has a clearly lower thickness error for almost the same Dice.## EvaluationValidation split (in-house plus OIMHS), final checkpoint:| Metric | Value ||---|---|| Dice | 0.958 || Choroid thickness MAE (per A-scan) | 12.8 µm || CSI position MAE (per A-scan) | 19.5 µm |**How the errors are computed**- Errors are per column, over the columns where the ground truth has choroid, at 1.95 µm/px.- The CSI is the deepest choroid pixel of each column.## Limitations- **Single frames:** the model segments each B-scan independently, with notemporal consistency across video frames. In the pipeline, consistency comesfrom the registration stage.- **Training domain:** trained on PLEX Elite and Spectralis only, with mostlymacular and some optic nerve head scans. Other devices, or scans withpathologies that change choroid appearance, may need validation.- **CSI:** the choroid-sclera interface is the hardest boundary, and its error islarger than the thickness error.- **Research use only.** This is not a medical device.## Version history- `version-3.0.0`:- UPerNet ConvNeXt-T;- new annotated set plus OIMHS, everything at the PLEX pixel size;- final-epoch checkpoint.- `version-2.0.0`: previous model, kept on its branch.## CitationIf you use this model, please cite the OcularRigidity work (reference to come)and the OIMHS dataset:```12342 unmodified lines7891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071---library_name: pytorchpipeline_tag: image-segmentationtags:2 unmodified lines- oct- choroid- segmentation- segmentation-models-pytorch- model_hub_mixin- pytorch_model_hub_mixin---# Choroid segmentation in OCT B-scansBinary segmentation models for the **choroid** in OCT B-scans: the regionbetween Bruch's membrane and the choroid-sclera interface. They are the firststage of the OcularRigidity pipeline: choroid segmentation, then videoregistration, then pulsation analysis.Each version is on its own branch. **Always load with an explicit `revision`.**Without one you get the weights of `main`, which is the first, legacy model(described below), not the current one.| Revision | Model | Training data | Status ||---|---|---|---|| [`version-3.0.0`](https://huggingface.co/ClementP/ChoroidSegmentationModule/tree/version-3.0.0) | UPerNet, ConvNeXt-Tiny encoder | Annotated in-house set (Zeiss PLEX Elite, Heidelberg Spectralis) + OIMHS | **Current.** Full model card on its branch || [`version-2.0.0`](https://huggingface.co/ClementP/ChoroidSegmentationModule/tree/version-2.0.0) | SegFormer, MiT-B2 encoder | | Superseded || `main` | U-Net, SE-ResNet50 encoder | OIMHS only | Legacy, kept for reproducibility |```pythonfrom ocularrigidity.segmentation.trainer.pl_module import ChoroidSegmentationModulemodel = ChoroidSegmentationModule.from_pretrained("ClementP/ChoroidSegmentationModule", revision="version-3.0.0").eval()```The registration model[`ClementP/OCTVideoRegistration`](https://huggingface.co/ClementP/OCTVideoRegistration)reads the encoder features of `version-3.0.0`, so the two must be used together.## The model on `main` (legacy)The first model of the project, uploaded in May 2026.| | ||---|---|| Architecture | U-Net, SE-ResNet50 encoder (ImageNet init), from `segmentation_models_pytorch` || Input | 1 channel (grayscale B-scan), normalised as `(x / 255 - 0.5) / 0.5` || Output | 1 channel of logits; choroid = `logit > 0` || Training data | [OIMHS](https://www.nature.com/articles/s41597-023-02675-1) only (Heidelberg Spectralis, macular-hole patients, choroid label), 80 / 20 split by patient (seed 42) || Input scale in training | OIMHS B-scans resized from 496 × 512 to 1024 × 1024, meant to approximate the PLEX Elite pixel size || Augmentation | Horizontal flip, scale 0.8–1.2 (lateral) and 0.75–1.25 (axial), rotation ±5°, Gaussian noise, brightness and contrast || Loss | Dice + cross-entropy, plus thickness-smoothness (0.05) and gap-detection (0.05) terms || Optimiser | AdamW, learning rate 1e-4, weight decay 1e-5, batch size 16, early stopping on validation Dice || Validation Dice | 0.986, on the OIMHS validation patients only |It never saw a PLEX Elite image in training, and it was evaluated on OIMHSonly. Its Dice cannot be compared with the scores of later versions, which aremeasured on a mixed in-house + OIMHS split.**Research use only.** This is not a medical device.## CitationIf you use these models, please cite the OcularRigidity work (reference to come)and the OIMHS dataset:```
README.md+35-92