Computer Science
Computer Science-2021.gz:143233
Computer Science
e32728e7809dab95d0f614f6fc9ef68a8c43393a
Domain Adaptive Knowledge Distillation for Driving Scene Semantic Segmentation

Practical autonomous driving systems face two crucial challenges: memory constraints and domain gap issues. In this paper, we present a novel approach to learn domain adaptive knowledge in models with limited memory, thus bestowing the model with the ability to deal with these issues in a comprehensive manner. We term this as"Domain Adaptive Knowledge Distillation"and address the same in the context of unsupervised domain-adaptive semantic segmentation by proposing a multi-level distillation strategy to effectively distil knowledge at different levels. Further, we introduce a novel cross entropy loss that leverages pseudo labels from the teacher. These pseudo teacher labels play a multifaceted role towards: (i) knowledge distillation from the teacher network to the student network&(ii) serving as a proxy for the ground truth for target domain images, where the problem is completely unsupervised. We introduce four paradigms for distilling domain adaptive knowledge and carry out extensive experiments and ablation studies on real-to-real as well as synthetic-to-real scenarios. Our experiments demonstrate the profound success of our proposed method.


Introduction
Semantic segmentation is one of the fundamental tasks in perception for autonomous vehicles. The goal of semantic segmentation is to assign a label (car, tree, sky, etc.) to every pixel in the image. This information is quite relevant in the decision making of autonomous vehicles, as it provides information regarding shape/location of objects and the background. Recently, deep neural networks have imparted immense progress in this field. Some benchmark architectures include Fully Connected Networks [22], Dilated Residual Networks [43], and DeepLab [5], PSPNet [46], and Gated-scnn [34].
Despite these advancements, there are some practical challenges that cause a hindrance to even the best perform-ing models. One such major drawback is the "domaingap" issue. It particularly exists in 'in-the-wild' scenarios, where neural networks trained on one domain won't generalize well on other domains, due to large domain gaps between the source (on which the neural network was trained) and the target (test) domains. This is mainly due to significant changes in the illumination, weather conditions and seasonal changes across domains. Additionally, collecting ground-truth (GT) annotations for different domains is a laborious and expensive task. This calls for an approach, that is capable of leveraging existing ground truth information in some domains to improve performance in other domains in an unsupervised manner. To this end, Unsupervised Domain Adaptation (UDA) has emerged as a solution. The goal of UDA is to align features (reduce domain gap) across the source (labelled) and target (unlabelled) domains, so that the adapted model performs well on both domains.
Another key issue at the production end is the memory constraint of the system. Most of the best-performing models are very deep and have high memory requirements. However, practical applications require the model to fit and evaluate on large images (as captured from a car) with limited memory, as in mobile devices. Many recent approaches have been inviting attention towards using compact light weight models [24], [45], [29]. However, these models result in lower performance efficiency in comparison with the state-of-the-art (SOTA) architectures that use deep backbones. With respect to this, model compression techniques like Knowledge Distillation [16], [32] have contributed significantly in fuelling the performance of a compact Student network by transferring knowledge from a cumbersome Teacher network.
In this paper, we propose a novel holistic end-toend approach for distilling domain adaptive segmentation knowledge to tackle the challenges of domain gap and memory constraint, simultaneously. The goal is to distil domain-adaptive knowledge from a computationally expensive teacher network to a compact student network, to boost its performance in the target domain. To the best of our knowledge, this paper marks one of the first approaches to-wards this multifaceted goal. To facilitate our proposal, we propose a multi-level distillation (MLD) strategy with novel loss functions to improve performance for both knowledge distillation (KD) and domain adaptation (DA) in a simultaneous manner.
Our proposed method distils knowledge at two levelsfeature space and output space -using a combination of KL divergence and MSE loss terms. Furthermore, in order to optimize our model for both tasks simultaneously, we discern the need for an additional loss function that is tailored explicitly to serve the multitudinous goal. In this regard, we leverage the teacher network soft predictions to generate pseudo labels. These pseudo labels enhance knowledge transfer at the output space. These labels are particularly relevant in the target domain, as they serves as a proxy for ground truth, which is otherwise unavailable. Our newly presented cross entropy loss function with pseudo-labels serves as a multifarious objective function, by serving as an emissary for the unavailable ground truth in the target domain, while also amplifying the distillation from the teacher to the student.
We evaluate our proposed method on large-scale autonomous driving datasets. In addition to the benchmark synthetic-to-real adaptation case scenario (GTA5 to Cityscapes), we assess our pipeline on a real-to-real scenario too (BDD to Cityscapes). In summary, the key contributions of this paper are as follows: (1) A novel framework that distils domain adaptive knowledge to address two core practical problems (i.e. low memory networks & domain gap) concurrently.; (2) A multi-level distillation strategy carried out at the feature and output spaces.; (3) Proposal of a tailor-made loss function: cross entropy with pseudo teacher labels for this multifaceted problem.; (4) Extensive experimental analysis and ablation studies on both synthetic-to-real, and on real-toreal cases.

