[CVPR 2022] Semi-Supervised Semantic Segmentation Using Unreliable Pseudo-Labels

Overview

Using Unreliable Pseudo Labels

Official PyTorch implementation of Semi-Supervised Semantic Segmentation Using Unreliable Pseudo Labels, CVPR 2022.

Please refer to our project page for qualitative results.

Abstract. The crux of semi-supervised semantic segmentation is to assign adequate pseudo-labels to the pixels of unlabeled images. A common practice is to select the highly confident predictions as the pseudo ground-truth, but it leads to a problem that most pixels may be left unused due to their unreliability. We argue that every pixel matters to the model training, even its prediction is ambiguous. Intuitively, an unreliable prediction may get confused among the top classes (i.e., those with the highest probabilities), however, it should be confident about the pixel not belonging to the remaining classes. Hence, such a pixel can be convincingly treated as a negative sample to those most unlikely categories. Based on this insight, we develop an effective pipeline to make sufficient use of unlabeled data. Concretely, we separate reliable and unreliable pixels via the entropy of predictions, push each unreliable pixel to a category-wise queue that consists of negative samples, and manage to train the model with all candidate pixels. Considering the training evolution, where the prediction becomes more and more accurate, we adaptively adjust the threshold for the reliable-unreliable partition. Experimental results on various benchmarks and training settings demonstrate the superiority of our approach over the state-of-the-art alternatives.

Results

PASCAL VOC 2012

Labeled images are selected from the train set of original VOC, 1,464 images in total. And the remaining 9,118 images are all considered as unlabeled ones.

For instance, 1/2 (732) represents 732 labeled images and remaining 9,850 (9,118 + 732) are unlabeled.

Method 1/16 (92) 1/8 (183) 1/4 (366) 1/2 (732) Full (1464)
SupOnly 45.77 54.92 65.88 71.69 72.50
U2PL (w/ CutMix) 67.98 69.15 73.66 76.16 79.49

Labeled images are selected from the train set of augmented VOC, 10,582 images in total.

Method 1/16 (662) 1/8 (1323) 1/4 (2646) 1/2 (5291)
SupOnly 67.87 71.55 75.80 77.13
U2PL (w/ CutMix) 77.21 79.01 79.30 80.50

Cityscapes

Labeled images are selected from the train set, 2,975 images in total.

Method 1/16 (186) 1/8 (372) 1/4 (744) 1/2 (1488)
SupOnly 65.74 72.53 74.43 77.83
U2PL (w/ CutMix) 70.30 74.37 76.47 79.05
U2PL (w/ AEL) 74.90 76.48 78.51 79.12

Checkpoints

  • Models on Cityscapes with AEL (ResNet101-DeepLabv3+)
1/16 (186) 1/8 (372) 1/4 (744) 1/2 (1488)
Google Drive Google Drive Google Drive Google Drive
Baidu Drive
Fetch Code: rrpd
Baidu Drive
Fetch Code: welw
Baidu Drive
Fetch Code: qwcd
Baidu Drive
Fetch Code: 4p8r

Installation

git clone https://github.com/Haochen-Wang409/U2PL.git && cd U2PL
conda create -n u2pl python=3.6.9
conda activate u2pl
pip install -r requirements.txt
pip install pip install torch==1.8.1+cu102 torchvision==0.9.1+cu102 -f https://download.pytorch.org/whl/torch_stable.html

Usage

U2PL is evaluated on both Cityscapes and PASCAL VOC 2012 dataset.

Prepare Data

For Cityscapes

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

Next, unzip the files to folder data and make the dictionary structures as follows:

data/cityscapes
├── gtFine
│   ├── test
│   ├── train
│   └── val
└── leftImg8bit
    ├── test
    ├── train
    └── val
For PASCAL VOC 2012

Download "VOCtrainval_11-May-2012.tar" from: http://host.robots.ox.ac.uk/pascal/VOC/voc2012/VOCtrainval_11-May-2012.tar.

And unzip the files to folder data and make the dictionary structures as follows:

data/VOC2012
├── Annotations
├── ImageSets
├── JPEGImages
├── SegmentationClass
├── SegmentationClassAug
└── SegmentationObject

Finally, the structure of dictionary data should be as follows:

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

Prepare Pretrained Backbone

Before training, please download ResNet101 pretrained on ImageNet-1K from one of the following:

After that, modify model_urls in semseg/models/resnet.py to </path/to/resnet101.pth>

Train a Fully-Supervised Model

For instance, we can train a model on PASCAL VOC 2012 with only 1464 labeled data for supervision by:

