Holistic Weighted Distillation for Semantic Segmentation

May 28, 2023 ยท View on GitHub

This repository contains the source code of HWD. You can download the pre-trained teacher models and ImageNet pre-trained student models from the URLs provided by CIRKD.

Since ADE20K and COCO-Stuff teacher models are not released when we submitted our paper, we trained these models by ourselves. Larger iterations (e.g., 80K, 160K) should be used when training the teacher.

General parameter choices

model psp, psp_mobile, deeplabv3, deeplabv3_mobile

backbone resnet18, resnet50, resnet101, mobile

Hyper-parameters in HWD

Check the comments in train_hwd.py.

Training Guidances

First, modify the data path in settings.py!!!

Train the baseline method (Cityscapes, DeepLabV3-ResNet18)

python -m torch.distributed.launch --nproc_per_node=4 train_baseline.py \
    --gpu-id 0,1,2,3 --dataset citys \
    --model deeplabv3 --backbone resnet18 \
    --pretrained-base [your checkpoint path]/resnet18-imagenet.pth

Train the distillation method xxx (Cityscapes, DeepLabV3-ResNet101->DeepLabV3-ResNet18)

python -m torch.distributed.launch --nproc_per_node=4 train_xxx.py \
    --gpu-id 0,1,2,3 --dataset citys \
    --teacher-model deeplabv3 --teacher-backbone resnet101 \
    --teacher-pretrained [your checkpoint path]/deeplabv3_resnet101_citys_best_model.pth \
    --student-model deeplabv3 --student-backbone resnet18 \
    --student-pretrained-base [your checkpoint path]/resnet18-imagenet.pth

Train HWD (Cityscapes, DeepLabV3-ResNet101->DeepLabV3-ResNet18)

python -m torch.distributed.launch --nproc_per_node=4 train_hwd.py \
    --gpu-id 0,1,2,3 --dataset citys \
    --teacher-model deeplabv3 --teacher-backbone resnet101 \
    --teacher-pretrained [your checkpoint path]/deeplabv3_resnet101_citys_best_model.pth \
    --student-model deeplabv3 --student-backbone resnet18 \
    --student-pretrained-base [your checkpoint path]/resnet18-imagenet.pth \
    --activation --L MSE --process E --parameter 0.1 --shift 1.0 --DivPixel None

Evaluation Guidances

First, modify the data path in settings.py!!!

Eval the method xxx (Cityscapes, DeepLabV3-ResNet18)

python -m torch.distributed.launch --nproc_per_node=4 eval.py \
    --gpu-id 0,1,2,3 --dataset citys \
    --model deeplabv3 --backbone resnet18 \ 
    --method xxx \
    --pretrained [your checkpoint path]/xxx_deeplabv3_resnet18_citys_best_model.pth

More Results

Default Setting

Input Size 512x512, Batchsize 8, Iterations 40000, DeepLabV3-ResNet101->DeepLabV3-ResNet18

bold best result, italic worse than the baseline

Logit Softmax in DIST

MethodCityscapesADE20K
Baseline71.78429.862
CWD73.56532.898
DIST (w/ Softmax)73.4230.168
DIST (w/o Softmax)71.98431.677
HWD74.71833.846

The DIST paper uses softmax for logit before calculating distillation loss, but in our experiments, the performance obtained with or without using softmax varies with the data set. Based on the experimental results in the table above, we did not use softmax for logit in our appendix experiments. Whether used or not, its performance did not surpass CWD.

More Datasets with Default Distillation Iterations

MethodCityscapes (512x1024, Batchsize 16, Iterations 20000)VOC
Baseline72.79371.979
SKD73.64371.277
IFVD73.96370.907
CWD74.44474.439
CIRKD74.19171.275
DIST73.01972.575
MGD73.50872.142

Longer Distillation Iterations (Iterations 80000)

MethodCityscapesCityscapes (512x1024, Batchsize 16, Iterations 40000)VOCADE20K
Baseline73.62973.86573.15534.276
SKD74.175.54874.02134.875
IFVD74.79976.26574.08733.679
CWD75.94276.1275.80936.085
CIRKD74.94476.5474.77234.019
DIST74.65575.15874.58834.828
MGD74.41975.51274.59135.259
HWD---37.243

It can be seen that although training with longer distillation iterations can help spatial-wise methods (SKD, IFVD, and CIRKD) achieve better performance than the baseline, these methods are still inferor to CWD in most cases.

In addition, these methods seem to be more suitable for simple datasets with a small number of categories (Cityscapes with 19 categories and VOC with 21 categories) and can easily fall short of the baseline when the number of categories in the dataset increases dramatically (ADE20K with 150 categories). But the channel-wise methods (CWD and HWD) can cope with complex datasets well. Since our weight distribution is category-dependent, our approach is actually more applicable to complex datasets (e.g., ADE20K and COCO-Stuff).

Citation

If you find this repository useful, please consider citing the following paper (will be updated once the paper is formally published):

@inproceedings{sun2023holistic,
  title={Holistic Weighted Distillation for Semantic Segmentation},
  author={Sun, Wujie and Chen, Defang and Wang, Can and Ye, Deshi and Feng, Yan and Chen, Chun},
  booktitle={2023 IEEE International Conference on Multimedia and Expo (ICME)},
  year={2023},
  organization={IEEE},
}