Domain adaptation
Domain adaptation is a subfield of machine learning that deals with employing a model trained on a source distribution in the context of a different (but related) target distribution. The goal is to reduce the domain gap and to find a common feature space that works well across domains. This problem has seen immense progress in the past. Domain gaps can be reduced in an adversarial way [37,36], by reconstruction [15,26] or by minimizing distance between distributions [23,33].
Domain-adaptive semantic segmentation is of keen interest to researchers as semantic labelling is an incredibly labor-intensive task. One of the first methods was reported in [17]. The method uses fully convolutional networks for semantic segmentation and adversarial training for domain alignment. Kalluri et al. [18] performs semi supervised domain adaptation by using an entropy module that minimizes a similarity metric computing by projecting the representation at each pixel to an embedding space of different directions. Murez et al. [26] uses cycleGAN to transform images from one domain to another, and then uses both the original and the transformed images to find a model agnostic feature space. Tsai et al. [35] uses multi level adversarial learning to align features at different levels of the network. Vu et al. [38] uses losses based on the entropy of pixel wise predictions. Chen et al. [7] uses an image-to-image translation network, domain-specific task networks and cross domain consistency to find a common feature space.

Model compression via knowledge distillation:
Recently, there has been a surge in papers addressing model compression techniques in various vision problems. A thorough review of various compression techniques is reported in the survey paper [8]. One of the pioneer works in the field by Hinton et al. [16] showed that the extra information a.k.a. "dark knowledge" encapsulated in the soft targets (class probabilities produced by teacher) could be used for training the compact student model. Motivated by this observation, several other works were followed leveraging more teacher information. For instance, Romero et al. [31] presented an idea for distilling from the intermediate feature representations, whereas Yim et al. [42] proposed to distil the knowledge in terms of flow between layers, which is calculated by computing the inner product between features from two layers. In addition to various KD models in image classification [6], [9], it has been successfully applied in object detection [4], video classification [3] and speech recognition [40] as well. The idea has been explored for semantic segmentation tasks as well. Ros et al. [32] investigated the problem of road scene semantic segmentation leveraging different knowledge transfer frameworks based on the output probability of the teacher network. Further work includes distilling zero-order and first-order knowledge from teacher models [41] and distilling structured knowledge via pairwise and holistic distillation [21]. The paper on feature level distillation [12] explores the topic in the setting of action recognition.

