# Swin-YOLO for Concealed Object Detection in Millimeter Wave Images
## 3 Theoretical Model
### The Proposed Object Detection Network
#### 3.2.3 Local Perception Swin Transformer (LPST) Layer  
The proposed Local Perception Swin Transformer (LPST) Layer consists of two consecutive Local Perception Swin Transformer Blocks, which, combined with the Local Perception Module (LPM), enable the Swin Transformer to obtain local information. The structure of the LPST Layer is shown in Figure 4a. The key component of the LPST Layer is the Swin Transformer Layer. The Swin Transformer Layers consist of two successive Swin Transformer Blocks in series. The two Swin Transformer Blocks are alternatively equipped with Window Multi-head Self-Attention (W-MSA) and Shifted Window Multi-Head Self-Attention (SW-MSA) modules. The first Swin Transformer Block computes multi-headed attention (MSA) in small windows within an image, and establishes a self-attention interaction between windows in the second Block. The Swin Transformer Block has a similar structure to the Transformer Block, with the difference that the MSA is replaced by the W-MSA and SW-MSA, while the rest of the structure remains the same. Specifically, the Swin Transformer Block consists of a window-based MSA module and an MLP layer. The W-MSA module, the SW-MSA module, and the MLP module are connected with LayerNorm layers and use the residual structure. Figure 4: The architecture of the Local Perception Swin Transformer (LPST). (**a**) The detailed structure of the Local Perception Swin Transformer Layer; (**b**) The detailed structure of the Local Perception Module. MSA is the core of the Transformer, which integrates the self-attention matrices of multiple independent subspaces through parallel self-attention calculations. For a feature maps \(X\in R^{H\times W\times C}\), after being transformed by linear projection and reshaping operations, it becomes \(Q,\ K,\ V\ \in\ R^{N\times C}\), where \(N=H\times W\). The self-attention can be expressed as follows:  
\[Z=AV, \tag{4}\]  
\[A\ =\textit{softmax}\Big{(}QK^{T}\Big{)}, \tag{5}\]  
where \(A\)\(\in R^{N\times N}\) is the attention matrix that represents the relationship between all elements and other elements in the feature map. Output \(Z\) aggregates global information. The W-MSA module is an improvement of MSA. Unlike the Transformer, it calculates self-attention within a window and introduces cross-window connections through the shifted windows. The design of shifted windows reduces the computational complexity of the Transformer and enables information transmission between different windows. In particular, for the feature map \(X\)\(\in R^{H\times W\times C}\), the window size is \(\text{m}\times\text{m}\) and the computational complexity \(\Omega\) is as follows:  
\[\Omega(\text{MSA})=4 HWC^{2}+2(HW)^{2}C, \tag{6}\]  
\[\Omega(\text{W-MSA})=4 HWC^{2}+2(HW)^{2}C, \tag{7}\]  
The SW-MSA module solves the problem of a lack of information interaction of W-MSA. It achieves cross-window communication through the shifted windows, as shown in Figure 5. First, the Swin Transformer uses W-MSA in Figure 5a to performs window partitioning of the input feature map and calculates the self-attention in each window. Subsequently, as shown in Figure 5b, each window is moved upwards and to the left by half of the window size, which generates new windows that provide connections between windows of Figure 5a. For efficient batch computation, the green, yellow, and red regions in Figure 5c are moved to the bottom, right, and bottom-right of the image, respectively, as illustrated in Figure 5d. In comparison with the YOLOv5 improved network that utilizes the Swin Transformer Encoder [47], SW-MSA effectively facilitates cross-window information interaction. Although the Swin Transformer alleviates the problem of lacking local correlation and structural information caused by positional encoding through shifted windows, large-scale spatial contextual information still cannot be well encoded. Therefore, we added the key component of extracting local information, the Local Perception Module, before each Swin Transformer Block.