Home

Awesome

Diverse Co-training

Official PyTorch implementation of ICCV 2023 paper "Diverse Cotraining Makes Strong Semi-Supervised Segmentor".

Abstract.

Deep co-training has been introduced to semi-supervised segmentation and achieves impressive results, yet few studies have explored the working mechanism behind it. In this work, we revisit the core assumption that supports co-training: multiple compatible and conditionally independent views. By theoretically deriving the generalization upper bound, we prove the prediction similarity between two models negatively impacts the model's generalization ability. However, most current co-training models are tightly coupled together and violate this assumption. Such coupling leads to the homogenization of networks and confirmation bias which consequently limits the performance. To this end, we explore different dimensions of co-training and systematically increase the diversity from the aspects of input domains, different augmentations and model architectures to counteract homogenization. Our \textit{Diverse Co-training} outperforms the state-of-the-art (SOTA) methods by a large margin across different evaluation protocols on the Pascal and Cityscapes. For example. we achieve the best mIoU of 76.2%, 77.7% and 80.2% on Pascal with only 92, 183 and 366 labeled images, surpassing the previous best results by more than 5%.

Results

Pascal

labeled data sampled from high-quality training set

Labeled images are sampled from the original high-quality training set. Results are obtained by DeepLabv3+ with ResNet-101 and SegFormer-b3.

MethodResolution1/115 (92)1/57 (183)1/28 (366)1/14 (732)1/7 (1464)
SupOnly321x32144.454.063.467.271.8
ReCo321x32164.872.073.174.7-
ST++321x32165.271.074.677.379.1
Ours(2-cps)321x32174.877.679.580.381.7
Ours(3-cps)321x32175.476.879.680.481.6
SupOnly513x51342.356.664.268.172.0
U<sup>2</sup>PL512x51268.069.273.776.279.5
PS-MT512x51265.869.676.678.480.0
Ours(2-cps)513x51376.276.680.280.881.9
Ours(3-cps)513x51375.777.780.180.982.0

labeled data sampled from blened training set

Labeled images are sampled from the blened training set. Results obtained by DeepLabv3+ with ResNet-50 and SegFormer-b2.

MethodResolution1/32 (331)1/16 (662)1/8 (1323)1/4 (2646)
SupOnly321x32155.860.366.871.3
ST++321x321-72.674.475.4
Ours(2-cps)321x32175.276.076.276.5
Ours(3-cps)321x32174.976.476.376.6
SupOnly513x51354.160.767.771.9
U<sup>2</sup>PL512x512-72.075.176.2
PS-MT512x512-72.875.776.4
Ours(2-cps)513x51375.276.277.077.5
Ours(3-cps)513x51374.776.377.277.7

Results obtained by DeepLabv3+ with ResNet-101 and SegFormer-b3.

MethodResolution1/16 (662)1/8 (1323)1/4 (2646)
SupOnly321x32167.570.473.7
CAC321x32172.474.676.3
CTT*321x32173.775.1-
ST++321x32174.576.376.6
Ours(2-cps)321x32177.678.378.7
Ours(3-cps)321x32177.378.078.6
SupOnly513x51366.670.574.5
MT512x51270.673.276.6
CCT512x51267.973.076.2
GCT512x51267.272.273.6
CPS512x51274.576.477.7
3-CPS512x51275.878.079.0
CutMix512x51272.672.774.3
DSBN‡769x769-74.177.8
ELN512x512-75.176.6
PS-MT512x51275.578.278.7
AEL513x51377.277.678.1
U<sup>2</sup>PL513x51374.477.678.7
Ours(2-cps)513x51377.978.779.0
Ours(3-cps)513x51377.679.080.0

Cityscapes

Results are obtained by DeepLabv3+ with ResNet-50/101 and SegFormer-b2/b3 with resolution 769x769. Results of U<sup>2</sup>PL are from UniMatch.

ResNet-501/301/81/4ResNet-1011/161/81/4
SupOnly54.870.273.6SupOnly66.872.576.4
U<sup>2</sup>PL59.873.076.3U<sup>2</sup>PL74.976.578.5
ST++61.472.773.8PS-MT-76.977.6
Ours (2-cps)64.576.377.1Ours (2-cps)75.077.378.7
Ours (3-cps)65.576.577.9Ours (3-cps)75.777.478.5

Training Logs

We release the training logs in logs folder. Training logs on CItyscapes dataset can be found in logs/cityscapes. Training logs on VOC dataset can be found in logs/voc.

Getting Started

Installation

conda create -n cotraining python=3.7
conda activate cotraining
pip install torch torchvision torchaudio
pip install -r requirements.txt

We use implementation of SegFormer from mmsegmentation, so installation of mmcv and mmsegmentation libraries is needed

pip install openmim
mim install mmcv
pip install mmsegmentation

Proprosessing of DCT domain requires jpeg2dct and PyTurboJPEG libraries.

Before installing jpeg2dct, first install either libjpeg or libjpeg-turbo library.

apt install libjpeg-turbo
pip install jpeg2dct PyTurboJPEG

For more details regarding the installation of jpeg2dct, we refer to jpeg2dct. We also refer to DCTNet for more details of DCT transform.

Pretrained Backbone:

We provide the pretrain as followed:

ResNet-50 | ResNet-101 | ResNet-50-dct | ResNet-101-dct

├── ./pretrained
    ├── resnet50.pth
    ├── resnet101.pth
    ├── resnet50_dct.pth
    └── resnet101_dct.pth

Note: The ResNet variants all use official weights and we have pretrained DCT ResNet with comparable performance as ResNet couterparts. More details can be found in our paper.

Dataset:

├── [Your Pascal Path]
    ├── JPEGImages
    └── SegmentationClass
    
├── [Your Cityscapes Path]
    ├── leftImg8bit
    └── gtFine

Usage

Diverse Co-training

# use torch.distributed.launch
# To start training, the general format is as followed
sh <script> <num_gpu> <port> <data partition> <threshold>
# e.g. bash tools/voc/dist_train_cotraining_2cps.sh 4 29873 1_16 0.0

# we also provide a srun script for training on slurm cluster
# e.g. bash tools/voc/srun_train_cotraining_2cps.sh 4 29873 1_16 0.0

In order to run on different labeled data partitions or different datasets, please modify:

config, labeled_id_path, unlabeled_id_path, and save_path in the training shell script.

Supervised Baseline

Modify the py file to supervised.py in the script, and double the batch_size in the configuration file if you use the same number of GPUs as semi-supervised setting (no need to change lr).

If you want to run supervised on DCT input domain, follow the above instructions to modify supervised_dct.py in the script, everything is the same except for the input domain is changed.

Citation

If you find this project useful, please consider citing:

@InProceedings{Li_2023_ICCV,
    author    = {Li, Yijiang and Wang, Xinjiang and Yang, Lihe and Feng, Litong and Zhang, Wayne and Gao, Ying},
    title     = {Diverse Cotraining Makes Strong Semi-Supervised Segmentor},
    booktitle = {Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV)},
    month     = {October},
    year      = {2023},
    pages     = {16055-16067}
}