Differences from past methods
While we acknowledge that there has been good headway on the ideas of domain adaptation and knowledge distillation as two separate problems, it is notable that in this paper, we conceptualize the best of both in a single holistic model, in a novel way. To the best of our knowledge, this is for the first time that the usage of domain adapta- tion along with knowledge distillation has been explored in semantic segmentation. Albeit some early works addressed both of these concepts, those were on other problem settings such as Semi-supervised domain adaptation (SDA) [1], [28] or upon clinical/acoustic platforms [28], [2]. Further, they used knowledge distillation as a means for domain adaptation. On the contrary, we address a much more difficult problem setting -Unsupervised Domain Adaptation (UDA), on autonomous driving scene understanding, an area of stupendous practical implication. Unlike leveraging distillation as a means for domain adaptation [13], [27], [47], the design of our architecture is very well fine-tuned to serve both the goals of compression & domain adaptation in a specialized manner. Pseudo labels have been used for self-training in certain domain adaptation architectures [48,10,14,25]. Additionally, noisy labels have also been used for partial knowledge transfer [20,39]. In contrast, our paper proposes a method that leverages pseudo labels and improves both domain adaptation performance and knowledge distillation performance in a complementary manner.

Distillation model for UDA semantic segmentation
We propose a novel framework for distilling domain adaptive knowledge from a cumbersome teacher network to a lightweight student network, in the context of unsupervised semantic segmentation. In this section, the overall network architecture, distillation strategies and the associated objective functions are explained.

Overview of Network Architecture
The proposed network architecture is shown in Fig. 1. It consists of two neural networks viz. a cumbersome teacher segmentation network T and a compact student segmentation network S. RGB images from both source and target domains and the segmentation maps for the corresponding source domain images are the inputs to the networks. The problem is completely unsupervised in the target domain i.e., no labels are available for the target domain. First, the teacher T and the student S networks are initialized with parameters trained for the task of domain adaptation (DA) on a source-target dataset pair. The baseline DA model used in both student and teacher networks is detailed in later Section 3.2. The teacher network T (weights frozen after training) is used to distil knowledge to the compact student network S (distillations are shown in Fig. 1 via arrows). The task of the student network is to learn a domain-adaptive set of parameters, while taking advantage of the mastery of the teacher network. The transfer of knowledge can help the much smaller student network perform better than its innate capabilities.
In order to facilitate efficient knowledge distillation, we propose a multi-level distillation scheme, wherein knowledge transfer is carried out at multiple levels of the network: feature space and output space, as explained in Section 3.3. Further, two modes of distillations are designed at each level i.e. source distillation (red arrows) and target distillation (blue arrows). In addition, at the output space, we introduce a loss function that leverages pseudo labels from the teacher network. These pseudo labels serve two purposes: knowledge distillation from the teacher to the student & proxy for the target domain ground truth, which is otherwise unavailable. A detailed explanation on the pseudo teacher label based distillation is provided in Section 3.3.3.

Baseline domain adaptation (DA) model
It is important to use a good domain adaptation strategy for each of the teacher and student networks. To this end, we use the popular multi-level domain adaptation strategy [35] to pretrain both the networks. To train the generator, segmentation loss L seg (cross entropy loss) is applied on images from the source domain, and adversarial loss L adv is applied for images from the target domain. The discriminators are optimised with a binary cross entropy loss applied on images from both the domains. The mathematical formulations [35] are as follows: where Y s represents ground truth, P s is the probability map predictions for source images and P t is the probability map predictions of target images. C represents the number of classes. The net equation to optimise the generator network is a sum of the segmentation and adversarial loss terms at feature and output level. This is optimized using the minmax criterion.

Multi-level distillation
We present a multi-level distillation method to transfer knowledge at both the feature and the output space to bestow the student network with improved performance capabilities while retaining its compactness. In this regard, we present the following loss functions:

