## 3 Methodology
### Encoder  
The encoder of the SegMine model is constructed based on Vision Transformer. In order to solve the segmentation errors caused by the disappearance of local area features such as edges and textures in the mining area, as well as the loss of small-scale features in the mining area, a multi-scale local spatial feature complementary module is proposed. This module learns the multi-scale local spatial features of the image through convolutional bypass branching and then injects the multi-scale local spatial features into the global features of Transformer blocks by using the cross-attention mechanism. Having completed this, the ability of the model to obtain local spatial detail information is enhanced, and problems such as the disappearance of small-scale features and a lack of information expression in the mining area are overcome to a large extent. The encoding process consists of three main steps: multi-scale local spatial feature acquisition, global semantic feature construction, and feature inter-injection. First, multiple convolution operations are performed on the original image in order to aggregate the multi-scale correlations of the image and obtain multi-scale local spatial features. Second, the original images are passed into Vision Transformer to construct global semantic features. Finally, a cross-attention operation is performed on the multi-scale local spatial features and global semantic features, which can achieve the injecting of local spatial features into the global semantic features and, at the same time, the injecting of global semantic information into the multi-scale local spatial features. The multi-scale local spatial feature complementary module is interspersed between Transformer blocks in order to realize the information interaction between the multi-scale local spatial features and the global semantic features so that the global semantic features output from each Transformer block contain multi-scale local spatial features. In SegMine, Vision Transformer consists of a patch embedding layer and L Transformer block layers. The patch embedding layer divides the input image into equal-sized image blocks. The linear projection layer maps the features into \(D\) dimensions and converts the extraction operation of image features into a sequence-to-sequence task. The Transformer block layer encodes the image features and learns the long-range semantic information of the image by using the mechanism of multi-head attention. The input image for the patch embedding layer is \(\mathbf{x}\in R^{H\times W\times C}\), where \(H\), \(W\), \(C\) denote the height, width, and number of channels of the input image, respectively. Through the patch embedding layer, the original image is partitioned into a sequence of \(N\) fixed-size image blocks \(\left\{\mathbf{x}_{p}^{i}|i=1,2,\cdots N\right\}\), \(N=HW/P^{2}\), and \(P\) is the image block size. Then, through the linear mapping layer, the image block sequences are mapped into \(D\)-dimensional sequences in order to accommodate the computation of multi-head self-attention. Finally, a learnable positional embedding \(P_{pos}\in R^{N\times D}\) is added to the \(D\)-dimensional sequence in order to preserve the positional information between image blocks. The input sequence of Transformer blocks can be represented as (1):  
\[F_{0}=\left[\mathcal{F}\left(\mathbf{x}_{p}^{1}\right);\mathcal{F}\left(\mathbf{x}_{p} ^{2}\right);\cdots;\mathcal{F}\left(\mathbf{x}_{p}^{N}\right)\right]+P_{pos} \tag{1}\]  
where \(\mathcal{F}\) denotes the linear mapping of markers into \(D\)-dimensional features that can be processed by the Transformer. The output sequence \(F_{0}\in R^{N\times D}\) of the patch embedding layer is fed into the Transformer blocks for encoding and learning global semantic features. In this case, the Transformer block consists of multi-head self-attention block (_MSA_) and multilayer perceptron block (_MLP_) in an alternating manner.