IVCM mosaic segmentation: corneal nerves and dendritic cells

ResUNet weights for segmenting corneal sub-basal nerves and dendritic cells in in-vivo confocal microscopy (IVCM) mosaics. Mosaics are much larger than the models' 384x384 input, so they are segmented tile by tile and the tiles are blended back together. The code that does this will be linked here once its repository is public.

Files

Two sets are published, v1 and v2. They differ only in the nerve model; the dendritic cell model is the same file in both.

File Used in Segments Size SHA-256
mosaic_nerves_v1.keras v1 corneal nerves 133.0 MB f9e6bdca92b877e92f4ed8b609ae0ec36519e04f93744c84d5dabf535e33e197
mosaic_nerves_v2.keras v2 corneal nerves 133.0 MB 2f4b2f9ec62fd0f37567505021d87db435af02ae91e59b56285f4e7fb6badde1
mosaic_dc.keras v1 and v2 dendritic cells, types 1 and 2 133.3 MB d91a188d3c69094f9686221f52685fc643ac803073480da2d9f5c887fc43b58c
  • v1: nerve model trained on 1,213 IVCM images plus 637 mosaic crops.
  • v2: newer nerve model trained on 16,313 mosaic crops.

Models

Both architectures are residual U-Nets taking a 384x384 single-channel tile, but they are not the same network:

Model Encoder levels Base filters Classes Mask values Parameters
nerves (v1, v2) 4 64 background, nerve 0, 255 33,156,994
dendritic cells 5 32 background, type 1, type 2 0, 127, 255 33,227,235

The files are Keras 3 archives with the optimizer state removed. Load them without compiling; no custom objects are needed:

import os
os.environ["KERAS_BACKEND"] = "torch"
import keras

model = keras.models.load_model("mosaic_nerves_v2.keras", compile=False)

Usage

To segment a whole mosaic and remove dendritic cells from the nerve mask, use the tiling code from the repository:

hf download yansonng/ivcmassist --local-dir weights

python scripts/predict.py --image mosaic.tif --model weights/mosaic_nerves_v2.keras --output nerves.tif
python scripts/predict.py --image mosaic.tif --model weights/mosaic_dc.keras --output dc.tif
python scripts/subtract_dc.py --nerves-mask nerves.tif --dc-mask dc.tif --output nerves_clean.tif

The nerve models label part of each dendritic cell as nerve. Measure nerves on nerves_clean.tif; the raw nerve mask gives inflated nerve lengths.

Relationship to the article

This work builds on Ji, Song et al., Scientific Reports 16, 1620 (2026), which evaluated segmentation on individual IVCM images. The article was published on 2026-01-13. Both mosaic nerve models were trained after that (v1 on 2026-02-15, v2 on 2026-05-18), so neither is the nerve model evaluated there, and the article reports no mosaic results. The dendritic cell model was trained earlier, on 2025-04-17.

Intended use and limitations

  • Research use only. Not a medical device and not validated for clinical decisions.
  • Trained on IVCM mosaics of the corneal sub-basal nerve plexus with a 400 um field of view sampled at 384 px (about 1.042 um/px). Other devices, magnifications and corneal layers have not been tested.
  • The released code reproduces the study's reference masks bit-for-bit on CUDA. On CPU a few borderline pixels can differ (measured: 0.0015%).
  • A mosaic smaller than 384x384 pixels cannot be segmented.

Citation

@article{ji2026deep,
  title   = {Deep learning-based segmentation and density estimation of corneal nerves and dendritic cells from In Vivo confocal microscopy images},
  author  = {Ji, Meichen and Song, Yan and Roth, Jenny and Dashti, Ava and Lazo, Jorge and Lincke, Alisa and Macedo, Ant{\'o}nio Filipe Teixeira and L{\"o}we, Welf and Lagali, Neil},
  journal = {Scientific Reports},
  volume  = {16},
  number  = {1},
  pages   = {1620},
  year    = {2026},
  doi     = {10.1038/s41598-025-34412-6}
}

License

The weights are released under CC-BY-4.0. The code in the repository is licensed separately under Apache-2.0.

Downloads last month
82
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support