## 3 Proposed Method
### Cross-Attention Feature Fusion Module (CaFF)  
As shown in Figure 2, the features extracted from the Swin Transformer and ResNet50 branches are input into the CaFF module. The purpose of this module is to achieve complementary fusion of features from the two different branches through a cross-branch attention mechanism. The feature maps from the Swin Transformer and ResNet50 branches are labeled as \(S_{1}\) and \(R_{1}\), respectively. The design inspiration for this algorithm comes from the multi-head attention mechanism in the transformer architecture, aiming to enhance feature representation through cross-modal interactions. Compared to traditional feature fusion methods, the CaFF algorithm can not only capture more detailed information but also handle noise and interference more effectively, demonstrating superior performance across various application scenarios. The Algorithm 1 flowchart is shown below:  
```
0:\(F_{1}\), \(F_{2}\)\(\triangleright\) Two input feature maps
0:\(output\)\(\triangleright\) The fused output feature map
0: Apply \(low\_conv\) on \(F_{1}\) to obtain \(F_{1}^{\prime}\)
0: Extract \(K_{1}\), \(Q_{1}\), \(V_{1}\) from \(F_{1}^{\prime}\)
0: Extract \(K_{2}\), \(Q_{2}\), \(V_{2}\) from \(F_{2}\)
0: Reshape \(K_{1}\), \(Q_{1}\), \(V_{1}\) for attention computation
0: Reshape \(K_{2}\), \(Q_{2}\), \(V_{2}\) for attention computation
0: Compute attention matrix \(AM_{1}=\text{Softmax}(Q_{1}^{\top}\cdot K_{2})\)
0: Apply attention: \(out_{1}=\alpha\cdot V_{1}\cdot AM_{1}^{\top}+F_{1}\)
0: Compute new \(K\), \(Q\), \(V\) from \(out_{1}\)
0: Compute \(Q_{3}=Q+Q_{2}\)
0: Compute attention matrix \(AM_{2}=\text{Softmax}(Q_{3}^{\top}\cdot K_{1})\)
0: Apply attention: \(out_{2}=\beta\cdot V_{2}\cdot AM_{2}^{\top}+F_{2}\)
0: Compute \(Q_{4}\) from \(out_{2}\)
0: Compute attention matrix \(AM_{3}=\text{Softmax}(Q_{4}^{\top}\cdot K)\)
0: Apply attention: \(out_{3}=\gamma\cdot V\cdot AM_{3}^{\top}\)
0: Apply final convolution on \(out_{3}\): \(output=conv3(out_{3})\)
0:return\(output\)\(\triangleright\) Final fused output feature map
```  
**Algorithm 1** Cross-attention feature fusion (CaFF) algorithm  
The main design of this module is based on three feature vectors: the query vector \(Q\), key vector \(K\), and value vector \(V\). These vectors are derived from the input feature maps of each branch. To meet the computational requirements of cross-branch attention fusion, \(S_{1}\) and \(R_{1}\) are first processed through a sequential network. This network con  
Figure 2: CaFF module network architecture. sists of two \(1\times 1\) convolution layers and a batch-norm layer, referred to as the _low_Conv_ convolution layer. \[S_{1}=low\_Conv(Input_{Map1}) \tag{7}\]  
\[R_{1}=low\_Conv(Input_{Map2}) \tag{8}\]  
This operation successfully adjusts the number of feature channels to ensure consistency in the channel dimensions during cross-branch feature interaction. In the cross-attention mechanism, query vector \(Q_{2}\) and key vector \(K_{1}\) are multiplied and pooled to generate the first attention matrix, \(AM_{1}\), which provides the attention weight distribution. \[AM_{1}=\text{Softmax}(K_{1}\times Q_{2}^{T}) \tag{9}\]  
Next, \(AM_{1}\) is multiplied with the value vector \(v_{1}\) from the Swin Transformer branch to generate the weighted feature, \(Out_{1}\). In these three rounds of computation, the attention matrices are scaled by the coefficients \(\alpha\), \(\beta\), and \(\gamma\). \[Out_{1}=\alpha\cdot V_{1}\cdot AM_{1}^{T}+S_{1} \tag{10}\]  
Similarly, the query vectors \(Q_{1}\) and \(Q_{3}\) are fused and multiplied with the key vector \(K_{2}\), followed by a pooling operation to generate the second attention matrix, \(AM_{2}\):  
\[AM_{2}=\text{Softmax}(K_{2}\times(Q_{1}+Q_{3})^{T}) \tag{11}\]  
Then, \(AM_{2}\) is multiplied with the value vector \(V_{2}\) from the ResNet50 branch to obtain the weighted feature \(Out_{2}\).