Semi-Supervised Semantic Segmentation via Marginal Contextual Information

May 17, 2023 · View on GitHub

Description:information_source:

This is an official PyTorch implementation of the "Semi-Supervised Semantic Segmentation via Marginal Contextual Information" paper submission for NeurIPS 2023.

The method utilize contextual information to produce higher quality and higher quantity of pseudo-labels.

Results :bar_chart:

Results for PASCAL VOC 12, using additional coarse annotated:

Method1/161/81/41/2full
Sup only45.7754.9265.8871.6972.50
baseline52.1663.4769.4673.7376.54
S4MC + CutMix-Seg70.9671.6*75.4177.7380.58
S4MC + FixMatch74.3275.6277.8479.7281.51

For all the results, please refer to the paper experiment section

A visual example for the results:

Installation :writing_hand:

git clone https://github.com/s4mcontext/s4mc.git && cd s4mc conda create -n s4mc conda activate s4mc pip install -r requirements.txt

You also need to download a backbone trained on ImageNet-1k by either:

Preperation :card_index_dividers:

Before training the models please put the datasets in the data sub-directory.

For PASCAL VOC 2012: follow this instuction and download PASCAL VOC 2012 augmented with SBD dataset.

For Cityscapes: Download "leftImg8bit_trainvaltest.zip" and "gtFine_trainvaltest.zip" from: https://www.cityscapes-dataset.com/downloads/

unzip all into data with the following structure:

data
├── cityscapes
│   ├── gtFine
│   └── leftImg8bit
├── splits
│   ├── cityscapes
│   └── pascal
└── VOC2012
    ├── Annotations
    ├── ImageSets
    ├── JPEGImages
    ├── SegmentationClass
    ├── SegmentationClassAug
    └── SegmentationObject

4. Go over the dependencies.

Training :weight_lifting:

For training a semi-supervised model you need to first set a config. We've provided an example config for PASCAL. all the splits of data are provided in the data sub-directory as well, so simply change the config with the desired parameters and dataset.

To run the code distributed, go to experiments and run:

python -m torch.distributed.launch --nproc_per_node=<#GPUs> --nnodes=1 ../train_semi.py --config=<path_to_config> --seed <random_seed> --name <exp_name>

where <#GPUs> is the number of cuda devices avalible for distributed training. <path_to_config> is the path to your config <random_seed> to set a random seed for reproducability <exp_name> will save the model and tensorboard with the experiment name

License :paperclip:

This project is released under the Apache 2.0 license.

This repository code is heavily based on U2PL as well as the link for the pre-trained model provided in here.