## 3 Methodology
### Decoder  
The decoder of the SegMine model solves the semantic segmentation problem by generating masks. Previous decoders for pixel-by-pixel classification ignored the importance of contextual learning when assigning labels to each pixel, and feature upsampling is prone to cause blurring of the boundaries of the mining area. In order to fully utilize the learned contextual semantic features to solve the problem of sticky boundaries and blurred boundaries of the mining area, the attention mask decoder is proposed. The attention mask decoder generates meaningful similarity mapping and then converts the similarity mapping into a segmentation mask. In order to obtain segmentation results with semantic information, it avoids the possible accuracy degradation caused by downsampling and then upsampling operations on feature maps. The decoding process consists of three main steps: generating a classification token, generating a segmentation mask, and completing semantic segmentation. First, the attention mask module takes the global semantic features output from Transformer blocks as input and generates a specific classification token that represents a mining area. Second, it calculates the similarity between the classification token and the global semantic features and converts the similarity mapping into a segmentation mask through _Sigmoid_. Meanwhile, the information interaction between the global semantic features and the classification token is realized through cross-attention calculation so that the classification token contains global semantic information and generates meaningful similarity mapping. Finally, the module outputs the updated classification token and \(L\) attention masks. The classification token is linearly transformed using the _SoftMax_ operation to obtain the class probability prediction and thereby determine the presence of the class of open-pit mining areas in the image. The combined \(L\) attention masks are then multiplied term by term with the class probability prediction in order to obtain the final segmentation output. In the overall structure, the Attention Mask module is used after each Transformer block, and the final segmentation mask is obtained by summing the Attention Mask outputs from the Attention Mask module. The class probability prediction of the classification token is multiplied with the segmentation mask item by item in order to achieve the semantic segmentation of the mining area. The overall flow of the attention mask module is shown in Figure 3.  
First, the module generates a sequence of learnable classification token with category number \(C\) based on the input global semantic feature \(G\in R^{C\times D}\) and calculates the feature similarity between the classification token and the global semantic feature. The two sequences are linearly transformed with the classification token as query \(Q\) and the global semantic features as key \(K\) and value \(V\). \[Q=GW_{q}\in R^{C\times D} \tag{12}\]\[K=F_{i}W_{k}\in R^{N\times D} \tag{13}\]  
\[V=F_{i}W_{v}\in R^{N\times D} \tag{14}\]  
where \(F_{i}\) is the image feature output by the \(i\)-th Transformer block, and \(W_{q}\), \(W_{k}\), and \(W_{v}\) are three trainable parameter matrices. The similarity mapping between the categorized token and the global semantic feature query \(Q\) and key \(K\) is computed by dot product. \[Similar(Q,K)=\frac{QK^{T}}{\sqrt{d}}\in R^{C\times N} \tag{15}\]  
The similarity mapping is input to \(SoftMax\) to obtain the cross-attention weights, and the cross-attention weights are multiplied term by term with \(V\) to obtain the result of the classification token update. The updated categorization token is used as the categorization token for the next attention mask decoder. \[CrossAttention(Q,K)=SoftMax(Similar(Q,K)) \tag{16}\]  
\[CA(G,F_{i})=CrossAttention(Q,K)\cdot V\in R^{N\times D} \tag{17}\]  
Second, similarity mapping is converted to semantic mask by \(Sigmoid\).