# An Object Detection Method Based on Feature Uncertainty Domain Adaptation for Autonomous Driving
## 3 Domain Adaptation Object Detection Based on Feature Uncertainty
### Problem Definition  
Following the common representation of domain adaptation methods, the image from the source domain is represented as \(X_{S}=\{{{x_{1}}^{S},{x_{2}}^{S},\ldots,{x_{i}}^{S}}\},i=1,2,\ldots,n_{S}\), the label from the source domain is represented as \(Y_{S}=\{{y_{1}}^{S},{y_{2}}^{S},\ldots,{y_{i}}^{S}\},i=1,2,\ldots,n_{S}\), and the image from the target domain is represented as \(X_{T}=\{{x_{1}}^{T},{x_{2}}^{T},\ldots,{x_{i}}^{T}\},i=1,2,\ldots,n_{T}\). For the target detection task, the feature extraction network \(F\) extracts features from the input image to obtain a feature map, which is then fed to the RPN network \(R\) to generate numerous Region of Interest (ROI) proposals. Finally, the detection head \(H\), consisting of multiple fully connected layers, produces the final object locations and classifications. The training loss in the source domain can be formulated as:  
\[\mathcal{L}_{det}{=\frac{1}{n_{S}}{\sum_{i=1}^{n_{S}}{H(R(F({x_{i}}^{S})),{y_{ i}}^{S})}}} \tag{1}\]  
For target domain data, similar loss objectives cannot be established due to the lack of labels \(Y_{T}=\{{y_{1}}^{T},{y_{2}}^{T},\ldots,{y_{i}}^{T}\}\). Therefore, existing methods [25; 26; 29] attempt to add an additional local image-level domain discriminator \(D_{img}\) to guide \(\text{argmin}|{F({x_{i}}^{S})-F({x_{i}}^{T})}|\), which enables the network to produce similar feature maps for images from different domains. The local image-level domain discriminator \(D_{img}\) can distinguish whether the current feature is from the source domain or the target domain and achieve domain adaptation through adversarial training by using the gradient reversal layer (GRL). The training objective can be represented as:  
\[\mathcal{L}_{img}{=\frac{1}{n_{S}}{\sum_{i=1}^{n_{S}}{D_{img}(F({x_{i}}^{S})), {l_{i}}^{S})}}}+\frac{1}{n_{T}}{\sum_{i=1}^{n_{T}}{D_{img}(F({x_{i}}^{T})),{l _{i}}^{T})}} \tag{2}\]  
where \({l_{i}}^{S}\) and \({l_{i}}^{T}\) represent the classification labels for source and target domains, respectively, with 0 and 1. Similarly, the domain adaptive training objective for the detection head \(H\) can be expressed as:  
\[\mathcal{L}_{ins}{=\frac{1}{n_{S}}{\sum_{i=1}^{n_{S}}{D_{ins}(H(R(F({x_{i}}^{ S}))),{l_{i}}^{S})}}}+\frac{1}{n_{T}}{\sum_{i=1}^{n_{T}}{D_{ins}(H(R(F({x_{i}}^{T}))), {l_{i}}^{T})}} \tag{3}\]  
Figure 2: Diagram of proposed domain adaptive target detection algorithm based on feature uncertainty. The black arrows represent the data flow of the detector during the prediction phase. The red The gray arrows and red arrows represent the data flow of the detector during the train phase.  
where \(D_{ins}\) refers to instance-level domain discriminator. The final total loss can be expressed as:  
\[\mathcal{L}=\mathcal{L}_{det}+\mathcal{L}_{img}+\mathcal{L}_{ins} \tag{4}\]  
However, directly aligning the features may result in misalignment of the already aligned features. To address this issue, this paper proposes an uncertain alignment module based on feature channel entropy. In addition, existing methods are not suitable for the problem of target position and classification output in object detection algorithms. Therefore, an instance-level uncertainty alignment module based on multiple classifiers and regressors is proposed.