PyTorch implementation of: Michieli U. and Zanuttigh P., "Continual Semantic Segmentation via Repulsion-Attraction of Sparse and Disentangled Latent Representations", CVPR 2021.

Related tags

Deep Learning SDR
Overview

Continual Semantic Segmentation via Repulsion-Attraction of Sparse and Disentangled Latent Representations

This is the official PyTorch implementation of our work: "Continual Semantic Segmentation via Repulsion-Attraction of Sparse and Disentangled Latent Representations" published at CVPR 2021.

In this paper, we present some novel approaches constraining the feature space for continual learning semantic segmentation models. The evaluation on Pascal VOC2012 and on ADE20K validated our method.

Paper
5-min video
slides
poster
teaser

Requirements

This repository uses the following libraries:

  • Python (3.7.6)
  • Pytorch (1.4.0) [tested up to 1.7.1]
  • torchvision (0.5.0)
  • tensorboardX (2.0)
  • matplotlib (3.1.1)
  • numpy (1.18.1)
  • apex (0.1) [optional]
  • inplace-abn (1.0.7) [optional]

We also assume to have installed pytorch.distributed package.

All the dependencies are listed in the requirements.txt file which can be used in conda as:
conda create --name <env> --file requirements.txt

How to download data

In this project we use two dataset, ADE20K and Pascal-VOC 2012. We provide the scripts to download them in 'data/download_<dataset_name>.sh'. The script takes no inputs and you should use it in the target directory (where you want to download data).

How to perform training

The most important file is run.py, that is in charge to start the training or test procedure. To run it, simpy use the following command:

python -m torch.distributed.launch --nproc_per_node=<num_GPUs> run.py --data_root <data_folder> --name <exp_name> .. other args ..

The default is to use a pretraining for the backbone used, which is the one officially released by PyTorch models and it will be downloaded automatically. If you don't want to use pretrained, please use --no-pretrained.

There are many options and you can see them all by using --help option. Some of them are discussed in the following:

  • please specify the data folder using: --data_root <data_root>
  • dataset: --dataset voc (Pascal-VOC 2012) | ade (ADE20K)
  • task: --task <task>, where tasks are
    • 15-5, 15-5s, 19-1 (VOC), 100-50, 100-10, 50, 100-50b, 100-10b, 50b (ADE, b indicates the order)
  • step (each step is run separately): --step <N>, where N is the step number, starting from 0
  • (only for Pascal-VOC) disjoint is default setup, to enable overlapped: --overlapped
  • learning rate: --lr 0.01 (for step 0) | 0.001 (for step > 0)
  • batch size: --batch_size 8 (Pascal-VOC 2012) | 4 (ADE20K)
  • epochs: --epochs 30 (Pascal-VOC 2012) | 60 (ADE20K)
  • method: --method <method name>, where names are
    • FT, LWF, LWF-MC, ILT, EWC, RW, PI, MIB, CIL, SDR
      Note that method overwrites other parameters, but can be used as a kickstart to use default parameters for each method (see more on this in the hyperparameters section below)

For all the details please follow the information provided using the help option.

Example training commands

We provide some example scripts in the *.slurm and *.bat files.
For instance, to run the step 0 of 19-1 VOC2012 you can run:

python -u -m torch.distributed.launch 1> 'outputs/19-1/output_19-1_step0.txt' 2>&1 \
--nproc_per_node=1 run.py \
--batch_size 8 \
--logdir logs/19-1/ \
--dataset voc \
--name FT \
--task 19-1 \
--step 0 \
--lr 0.001 \
--epochs 30 \
--debug \
--sample_num 10 \
--unce \
--loss_de_prototypes 1 \
--where_to_sim GPU_windows

Note: loss_de_prototypes is set to 1 only for having the prototypes computed in the 0-th step (no distillation is actually computed of course).

Then, the step 1 of the same scenario can be computed simply as:

python -u -m torch.distributed.launch 1> 'outputs/19-1/output_19-1_step1.txt'  2>&1 \
--nproc_per_node=1 run.py \
--batch_size 8 \
--logdir logs/19-1/ \
--dataset voc \
--task 19-1 \
--step 1 \
--lr 0.0001 \
--epochs 30 \
--debug \
--sample_num 10 \
--where_to_sim GPU_windows \
--method SDR \
--step_ckpt 'logs/19-1/19-1-voc_FT/19-1-voc_FT_0.pth'

