|
1 | 1 | <div align="center">
|
2 | 2 |
|
3 |
| -# PLOP: Learning without Forgetting for Continual Semantic Segmentation |
4 |
| - |
5 |
| -[](https://arxiv.org/abs/2011.11390) |
6 |
| -[](https://arxiv.org/abs/2011.11390) |
7 |
| -[](https://youtu.be/GmnglAsraAM?t=2562) |
| 3 | +## LGKD: Label-Guided Knowledge Distillation for Continual Semantic Segmentation on 2D Images and 3D Point Clouds |
8 | 4 |
|
| 5 | +[](https://openaccess.thecvf.com/content/ICCV2023/papers/Yang_Label-Guided_Knowledge_Distillation_for_Continual_Semantic_Segmentation_on_2D_Images_ICCV_2023_paper.pdf) |
| 6 | + |
| 7 | + |
| 8 | + |
9 | 9 | </div>
|
10 | 10 |
|
| 11 | +Existing knowledge distillation based continual semantic segmentation (CSS) methods continue to suffer from the confusion between the background and novel classes. |
| 12 | +To address this issue, we propose a new label-guided knowledge distillation (LGKD) loss for CSS, which builds a reliable **class correspondence** across incremental steps and alleviates the **novel-background confusion**. |
| 13 | +The figure below illustrates the distinction of our proposed LGKD loss from existing arts. |
| 14 | +<div align="center"> |
| 15 | + <img src="images/teaser.png" width="600"> |
| 16 | +</div> |
11 | 17 |
|
12 |
| - |
13 |
| - |
14 |
| - |
15 |
| -This repository contains all of our code. It is a modified version of |
16 |
| -[Cermelli et al.'s repository](https://github.com/fcdl94/MiB). |
17 |
| - |
18 |
| - |
| 18 | +This repository contains the official implementation for [LGKD](https://openaccess.thecvf.com/content/ICCV2023/papers/Yang_Label-Guided_Knowledge_Distillation_for_Continual_Semantic_Segmentation_on_2D_Images_ICCV_2023_paper.pdf), built upon [Douillard et al.'s repository](https://github.com/arthurdouillard/CVPR2021_PLOP). |
| 19 | +If you find it useful, please consider to cite our paper: |
19 | 20 | ```
|
20 |
| -@inproceedings{douillard2021plop, |
21 |
| - title={PLOP: Learning without Forgetting for Continual Semantic Segmentation}, |
22 |
| - authors={Douillard, Arthur and Chen, Yifu and Dapogny, Arnaud and Cord, Matthieu}, |
23 |
| - booktitle={Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR)}, |
24 |
| - year={2021} |
| 21 | +@inproceedings{yang2023label, |
| 22 | + title={Label-guided knowledge distillation for continual semantic segmentation on 2d images and 3d point clouds}, |
| 23 | + author={Yang, Ze and Li, Ruibo and Ling, Evan and Zhang, Chi and Wang, Yiming and Huang, Dezhao and Ma, Keng Teck and Hur, Minhoe and Lin, Guosheng}, |
| 24 | + booktitle={Proceedings of the IEEE/CVF International Conference on Computer Vision}, |
| 25 | + pages={18601--18612}, |
| 26 | + year={2023} |
25 | 27 | }
|
26 | 28 | ```
|
27 | 29 |
|
28 |
| -# Requirements |
| 30 | +## Installation |
29 | 31 |
|
30 |
| -You need to install the following libraries: |
31 |
| -- Python (3.6) |
32 |
| -- Pytorch (1.8.1+cu102) |
33 |
| -- torchvision (0.9.1+cu102) |
34 |
| -- tensorboardX (1.8) |
| 32 | +This repo is tested with the following environment (see [environment.yml](environment.yml) for details) on 2x RTX 3090, though it may also work with other versions. |
| 33 | +- Python (3.8.12) |
| 34 | +- Pytorch (1.10.2+cu11.3.1) |
35 | 35 | - apex (0.1)
|
36 |
| -- matplotlib (3.3.1) |
37 |
| -- numpy (1.17.2) |
38 |
| -- [inplace-abn](https://github.com/mapillary/inplace_abn) (1.0.7) |
39 |
| - |
40 |
| -Note also that apex seems to only work with some CUDA versions, therefore try to install Pytorch (and torchvision) with |
41 |
| -the 10.2 CUDA version. You'll probably need anaconda instead of pip in that case, sorry! Do: |
| 36 | +- [inplace-abn](https://github.com/mapillary/inplace_abn) (1.1.0) |
42 | 37 |
|
| 38 | +Readily setup with the following command lines. Do remember to check your own cuda version. |
43 | 39 | ```
|
44 |
| -conda install -y pytorch torchvision cudatoolkit=10.2 -c pytorch |
45 |
| -cd apex |
46 |
| -pip3 install -v --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./ |
47 |
| -``` |
48 |
| - |
49 |
| -Note that while the code should be runnable without mixed precision (apex), some have reported lower perfs without it. So try with it! |
50 |
| - |
51 |
| -# Dataset |
| 40 | +# pytorch installation |
| 41 | +conda install pytorch torchvision pytorch-cuda=12.1 -c pytorch -c nvidia |
52 | 42 |
|
53 |
| -Two scripts are available to download ADE20k and Pascal-VOC 2012, please see in the `data` folder. |
54 |
| -For Cityscapes, you need to do it yourself, because you have to ask "permission" to the holders; but be |
55 |
| -reassured, it's only a formality, you can get the link in a few days by mail. |
| 43 | +# other required packages |
| 44 | +pip install matplotlib inplace_abn tensorboardX tensorboard termcolor |
56 | 45 |
|
57 |
| - |
58 |
| - |
59 |
| - |
60 |
| -# How to perform training |
61 |
| -The most important file is run.py, that is in charge to start the training or test procedure. |
62 |
| -To run it, simpy use the following command: |
63 |
| - |
64 |
| -> python -m torch.distributed.launch --nproc_per_node=\<num_GPUs\> run.py --data_root \<data_folder\> --name \<exp_name\> .. other args .. |
65 |
| -
|
66 |
| -The default is to use a pretraining for the backbone used, that is searched in the pretrained folder of the project. |
67 |
| -We used the pretrained model released by the authors of In-place ABN (as said in the paper), that can be found here: |
68 |
| - [link](https://github.com/mapillary/inplace_abn#training-on-imagenet-1k). I've also upload those weights there: [link](https://github.com/arthurdouillard/CVPR2021_PLOP/releases/download/v1.0/resnet101_iabn_sync.pth.tar). |
69 |
| - |
70 |
| -Since the pretrained are made on multiple-gpus, they contain a prefix "module." in each key of the network. Please, be sure to remove them to be compatible with this code (simply rename them using key = key\[7:\]) (if you're working on single gpu). |
71 |
| -If you don't want to use pretrained, please use --no-pretrained. |
72 |
| - |
73 |
| -There are many options (you can see them all by using --help option), but we arranged the code to being straightforward to test the reported methods. |
74 |
| -Leaving all the default parameters, you can replicate the experiments by setting the following options. |
75 |
| -- please specify the data folder using: --data_root \<data_root\> |
76 |
| -- dataset: --dataset voc (Pascal-VOC 2012) | ade (ADE20K) |
77 |
| -- task: --task \<task\>, where tasks are |
78 |
| - - 15-5, 15-5s, 19-1 (VOC), 100-50, 100-10, 50, 100-50b, 100-10b, 50b (ADE, b indicates the order) |
79 |
| -- step (each step is run separately): --step \<N\>, where N is the step number, starting from 0 |
80 |
| -- (only for Pascal-VOC) disjoint is default setup, to enable overlapped: --overlapped |
81 |
| -- learning rate: --lr 0.01 (for step 0) | 0.001 (for step > 0) |
82 |
| -- batch size: --batch_size \<24/num_GPUs\> |
83 |
| -- epochs: --epochs 30 (Pascal-VOC 2012) | 60 (ADE20K) |
84 |
| -- method: --method \<method name\>, where names are |
85 |
| - - FT, LWF, LWF-MC, ILT, EWC, RW, PI, MIB |
86 |
| - |
87 |
| -For all details please follow the information provided using the help option. |
| 46 | +# apex installation |
| 47 | +git clone https://github.com/NVIDIA/apex |
| 48 | +cd apex |
| 49 | +# if pip >= 23.1 (ref: https://pip.pypa.io/en/stable/news/#v23-1) which supports multiple `--config-settings` with the same key... |
| 50 | +pip install -v --disable-pip-version-check --no-cache-dir --no-build-isolation --config-settings "--build-option=--cpp_ext" --config-settings "--build-option=--cuda_ext" ./ |
| 51 | +# otherwise |
| 52 | +pip install -v --disable-pip-version-check --no-cache-dir --no-build-isolation --global-option="--cpp_ext" --global-option="--cuda_ext" ./ |
| 53 | +``` |
88 | 54 |
|
89 |
| -#### Example commands |
| 55 | +## Dataset |
90 | 56 |
|
91 |
| -LwF on the 100-50 setting of ADE20K, step 0: |
92 |
| -> python -m torch.distributed.launch --nproc_per_node=2 run.py --data_root data --batch_size 12 --dataset ade --name LWF --task 100-50 --step 0 --lr 0.01 --epochs 60 --method LWF |
| 57 | +Download ADE20k and Pascal-VOC 2012 with the scripts in the `data` folder. |
| 58 | +Feel free to create a symbolic link instead if you already have a local copy of the standard PASCAL-VOC benchmark. |
93 | 59 |
|
94 |
| -MIB on the 50b setting of ADE20K, step 2: |
95 |
| -> python -m torch.distributed.launch --nproc_per_node=2 run.py --data_root data --batch_size 12 --dataset ade --name MIB --task 100-50 --step 2 --lr 0.001 --epochs 60 --method MIB |
| 60 | +**Expected dataset structure for PASCAL VOC 2012:** |
96 | 61 |
|
97 |
| -LWF-MC on 15-5 disjoint setting of VOC, step 1: |
98 |
| -> python -m torch.distributed.launch --nproc_per_node=2 run.py --data_root data --batch_size 12 --dataset voc --name LWF-MC --task 15-5 --step 1 --lr 0.001 --epochs 30 --method LWF-MC |
| 62 | + PascalVOC2012 |
| 63 | + ├── VOCdevkit # standard Pascal VOC benchmark |
| 64 | + │ ├── (VOC2007) # optional, will not be downloaded by the script |
| 65 | + │ │ ├── ImageSets |
| 66 | + │ │ └── ... |
| 67 | + │ └── VOC2012 |
| 68 | + │ ├── ImageSets |
| 69 | + │ └── ... |
| 70 | + ├── SegmentationClassAug |
| 71 | + ├── SegmentationClassAug_Visualization |
| 72 | + └── list |
| 73 | +**Expected dataset structure for ADE20k:** |
99 | 74 |
|
100 |
| -PLOP on 15-1 overlapped setting of VOC, step 1: |
101 |
| -> python -m torch.distributed.launch --nproc_per_node=2 run.py --data_root data --batch_size 12 --dataset voc --name PLOP --task 15-5s --overlapped --step 1 --lr 0.001 --epochs 30 --method FT --pod local --pod_factor 0.01 --pod_logits --pseudo entropy --threshold 0.001 --classif_adaptive_factor --init_balanced --pod_options "{\"switch\": {\"after\": {\"extra_channels\": \"sum\", \"factor\": 0.0005, \"type\": \"local\"}}}" |
| 75 | + ADEChallengeData2016 # standard ADE20k benchmark |
| 76 | + ├── annotations |
| 77 | + ├── images |
| 78 | + ├── objectInfo150.txt |
| 79 | + └── sceneCategories.txt |
102 | 80 |
|
| 81 | +## Getting Started |
103 | 82 |
|
104 |
| -Once you trained the model, you can see the result on tensorboard (we perform the test after the whole training) |
105 |
| - or you can test it by using the same script and parameters but using the command |
106 |
| -> --test |
| 83 | +We used the pretrained model released by the authors of [In-place ABN](https://github.com/mapillary/inplace_abn#training-on-imagenet-1k). |
| 84 | +Create a directory named `./pretrained` and download the [weights](https://github.com/Ze-Yang/LGKD/releases/download/v1.0/resnet101_iabn_sync.pth.tar) of ResNet pretrained on ImageNet. |
107 | 85 |
|
108 |
| -that will skip all the training procedure and test the model on test data. |
| 86 | +### Train & Evaluation with script |
109 | 87 |
|
110 |
| -Or more simply you can use one of the provided script that will launch every step of a continual training. |
| 88 | +To reproduce our results, simply run the corresponding script (VOC 15-1 for example): |
| 89 | +``` |
| 90 | +bash scripts/voc/lgkd_15-1.sh |
| 91 | +``` |
111 | 92 |
|
112 |
| -For example, do |
| 93 | +- Note that you will need to specify your own data path. |
| 94 | +- By default, we use 2 GPUs. Change the batch size accordingly if you use different number of GPUs. |
| 95 | +For instance, double the batch size if you train on a single GPU. |
113 | 96 |
|
114 |
| -```` |
115 |
| -bash scripts/voc/plop_15-1.sh |
116 |
| -```` |
| 97 | +### Evaluation in command line |
117 | 98 |
|
118 |
| -Note that you will need to modify those scripts to include the path where your data. |
| 99 | +To evaluate the trained models, run |
| 100 | +``` |
| 101 | +torchrun --master_port free_port --nproc_per_node=1 run.py --data_root path/to/data --overlap --batch_size 12 --dataset voc --name LGKD --task 15-5s --step 5 --method LGKD --opt_level O1 --ckpt model_to_test.pth --test |
| 102 | +``` |
0 commit comments