The implementation of: A Multi-Strategy Contrastive Learning Framework for Weakly Supervised Semantic Segmentation.
- Download PASCAL VOC 2012 devkit (follow instructions in http://host.robots.ox.ac.uk/pascal/VOC/voc2012/#devkit). Put the data under ./data/VOC2012 folder.
- Download model weights from google drive, including pretrained MCL, MuSCLe and IRN models.
- install conda from conda.io
- build cond env from file
conda env create --name muscle --file environment.yaml
conda activate muscle
python train_mcl.py --voc12_root data --train_list data/train_aug.txt --weights PATH_TO_TRAINED_MODEL --tblog_dir logs/tblog_mcl
python infer_mcl.py --voc12_root PATH_TO_VOC12 --infer_list PATH_TO_INFER_LIST --weights PATH_TO_TRAINED_MODEL --out_npy OUTPUT_DIR
python infer_irn.py --cam_dir CAM_DIR --sem_seg_out_dir OUTPUT_PSEUDO_LABEL_DIR --soft_output 0 --irn_weights_name PATH_TO_PRETRAINED_IRN_MODEL
cd src
python evaluation.py --comment COMMENTS --type npy --list data/train.txt --predict_dir CAM_DIR --curve True
cd ..
cd src
python evaluation.py --comment COMMENTS --type png --list data/train.txt --predict_dir REFINED_CAM_DIR
cd ..
python train_muscle.py --voc12_root data --train_list data/train_aug.txt --weights PATH_TO_TRAINED_MODEL --tblog_dir logs/tblog_muscle --mask_root OUTPUT_PSEUDO_LABEL_DIR --session_name runs/muscle
- sepcify model to use in argument --pretrained (default b7)
python infer_seg.py --weights PATH_TO_TRAINED_MuSCLe_MODEL --out_seg OUTPUT_SEGMENTATION_MAP_DIR --infer_list PATH_TO_INFER_LIST --crf 1 --pretrained b7
We thank the author of IRN and SEAM for their great work. This repository heavily relys on their processing pipeline and evaluation codes.
Please cite our work if it's helpful to your research.
@article{yuan2023multi,
title={A Multi-Strategy Contrastive Learning Framework for Weakly Supervised Semantic Segmentation},
author={Yuan, Kunhao and Schaefer, Gerald and Lai, Yu-Kun and Wang, Yifan and Liu, Xiyao and Guan, Lin and Fang, Hui},
journal={Pattern Recognition},
pages={109298},
year={2023},
publisher={Elsevier}
}