The results obtained are reported inside the outputs/ and logs/ folder, which can be downloaded here, and are 0.4% of mIoU higher than those reported in the main paper due to a slightly changed hyperparameter.

To run other approaches it is sufficient to change the --method parameter into one of the following: FT, LWF, LWF-MC, ILT, EWC, RW, PI, MIB, CIL, SDR.

Note: for the best results, the hyperparameters may change. Please see further details on the hyperparameters section below.

Once you trained the model, you can see the result on tensorboard (we perform the test after the whole training) or on the output files. or you can test it by using the same script and parameters but using the option

--test

that will skip all the training procedure and test the model on test data.

Do you want to try our constraints on your codebase or task?

If you want to try our novel constraints on your codebase or on a different problem you can check the utils/loss.py file. Here, you can take the definitions of the different losses and embed them into your codebase
The names of the variables could be interpreted as:

  • targets-- ground truth map,
  • outputs-- segmentation map output from the current network
  • outputs_old-- segmentation map output from the previous network
  • features-- features taken from the end of the currently-trained encoder,
  • features_old-- features taken from the end of the previous encoder [used for distillation on the encoder on ILT, but not used on SDR],
  • prototypes-- prototypical feature representations
  • incremental_step -- index of the current incremental step (0 if first non-incremental training is performed)
  • classes_old-- index of previous classes

Range for the Hyper-parameters

For what concerns the hyperparameters of our approach:

  • The parameter for the distillation loss is in the same range of that of MiB,
  • Prototypes matching: lambda was searched in range 1e-1 to 1e-3,
  • Contrastive learning (or clustering): lambda was searched in the range of 1e-2 to 1e-3,
  • Features sparsification: lambda was searched in the range of 1e-3 to 1e-5 A kick-start could be to use KD 10, PM 1e-2, CL 1e-3 and FS 1e-4.
    The best parameters may vary across datasets and incremental setup. However, we typically did a grid search and kept it fixed across learning steps.

So, writing explicitly all the parameters, the command would look something like the following:

python -u -m torch.distributed.launch 1> 'outputs/19-1/output_19-1_step1_custom.txt'  2>&1 \
--nproc_per_node=1 run.py \
--batch_size 8 \
--logdir logs/19-1/ \
--dataset voc \
--task 19-1 \
--step 1 \
--lr 0.0001 \
--epochs 30 \
--debug \
--sample_num 10 \
--where_to_sim GPU_windows \
--unce \
--loss_featspars $loss_featspars \
--lfs_normalization $lfs_normalization \
--lfs_shrinkingfn $lfs_shrinkingfn \
--lfs_loss_fn_touse $lfs_loss_fn_touse \
--loss_de_prototypes $loss_de_prototypes \
--loss_de_prototypes_sumafter \
--lfc_sep_clust $lfc_sep_clust \
--loss_fc $loss_fc \
--loss_kd $loss_kd \
--step_ckpt 'logs/19-1/19-1-voc_FT/19-1-voc_FT_0.pth'

Cite us

If you use this repository, please consider to cite

   @inProceedings{michieli2021continual,
   author = {Michieli, Umberto and Zanuttigh, Pietro},
   title  = {Continual Semantic Segmentation via Repulsion-Attraction of Sparse and Disentangled Latent Representations},
   booktitle = {Computer Vision and Pattern Recognition (CVPR)},
   year      = {2021},
   month     = {June}
   }

And our previous works ILT and its journal extension.

Acknowledgements

We gratefully acknowledge the authors of MiB paper for the insightful discussion and for providing the open source codebase, which has been the starting point for our work.
We also acknowledge the authors of CIL for providing their code even before the official release.

