## 3 Methods
### Region-Adaptive Attention Mechanism  
In cellular segmentation tasks, the inherent challenges posed by highly heterogeneous morphological and textural characteristics of cells, particularly in regions exhibiting fine structures, low contrast, or ambiguous boundaries, significantly compromise the effectiveness of conventional convolutional neural networks (CNNs) and standard attention mechanisms. These limitations primarily manifest in two aspects: (1) Traditional attention frameworks employ static weighting strategies that fail to adaptively recalibrate feature importance according to regional complexity levels, resulting in insufficient attention allocation to diagnostically critical areas. (2) The inherent confirmation bias in pseudo-labeling processes tends to reinforce erroneous high-confidence predictions during iterative training, thereby exacerbating error propagation and ultimately degrading segmentation accuracy. To address these critical issues, we proposed a region-adaptive attention (RAA) mechanism based on gradient changes, as illustrated in Figure 3. By dynamically adjusting focus on different regions, this mechanism mitigates the model's reinforcement of incorrectly predicted areas, thereby improving segmentation performance in complex regions. Specifically, each scale \(T_{i}\) (the four different scale outputs from the encoder) is processed to compute the difficulty score \(g(x_{i})\) for each region. This score is derived based on the gradient variation within the region, reflecting the complexity of feature changes in that region. For each region \(x_{i}\), its gradient magnitude \(|\ \
abla I(x_{i})\ |\) is computed, which represents the degree of pixel intensity variation in the region. The variance \(g(x_{i})\) in the gradient  
Figure 3: Structure diagram of the region-adaptive attention. magnitude for the region is then calculated using Equation (12) to assess the difficulty level of the region. \[g(x_{i})=\text{Var}(\mid\
abla I(x_{i})\mid) \tag{12}\]  
Regions with large gradient variance typically exhibit high feature variation, such as blurred boundaries or complex textures, indicating that these regions are more challenging. Consequently, they will receive greater attention in subsequent steps. Based on the gradient variance \(g(x_{i})\), dynamic weights \(\alpha_{i}\) are assigned to each region to reflect the level of attention required. During computation, the Sigmoid function is applied to map the difficulty score, thereby obtaining the dynamic weights as shown in Equation (13):  
\[\alpha_{i}=\frac{1}{1+\exp(-g(x_{i}))} \tag{13}\]  
This weight ensures that regions with larger gradient variations (i.e., higher difficulty regions) receive increased attention, enabling the model to concentrate its resources on processing these complex areas more effectively. Through this dynamic adjustment mechanism, the model adaptively prioritizes challenging regions during training while mitigating overfitting to easily distinguishable regions. Then, a multi-head self-attention mechanism [41] was adopted to combine features of different scales, and a dynamic weight \(\alpha_{i}\) was introduced in the attention calculation to further enhance the focus on regions with higher difficulty. Specifically, for each scale \(T_{i}(i=~{}1,~{}2,~{}3,~{}4)\), the corresponding Query, Key, and Value were calculated through Equations (4)-(14):  
\[Q=\hat{T}_{i}W_{Q},\quad K=\sum\hat{T}W_{K},\quad V=\sum\hat{T}W_{V} \tag{14}\]  
Among them, \(W_{Q}\), \(W_{K}\), and \(W_{V}\) are the corresponding weight matrices, \(\hat{T}_{i}\) represents the input region tokens, and \(\sum\hat{T}\) is the result of concatenating all scale outputs. The similarity matrix \(W_{i}\) is calculated through these inputs, and the weighted output \(\hat{O}_{i}\) is obtained through Equation (15) to acquire the feature representation of each region.