## 3 Method
### Overall Pipeline
#### 3.1.1 The Swin Transformer  
The Swin Transformer [36] is a vision Transformer architecture that has demonstrated considerable success within the realm of computer vision in recent years. The fundamental concept underlying the Swin Transformer involves transitioning the computation of the self-attention mechanism from a global to a local mode. In conventional Transformer models, every pair of elements within the input sequence is subjected to computation, which proves to be inefficient for the processing of high-resolution images. To mitigate this challenge, the Swin Transformer incorporates local and shifted windows, thereby significantly reducing computational complexity while maintaining the capacity to model global information effectively. In the Swin Transformer architecture, the initial step involves partitioning the input image into numerous smaller windows, which are subsequently transformed into fixed-dimensional vectors via Linear Embedding. The computation of self-attention is then performed within each individual window, leading to a notable reduction in computational complexity. To mitigate the challenges associated with long-range dependencies that arise from the localized nature of the windows, the Swin Transformer incorporates a window-shifting mechanism. This mechanism facilitates effective interactions among neighboring positions, thereby enabling the model to capture a more extensive range of global information. In conventional self-attention frameworks, the representation of each position is contingent upon all other positions within the input, resulting in substantial computational demands when handling large images. Conversely, the Swin Transformer addresses this issue by segmenting the input image into smaller local windows, applying self-attention mechanisms exclusively within these defined windows. Specifically, given an input feature matrix \(X\in\mathbb{R}^{H\times W\times C}\), where H and W represent the height and width of the image and C represents the number of channels, the Swin Transformer divides it into multiple M \(\times\) M windows and performs self-attention within each window. The self-attention mechanism applicable to a window can be articulated using the following formula:  
\[\text{Attention}(Q_{w},K_{w},V_{w})=\text{softmax}\bigg{(}\frac{Q_{w}K_{w}^{ T}}{\sqrt{d_{k}}}\bigg{)}V_{w} \tag{1}\]  
Here, \(Q_{w}\), \(K_{w}\), and \(V_{w}\) represent the Query, Key, and Value matrices, respectively, while \(d\) denotes the dimension of the Query/Key. In this framework, the matrices designated as Query, Key, and Value are computed within a specified window, with the dimension of the key. The implementation of this localized window strategy in the Swin Transformer restricts the attention mechanism to smaller segments, thereby enhancing the computational efficiency considerably. To address the challenges associated with long-range dependencies in conventional self-attention mechanisms, the Swin Transformer incorporates a shifted window approach. This method involves displacing the windows from their initial positions at each stage, thereby facilitating interactions among neighboring positions and effectively capturing long-range dependencies. Furthermore, the Swin Transformer employs a hierarchical architecture that progressively enhances feature dimensions from lower resolution inputs. This design not only preserves computational efficiency but also enables the processing of more detailed image information. The output features generated at each layer are integrated with features from other layers through self-attention mechanisms within localized windows, allowing the model to incrementally acquire global semantic insights regarding the image. This hierarchical framework not only mitigates computational expenses but also adeptly manages large-scale image datasets.