Comments
  • Questions about differences between the codes and the description in the paper

    Questions about differences between the codes and the description in the paper

    Hello, thank you for sharing your codes.

    I have questions about DeepLab and learning rates.

    According to the paper, SDR adopts DeepLab-V3+ and an initial learning rate is set to 1e-2 / 1e-3 for the first step / following steps, respectively.

    However, in the provided code, SDR uses DeepLab-V3 as in 'MiB' and the initial learning rate is set to 1e-3 / 1e-4 for the first step / following steps, respectively.

    Could you please clarify this? Thank you again

    opened by 50min 10
  • Nan mIoU on

    Nan mIoU on "voc 19-1 step1" task under "Sequential" setting

    Hello, thanks for your innovative method and such a good work! Sorry to bother you. I got a similar result as yours under the disjoint setting, but when I try to reproduce the 'Sequential' tasks, I got a weird nan mIoU and class loss 0.0 on the validation of "voc 19-1 step1".
    I noticed the .npy files have the same image indexes between "voc/19-1/" and"voc/19-1-oldclICCVW2019", I train the step1 model using just the same step0 model trained on 'disjoint 19-1 step0' settings, and my command is:

    python -u -m torch.distributed.launch 1> 'outputs/19-1/output_19-1_step1_LWF_seq.txt' 2>&1 --nproc_per_node=1 run.py --batch_size 8 --logdir logs/19-1/ --dataset voc --name LWF_seq --task 19-1 --step 1 --lr 0.0001 --epochs 30 --debug --sample_num 10 --where_to_sim GPU_windows --method LWF --step_ckpt 'logs/19-1/19-1-voc_FT/19-1-voc_FT_0.pth' --no_mask

    the loss during training seems working normally but the validation outputs is: INFO:rank0: Validation, Class Loss=0.0, Reg Loss=0.011368847452104092 (without scaling) INFO:rank0: Done validation on Val set INFO:rank0: End of Validation 15/30, Validation Loss=0.011368847452104092, Class Loss=0.0, Reg Loss=0.011368847452104092 INFO:rank0: Total samples: 74.000000 Overall Acc: nan Mean Acc: nan FreqW Acc: 0.000000 Mean IoU: nan Class IoU: class 0: X class 1: X class 2: X class 3: X class 4: X class 5: X class 6: X class 7: X class 8: X class 9: X class 10: X class 11: X class 12: X class 13: X class 14: X class 15: X class 16: X class 17: X class 18: X class 19: X class 20: X Class Acc: class 0: X class 1: X class 2: X class 3: X class 4: X class 5: X class 6: X class 7: X class 8: X class 9: X class 10: X class 11: X class 12: X class 13: X class 14: X class 15: X class 16: X class 17: X class 18: X class 19: X class 20: X

    I didn't modified your code. Could you give me some comments?Thank you very much!

    opened by SSSKYue 7
  • The command about 15-5s.

    The command about 15-5s.

    Hello,

    Thank you for your interesting work. Recently I have been reproduction your work. But I failed. Would you please help me to check whether the running command is correct?

    voc-15-5s

    python run.py
    --batch_size 8
    --logdir logs/15-5s/
    --dataset voc
    --name FT
    --task 15-5s
    --step 0
    --lr 0.001
    --epochs 30
    --debug
    --sample_num 10
    --unce
    --loss_de_prototypes 1
    --where_to_sim GPU_windows

    python run.py
    --batch_size 8
    --logdir logs/15-5s/
    --dataset voc
    --name SDR1
    --task 15-5s
    --step 1
    --lr 0.0001
    --epochs 30
    --debug
    --sample_num 10
    --where_to_sim GPU_windows
    --method SDR
    --step_ckpt 'logs/15-5s/15-5s-voc_FT/15-5s-voc_FT_0.pth'

    python run.py
    --batch_size 8
    --logdir logs/15-5s/
    --dataset voc
    --name SDR2 --task 15-5s
    --step 2
    --lr 0.0001
    --epochs 30
    --debug
    --sample_num 10
    --where_to_sim GPU_windows
    --method SDR
    --step_ckpt 'logs/15-5s/15-5s-voc_SDR1/15-5s-voc_SDR1_1.pth'

    python run.py
    --batch_size 8
    --logdir logs/15-5s/
    --dataset voc
    --name SDR3 --task 15-5s
    --step 3
    --lr 0.0001
    --epochs 30
    --debug
    --sample_num 10
    --where_to_sim GPU_windows
    --method SDR
    --step_ckpt 'logs/15-5s/15-5s-voc_SDR2/15-5s-voc_SDR2_2.pth'

    python run.py
    --batch_size 8
    --logdir logs/15-5s/
    --dataset voc
    --name SDR4 --task 15-5s
    --step 4
    --lr 0.0001
    --epochs 30
    --debug
    --sample_num 10
    --where_to_sim GPU_windows
    --method SDR
    --step_ckpt 'logs/15-5s/15-5s-voc_SDR3/15-5s-voc_SDR3_3.pth'

    python run.py
    --batch_size 8
    --logdir logs/15-5s/
    --dataset voc
    --name SDR5 --task 15-5s
    --step 5
    --lr 0.0001
    --epochs 30
    --debug
    --sample_num 10
    --where_to_sim GPU_windows
    --method SDR
    --step_ckpt 'logs/15-5s/15-5s-voc_SDR4/15-5s-voc_SDR4_4.pth'

    Thanks.

    opened by ljx97 6
  • The split method in test data set

    The split method in test data set

    Hello, how is the test data set divided? For example, I observed that the content of /voc/19-1/test_on_val-1.npy is not exactly the same as the content of /voc/19-1/test_on_val-0.npy. Why is the content of the test set different in each incremental step?

    opened by ljx97 2
  • Questions about formulas in code and papers

    Questions about formulas in code and papers

    Hello, thank you for sharing your codes. I have some questions about the paper and codes, I hope you can help me clear my doubts.

    1. The first doubt is the Frobenius norm and MSELoss. Are Frobenius norm and MSE equal? Is the Frobenius norm in the paper reflected in the code with MSE?
    2. Is the part of the green box in the image multiplied or the part of the vector in fi? image image Hope to get your answer, I will be very grateful.
    opened by gzgz-code 1
  • Details about VOC: 15-5s

    Details about VOC: 15-5s

    First of all, thank you for your code! You've made a brilliant work! Since I am a beginner in increment learning, I have a question in VOC task :15-5s:

    If I want to learn the second task: which means opt.step = 2, but I have no pretrained model for task 0 and task 1, how should I run the project? Or should I first follow the sequential training stage: task 0->task 1->task 2?

    Hope you can solve my doubt, Thanks a lot!

    opened by LIUZIJING-CHN 1
  • the division of data set

    the division of data set

    Hello,

    Thank you for sharing the code. I'm interesting in your work. But I still have a question about the division of the data set. How did you divide your test data set?

    opened by ljx97 1
  • Results for ADE20k and other Pascal VOC

    Results for ADE20k and other Pascal VOC

    Hi, thanks for sharing your work.

    I have a quick question. Could you please share the log results for ADE20k and other Pasacal VOC besides 19-1?

    Thanks.

    opened by HieuPhan33 1
  • Asking for exact data for each step.

    Asking for exact data for each step.

    Hello, Hope not to disturb you, but I'm wondering if you can offer us the performance(mIoU, to be exactly) of SDR of each step on both Pascal-VOC 15-5s disjoint as well as overlap? It's very interesting to follow your impressive work and understand the principles behind the paper. Still I have to do some analysis over these data. I'd appreciate it if you can help us.

    opened by schuy1er 1