KL divergence loss L KL
The output of the networks are probability distributions. We use the KL divergence loss [19] to motivate the student to achieve distributions close to the teacher at the output level. This encourages the output of the student network to emulate the output of the teacher network.
Here, λ KL represents the weight hyperparameter for KL divergence distillation, q s i denotes student domain probability maps and q t i denotes the corresponding counterpart for teacher domain. To facilitate enhanced distillation, we enforce another KL divergence loss term at the high dimensional feature space (where feature-space adaptation is done), nevertheless with a lower weight hyperparameter. Note that, in consistency with multi-level DA, Adapt-SegNet [35], we project the feature maps to segmentation probability maps. This enables us to apply KL divergence distillation at the feature space (Mathematically, KL divergence can be used to only constrain probability distributions). Thus, this loss is implemented at two stages viz., output and feature levels and we denote them as L KL,out and L KL,f eat respectively. It is mathematically formulated as: These feature maps correspond to the level at which feature-level domain adaptation is done. If the feature size between the student and teacher model is different, bilinear upsampling (proven to be effective in generating segmentation maps from feature maps) can be used to make the feature sizes same, followed by the application of the loss functions. is distilled to the counterpart student network via multiclass cross entropy loss term. This is in addition to the segmentation multi-class cross entropy loss L seg that is applied using the ground truth for images from the source domain.
(ii) Proxy ground truth for images in the target domain, where the problem is completely unsupervised. The enchantment of these pseudo-labels is mainly exhibited in the case of the student target domain, wherein teacher domain pseudo-labels serve as a proxy for the ground truth. On this notion, we apply cross entropy loss between the student network target domain outputs and the corresponding pseudolabels from teacher, that we term as L pseudoT . While one may argue that for probability distributions, KL divergence and cross entropy play very similar roles and are thus equivalent to each other, we wish to emphasize that KL divergence is applied between the teacher and student probability distributions wherein the teacher distribution carries information about all classes. This can thus capture knowledge about semantically similar classes. However, for the pseudo label cross entropy loss term, we deterministically predict the label for each pixel from the teacher network probability distribution. This carries no information about the labels for other classes, and can also introduce false positives, which is countered with the KL divergence loss term. We observe that these pseudo-labels significantly improve the results. Mathematically, λ pseudoT represents the hyperparameter for distillation with pseudo-labels, Y pseudoT denotes pseudo-labels from the teacher network, and P student denotes predictions (probability map) of the student network. The equation takes the same form for both source and target domain images.

Overall objective function:
The student network is trained with both domain adaptation losses (section 3.2), and distillation losses. The overall objective function for distillation is the weighted sum of the individual distillation loss functions. Taking advantage of the similitude between the source (s) and target (t) domains, we propose to introduce a scaling factor λ target . For target domain distillation, we use parameters that are λ target times the corresponding parameters used for source domain distillation.

Distillation paradigms
We institute four distillation paradigms (Fig. 2). Fig.  2(a) represents the case where only images from the source domain are distilled. Similarly, Fig. 2(b) represents the case where only images from the target domain are distilled. Fig. 2(c) represents source + target distillation, the complete model as proposed in Fig. 1. Fig. 2(d) represents target distillation, where the student network is initialised with weights trained as in case 2(c). Each of these distillation paradigms contributes to improving performance of the overall architecture in different aspects, and we discuss these effects in detail in section 5.1.

Datasets & Evaluation Protocols
We evaluate the proposed algorithm on three popular large-scale autonomous driving datasets. The Cityscapes (CS) [11] dataset and Berkeley Deep Drive (BDD) [44] dataset are real scenes captured in Europe and the USA respectively. In particulat, BDD captures varying illumination conditions, seasonal changes. GTA5 [30] is a popular synthetic driving dataset, and majorly emerged out of computer games. For Cityscapes, we use only the finely annotated images. The class definitions in all these datasets are compatible with each other.
We evaluate our models on the validation images of the target domain dataset, using the standard segmentation evaluation metrics: Intersection over Union (IoU) and pixel wise accuracy. The IoU score is calculated as the ratio of intersection and union of the ground truth mask and the predicted mask for each class. We report classwise IoUs for and also compute the mIoU (mean IoU) as the mean of all classwise IoU scores. Additionally, we report the overall pixel accuracy as the ratio of the pixels classified correctly to the number of overall pixels.

Implementation details
We follow the standard procedure for training a GAN and alternate between two steps: i) Fix the discriminator and train the segmentation network with segmentation loss (source domain), domain discrimination loss (target domain) and distillation losses (source and target domains) ii) Fix the generator network and train the discriminator. Details regarding the learning rate, optimizers and GPU configurations are provided in the supplementary material.

