# Segmentation of Stone Slab Cracks Based on an Improved YOLOv8 Algorithm
## 2 Improved YOLOv8 Segmentation Network  
### U-NetV2  
U-Net is a convolutional neural network based on an encoder-decoder architecture [29], as shown in Figure 1. Its core innovation lies in the symmetric contracting path, which captures global contextual information. While U-Net effectively captures object contours, its feature fusion strategy is relatively simple. In addition, traditional convolution has limited the ability to model complex textures. U-NetV2 builds upon the original U-Net structure and introduces improvements in three key areas: feature fusion efficiency, semantic alignment, and computational cost. First, a dynamic feature recalibration mechanism is introduced. It adaptively assigns channel weights and focuses on key spatial regions from the encoder, helping to reduce semantic misalignment across hierarchical features. Second, heterogeneous convolution replaces standard convolution. Residual connections are added to enhance gradient flow and improve sensitivity to fine structures and weak edges. In addition, U-NetV2 [30] adopts a progressive feature refinement strategy during decoding. A multi-level cross-scale interaction module nonlinearly fuses low-resolution semantic information with high-resolution detail features. This improves boundary accuracy in complex scenes. Through dynamic feature interaction and cross-scale reasoning, U-NetV2 achieves better feature decoupling and semantic consistency under limited computational resources. Figure 1: U-Net network structure. As shown in Figure 2, the U-NetV2 architecture consists of an encoder, an SDI module, and a decoder. Given an input image I\(\in\)RH \(\times\) W \(\times\) C, the encoder first extracts feature representations. These features are then passed to the SDI module for further processing. In the multi-level feature representations generated by the encoder, spatial and channel attention modules are jointly applied. This setup enables the network to dynamically aggregate local pixel-level details while modeling high-order semantic dependencies across channels. The dual-path attention fusion mechanism effectively enhances fine-grained spatial awareness and global channel responses in a complementary manner. \[f_{i}^{1}=\varphi_{i}^{c}(f_{i}^{8}(f_{i}^{0})) \tag{1}\]  
\(\varphi_{i}^{c}\) denotes the channel-wise dynamic recalibration function (implemented as a lightweight \(1\times 1\) convolution followed by sigmoid gating). \(\varphi_{i}^{8}\) denotes the 8-directional spatial offset generator. A \(1\times 1\) convolution is first introduced to compress the feature tensor along the channel dimension. The resulting low-dimensional feature tensor is denoted as \(f_{i}^{2}\). This tensor is then passed into the decoder. During each stage of decoding, \(f_{i}^{2}\) serves as the reference signal. Feature tensors from other layers are resized to match the spatial resolution of \(f_{i}^{2}\), enabling effective cross-level fusion and scale normalization. The specific operations are as follows:  
\[f_{ij}^{3}=\left\{ \begin{array}{ll}G_{\text{D}}\Big{(}f_{j}^{2},(H_{i},W_{i} )\Big{)}\text{ \emph{if j<i},}\\ G_{\text{I}}\Big{(}f_{j}^{2}\Big{)}\text{ \emph{if j=i},}\\ G_{\text{U}}\Big{(}f_{j}^{2},(H_{i},W_{i})\Big{)}\text{ \emph{if j>i},}\end{array} \right. \tag{2}\]  
To enhance multi-scale feature fusion, a heterogeneous transformation group is designed. It consists of adaptive average pooling (D) for dynamic receptive field adjustment, identity mapping (I) for preserving original feature topology, and bilinear upsampling (U). These components work together to build a multi-granularity feature representation space. Based on this, depthwise separable convolution is applied to normalize the recalibrated feature tensor. The detailed process is as follows:  
\[f_{ij}^{4}=\theta_{ij}\big{(}f_{ij}^{3}\big{)} \tag{3}\]  
\(\theta_{ij}\) denotes the learnable channel-wise gating function applied at a spatial location (\(i,j\)).