Owner
Multimedia Technology and Telecommunication Lab
Department of Information Engineering, University of Padova
Multimedia Technology and Telecommunication Lab
[CVPR 21] Vectorization and Rasterization: Self-Supervised Learning for Sketch and Handwriting, IEEE Conf. on Computer Vision and Pattern Recognition (CVPR), 2021.

Vectorization and Rasterization: Self-Supervised Learning for Sketch and Handwriting, CVPR 2021. Ayan Kumar Bhunia, Pinaki nath Chowdhury, Yongxin Yan

Ayan Kumar Bhunia 44 Dec 12, 2022
Official Pytorch implementation of "Beyond Static Features for Temporally Consistent 3D Human Pose and Shape from a Video", CVPR 2021

TCMR: Beyond Static Features for Temporally Consistent 3D Human Pose and Shape from a Video Qualtitative result Paper teaser video Introduction This r

Hongsuk Choi 215 Jan 6, 2023
PyTorch implementation of paper "Neural Scene Flow Fields for Space-Time View Synthesis of Dynamic Scenes", CVPR 2021

Neural Scene Flow Fields PyTorch implementation of paper "Neural Scene Flow Fields for Space-Time View Synthesis of Dynamic Scenes", CVPR 20

Zhengqi Li 585 Jan 4, 2023
Official pytorch implementation of paper "Inception Convolution with Efficient Dilation Search" (CVPR 2021 Oral).

IC-Conv This repository is an official implementation of the paper Inception Convolution with Efficient Dilation Search. Getting Started Download Imag

Jie Liu 111 Dec 31, 2022
Official PyTorch implementation of RobustNet (CVPR 2021 Oral)

RobustNet (CVPR 2021 Oral): Official Project Webpage Codes and pretrained models will be released soon. This repository provides the official PyTorch