Experimental results
The performance of our model is evaluated in various distillation paradigms on real-to-real and synthetic-to-real scenarios. Extensive ablation studies are also carried out to determine the performance of various components of our model under various settings.

Real to real adaptation: Berkeley Deep Drive to Cityscapes
The results of domain-adaptive distillation from a real environment to another real environment viz., BDD to CS are shown in Table 1(I) (Visual results in Fig. 3). The first two rows represent the baseline teacher(DRN-D-38, 26.5 M parameters) and student(DRN-D-22, 16.4 M parameters) networks respectively, that are trained using multi-level DA [35]. The results in the subsequent four rows correspond to distillation via the four distillation paradigms (section 3.4). The weights for knowledge distillation (in both source and target domains) are set at 0.1, 0.01 and 1.0 for λ KL (output level), λ M SE (feature level) and λ pseudoT (output level) respectively. For KL divergence distillation at the feature level, we set the hyperparameter as one-tenth of its counterpart at the output level.
Analysis of the effects of distilling via the four distillation paradigms ( as per Fig 2): As we can observe in Table 1, source distillation (case (a)) and target distillation (case (b)) outperform the corresponding undistilled student network by 10.43 % and 14.08 % (4 and 5.4 mIoU points in terms of absolute numbers) respectively. Target distillation performs better than source distillation. This can be ascribable to the fact that distilling only in the target domain reduces the bias of the model towards the source domain, and improves performance in the target domain. In addition, our network in case (b) (target distillation) outperforms even the teacher network by 3.30 % (1.4 mIoU points in terms of absolute numbers). Further, in concurrence with our intuition, case (c) (where both source and target distillation are done simultaneously) performs better than both case (a) and case (b), achieving an mIoU of 43.97 (14.71 % and 3.87 % relative improvement over the student and teacher networks respectively). Among all the distillation case studies, we observe that case (d) performs the best with a improvement of 15.18 % and 4.29 % (5.82 and 1.82 mIoU points respectively) over the student and teacher networks respectively. This is because the model in this case has the best of both worlds -it is initialised with the weights of case (c) thus providing it with the pre-requisite information necessary for source distillation. Finetuning it with target distillation brings target distillation at the focus of the model thus improves the results in the target domain via generalization. We also accredit the improved performance gain of the student network via knowledge distillation to the customized objective functions that we employed in this task, such as cross-entropy loss with pseudo teacher labels L pseudoT . We conjecture that the dark knowledge [16] encapsulated within these pseudo-labels in both source and the target domains substantially augment the individual performance of the compact student network. The fact that our network surpasses even the teacher network by 4.29 % (1.82 mIoU points in terms of absolute numbers), which is an appreciable number, is commendable given that the teacher network has almost 10 M parameters more than the student network. We notice similar trends in the mAcc scores too.

