# MD-TransUNet: An Image Segmentation Network for Car Front Face Design
## 2 Materials and Methods  
### Overall Architecture of the MD-TransUNet Network  
The proposed improved network adopts an encoder-decoder structure, as illustrated in Figure 1. The encoder utilizes the R50-ViT-B/16 model [25], which combines the Vision Transformer (ViT) with ResNet50. This combination enables the extraction of fine structures and texture information from images, offering robust feature extraction capabilities. In the decoder, the MSAG module is integrated before the two-dimensional sequence is fed into the Transformer layer. The MSAG module enhances the encoder's ability in multi-scale feature fusion and is concatenated with the upsampled features for precise localization. The DCGCN module is integrated into the connection between high-level and low-level features within the encoder and decoder. It projects image channels into a topological domain and integrates the characteristics of each channel within the topological graph, efficiently capturing the relationships among different feature maps. When the input image has a spatial resolution of \(H\times W\) and \(x\in R^{H\times W\times C}\) channels, i.e., \(x\in R^{H\times W\times C}\), it first undergoes local feature extraction via a CNN. The ViT model subsequently extracts features at both low and high levels, which are connected to the feature maps generated by the decoding module through cross-layer connections. This sequence is input into a 12-layer Transformer module for global information extraction. The Transformer module consists of multi-head self-attention (MSA), a multi-layer perceptron (MLP), and layer normalization (LN) [26]. Within the Transformer module, the image \(\chi\) is reshaped into a sequence of 2D patches of size \(P\times P\), represented as \(\left\{x_{p}^{i}\in R^{P^{2}\times C}\middle|1,\ldots,N,\ N=(HW)/P^{2}\right\}\), as shown in Equation (1). \[z_{0}=\left[x_{p}^{1}E;x_{p}^{2}E_{i}\cdots;x_{p}^{N}E\right]+E_{pos}, \tag{1}\]  
In the equation, \(E\in R^{(P^{2}\cdot C)\times D}\) denotes the patch embedding projection, and \(E_{pos}\in R^{N\times D}\) denotes the positional embedding. The sequence patches, serving as an embedded sequence, first undergo layer normalization before being input into the MSA module. The MSA module captures global information by calculating correlations between different positions in the input sequence. Figure 1: The overall design of the enhanced TransUNet model. The output of the MSA is added to the normalized input through residual connections to retain original information and prevent gradient vanishing. This result is normalized again and fed into the MLP module for further feature extraction and transformation. Ultimately, the output from the MLP is combined with its input through residual connections, resulting in the final output of the \(l\)-th layer:  
\[\text{z}_{l}^{\prime}=\text{MSA}(\text{LN}(z_{l-1}))+z_{l-1}, \tag{2}\]  
\[z_{l}=\text{MLP}\big{(}\text{LN}\big{(}z_{l}^{\prime}\big{)}\big{)}+z_{l}^{ \prime}, \tag{3}\]  
In the equation, \(\text{LN}(\cdot)\) denotes the layer normalization operator, \(\text{z}_{l}^{\prime}\) represents the residual connection between the MSA output and \(\text{z}_{l-1}\), and \(z_{L}\) represents the encoded image. The TransUNet network employs sequence-to-sequence prediction with a self-attention mechanism. To address feature resolution loss in the Transformer model, TransUNet uses a CNN-Transformer hybrid encoder. This architecture allows the CNN to extract high-resolution features like the shape and boundaries of headlights, while the Transformer encodes global contextual information more effectively. The decoder positioned on the right of the TransUNet architecture is a cascaded upsampler (CUP), which decodes the hybrid encoder's output features to produce the segmentation result. The hidden feature sequence \(z_{L}\)\(\in\)\(R^{\frac{HW}{P^{2}}\times D}\) output by the hybrid encoder is reshaped from \(R^{\frac{HW}{P^{2}}\times D}\) to \(R^{\frac{HW}{P^{2}}\times D}\).