cd experiments/pascal/1464/suponly
# use torch.distributed.launch
sh train.sh <num_gpu> <port>

# or use slurm
# sh slurm_train.sh <num_gpu> <port> <partition>

Or for Cityscapes, a model supervised by only 744 labeled data can be trained by:

cd experiments/cityscapes/744/suponly
# use torch.distributed.launch
sh train.sh <num_gpu> <port>

# or use slurm
# sh slurm_train.sh <num_gpu> <port> <partition>

After training, the model should be evaluated by

sh eval.sh

Train a Semi-Supervised Model

We can train a model on PASCAL VOC 2012 with 1464 labeled data and 9118 unlabeled data for supervision by:

cd experiments/pascal/1464/ours
# use torch.distributed.launch
sh train.sh <num_gpu> <port>

# or use slurm
# sh slurm_train.sh <num_gpu> <port> <partition>

Or for Cityscapes, a model supervised by 744 labeled data and 2231 unlabeled data can be trained by:

cd experiments/cityscapes/744/ours
# use torch.distributed.launch
sh train.sh <num_gpu> <port>

# or use slurm
# sh slurm_train.sh <num_gpu> <port> <partition>

After training, the model should be evaluated by

sh eval.sh

Train a Semi-Supervised Model on Cityscapes with AEL

First, you should switch the branch:

git checkout with_AEL

Then, we can train a model supervised by 744 labeled data and 2231 unlabeled data by:

cd experiments/city_744
# use torch.distributed.launch
sh train.sh <num_gpu> <port>

# or use slurm
# sh slurm_train.sh <num_gpu> <port> <partition>

After training, the model should be evaluated by

sh eval.sh

Note

<num_gpu> means the number of GPUs for training.

To reproduce our results, we recommend you follow the settings:

  • Cityscapes: 4 for SupOnly and 8 for Semi-Supervised
  • PASCAL VOC 2012: 2 for SupOnly and 4 for Semi-Supervised

Or, change the lr in config.yaml in a linear manner (e.g., if you want to train a SupOnly model on Cityscapes with 8 GPUs, you are recommended to change the lr to 0.02).

If you want to train a model on other split, you need to modify data_list and n_sup in config.yaml.

Due to the randomness of function torch.nn.functional.interpolate when mode="bilinear", the results of semantic segmentation will not be the same EVEN IF a fixed random seed is set.

Therefore, we recommend you run 3 times and get the average performance.

License

This project is released under the Apache 2.0 license.

Acknowledgement

The contrastive learning loss and strong data augmentation (CutMix, CutOut, and ClassMix) are borrowed from ReCo. We reproduce our U2PL based on AEL on branch with_AEL.

Thanks a lot for their great work!

Citation

@inproceedings{wang2022semi,
    title={Semi-Supervised Semantic Segmentation Using Unreliable Pseudo Labels},
    author={Wang, Yuchao and Wang, Haochen and Shen, Yujun and Fei, Jingjing and Li, Wei and Jin, Guoqiang and Wu, Liwei and Zhao, Rui and Le, Xinyi},
    booktitle={Proceedings of the IEEE/CVF International Conference on Computer Vision and Patern Recognition (CVPR)},
    year={2022}
}

Contact

