This repository provides the official implementation of MOSAIC, a multi-scale, rotation-aware transformer-based framework designed for robust nuclei segmentation and centroid/heatmap prediction in histopathology images (ER-IHC, MoNuSAC, CoNSeP).
The model integrates hierarchical feature extraction, rotation-aware multi-scale fusion, and transformer-based long-range reasoning, enabling accurate segmentation under scale variation, heterogeneous morphology, and rotational distortions.
-
Multi-Scale Patch Extraction
- Large: 512×512
- Medium: 256→512
- Small: 128→512
- All scales form parallel training streams.
-
Rotation-Aware Feature Fusion
- Designed to maintain robustness across nuclei orientations.
-
Transformer Context Aggregation
- Enhances long-range spatial reasoning.
-
Dual Task Prediction
- Semantic segmentation (multi-class or binary)
- Centroid/heatmap estimation for instance separation
-
Dataset Ready
- ER-IHC
- MoNuSAC
- CoNSeP
├── mosaic.ipynb # Main notebook: preprocessing, model, training, and evaluation
├── /Dataset/ # Example dataset folders (user should add)
└── README.md
- Python 3.8+
- TensorFlow 2.x / Keras
- NumPy, OpenCV, Matplotlib
- scikit-image, scikit-learn
- tqdm, seaborn
Install using:
pip install tensorflow numpy opencv-python matplotlib scikit-image scikit-learn seaborn tqdmOn Kaggle, all dependencies are already available.
-
Upload or open
mosaic.ipynbin a Kaggle Notebook. -
Add your dataset(s) as input sources.
-
Update dataset paths inside the notebook:
data_path = "/kaggle/input/your-dataset/"
-
Enable GPU or TPU.
-
Run all cells sequentially:
- Multi-scale patch generation
- Label and mask preprocessing
- Model definition (CNN + Transformer fusion)
- Training
- Validation & visualization
The best model is automatically saved to:
/kaggle/working/MOSAIC_savedmodel/
-
Clone the repository:
git clone https://github.com/<your-repo>/MOSAIC.git cd MOSAIC
-
Open Jupyter Notebook:
jupyter notebook mosaic.ipynb
-
Update dataset paths inside the notebook.
-
Run cells in order.
GPU is strongly recommended for training.
Running MOSAIC will produce:
-
Predicted nuclei segmentation masks
-
Predicted centroid heatmaps
-
Multi-scale visualization plots
-
Quantitative metrics:
- Dice
- AJI
- PQ
- F1 score
-
Trained model folder (
MOSAIC_savedmodel)
Optional post-processing:
- Watershed-based instance segmentation
- Centroid-guided instance splitting
If you use this framework, preprocessing pipeline, or model structure, please cite the MOSAIC publication (update with your final BibTeX once accepted/published):
@article{yourcitation2025mosaic,
title={MOSAIC: Multi-Scale Orientation-Aware Segmentation and Instance Classification Network},
author={Sufyan, Arbab and ...},
journal={Expert Systems with Applications},
year={2025},
publisher={Elsevier}
}