Sungha Choi 173 Dec 21, 2022
PyTorch implementation for COMPLETER: Incomplete Multi-view Clustering via Contrastive Prediction (CVPR 2021)

Completer: Incomplete Multi-view Clustering via Contrastive Prediction This repo contains the code and data of the following paper accepted by CVPR 20

XLearning Group 72 Dec 7, 2022
Official pytorch implementation of Rainbow Memory (CVPR 2021)

Rainbow Memory: Continual Learning with a Memory of Diverse Samples

Clova AI Research 91 Dec 17, 2022
Pytorch implementation for "Adversarial Robustness under Long-Tailed Distribution" (CVPR 2021 Oral)

Adversarial Long-Tail This repository contains the PyTorch implementation of the paper: Adversarial Robustness under Long-Tailed Distribution, CVPR 20

Tong WU 89 Dec 15, 2022
Official PyTorch Implementation of Embedding Transfer with Label Relaxation for Improved Metric Learning, CVPR 2021

Embedding Transfer with Label Relaxation for Improved Metric Learning Official PyTorch implementation of CVPR 2021 paper Embedding Transfer with Label

Sungyeon Kim 37 Dec 6, 2022
[CVPR 2021] Pytorch implementation of Hijack-GAN: Unintended-Use of Pretrained, Black-Box GANs

Hijack-GAN: Unintended-Use of Pretrained, Black-Box GANs In this work, we propose a framework HijackGAN, which enables non-linear latent space travers

Hui-Po Wang 46 Sep 5, 2022
A Pytorch implementation of CVPR 2021 paper "RSG: A Simple but Effective Module for Learning Imbalanced Datasets"

RSG: A Simple but Effective Module for Learning Imbalanced Datasets (CVPR 2021) A Pytorch implementation of our CVPR 2021 paper "RSG: A Simple but Eff

null 120 Dec 12, 2022
PyTorch implementation for Partially View-aligned Representation Learning with Noise-robust Contrastive Loss (CVPR 2021)

2021-CVPR-MvCLN This repo contains the code and data of the following paper accepted by CVPR 2021 Partially View-aligned Representation Learning with

XLearning Group 33 Nov 1, 2022
Official PyTorch implementation of the preprint paper "Stylized Neural Painting", accepted to CVPR 2021.

Official PyTorch implementation of the preprint paper "Stylized Neural Painting", accepted to CVPR 2021.

Zhengxia Zou 1.5k Dec 28, 2022
Official PyTorch Implementation of Convolutional Hough Matching Networks, CVPR 2021 (oral)

Convolutional Hough Matching Networks This is the implementation of the paper "Convolutional Hough Matching Network" by J. Min and M. Cho. Implemented

Juhong Min 70 Nov 22, 2022
Official PyTorch implementation of "VITON-HD: High-Resolution Virtual Try-On via Misalignment-Aware Normalization" (CVPR 2021)

VITON-HD — Official PyTorch Implementation VITON-HD: High-Resolution Virtual Try-On via Misalignment-Aware Normalization Seunghwan Choi*1, Sunghyun Pa

Seunghwan Choi 250 Jan 6, 2023
An implementation for Neural Architecture Search with Random Labels (CVPR 2021 poster) on Pytorch.

Neural Architecture Search with Random Labels(RLNAS) Introduction This project provides an implementation for Neural Architecture Search with Random L

null 18 Nov 8, 2022
This repository is the offical Pytorch implementation of ContextPose: Context Modeling in 3D Human Pose Estimation: A Unified Perspective (CVPR 2021).

Context Modeling in 3D Human Pose Estimation: A Unified Perspective (CVPR 2021) Introduction This repository is the offical Pytorch implementation of

null 37 Nov 21, 2022
[CVPR 2021] Official PyTorch Implementation for "Iterative Filter Adaptive Network for Single Image Defocus Deblurring"

IFAN: Iterative Filter Adaptive Network for Single Image Defocus Deblurring Checkout for the demo (GUI/Google Colab)! The GUI version might occasional

Junyong Lee 173 Dec 30, 2022
PyTorch implementation of paper "IBRNet: Learning Multi-View Image-Based Rendering", CVPR 2021.

IBRNet: Learning Multi-View Image-Based Rendering PyTorch implementation of paper "IBRNet: Learning Multi-View Image-Based Rendering", CVPR 2021. IBRN

Google Interns 371 Jan 3, 2023