Home

Awesome

Structured Knowledge Distillation for Dense Prediction

This repository contains the source code of our paper Structured Knowledge Distillation for Dense Prediction. It is an extension of our paper Structured Knowledge Distillation for Semantic Segmentation (accepted for publication in CVPR'19, oral).

We have update a more stable version of training the GAN part in the master branch.

If you want to transfer our pair-wise distilaltion and pixel-wise distillation in your own work or you want to use our trained models in the conference version, you can checkout to the old branck 'cvpr_19'.

Sample results

Demo video for the student net (ESPNet) on Camvid

After distillation with mIoU 65.1: image

Before distillation with mIoU 57.8: image

Structure of this repository

This repository is organized as:

Performance on the Cityscape dataset

We apply the distillation method to training the PSPNet. We used the dataset splits (train/val/test) provided here. We trained the models at a resolution of 512x512. Pi: Pixel-wise distillation PA: Pair-wise distillation HO: holistic distillation

ModelAverage
baseline69.10
+Pi70.51
+Pi+Pa71.78
+Pi+Pa+Ho74.08

Pre-trained model and Performance on other tasks

Pretrain models for three tasks can be found here:

TaskDatasetNetworkMethodEvaluation MetricLink
Semantic SegmentationCityscapesResNet18Baselinemiou: 69.10-
Semantic SegmentationCityscapesResNet18+ our distillationmiou: 75.3link
Object DetectionCOCOFCOS-MV2-C128BaselinemAP: 30.9-
Object DetectionCOCOFCOS-MV2-C128+ our distillationmAP: 34.0link
Depth estimationnyudv2VNLbaselinerel: 13.5-
Depth estimationnyudv2VNL+ our distillationrel: 13.0link

Note: Other chcekpoints can be obtained by email: yifan.liu04@adelaide.edu.au if needed.

Requirement

python3.5

pytorch0.4.1

ninja

numpy

cv2

Pillow

We recommend to use Anaconda.

We have tested our code on Ubuntu 16.04.

Compiling

Some parts of InPlace-ABN have a native CUDA implementation, which must be compiled with the following commands:

cd libs
sh build.sh
python build.py

The build.sh script assumes that the nvcc compiler is available in the current system search path. The CUDA kernels are compiled for sm_50, sm_52 and sm_61 by default. To change this (e.g. if you are using a Kepler GPU), please edit the CUDA_GENCODE variable in build.sh.

Quick start to test the model

  1. download the Cityscape dataset
  2. sh run_test.sh [you should change the data-dir to your own]. By using our distilled student model, which can be gotten in [ckpt], an mIoU of 73.05 is achieved on the Cityscape test set, and 75.3 on validation set.
ModelAveragerodasidewalkbuildingwallfencepoletrafficlighttrafficsignvegetationterrainskypersonridercartruckbustrainmotorcyclebicycle
IoU73.0597.5778.8091.4250.7650.8860.7767.9373.1892.4970.3694.5682.8161.6494.8960.1466.6259.9361.5071.71

Note: Depth estimation task and object detection task can be test through the original projects of VNL and FCOS using our checkpoints.

Train script

Download the pre-trained teacher weight:

If you want to reproduce the ablation study in our paper, please modify is_pi_use/is_pa_use/is_ho_use in the run_train_eval.sh. sh run_train_eval.sh

Test script

If you want to test your method on the cityscape test set, please modify the data-dir and resume-from path to your own, then run the test.sh and submit your results to www.cityscapes-dataset.net/submit/ sh test.sh