## 2 Methodology
### Double-Branched Backbone
CSWSA in CSwin is a special self-attention mechanism, as shown in Figure 3. Firstly, the \(K\) attention heads \(h_{i}(i\in[1,K])\) in the multi-head self-attention mechanism are divided into two groups, and the cross area is divided into horizontal and vertical bar areas, in which the width of the bar area is controlled by adjusting the SW value. Two sets of attention heads compute local self-attention within horizontal and vertical strip regions, respectively. Local Enhanced Position Encoding (LEPE) is adopted to encode positional information. The function of LEPE is to conduct depthwise separable convolution on the input feature vectors. Subsequently, the features enhanced by LEPE are integrated with the generated attention features via a residual connection. Finally, the outcomes from the horizontal and vertical directions are merged using the Concat operation to generate cross-shaped attention features. In contrast to the full self-attention mechanism, CSWSA cuts down on computational costs, and LEPE enhances the capacity to represent local information. For the input features \(X\in R^{(H\times W)\times C}\), \(K\) attention heads are generated by linear projection, and then these attention heads are divided into two groups. One set of attention heads carries out self-attention computation horizontally, and the other set does so vertically. Taking a horizontal self-attention head calculation as an example, the input feature \(X\) is split into \(M\) (i.e., \(\frac{H}{SW}\), horizontal bar features \(X^{i}(i\in[1,M])\), where \(SW\) is the width of the horizontal bar region. After that, each horizontal bar feature \(X^{i}\) was self-focused and calculated to obtain the feature \(Y^{i}\). Finally, \(M\) features \(Y^{i}\) are spliced together to obtain the  
Figure 3: The particular design of the self-attention mechanism within the cruciform window. \(\oplus\) represents feature addition. output of the \(k\)-th horizontal attention head. The formula for calculating the \(k\)-th horizontal attention head \(H\_Atten_{k}\) is as follows:  
\[X=[X^{1},X^{2},...,X^{M}],\text{where }X\in R^{(H\times W)\times C},X\in R^{(SW \times W)\times C},M=\frac{H}{SW} \tag{1}\]  
\[Y^{i}_{k}=Atten(X^{i}W^{Q}_{k},X^{i}W^{K}_{k},X^{i}W^{V}_{k}),i\in[1,M] \tag{2}\]  
\[Atten(Q,K,V)=softmax(\frac{QK^{T}}{\sqrt{d}})\times V+DWconv(V) \tag{3}\]  
\[H\_Atten_{k}(X)=[Y^{1}_{K},Y^{2}_{K},...,Y^{M}_{K}] \tag{4}\]  
where \(X^{i}W^{Q}_{k},X^{i}W^{K}_{k}\), and \(X^{i}W^{V}_{k}\) represent the projection matrix of queries, keys, and values for the \(k\)-th attention head, and DWConv for the depth separable convolution. The formula for calculating the vertical attention head is similar to the one above, with the only difference being the width of the initial split input feature, i.e., \(M\) becomes \(\frac{W}{SW}\cdot\frac{K}{2}\) horizontal attention head and \(\frac{K}{2}\) vertical attention head are concatenated to form the output of CSWSA, and the formula is as follows:  
Figure 1:0  
\[h_{k}=\left\{ \begin{array}{ll}H\_Atten_{k}(X)&\quad k\in[1,\frac{K}{2}]\\ V\_Atten_{k}(X)&\quad k\in[\frac{K}{2}+1,K]\end{array} \right. \tag{6}\]  
where \(W^{0}\) represents the projection matrix, \(h_{k}\) represents the \(k\)-th attention head, and \(H\_Atten_{k}\) or \(V\_Atten_{k}\) represents the \(k\)-th horizontal or vertical attention head calculation. This kind of cross-cutting window effectively expands the attention range of word vectors, and also greatly reduces the computational cost of the attention mechanism.