Official implementation of S2L-CM: Scribble-supervised nuclei segmentation in histopathology images using contrastive regularization and pixel-level multiple instance learning.
The method has two stages:
- Warmup (100 epochs in the paper setup): train the scribble-supervised pixel-MIL model and save the warmup model and pseudo labels.
- Main training: initialize from the warmup artifacts and optimize the pixel-level MIL and multi-scale contrastive regularization objectives;
best_model.pthis selected on the validation fold.
conda create -n s2lcm python=3.10 -y
conda activate s2lcm
pip install -r requirements.txtThe original images and full masks are not redistributed. Obtain each source dataset according to its license, then arrange a data root as follows (the supplied YAML files use the same convention):
DATA_ROOT/
images/MoNuSeg/
labels/MoNuSeg/full/
labels/MoNuSeg/train.csv
labels/MoNuSeg/test.csv
labels/MoNuSeg/scribble_manual/
data/manual_scribbles/monuseg/ contains the manual MoNuSeg scribbles used by the study. Other scribble variants can be generated from full masks using scripts in preprocessing/; generated labels must be placed under the corresponding labels/<dataset>/ directory. The original local locations are intentionally not encoded in this release.
Run from s2l_cm/. --data_root replaces the historical machine-specific /Dataset/examples prefix and --output_root controls all outputs.
cd s2l_cm
# Stage 1: warmup. Saves the warmup checkpoint and pseudo labels.
python Train.py --stage warmup --dataset monu --fold 0 --p_heads 0,4 \
--data_root /path/to/DATA_ROOT --output_root ../outputs --warmup_id warmup
# Stage 2: main S2L-CM training. Loads the Stage 1 artifacts and saves best_model.pth.
python Train.py --stage main --dataset monu --fold 0 --p_heads 0,4 --lambda_c 0.01 \
--data_root /path/to/DATA_ROOT --output_root ../outputs --warmup_id warmup \
--exp_id s2l_cmRepeat for all folds and report the aggregate evaluation. Dataset settings are in s2l_cm/data_setting/ for MoNuSeg, CPM17, TNBC, and PAIP2023.
The paper MoNuSeg configuration is also provided as executable scripts:
DATA_ROOT=/path/to/DATA_ROOT FOLD=0 DEVICE=0 bash scripts/train_monuseg_warmup.sh
DATA_ROOT=/path/to/DATA_ROOT FOLD=0 DEVICE=0 bash scripts/train_monuseg_main.shThe number of trainable parameters depends on the encoder and the selected projection heads. Report the exact configuration with:
python tools/count_parameters.py --encoder resnet34 --p-heads 0,4preprocessing/ contains the dataset preprocessing and automatic scribble-generation scripts used during development. They retain their dataset-specific input assumptions; update only the input/output arguments for your locally obtained source data. Do not commit source images, full masks, trained models, experiment logs, or generated pseudo labels.
@article{oh2025s2l,
title={S2L-CM: Scribble-supervised nuclei segmentation in histopathology images using contrastive regularization and pixel-level multiple instance learning},
author={Oh, Hyun-Jic and Min, Seonghui and Jeong, Won-Ki},
journal={Computers in Biology and Medicine},
volume={192},
pages={110293},
year={2025},
publisher={Elsevier}
}