Strictly implement the semantic segmentation network based on ResNet38 of 2018 CVPR PSA(Learning Pixel-level Semantic Affinity with Image-level Supervision for Weakly Supervised Semantic Segmentation). We hope that this code will be of some help to those studying weakly supervised semantic segmentation.
Thanks to the work of jiwoon-ahn, the code of this repository borrow heavly from his AffinityNet repository.
- Python 3.6
- pytorch 0.4.1, torchvision 0.2.1
- CUDA 9.0
- 1 x GPUs (11GB)
- Download the repository.
git clone https://github.com/peihan-miao/ResNet38-Semantic-Segmentation.git
- Install python dependencies.
pip install -r requirements.txt
-
Download model weights from google drive, including ImageNet pretrained models and our training results.
-
Download PASCAL VOC 2012 devkit (follow instructions in http://host.robots.ox.ac.uk/pascal/VOC/voc2012/#devkit). It is suggested to make a soft link toward downloaded dataset.
ln -s $your_dataset_path/VOCdevkit/VOC2012 VOC2012
- Train SegNet.
python train_seg.py --weights $pretrained_model --image_dir $train_image --mask_dir $train_mask
- Test SegNet.
python infer_seg.py --weights $pretrained_model --image_dir $test_image_dir --output_crf $output_crf_dir
- Evaluation.
python evaluation.py --list $VOC2012/ImageSets/Segmentation/[val.txt | train.txt] --predict_dir $your_predict_dir --gt_dir VOC2012/SegmentationClass --comment $your_comments --type npy --curve True
We use the pseudo mask generated by AffinityNet to train the semantic segmentation network and compare it with 2018 CVPR PSA.
Model | Val (mIoU) | |
---|---|---|
ResNet-38 | 61.7 | PSA |
ResNet-38 | 62.4 | [Weights] |
[1] J. Ahn and S. Kwak. Learning pixel-level semantic affinity with image-level supervision for weakly supervised semantic segmentation. In Proc. IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2018.