# MD-TransUNet: An Image Segmentation Network for Car Front Face Design
## 2 Materials and Methods
### MSAG Module  
The headlights and grilles in the front of a car exhibit distinct geometric shapes and size characteristics, which are crucial for segmenting automotive front face elements. Traditional image segmentation methods [27] often struggle to capture both large-scale structures and fine details simultaneously due to limitations in multi-scale information processing. To address this, we integrated the MSAG module, which computes attention weights at various scales. The architecture of the MSAG module is shown in Figure 2. It captures correlations across different regions of an image at multiple scales. The MSAG module extracts and fuses feature maps at various scales from the input image. Using a self-attention mechanism, it processes these feature maps to capture global and local information at different scales. This multi-scale attention mechanism dynamically adjusts the significance of features at each scale, filtering out irrelevant background noise, and enabling the model to focus on key features like headlights and grilles.  
Figure 2: Structure of the MSAG module.  
The MSAG module is integrated with skip connections to enhance the extraction of valuable features. To adaptively select features at different resolutions, three types of convolutions with varying receptive fields are used: \(1\times 1\) pointwise convolution; \(3\times 3\) ordinary convolution; and \(3\times 3\) dilation convolution. The \(1\times 1\) pointwise convolution is employed for linear transformation and dimensionality reduction, the \(3\times 3\) ordinary convolution is applied for detailed local feature extraction and enhancement, and the \(3\times 3\) dilation convolution is utilized to expand \(G\) the receptive field by introducing strategic gaps, thereby capturing broader and more comprehensive feature information. By combining these convolution operations and applying batch normalization (BN), it is ensured that the resulting feature maps have uniform dimensions, facilitating subsequent feature fusion.  
During feature fusion, the input feature \(f\) is extracted using three different convolution operations: \(f_{\text{Pointwise}}\), \(f_{\text{Ordinary}}\), \(f_{\text{Dilation}}\). After batch normalization, these three feature maps are represented as:  
\[f_{\text{Pointwise}}^{BN} =\text{BN}(\text{PointwiseConv}(f)), \tag{4}\] \[f_{\text{Ordinary}}^{BN} =\text{BN}(\text{OrdinaryConv}(f)),\] (5) \[f_{\text{Dilation}}^{BN} =\text{BN}(\text{DilationConv}(f)), \tag{6}\]  
The three output feature maps of the same size are fused, with the ReLU activation function non-linearly combining features of different scales. This allows the network to adaptively select and enhance valuable features. While retaining the diversity of the original features, the attention mechanism further strengthens the representation of important features. The valuable features are then selected through pointwise convolution, as shown in Equation (7):  
\[f_{\text{Concat}}=\sigma_{2}\Big{(}\text{Concat}\Big{\{}f_{\text{Pointwise}}^ {BN},f_{\text{Ordinary}}^{BN},f_{\text{Dilation}}^{BN}\Big{\}}\Big{)}, \tag{7}\]  
In the equation, \(f_{Concat}\) denotes the merged features, and \(\sigma_{2}\) denotes the ReLU activation function.  
After selecting valuable features from the fused feature maps, pointwise convolution is applied to the fused feature maps, generating a weight map through the Sigmoid activation function \(\sigma_{3}(\text{PointwiseConv}(f_{\text{concat}}))\). The resulting output feature from the multi-scale attention gate, \(f_{s}\) is then obtained:  
\[f_{s}=f\times\sigma_{3}(\text{PointwiseConv}(f_{\text{concat}}))+fs, \tag{8}\]