Home

Awesome

BECO - Official Pytorch Implementation

Boundary-enhanced Co-training for Weakly Supervised Semantic Segmentation

Shenghai Rong, Bohai Tu, Zilei Wang, Junjie Li

Paper

PWC

PWC

PWC

<img src = "https://github.com/ShenghaiRong/BECO-5681/blob/main/figures/framework.png" width="100%" height="100%">

Prerequisite

Usage

Install python dependencies

$ pip install -r requirements.txt

Download PASCAL VOC 2012 devkit

Download ImageNet pretrained model of DeeplabV3+

Download ImageNet pretrained model of DeeplabV2 and SegFormer (Optional)

Generate pseudo-labels and confidence masks

Prepare the data directory

$ cd BECO/
$ mkdir data
$ mkdir data/model_zoo
$ mkdir data/logging

And put the data and pretrained model in the corresponding directories like:

data/
    --- VOC2012/
        --- Annotations/
        --- ImageSet/
        --- JPEGImages/
        --- SegmentationClass/
        --- ...
    --- irn_pseudo_label/
        --- ****.png
        --- ****.png
    --- irn_mask/
        --- ****.png
        --- ****.png
    --- model_zoo/
        --- resnetv1d101_mmcv.pth
    --- logging/

Weakly Supervised Semantic Segmentation on VOC2012

Train

$ CUDA_VISIBLE_DEVICES=0,1,2,3 python main.py -dist --logging_tag beco1

This code also supports AMP acceleration to reduce the GPU memory cost in half. Note that the "batch_size" in main.py refers to the batch_size of per GPU. So you should modify it when using different numbers of GPUs to keep the total batch_size of 16.

$ CUDA_VISIBLE_DEVICES=0,1 python main.py -dist --logging_tag beco1 --amp

Test

$ CUDA_VISIBLE_DEVICES=0 python main.py --test --logging_tag beco1 --ckpt best_ckpt.pth

Please refer to pydensecrf to install CRF python library for testing with the CRF post-processing.

$ python test.py --crf --logits_dir ./data/logging/beco1/logits --mode "val"

Main Results

<img src = "https://github.com/ShenghaiRong/BECO-5681/blob/main/figures/results.png" width="100%" height="100%">
MethodDatasetBackboneWeightsVal mIoU (w/o CRF)
BECOVOC2012ResNet101[Google Drive] / [Baidu Drive]70.9
BECOCOCO2014ResNet101[Google Drive] / [Baidu Drive]45.6

Citation

If you find our work inspiring or use our codebase in your research, please consider giving a star ⭐ and a citation.

@InProceedings{Rong_2023_CVPR,
    author    = {Rong, Shenghai and Tu, Bohai and Wang, Zilei and Li, Junjie},
    title     = {Boundary-Enhanced Co-Training for Weakly Supervised Semantic Segmentation},
    booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
    month     = {June},
    year      = {2023},
    pages     = {19574-19584}
}