## 3 Results and Discussion  
### Implementation Details and Evaluation Index  
The model was trained using Python 3.7, PyTorch 1.10.0 and CUDA 11.3, with Windows operating system and NVIDIA GeForce RTX3090 GPU model (AUSTeK Computer Inc., Taipei, Taiwan). Based on the performance of the computing device, the batch size for model training is set to 2, the epoch is 50, the total number of iterations of the model is 10,000, and the patch size input to the Transformer network is 16. The Momentum-SGD optimizer trains the model to speed up the training of the model so that it converges quickly. The initial learning rate of the model is set to 0.01, the momentum parameter is set to 0.9, and the weight attenuation coefficient is 0.0001.  
The difference between the predicted results and the true results is calculated by the loss function during the training process to optimize the training model. The cross-entropy loss function is commonly used in classification problems to evaluate the degree of difference between the predicted pixel value distribution probability of the model and the ground truth. Dice loss is a loss function used to measure the degree of overlap between model prediction results and ground truth, which pays more attention to the target region, so it can solve the category imbalance problem in image segmentation to a certain extent. In response to the problem of variable target size and shape in solidified region image segmentation as well as the significant difference in the proportion of foreground and background occupation, this paper adopts a loss function combined cross-entropy loss and dice loss to measure and optimize the training results. The calculation formula for the loss function \(L\) is as follows:  
\[L=\lambda L_{ce}+\mu L_{dice} \tag{1}\]  
\[L_{ce}=-\sum_{i=1}^{N}y_{i}logy_{i}^{\prime} \tag{2}\]  
\[L_{dice}=1-2\sum_{i=1}^{N}y_{i}y_{i}^{\prime}/\left(\sum_{i=1}^{N}y_{i}+\sum _{i=1}^{N}y_{i}^{\prime}\right) \tag{3}\]  
Among them, \(L_{ce}\) is the cross-entropy loss, and \(L_{dice}\) is the dice loss. \(y_{i}\) is the label value, \(y_{i}^{\prime}\) is the predicted value, \(N\) is the total number of pixels, \(\lambda\) and \(\mu\) are the weight parameters of each loss function, which are 0.6 and 0.4, respectively.  
In this paper, the intersection over union (\(IoU\)) and dice similarity coefficient (\(Dice\)) are used as evaluation indices for segmentation results. \(IoU\) reflects the ratio of the intersection and union regions of pixels between image prediction results and ground-truth labels. \(Dice\) evaluates the degree of overlap between prediction results and labels. Both \(IoU\) and \(Dice\) are metrics used to measure the similarity between two sets, which are used to evaluate the similarity between the segmentation results predicted by the network and the manually annotated results in semantic segmentation tasks. Since the \(IoU\) focuses more on the overall segmentation performance, while the \(Dice\) is more sensitive to the segmentation of small objects, this paper employs both metrics simultaneously to achieve a more balanced evaluation. The calculation formula for both are as follows:  
\[Dice=2\times TP/\left[(TP+FN)+(TP+FP)\right] \tag{4}\]  
\[IoU=TP/(TP+FN+FP) \tag{5}\]  
For binary classification tasks, \(TP\) in the equation represents the sample that is predicted to be positive, and the ground-truth label is positive. \(FN\) represents the sample that is predicted to be anti-class, but the ground-truth label is positive. \(FP\) represents the samplethat is predicted to be positive, but the ground-truth label is negative. \(TN\) represents the sample that is predicted to be anti-class, and the ground-truth label is negative.