Mingen Zhang, Yuanyuan Gu, Meng Wang, Lei Mou, Jingfeng Zhang, Yitian Zhao
Medical Image Analysis (MedIA), 2026
YoloSeg is a two-stage framework for medical image segmentation using only one labeled image.
-
Foundation model-drvien pseudo-label generation
Generating multi-view pseudo labels and divergence masks from a single labeled image using SAM2. -
Robust pseudo-label learning for segmentation model
Training a segmentation network with dual-component loss and cross-patch data augmentation.
We validated YoloSeg on 10 diverse public datasets, achieving an average Dice only 3.08% lower than the fully supervised baseline.
git clone https://github.com/iMED-Lab/YoloSeg.git
cd YoloSegconda create -n yoloseg python=3.10 -y
conda activate yolosegpip install torch==2.4.1 torchvision==0.19.1 torchaudio==2.4.1 --index-url https://download.pytorch.org/whl/cu118pip install -e ./code_pl
pip install -r requirements.txtPlease organize the dataset as follows:
DatasetName/
βββ file_list/
β βββ train_all_frames.txt
β βββ train_label_frames.txt
β βββ test_all_frames.txt
βββ Train/
β βββ JPEGImages/
β β βββ XXX001.png
β β βββ XXX002.png
β β βββ ...
β βββ Annotations/
β βββ XXX001.png
β βββ XXX002.png
β βββ ...
βββ Test/
βββ JPEGImages/
β βββ XXX101.png
β βββ XXX102.png
β βββ ...
βββ Annotations/
βββ XXX101.png
βββ XXX102.png
βββ ...
Notes:
train_all_frames.txt: all training image filenamestrain_label_frames.txt: the selected labeled image filename for the one-shot settingtest_all_frames.txt: all test image filenames- Filenames in
file_list/*.txtshould be plain filenames, for example:XXX001.png - Input images should be 3-channel
.png - Ground-truth labels should be single-channel
.png - Pseudo labels generated in Stage 1 are also single-channel
.png
We provide a dataset structure example in: YoloSeg/data/ISIC2016
Please download SAM2 checkpoints from the official repository: SAM2 Official Repository
Then place the downloaded checkpoint files under: YoloSeg/code_pl/checkpoints/
For example:
YoloSeg/
βββ code_pl/
βββ checkpoints/
βββ sam2.1_hiera_tiny.pt
βββ sam2.1_hiera_small.pt
βββ sam2.1_hiera_base_plus.pt
βββ sam2.1_hiera_large.pt
We recommend using sam2.1_hiera_small.pt by default.
Run Stage 1 to generate:
pl_originalpl_rotatepl_flipdivergence_mask
python code_pl/multi_view_inference.py \
--data-root /path/to/DatasetName \
--checkpoint code_pl/checkpoints/sam2.1_hiera_small.pt \
--cfg code_pl/configs/sam2.1/sam2.1_hiera_s.yamlAfter Stage 1, the Train/ directory will be automatically updated as:
Train/
βββ JPEGImages/
βββ Annotations/
βββ pl_original/
βββ pl_rotate/
βββ pl_flip/
βββ divergence_mask/
Train the segmentation model with the generated pseudo labels:
python code_seg/train.py \
--data-root /path/to/DatasetName \
--exp-name yoloseg_unet \
--num-classes 2 \
--image-size 256 \
--batch-size 4 \
--epochs 100Run testing with the trained model:
python code_seg/test.py \
--data-root /path/to/DatasetName \
--checkpoint checkpoints/yoloseg_unet/best.pth \
--output-dir outputs/yoloseg_unet_test \
--num-classes 2 \
--image-size 256We would like to thank the authors of the following open-source projects:
Their excellent work has greatly inspired and supported this project.
If you find YoloSeg useful, please cite:
@article{yoloseg2026,
title = {YoloSeg: You Only Label Once for Medical Image Segmentation},
author = {Zhang, Mingen and Gu, Yuanyuan and Wang, Meng and Mou, Lei and Zhang, Jingfeng and Zhao, Yitian},
journal = {Medical Image Analysis},
year = {2026}
}If you have any questions, feel free to contact: zhangmingen@nimte.ac.cn