Synthetic to real adaptation: GTA5 to Cityscapes
Experiments on the synthetic to real dataset pair: GTA5 to Cityscapes with DRN-D-38 teacher (26.5 M parameters) and DRN-D-22 student (16.4 M parameters) are presented in Table 1(II) (Visual results in Fig. 3). The trends are analogous to the real to real adaptation case. Source distillation (case (a)) shows an improvement of 5 % over the undistilled student network (1.52 mIoU points). The other distillation paradigms (case b,c,d) not just outperform the undistilled student network by 8.52 % -11.25 % (1.52 -3.42 mIoU points in terms of absolute numbers), but also the teacher model by 1.50 % -4.06 % (0.49 -1.32 mIoU points in terms of absolute numbers). This improvement can be explained on the basis of the knowledge transfer from the teacher to student. Effect of change of teacher and student networks: It is important to study the effects of change of teacher and student networks in knowledge distillation algorithms ( Table [35] baseline architectures. Our distilled student networks demonstrate an improvement of 13.14 % -19.11 % (4.27 -5.81 mIoU points in terms of absolute numbers) over the corresponding undistilled student networks, thus showing the effect of knowledge transfer from a powerful and heavy teacher network to different lightweight student networks. Effect of change of Domain Adaptation backbone: Since our pipeline is immune to the internal domain adaptation strategy used in the teacher and student networks, it can be treated as a blackbox and can be replaced by any other powerful DA approach. Our domain adaptive distillation pipeline will help the student network to benefit accordingly. Table 2(b) shows the effect of using the domain adaptation method, ADVENT [38] with DeepLab (ResNet-101, 44.5 M parameters) backbone, as the teacher. We demonstrate an improvement of 20.63 % and 14.9 % (6.27 and 4.86 mIoU points respectively) over the corresponding undistilled DRN-D-22 and DRN-D-38 student networks respectively. SOTA comparisons: Since this paper marks the first approach towards this goal of tackling both domain adaptation and model compression issues in a simultaneous manner, the results shown in this paper set the benchmark for the problem. In addition, in the interest of thorough analysis, we compare the performance of our student model on the synthetic-to-real case against the performance of the current SOTA UDA methods on models with similar sizes, for fair comparison. The results are shown in Table 3. With the same backbone architecture (DRN-D-22, first row) and baseline DA strategy, our best model outperforms the popular multi-source DA method AdaptSegNet [35] by 4-6 mIoU points (14%-20%) with a model size that is 0.6x the model size of its counterpart. By extension, our model scales appropriately when evaluated against all other methods that have similar model sizes and are trained using similar DA strategies. This shows that our method enables our relatively lightweight model achieve SOTA results against comparatively heavier models, which is a testimony to the success of our proposed method.

Ablation Studies
To deduce the performance of the individual distillation loss functions, we conduct extensive ablation studies on the real-to-real adaptation case. We conduct these studies on distillation paradigm case (a) of Fig. 2. The rationale is that these results should scale for the other three cases as well.

Impact of various loss functions:
The impact of various distillation loss functions (which also correspond to studies on feature level distillation vs output level distillation) are shown in Table 4. For each of the distillation loss terms i.e., L KL , L M SE and L pseudoT , we conduct ablation studies by varying the corresponding hyper parameters (see Table 4(i),(ii) and (iii)). The ablation studies on loss term L M SE and L CE−pseudo are correspondent with feature level and output level distillation respectively. L KL is employed according to the MLD strategy. We observe that the loss function L pseudoT performs better than both L KL and L M SE , by achieving the best mIoU values of 40.27, 39.86 and 42.18 respectively. We observe that L KL performs its best at a weight of 0.4 at the output level(feature level:0.04). Similarly, L M SE performs its best at 0.01 and L pseudoT performs its best when its weight is 1. For pixels where the label (produced by the teacher network) is faithful, this loss function should mimic the ideal case of classical cross entropy loss function. A high hyperparameter (1.0) pushes the objective function towards this goal.
We also conduct experiments on various permutations of the three distillation loss functions, as per MLD scheme (see Table 4(iv)-(vii)). We observe that with careful tuning, each of the combinations can achieve better results than the individual loss terms involved. Our best results are obtained (mIoU 42.33) when we use all the three. 5.3.2 Impact of λ target (Table 4(viii)), ablation studies case (case Fig. 2(c))): The source distillation parameters are set at 0.1, 0.01 and 1.0 for the three loss terms respectively. For target distillation, we use the same parameters scaled by a factor λ target (see equation 7). The best results are obtained at a value of 1.0 (shown in bold). This can attributed to the same reason of ideal scenario where 1.0 works best for λ pseudoT . These teacher labels basically serve as a representative for target domain GT, where our problem is completely unsupervised.

Conclusion and Future work
We proposed a novel method for distilling domain adaptive segmentation knowledge in models with limited memory, which has important implications in autonomous driving scenarios. To the best of our knowledge, this paper  marks the first approach towards this goal. In this regard, we presented a multi-level distillation strategy and proposed a tailor-made multifarious loss function to simultaneously handle two key issues in segmentation models, domain gap and memory constraints. We instituted various distillation paradigms. Our experiments and extensive analysis show the success of our proposed method.