Comments
  • No such file: data/cityscapes/gtFine/train/bremen/bremen_000149_000019_gtFine_labelTrainIds.png

    No such file: data/cityscapes/gtFine/train/bremen/bremen_000149_000019_gtFine_labelTrainIds.png

    I manage cityscapes data dir structure as Prepare data in readme. But, raise an error of not find the file. I find that file path has been changed in BaseDataset, it add "gtFine_labelTrainIds.png" into file path and this cause error to occur. What should I do to fix the bug? Thank you!

    opened by zhjw0927 25
  • Size don't match when augument

    Size don't match when augument

    Hi, when I get ['pre'] from model and augument them.
    RuntimeError: The size of tensor a (57) must match the size of tensor b (224) at non-singleton dimension 1 Dimension of out don't match with real images Why ? Error come from decode or encoder of model ?

    opened by Holmes2002 21
  • 训练的问题

    训练的问题

    您好,我在跑train_sup.py的时候发现报错 raise KeyError(key) from None KeyError: 'RANK',好像是port的参数没有设置好,请问这个参数是什么意思呢?还有需要设置的local-rank,以及seed,分别代表什么呢? 还有请问如果训练自己的数据集是不是应该在train_sup.py中先训练出一个模型,然后再将该模型放入train_semi.py中作为teacher训练呢?如果是这样的话请问我该如何将模型导入train_semi.py中呢?

    opened by Richardcvpr 20
  • 正例的计算问题

    正例的计算问题

    非常优秀的paper和code 有个疑问,代码中 seg_proto_list.append( torch.mean( rep_teacher[low_valid_pixel_seg.bool()].detach(), dim=0, keepdim=True ) 计算正例使用的mask是 low_valid_pixel_seg,而根据前面计算low_valid_pixel_seg过程,其只是低熵的mask,并没有满足论文公式9,10中的pij(c) > δp 根据我对论文和代码的理解,或许应该使用 rep_mask_low_entropy = ( prob_seg > current_class_threshold ) * low_valid_pixel_seg.bool() 这个mask来计算正例?还是我理解出现偏差了。

    opened by icemy 14
  • About the results on VOC with 92 examples

    About the results on VOC with 92 examples

    Thank you for your expressive work and delicate code. When reproducing the results on VOC, I can reproduce the results with 183, 366, 732, 1464 examples, but only get about 52 with 92 examples, while the reported result is 67.98. Can you offer some help? Sincere gratitude to you.

    opened by Jin-Ying 13
  • Questions about VOC dataset

    Questions about VOC dataset

    Hi, thanks for the code sharing and I plan to run some basic experiments based on the tutorial in README file. I use the link [http://host.robots.ox.ac.uk/pascal/VOC/voc2012/VOCtrainval_11-May-2012.tar] to download the VOC dataset, but I just found that it does not contain the SegmentationClassAug folder which is required in your code [https://github.com/Haochen-Wang409/U2PL/blob/97284dbbddce4a65d00621bfe77863f39db9ddcd/u2pl/dataset/base.py#L27]. Could you please have a double check? Thanks

    opened by HeimingX 12
  • Questions about Augmented PASCAL-VOC2012

    Questions about Augmented PASCAL-VOC2012

    As with the use of the Augmented PASCAL-VOC2012 dataset in other semi-supervised semantic segmentation studies (i.e., CPS, PS_MT) , I would like to reproduce your study in 1/8 (1323) of the Augmented PASCAL-VOC. However, it seems to me that this github is training code from Full(1464). Any code that trains on 1/8 (1323) of Augmented PASCAL-VOC? Or is it possible by simply changing the options in the 'config.yaml' file?

    opened by DeepHM 11
  • About the results on VOC2012 with 92 examples

    About the results on VOC2012 with 92 examples

    Thank you for your expressive and remarkable work and delicate code!! But when I reproducting the results on VOC2012 with 92 examples,I only get 59 with examples,while the reported result is 67.98.Can you offer some suggest? Thank you sincerely!

    This is my log file! seg_20220414_150853.txt

    This is my tb about contrastive_loss and unsupervised loss! they're kind of weired and on an upward trend. uns_loss con_loss

    opened by GritCS 11
  • Hi, I meet some problems when reproduce the results using pascal voc dataset

    Hi, I meet some problems when reproduce the results using pascal voc dataset

    Hi, I try to reproduce your results reported in your paper but can't reach your results as your paper report. Because of computation resource limited, I use batch size 8 and learning rate 0.0005 which are half in your paper. 截屏2022-03-24 上午10 48 27 When try to reproduce "full" method using the superparameters mentioned before,I just reach 77.12 (running 3 times and average). Could you give me some advice to reproduce your method, thanks. The config file I used in reproduce experiment is as following. Besides, the annotations files are get as you mentioned in your repo.

    dataset: # Required.
      type: pascal_semi
      train:
        data_root: xxx/VOCdevkit/VOC2012
        data_list: xxx/U2PL/data/splits/pascal/1464/labeled.txt
        flip: True
        GaussianBlur: False
        rand_resize: [0.5, 2.0]
        #rand_rotation: [-10.0, 10.0]
        crop:
          type: rand
          size: [513, 513] # crop image with HxW size
      val:
        data_root: xxx/VOCdevkit/VOC2012
        data_list: xxx/U2PL/data/splits/pascal/val.txt
        crop:
          type: center
          size: [513, 513] # crop image with HxW size
      batch_size: 2
      n_sup: 1464
      noise_std: 0.1
      workers: 2
      mean: [123.675, 116.28, 103.53]
      std: [58.395, 57.12, 57.375]
      ignore_label: 255
    
    trainer: # Required.
      epochs: 80
      eval_on: True
      optimizer:
        type: SGD
        kwargs:
          lr: 0.0005  # 4GPUs
          momentum: 0.9
          weight_decay: 0.0001
      lr_scheduler:
        mode: poly
        kwargs:
          power: 0.9
      unsupervised:
        TTA: False
        drop_percent: 80
        apply_aug: cutmix
      contrastive:
        negative_high_entropy: True
        low_rank: 3
        high_rank: 20
        current_class_threshold: 0.3
        current_class_negative_threshold: 1
        unsupervised_entropy_ignore: 80
        low_entropy_threshold: 20
        num_negatives: 50
        num_queries: 256
        temperature: 0.5
    
    saver:
      snapshot_dir: checkpoints
      pretrain: ''
    
    criterion:
      type: CELoss
      kwargs:
        use_weight: False
    
    net: # Required.
      num_classes: 21
      sync_bn: True
      ema_decay: 0.99
      encoder:
        type: u2pl.models.resnet.resnet101
        kwargs:
          multi_grid: True
          zero_init_residual: True
          fpn: True
          replace_stride_with_dilation: [False, True, True]  #layer0...1 is fixed, layer2...4
      decoder:
        type: u2pl.models.decoder.dec_deeplabv3_plus
        kwargs:
          inner_planes: 256
          dilations: [12, 24, 36]
    
    
    opened by YanFangCS 10
  • Why you including all *HIGH QUALITY DATA* in your Pascal VOC12 AUG Experiment???

    Why you including all *HIGH QUALITY DATA* in your Pascal VOC12 AUG Experiment???

    Hi, It is totally unfair to including all your high quality labels in your AuG experiment settings, according to your 5291 sup list in here https://github.com/Haochen-Wang409/U2PL/blob/main/data/splits/pascal/5291/labeled.txt and also your 2646 sup list https://raw.githubusercontent.com/Haochen-Wang409/U2PL/main/data/splits/pascal/2646/labeled.txt. From CPS 1/2 ratio experiment https://github.com/charlesCXK/TorchSemiSeg/blob/main/DATA/pascal_voc/subset_train_aug/pseudoseg_unlabeled_1-2.txt, it contains 733 high quality data with 0.5006830601092896 percentage for all high quality data in total (which is expected). And what you are doing now is boosting your performance based on the supervised label's quality.

    IT IS VERY TRICKY and DISHONESTY !!!

    Could you report your result based on CPS partial protocol of data splits ?????

    opened by ghost 10
  • dataset构建

    dataset构建

    作者您好,有个问题想请教您一下,就是在数据读取时,一个batchsize里面有标签和无标签的比例是一定的,但是我在我自己项目中为了实现的方便,我把有标签和无标签数据混在一起,也就是说一个batchsize里面有标签数据和无标签数据的比例是变化的,可能这次迭代batchsize里面全是有标签,下一次迭代一个batchsize里面一半是有标签一半是无标签,你看这样的实现行吗,因为我看我训练时候MIOU一会很高一会接近于0,我分析是不是由于我数据采样原因,谢谢

    opened by qdd1234 9
Owner
Haochen Wang
Haochen Wang
noisy labels; missing labels; semi-supervised learning; entropy; uncertainty; robustness and generalisation.

ProSelfLC: CVPR 2021 ProSelfLC: Progressive Self Label Correction for Training Robust Deep Neural Networks For any specific discussion or potential fu

amos_xwang 57 Dec 4, 2022
Prototypical Pseudo Label Denoising and Target Structure Learning for Domain Adaptive Semantic Segmentation (CVPR 2021)

Prototypical Pseudo Label Denoising and Target Structure Learning for Domain Adaptive Semantic Segmentation (CVPR 2021, official Pytorch implementatio

Microsoft 247 Dec 25, 2022
Semi-supervised Semantic Segmentation with Directional Context-aware Consistency (CVPR 2021)

Semi-supervised Semantic Segmentation with Directional Context-aware Consistency (CAC) Xin Lai*, Zhuotao Tian*, Li Jiang, Shu Liu, Hengshuang Zhao, Li

Jia Research Lab 137 Dec 14, 2022
Anti-Adversarially Manipulated Attributions for Weakly and Semi-Supervised Semantic Segmentation (CVPR 2021)

Anti-Adversarially Manipulated Attributions for Weakly and Semi-Supervised Semantic Segmentation Input Image Initial CAM Successive Maps with adversar

Jungbeom Lee 110 Dec 7, 2022
Semi-supervised Semantic Segmentation with Directional Context-aware Consistency (CVPR 2021)

Semi-supervised Semantic Segmentation with Directional Context-aware Consistency (CAC) Xin Lai*, Zhuotao Tian*, Li Jiang, Shu Liu, Hengshuang Zhao, Li

DV Lab 137 Dec 14, 2022
git《Pseudo-ISP: Learning Pseudo In-camera Signal Processing Pipeline from A Color Image Denoiser》(2021) GitHub: [fig5]

Pseudo-ISP: Learning Pseudo In-camera Signal Processing Pipeline from A Color Image Denoiser Abstract The success of deep denoisers on real-world colo

Yue Cao 51 Nov 22, 2022
This is an unofficial PyTorch implementation of Meta Pseudo Labels

This is an unofficial PyTorch implementation of Meta Pseudo Labels. The official Tensorflow implementation is here.

Jungdae Kim 320 Jan 8, 2023
Contrastive learning of Class-agnostic Activation Map for Weakly Supervised Object Localization and Semantic Segmentation (CVPR 2022)

CCAM (Unsupervised) Code repository for our paper "CCAM: Contrastive learning of Class-agnostic Activation Map for Weakly Supervised Object Localizati

Computer Vision Insitute, SZU 113 Dec 27, 2022
Scribble-Supervised LiDAR Semantic Segmentation, CVPR 2022 (ORAL)

Scribble-Supervised LiDAR Semantic Segmentation Dataset and code release for the paper Scribble-Supervised LiDAR Semantic Segmentation, CVPR 2022 (ORA

null 102 Dec 25, 2022
This is the repository for the NeurIPS-21 paper [Contrastive Graph Poisson Networks: Semi-Supervised Learning with Extremely Limited Labels].

CGPN This is the repository for the NeurIPS-21 paper [Contrastive Graph Poisson Networks: Semi-Supervised Learning with Extremely Limited Labels]. Req

null 10 Sep 12, 2022
Learning Pixel-level Semantic Affinity with Image-level Supervision for Weakly Supervised Semantic Segmentation, CVPR 2018

Learning Pixel-level Semantic Affinity with Image-level Supervision This code is deprecated. Please see https://github.com/jiwoon-ahn/irn instead. Int

Jiwoon Ahn 337 Dec 15, 2022
Shape-aware Semi-supervised 3D Semantic Segmentation for Medical Images

SASSnet Code for paper: Shape-aware Semi-supervised 3D Semantic Segmentation for Medical Images(MICCAI 2020) Our code is origin from UA-MT You can fin

klein 125 Jan 3, 2023
ST++: Make Self-training Work Better for Semi-supervised Semantic Segmentation

ST++ This is the official PyTorch implementation of our paper: ST++: Make Self-training Work Better for Semi-supervised Semantic Segmentation. Lihe Ya

Lihe Yang 147 Jan 3, 2023
[ICCV 2021] A Simple Baseline for Semi-supervised Semantic Segmentation with Strong Data Augmentation

[ICCV 2021] A Simple Baseline for Semi-supervised Semantic Segmentation with Strong Data Augmentation

CodingMan 45 Dec 12, 2022
[cvpr22] Perturbed and Strict Mean Teachers for Semi-supervised Semantic Segmentation

PS-MT [cvpr22] Perturbed and Strict Mean Teachers for Semi-supervised Semantic Segmentation by Yuyuan Liu, Yu Tian, Yuanhong Chen, Fengbei Liu, Vasile

Yuyuan Liu 132 Jan 3, 2023
[CVPR 2021] MiVOS - Mask Propagation module. Reproduced STM (and better) with training code :star2:. Semi-supervised video object segmentation evaluation.

MiVOS (CVPR 2021) - Mask Propagation Ho Kei Cheng, Yu-Wing Tai, Chi-Keung Tang [arXiv] [Paper PDF] [Project Page] [Papers with Code] This repo impleme

Rex Cheng 106 Jan 3, 2023
[CVPR 2022] CoTTA Code for our CVPR 2022 paper Continual Test-Time Domain Adaptation

CoTTA Code for our CVPR 2022 paper Continual Test-Time Domain Adaptation Prerequisite Please create and activate the following conda envrionment. To r

Qin Wang 87 Jan 8, 2023
Implementation of the paper All Labels Are Not Created Equal: Enhancing Semi-supervision via Label Grouping and Co-training

SemCo The official pytorch implementation of the paper All Labels Are Not Created Equal: Enhancing Semi-supervision via Label Grouping and Co-training

null 42 Nov 14, 2022
Self-supervised Augmentation Consistency for Adapting Semantic Segmentation (CVPR 2021)

Self-supervised Augmentation Consistency for Adapting Semantic Segmentation This repository contains the official implementation of our paper: Self-su

Visual Inference Lab @TU Darmstadt 132 Dec 21, 2022