A shale microcrack identification model training method based on a scanning electron microscope image
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-05-20
- Publication Date
- 2026-08-11
AI Technical Summary
[0007]为此,本申请提供一种基于扫描电镜图像的页岩微裂缝识别模型训练方法,以解决现有技术难以满足对复杂微裂缝网络进行精细化提取的问题
[0038]本申请提供了一种基于扫描电镜图像的页岩微裂缝识别模型训练方法,包括:对扫描电镜图像数据集进行基于物理视场的多尺度归一化预处理,并采用分层采样策略平衡正负样本分布;将预处理后的扫描电镜图像数据集输入至包含UNet++编码器、ASPP多尺度增强模块和Transformer全局建模模块的混合编码器架构中进行多层次特征提取,得到深层特征表示;根据深层特征表示生成粗略边缘预测图,并上采样至多个不同分辨率,得到多个尺度的边缘引导图;利用UNet++解码器在多个层级上逐步上采样并融合深层特征表示,生成从粗到精的解码节点;对于每个解码节点,取对应尺度的边缘引导图,经激活函数转换为注意力权重,并采用乘性注意力机制对解码节点的解码特征进行空间自适应增强;将增强后的解码特征通过两个独立的卷积层分别生成分割分支预测和边缘分支预测;利用构建的多组件混合损失函数反向传播更新模型参数,从而得到训练好的页岩微裂缝识别模型。利用本申请提供的方法训练出的页岩微裂缝识别模型,可以显著提升复杂微裂缝网络的拓扑完整性、边界定位精度及预测可靠性,真正满足了复杂微裂缝网络精细化提取与定量分析的需求。
Smart Images

Figure CN122551099A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of shale microcrack identification technology, specifically to a method for training a shale microcrack identification model based on scanning electron microscope images. Background Technology
[0002] Microcracks, as an important component of rock microstructure, provide crucial evidence for fracture temperature, fluid conditions, and formation sequence. The study of microcrack orientation can provide key information for fault zone growth and evolution, regional stress field evolution, and seismic activity cycles. Scanning electron microscopy (SEM) images can characterize the microscopic morphology and structural features of rock materials at high resolution. Therefore, identifying microcracks based on SEM rock images is a fundamental task in digital rock analysis, microstructure characterization, and related engineering evaluation.
[0003] Traditional image processing methods for shale SEM images rely on manual observation, sketching, or manual interpretation. This approach is not only inefficient but also susceptible to the influence of observer experience, interpretation standards, and working conditions, resulting in high subjectivity, insufficient consistency, and difficulty in meeting the demands of batch processing. With the development of digital image processing and deep learning technologies, automatically identifying cracks in rock SEM images using image segmentation methods has become an important direction in this field.
[0004] Existing technologies attempt to introduce semantic segmentation networks into the task of crack extraction from shale electron microscopy images. For example, Y. Wu et al. (2024) integrated a comprehensive automatic identification and segmentation model for low-contrast cracks based on numerous shale CT images and multiple ablation experiments, naming it ShaleSeg. Y. Feng et al. (2024) proposed a novel visual foundation model (FFSwinNet) for shale crack porosity identification, taking advantage of the unique characteristics of shale electron microscopy (SEM) images. Y. Zhang and G. Ma (2025) proposed a hybrid framework integrating deep learning (ST-UNet) and clustering techniques to achieve high-precision microcrack characterization.
[0005] The patent document, with publication number CN115240041A and titled "A Method for Extracting Cracks from Shale Electron Microscopy Images Based on Deep Learning Segmentation Networks," provides a method for automatic crack identification and extraction in shale scanning electron microscope (SEM) images. This method uses a deep learning semantic segmentation network as its core. First, it obtains the main information of the cracks through a main content extraction module and introduces an attention mechanism into the network to enhance the response to key crack features. Then, it sets up an independent edge extraction branch and uses the Canny algorithm to extract high-frequency edge details from the original image. Next, it fuses the main features and edge responses to balance the integrity of the crack body with the expression of detailed boundaries. Finally, during the training phase, it uses a hybrid loss function consisting of cross-entropy loss, Dice loss, and SSIM loss for joint supervision, thereby achieving relatively accurate segmentation and structured extraction of cracks in shale SEM images under complex background interference.
[0006] While this method (i.e., the patent document with publication number CN115240041A) can improve fracture extraction performance to some extent, its technical approach still mainly relies on convolutional local feature extraction, traditional edge enhancement, and subsequent feature fusion. Therefore, in shale SEM images containing strong background interference, large scale spans, low target saliency, and sparse and fine fractures, existing techniques still need improvement in areas such as global dependency modeling, cross-scale feature representation, false detection suppression, boundary localization, and structural continuity preservation. In particular, existing loss function designs mainly focus on pixel-level overlap and image-level structural similarity, but fail to impose sufficient constraints on the connectivity and topological integrity of the fracture skeleton, thus making it difficult to fully meet the needs for refined extraction and quantitative analysis of complex micro-fracture networks. Summary of the Invention
[0007] To address this issue, this application provides a training method for a shale microcrack identification model based on scanning electron microscope images, in order to solve the problem that existing technologies are insufficient for the refined extraction of complex microcrack networks.
[0008] To achieve the above objectives, this application provides the following technical solution:
[0009] Firstly, a method for training a shale microcrack identification model based on scanning electron microscope images includes:
[0010] Step 1: Obtain the scanning electron microscope (SEM) image dataset, perform multi-scale normalization preprocessing based on physical field of view on the SEM image dataset, and use a hierarchical sampling strategy to balance the positive and negative sample distribution of the SEM image dataset;
[0011] Step 2: Input the preprocessed scanning electron microscope image dataset into the hybrid encoder architecture for multi-level feature extraction to obtain deep feature representations rich in multi-scale semantic information and global context; the hybrid encoder architecture includes a sequentially connected UNet++ encoder, an ASPP multi-scale enhancement module, and a Transformer global modeling module;
[0012] Step 3: Generate a coarse edge prediction map through a convolutional layer based on the deep feature representation, and upsample the coarse edge prediction map to multiple different resolutions to obtain edge guidance maps of multiple scales;
[0013] Step 4: Utilize the UNet++ decoder to progressively upsample at multiple levels and fuse the multi-scale semantic information and global context in the deep feature representation to generate decoding nodes from coarse to fine.
[0014] Step 5: For each decoding node, take the edge guidance map of the corresponding scale, convert it into attention weights through an activation function, and use a multiplicative attention mechanism to spatially adaptively enhance the decoding features of the decoding node to obtain the enhanced decoding features;
[0015] Step 6: The enhanced decoded features are passed through two independent convolutional layers to generate segmentation branch prediction and edge branch prediction, respectively; the segmentation branch prediction is used to output the crack region, and the edge branch prediction is used to output the crack boundary;
[0016] Step 7: Construct a multi-component hybrid loss function, use the loss function to calculate the loss value between the segmentation branch prediction and the real annotation, and between the edge branch prediction and the boundary target extracted from the real annotation, and backpropagate to update the model parameters, thereby obtaining the trained shale microcrack identification model.
[0017] Optionally, step 1 specifically includes:
[0018] Step 101: Obtain the pixel physical size of each image in the scanning electron microscope image dataset, and calculate the corresponding cropping window size based on the pixel physical size and the preset target physical field of view size;
[0019] Step 102: Define the positive sample sampling ratio. For each scanning electron microscope image in the scanning electron microscope image dataset, generate a random number. If the random number is less than the positive sample sampling ratio, perform positive sample priority sampling; otherwise, perform normal random sampling.
[0020] Step 103: Based on the Gaussian mixture model and the Bayesian information criterion, automatically cluster the pixel physical size of the images in the scanning electron microscope image dataset. Use K-means clustering to divide the images in the scanning electron microscope image dataset into at least two scale groups and assign different positive sample sampling ratios to each scale group.
[0021] Step 104: Scale the image block obtained by cropping according to the cropping window size to a fixed output space size using bilinear interpolation, and scale the corresponding label mask block to the same output space size using nearest neighbor interpolation;
[0022] Step 105: Perform data augmentation on the scaled image patch and maintain the spatial correspondence between the augmented image patch and the corresponding labeled mask block; the data augmentation includes random flipping, rotation, brightness and contrast jitter, adding Gaussian noise and Gaussian blur;
[0023] Step 106: Normalize the pixel values of the enhanced image block to the [0, 1] interval, and convert the labeled mask block into tensor format after binarization.
[0024] Optionally, in step 102, the positive sample priority sampling specifically includes: extracting all pixel positions with label values greater than zero from the label mask to form a positive sample coordinate set; performing morphological dilation on the positive sample region to increase the sampling hit probability; randomly selecting a pixel from the dilated positive sample region as the cropping center point; and calculating the starting coordinates of the cropping window based on the cropping center point to ensure that the cropping window contains a sufficient number of crack pixels.
[0025] Optionally, in step 2, the UNet++ encoder adopts a five-layer encoder structure, with the number of feature channels in each layer being 1, 2, 4, 8, and 16 times the number of basic channels, respectively. Each layer contains two main components: a feature extraction module and a downsampling module.
[0026] Optionally, in step 2, the ASPP multi-scale enhancement module employs six parallel branches to capture feature information at different scales.
[0027] Optionally, in step 2, the Transformer global modeling module uses a 3-layer coding block. Each coding block contains two sub-layers: a multi-head self-attention mechanism and a feedforward neural network. Both sub-layers are equipped with residual connections and layer normalization.
[0028] Optionally, in step 5, if the spatial dimensions of the edge guide map and the decoding feature to be enhanced are inconsistent, bilinear interpolation is used to adjust the edge guide map to the same spatial dimensions as the decoding feature.
[0029] Optionally, in step 7, the hybrid loss function includes binary cross-entropy loss, class imbalance loss, false positive penalty loss, topological continuity loss, and edge supervision loss.
[0030] Secondly, a method for identifying microcracks in shale based on scanning electron microscopy images includes:
[0031] Step A: Acquire scanning electron microscope (SEM) images and divide the SEM images into grids according to block size;
[0032] Step B: Input each image block after grid division into the shale microcrack identification model for identification, and stitch the prediction results of each image block together to obtain a complete identification image; the shale microcrack identification model is trained by the shale microcrack identification model training method based on scanning electron microscope images according to any one of claims 1-8;
[0033] Step C: Convert the identified image into a probability using the Sigmoid function, and binarize it according to a preset threshold to generate an initial mask;
[0034] Step D: Perform connected component analysis on the initial mask, remove connected components with an area smaller than a preset area threshold, and remove isolated noise points to obtain an area-filtered mask;
[0035] Step E: Morphological skeletonization is performed on the area-filtered mask, the centerline skeleton with a width of one pixel is extracted, the skeleton is marked with connected components, short branches with a length less than a preset length threshold are removed, and the main crack with a significant length is retained, finally obtaining the filtered segmentation mask.
[0036] Optionally, it also includes: performing multi-dimensional quantitative evaluation and qualitative visualization analysis of the segmentation mask from three levels: pixel level, skeleton level, and boundary level.
[0037] Compared with the prior art, this application has at least the following beneficial effects:
[0038] This application provides a training method for a shale microcrack identification model based on scanning electron microscope (SEM) images, comprising: performing multi-scale normalization preprocessing on the SEM image dataset based on the physical field of view, and balancing the distribution of positive and negative samples using a hierarchical sampling strategy; inputting the preprocessed SEM image dataset into a hybrid encoder architecture containing a UNet++ encoder, an ASPP multi-scale enhancement module, and a Transformer global modeling module for multi-level feature extraction to obtain deep feature representations; generating coarse edge prediction maps based on the deep feature representations and upsampling them to multiple different resolutions to obtain edge guidance maps at multiple scales; using the UNet++ decoder to progressively upsample and fuse the deep feature representations at multiple levels to generate decoding nodes from coarse to fine; for each decoding node, taking the edge guidance map at the corresponding scale, converting it into attention weights through an activation function, and using a multiplicative attention mechanism to spatially adaptively enhance the decoding features of the decoding node; generating segmentation branch predictions and edge branch predictions through two independent convolutional layers respectively; and updating the model parameters using a constructed multi-component hybrid loss function through backpropagation to obtain a trained shale microcrack identification model. The shale microcrack identification model trained using the method provided in this application can significantly improve the topological integrity, boundary positioning accuracy, and prediction reliability of complex microcrack networks, truly meeting the needs for refined extraction and quantitative analysis of complex microcrack networks. Attached Figure Description
[0039] To more intuitively illustrate the prior art and this application, exemplary drawings are provided below. It should be understood that the specific shapes and structures shown in the drawings should not generally be regarded as limiting conditions for implementing this application; for example, based on the technical concept disclosed in this application and the exemplary drawings, those skilled in the art are able to easily make conventional adjustments or further optimizations to the addition / reduction / classification, specific shapes, positional relationships, connection methods, size ratios, etc. of certain units (components).
[0040] Figure 1 The main flowchart of a shale microcrack identification model training method based on scanning electron microscope images provided in Embodiment 1 of this application;
[0041] Figure 2 A flowchart illustrating the training method for a shale microcrack identification model based on scanning electron microscope images, provided in Embodiment 1 of this application;
[0042] Figure 3 This is a schematic diagram of the ASPP multi-scale enhancement module structure provided in Embodiment 1 of this application;
[0043] Figure 4 This is a schematic diagram of the Transformer global modeling module structure provided in Embodiment 1 of this application;
[0044] Figure 5 This is a schematic diagram of the edge-guided attention structure provided in Embodiment 1 of this application;
[0045] Figure 6 Comparison of segmentation prediction results of various comparative models provided in Embodiment 1 of this application on the shale SEM microcrack test set;
[0046] Figure 7 This is a flowchart of a method for identifying microcracks in shale based on scanning electron microscope images, provided in Embodiment 2 of this application. Detailed Implementation
[0047] The present application will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0048] In the description of this application: unless otherwise stated, "a plurality of" means two or more. The terms "first," "second," "third," etc., in this application are intended to distinguish the objects referred to and do not have any special meaning in terms of technical connotation (e.g., they should not be construed as an emphasis on importance or order). Expressions such as "including," "comprising," and "having" also mean "not limited to" (certain units, components, materials, steps, etc.).
[0049] The terms used in this application, such as "upper," "lower," "left," "right," and "middle," are generally used to indicate the general relative positional relationship for the purpose of intuitive understanding by referring to the accompanying drawings, and are not absolute limitations on the positional relationship in the actual product.
[0050] Example 1
[0051] Please see Figure 1 and Figure 2 This embodiment provides a training method for a shale microfracture identification model based on scanning electron microscope (SEM) images. It aims to address issues in existing technologies such as high false positive rates, poor topological connectivity, weak cross-device generalization ability, and low boundary positioning accuracy. The goal is to achieve high-precision, robust automatic detection of microfractures, providing reliable technical support for shale reservoir evaluation. The method includes:
[0052] S1, Physical field of view normalization preprocessing: Obtain the scanning electron microscope image dataset, perform multi-scale normalization preprocessing based on the physical field of view on the scanning electron microscope image dataset, and adopt a hierarchical sampling strategy to balance the positive and negative sample distribution of the scanning electron microscope image dataset.
[0053] Specifically, this step performs multi-scale normalization preprocessing on the original scanning electron microscope (SEM) images based on the physical field of view (field of view). This eliminates scale differences between images at different magnifications by unifying the physical observation scale, and employs a hierarchical sampling strategy to balance the distribution of positive and negative samples. S1 includes the following sub-steps:
[0054] S101, Calculation of physical field of view cropping window: Obtain the pixel physical size of each image in the scanning electron microscope image dataset, and calculate the corresponding cropping window size based on the pixel physical size and the preset target physical field of view size;
[0055] More specifically, this step involves reading the physical pixel size (unit: micrometers / pixel) of each image in the scanning electron microscope image dataset. This size information is pre-stored in the scale configuration file. Based on the preset target physical field of view size (unit: ... Given the physical pixel dimensions of each image, calculate the corresponding cropping window size (unit: ...). The calculation formula is:
[0056]
[0057] in, and These represent the width and height of the preset target's physical field of view, respectively; and These represent the physical pixel dimensions of the image; This indicates the floor function; and These represent the calculated width and height of the cropping window, respectively. To prevent information loss due to an excessively small window in extreme cases, a minimum cropping size threshold of 8×8 pixels is set.
[0058] S102, Hierarchical positive and negative sample sampling strategy: Define the positive sample sampling ratio. For each scanning electron microscope image in the scanning electron microscope image dataset, generate a random number. If the random number is less than the positive sample sampling ratio, perform positive sample priority sampling; otherwise, perform normal random sampling.
[0059] More specifically, this step employs a hierarchical sampling strategy to balance the distribution of positive and negative samples in the training data (i.e., the scanning electron microscope image dataset), thereby addressing the class imbalance problem caused by the sparse distribution of cracks in the images. The positive sample sampling ratio is defined. During training, the sampling method is randomly determined according to this ratio. For each training sample, a random number r∈[0,1] is generated. If r < If positive samples are selected first, then positive samples are selected first; otherwise, normal random sampling is performed.
[0060] The positive sample priority sampling process is as follows: First, extract all pixel locations with annotation values greater than zero from the annotation mask to form a positive sample coordinate set. Second, perform morphological dilation on the positive sample region to increase the sampling hit probability. The dilation uses an elliptical structuring element, and the dilation radius is determined based on the crack scale characteristics. Then, randomly select a pixel from the dilated positive sample region as the clipping center point. Finally, using this center point as a reference, calculate the starting coordinates of the clipping window to ensure that the clipping window contains a sufficient number of crack pixels.
[0061] S103, Dynamic Bucket Hierarchical Sampling: Based on Gaussian mixture model combined with Bayesian information criterion, the pixel physical size of the images in the scanning electron microscope image dataset is automatically clustered. K-means clustering is used to divide the images in the scanning electron microscope image dataset into at least two scale groups, and different positive sample sampling ratios are assigned to each scale group.
[0062] More specifically, to further optimize the sampling strategy, this step dynamically adjusts the positive sample sampling ratio based on the image's scale characteristics. First, an automatic clustering analysis of the pixel physical dimensions of the dataset images is performed using a Gaussian Mixture Model (GMM) combined with the Bayesian Information Criterion (BIC) to determine the optimal number of clusters. Then, the K-means clustering algorithm is used to divide the dataset images into two scale groups (buckets), each corresponding to a different positive sample sampling ratio. The grouping information is pre-calculated and stored in the scale configuration file.
[0063] During training, based on the group to which an image belongs, a corresponding value is selected from a preset sampling ratio parameter to achieve adaptive sampling of images at different scales. Specifically, the positive sample sampling ratios corresponding to the two scale groups are respectively... , Smaller-scale images (high magnification) typically have a higher proportion of cracks, corresponding to a lower positive sample sampling ratio; larger-scale images (low magnification) have sparser cracks, corresponding to a higher positive sample sampling ratio. This adaptive strategy effectively balances the differences in sample distribution between images of different scales.
[0064] S104, Spatial Size Normalization: The image block obtained by cropping according to the cropping window size is scaled to a fixed output spatial size using bilinear interpolation, and the corresponding label mask block is scaled to the same output spatial size using nearest neighbor interpolation.
[0065] More specifically, this step will crop the image patch (size: ) Scaling uniformly to a fixed output size ( ).image Scaling is performed using bilinear interpolation to ensure a smooth grayscale transition; a labeling mask is used. Scaling is performed using nearest neighbor interpolation to preserve binary properties. The normalized image... and annotation All dimensions are This achieves pixel-scale uniformity in multi-scale images.
[0066] S105, Data Augmentation: Perform data augmentation on the scaled image patch and maintain the spatial correspondence between the augmented image patch and the corresponding labeled mask patch; data augmentation includes random flipping, rotation, brightness and contrast jitter, adding Gaussian noise and Gaussian blur;
[0067] More specifically, this step applies geometric and grayscale data augmentation operations to the training set samples to improve the model's generalization ability and robustness. Data augmentation is applied only to the training set. Augmentation operations include:
[0068] (1) Random flipping: with probability Randomly flip the model vertically or horizontally to enhance its invariance to crack direction;
[0069] (2) 90-degree rotation: with probability Randomly rotate 0°, 90°, 180°, or 270° to further enhance orientation invariance;
[0070] (3) Small angle rotation: based on probability exist The image is randomly rotated within the range, bilinear interpolation is used for the image, nearest neighbor interpolation is used for the labels, and reflection mode is used for boundary filling to maintain image continuity.
[0071] (4) Brightness and contrast jitter: based on probability Randomly adjust brightness and contrast. Contrast factor c is... Uniform sampling within the range, brightness offset b in Sampling within the range, the transformation formula is as follows ;
[0072] (5) Gaussian noise: based on probability Add a mean of 0 and a standard deviation of Gaussian noise is used to simulate noise interference during image acquisition.
[0073] (6) Gaussian blur: based on probability Apply Gaussian blur, kernel size from The list is randomly selected, and the kernel size must be odd and greater than 0 to perform the fuzzy operation.
[0074] All probability parameters for augmentation operations are managed uniformly by the aug field in the configuration file. The augmented image and the annotation maintain spatial correspondence, ensuring the accuracy of the annotation of the training samples.
[0075] S106, Normalization and Tensor Transformation: Normalize the pixel values of the enhanced image block to the [0, 1] interval, and convert the labeled mask block into tensor format after binarization.
[0076] More specifically, this step normalizes the grayscale of the enhanced image, linearly mapping pixel values from the [0,255] interval to the [0,1] interval. The normalization formula is:
[0077]
[0078] All pixel values in the image are the same ( If the target is zero, then an array of all zeros is returned. The label mask is then binarized. This is then converted to a floating-point number, similarly increasing the channel dimension to form... The array is then converted to a PyTorch tensor (data type float32), which meets the input format requirements of deep learning models. ).
[0079] Advantages of the Physical Field-of-View Normalization Preprocessing Framework: In existing SEM image segmentation research, model training generally employs a standardized process of fixed-pixel window cropping and uniform random sampling. However, this process ignores the objective differences in pixel physical size at different magnifications, resulting in cracks of the same real scale exhibiting different pixel representations in different images. This makes it difficult for the network to establish stable and consistent crack context features, further exacerbating the risk of confusion between microcracks and mineral boundaries and pore contours. Simultaneously, microcrack pixels constitute an extremely sparse proportion of the entire image, and conventional indiscriminate sampling strategies easily lead to a background-dominated sample distribution during the training phase, causing severe class imbalance and missed detections. To address these two shortcomings, this embodiment proposes a complete physical field-of-view normalization preprocessing framework. This framework dynamically calculates the cropping window by reading the true physical scale of the image, eliminating scale bias across devices and magnifications from the perspective of physical observation. Secondly, it further introduces automatic scale clustering based on a Gaussian mixture model (GMM) combined with the Bayesian information criterion (BIC), and uses the K-means algorithm to divide the image into different blocks according to physical scale, adaptively configuring the positive sample sampling ratio for each scale group: a lower sampling ratio for high-magnification images with denser cracks, and a higher sampling ratio for low-magnification images with sparser cracks. This strategy not only effectively alleviates the problems of missed detections at low magnification and local overfitting at high magnification, but also improves the model's recognition stability, generalization ability, and robustness in complex multi-scale scenes.
[0080] S2, Hybrid Encoder Hybrid Extraction: The preprocessed scanning electron microscope image dataset is input into the hybrid encoder architecture for multi-level feature extraction, resulting in deep feature representations rich in multi-scale semantic information and global context; the hybrid encoder architecture includes a sequentially connected UNet++ encoder, an ASPP multi-scale enhancement module, and a Transformer global modeling module;
[0081] Specifically, this step uses a hybrid encoder architecture to extract multi-level features from the input image, sequentially passing them through a UNet++ encoder, an ASPP multi-scale enhancement module, and a Transformer global modeling module, to generate a deep feature representation rich in multi-scale semantic information and global context. S2 includes the following sub-steps:
[0082] S201, Five-layer UNet++ encoder downsampling: A five-layer encoder structure is used to downsample and extract features from the input image layer by layer, constructing a multi-scale feature pyramid. The number of feature channels in each layer of the encoder is sequentially determined by the number of basic channels. In this embodiment, the basic number of channels is 1 times, 2 times, 4 times, 8 times, and 16 times. The feature channels are set to 64, resulting in 64, 128, 256, 512, and 1024 for the five-layer encoder. Each layer contains two main components: a feature extraction module and a downsampling module. The feature extraction module consists of two consecutive convolution-batch normalization-activation units, using 3×3 convolutional kernels to extract local features. The downsampling module uses 2×2 max pooling to reduce the spatial resolution of the feature map to half its original size. The five-layer encoder structure, through four successive downsampling passes, reduces the resolution to 1 / 2, 1 / 4, 1 / 8, and 1 / 16 of the original size, forming a feature pyramid from fine-grained to coarse-grained. The features extracted from each layer are simultaneously saved as input to the dense skip connections of the subsequent decoder to fuse semantic information and spatial details at different scales.
[0083] S202, ASPP Multi-Scale Dilated Convolution Enhancement: Encoder Bottleneck Layer Features The Atrous Spatial Pyramid Pooling (ASPP) module is applied to capture contextual information across different receptive field ranges through parallel multi-scale atrous convolutions, enhancing the model's ability to represent cracks at different scales. The ASPP module employs six parallel branches to capture feature information at different scales, such as... Figure 3 As shown:
[0084] (1) 1×1 convolutional branch: A 1×1 convolutional kernel is used to capture point-level features, corresponding to the smallest receptive field;
[0085] (2) 3×3 dilated convolution branch group (dilation rate of 1): equivalent to standard 3×3 convolution, with a receptive field of 3×3, capturing local features of neighboring pixels;
[0086] (3) 3×3 dilated convolution branch group (dilation rate of 6): By inserting 5 holes between convolution kernel elements, the receptive field is expanded to 13×13, capturing medium-scale contextual features;
[0087] (4) 3×3 dilated convolution branch group (dilation rate 12): The receptive field is expanded to 25×25, capturing spatial correlation features at a larger scale;
[0088] (5) 3×3 dilated convolution branch group (dilation rate 18): The receptive field is expanded to 37×37, capturing large-scale contextual information and adapting to longer crack structures;
[0089] (6) Global average pooling branch: Global average pooling is performed on the entire feature map to capture image-level global context information, and then the original feature map size is restored through 1×1 convolution and bilinear upsampling.
[0090] The output features of the six branches are concatenated along the channel dimension to form a multi-scale fused feature, with the number of channels in the concatenated feature being six times that of a single branch output. Subsequently, a 1×1 convolutional layer is used for channel dimensionality reduction and feature fusion to generate an enhanced feature representation with the same number of channels as the input features. This multi-scale parallel architecture enables the model to simultaneously perceive multi-level features from local details to global layout, significantly improving the detection capability for cracks of different lengths and shapes.
[0091] S203, Transformer Global Context Modeling: Features of the Bottleneck Layer Enhanced by ASPP A Transformer encoder is applied for global context modeling. Unlike the local receptive field limitation of convolution operations, the Transformer can directly establish dependencies between pixels at any location in the feature map through a self-attention mechanism, capturing long-distance spatial correlations without the need for multi-layer stacking. This is of great significance for detecting crack structures with a large extension range.
[0092] Please see Figure 4 The Transformer encoder consists of several Transformer coding blocks stacked sequentially; in this embodiment, a 3-layer coding block is used. Each coding block contains two main sub-layers: a multi-head self-attention mechanism and a feedforward neural network. Both sub-layers are equipped with residual connections and layer normalization to stabilize the training process and promote gradient propagation.
[0093] The workflow of the multi-head self-attention mechanism is as follows: First, the input features are linearly projected into three representations: query, key, and value. Then, these three representations are evenly divided into multiple heads along the channel dimension (four heads are used in this embodiment), and each head independently calculates its attention weight. The attention weight is calculated using the dot product similarity between the query and key, and after scaling and softmax normalization, it is used to perform a weighted summation of the values. The outputs of the multiple heads are concatenated and linearly projected to obtain the final output of the multi-head self-attention mechanism. This multi-head mechanism enables the model to capture diverse feature dependencies from different representation subspaces.
[0094] The feedforward neural network performs a point-by-point nonlinear transformation on the features at each location in the feature map. It consists of two linear layers and one activation function layer, with the hidden layer having a dimension four times that of the input (i.e., an expansion ratio of 4), enhancing the expressive power of the features. Through multi-layer modeling by the Transformer encoder, the bottleneck layer features acquire rich global contextual information, laying the foundation for subsequent decoding and recovery of high-quality crack segmentation results.
[0095] Advantages of the UNet++-ASPP-Transformer cascaded hybrid encoder architecture: Existing micro-crack segmentation methods mostly use U-Net-like convolutional encoders as the core, which are limited by the local receptive field and have difficulty capturing the global topology of complex shale micro-cracks with wide extension range and varied morphology; while using Transformer alone for modeling can easily weaken the ability to characterize local details such as short cracks and fine boundaries due to overemphasizing global correlation. To address the above limitations, this embodiment constructs a bottom-up multi-level cascaded hybrid encoder path of "UNet++ encoder-ASPP multi-scale enhancement-Transformer global modeling". First, a five-layer UNet++ encoder constructs a feature pyramid from fine-grained to coarse-grained through progressive downsampling, and preserves shallow spatial details to the decoding stage using dense skip connections. Then, at the deepest bottleneck feature layer, a Hollow Spatial Pyramid Pooling (ASPP) module with six parallel branches is introduced. Through convolutions with different dilation rates and global context branches, this module collaboratively models the network, ensuring that fine cracks, curved cracks, and long-range extended cracks all receive receptive field support commensurate with their scale. Finally, a multi-head self-attention Transformer encoder is cascaded after the ASPP to perform global dependency modeling on the enhanced deep features, achieving a progressive improvement from local texture recognition to global crack network understanding. This structure balances local detail fidelity with global semantic awareness, significantly improving the unified recognition capability for complex cracks of various forms, including short, isolated, and long-range extended cracks.
[0096] S3, coarse-grained edge prediction: Based on the deep feature representation, a coarse edge prediction map is generated through a convolutional layer, and the coarse edge prediction map is upsampled to multiple different resolutions to obtain edge guidance maps of multiple scales;
[0097] Specifically, bottleneck features from the Transformer enhancement before UNet++ decoding. A coarse edge prediction is generated through 1×1 convolution, and the output dimension is... , representing the edge logits at 1 / 16 resolution. Then, it is upsampled to the three resolutions using bilinear interpolation: , , These are used to guide features at different decoding levels. The edge guidance maps at three scales are aligned with the corresponding decoding feature spaces, and the features are enhanced at key nodes of S4 decoding through the S5 mechanism.
[0098] S4, UNet++ Dense Decoding: Utilizes the UNet++ decoder to progressively upsample at multiple levels and fuse multi-scale semantic information and global context from deep feature representations to generate decoding nodes from coarse to fine.
[0099] Specifically, this step employs UNet++'s L3 decoding depth, fusing coded features from different levels through nested skip connections to gradually restore spatial resolution. The UNet++ decoder uses a densely connected mesh structure, progressively upsampling and fusing coded features across three levels to generate decoding nodes from coarse to fine. The first level of decoding generates four nodes, each fusing coded features from the same level and upsampled features from the previous level. The second level of decoding generates three nodes, each fusing coded features from the same level, the first column of decoded features from the same level, and upsampled features from the previous level. The third level of decoding generates the final node. (dimension) ), fusing four inputs: same-layer coding features Decoding features of the first two columns and and upsampling After integration via DoubleConv, the original resolution is restored. This is achieved at three key nodes ( , , After generation, the edge prior information is incorporated into the decoding process by combining the multi-scale edge guidance map pre-generated by S3 with the edge guidance attention mechanism of S5. All upsampling operations use bilinear interpolation, and all feature fusion is performed through the DoubleConv module.
[0100] S5, Edge-guided multi-layer attention: For each decoding node, the edge-guided map of the corresponding scale is taken, converted into attention weights by the activation function, and the decoding features of the decoding node are spatially adaptively enhanced by a multiplicative attention mechanism to obtain the enhanced decoding features;
[0101] For details, please refer to Figure 5 The edge-guided attention mechanism in this step achieves adaptive feature enhancement through the following process:
[0102] S501, Size Alignment: If the spatial size of the edge guide map is inconsistent with the spatial size of the feature to be enhanced, bilinear interpolation is used to adjust the edge guide map to the same spatial size as the feature map to ensure the spatial correspondence of subsequent pixel-by-pixel operations;
[0103] S502, Attention Weight Generation: Apply the Sigmoid activation function to the edge guidance map to convert the original predicted values into probability values in the [0,1] interval, which are then used as attention weights. The closer the weight value is to 1, the more likely that the location is a crack edge, requiring stronger feature enhancement.
[0104] S503, Feature Adaptive Modulation: A multiplicative attention mechanism is used to perform spatial adaptive modulation on the decoded features. The modulation formula is as follows:
[0105]
[0106] Where F' represents the enhanced feature; F represents the decoded feature to be enhanced; Indicates the reinforcement strength parameter; This represents element-wise multiplication; represents the Sigmoid activation function; E represents the edge guidance map at the corresponding resolution. This mechanism amplifies the feature values of the edge region while keeping the background region unchanged, achieving selective enhancement.
[0107] S6, Dual-branch output generation: The enhanced decoded features are passed through two independent convolutional layers to generate segmentation branch prediction and edge branch prediction respectively; the segmentation branch prediction is used to output the crack region, and the edge branch prediction is used to output the crack boundary.
[0108] Specifically, this step is in the final layer of the decoder. After feature decoding is completed, two independent 1×1 convolutional layers are used to generate dual-branch prediction outputs, namely segmentation branch and edge branch, to achieve complete detection of crack targets.
[0109] S601, Segmentation Branch: From the final decoded features enhanced by S5 (dimension) Segmentation predictions are generated using a 1×1 convolutional layer, with the number of input channels of this convolutional layer being... The output channel count is 1, and no bias term is used. When deep supervision is enabled, features are decoded simultaneously from three different depths ( , , Each of the three prediction outputs is generated through an independent 1×1 convolutional layer. , , The three predictions are combined using an arithmetic mean, with the following formula:
[0110]
[0111] in, Represents the segmentation prediction logits. , , This represents the output of three deep supervision functions. Finally, bilinear interpolation is used to... Upsampled to the original size of the input image The final segmentation prediction logits are obtained, with an output dimension of . .in, Indicates the basic number of channels. and These represent the height and width of the input image, respectively.
[0112] S602, Edge Branch: From the same final decoded feature Edge prediction is generated through another separate 1×1 convolutional layer. The convolutional layer structure is the same as the split branch, with the number of input channels being... The output channel count is 1, and no bias term is used. Similarly, bilinear interpolation is used to... Upsampled to the original size of the input image The edge prediction logits are obtained, with an output dimension of . .in, This represents the edge prediction logits. The edge branch focuses on capturing the boundary features of the cracks, providing auxiliary supervision signals for the main segmentation task. The model's forward propagation returns the two-branch prediction results: segmentation... and edge The outputs of both branches are raw logits without Sigmoid activation, with a dimension of 1. During the training phase, the logits of both branches are passed to the loss function for supervised learning; during the inference phase, only the logits of the two branches are extracted. For subsequent processing.
[0113] Advantages of multi-level edge-guided attention and dual-branch collaborative supervision mechanism: Existing edge-assisted segmentation methods mostly rely on shallow high-frequency gradient extraction or independent edge correction after prediction. Such strategies are easily interfered with by mineral texture noise in the complex background of shale SEM images, resulting in problems such as inaccurate boundary positioning, blurred contours, and confusion between crack and non-crack interfaces. To address this, this embodiment proposes a top-down edge guidance and dual-branch collaborative supervision mechanism. First, it breaks away from the conventional approach of relying on local gradients, directly predicting coarse-grained edge maps from the deepest bottleneck features enhanced by the Transformer, ensuring that edge representations simultaneously include local mutation information and global structural dependencies. Then, this edge prediction is progressively upsampled to multiple decoding resolutions. At key decoding nodes in UNet++, spatial attention weights are generated through Sigmoid normalization, and adaptively enhanced using multiplicative modulation of the corresponding scale's decoding features, thereby enhancing the response of real edge regions and suppressing background interference. At the output, a dual-head collaborative prediction mechanism is implemented, consisting of a segmentation branch and an edge branch. The edge branch dynamically generates boundary supervision targets through morphological differencing and directly drives the model to learn the geometric contour features of microcracks using weighted BCE loss. The segmentation branch, guided by the edge, synchronously optimizes the decoding representation quality of the intermediate layers. This collaborative mechanism integrates prior edge information into the entire process from deep feature adjustment to output supervision, significantly improving boundary localization accuracy, contour clarity, and crack backbone continuity.
[0114] S7, Multi-component loss function: Construct a multi-component hybrid loss function, use the loss function to calculate the loss value between the segmentation branch prediction and the real label, and between the edge branch prediction and the boundary target extracted from the real label, and backpropagate to update the model parameters, thereby obtaining the trained shale microcrack identification model.
[0115] Specifically, during the model training phase, a multi-component hybrid loss function is designed for the bi-branch prediction results to supervise the model from different perspectives, ensuring that the segmentation results simultaneously possess pixel-level accuracy, class balance, topological continuity, and edge sharpness. This includes the main segmentation loss, class imbalance loss, false positive penalty loss, and edge supervision loss, detailed below:
[0116] (1) Calculation of principal segmentation loss )
[0117] The segmentation prediction is supervised at the pixel level using the Binary Cross Entropy (BCE) loss function. The loss calculation formula is as follows:
[0118]
[0119] in, This represents the total number of pixels in the image; This represents the true label of the i-th pixel (0 represents the background, 1 represents the crack); This represents the model's prediction for the i-th pixel (raw logit). This represents the Sigmoid activation function; This represents the positive sample weighting coefficient, used to balance the imbalance between positive and negative samples. It is dynamically calculated based on the ratio of positive to negative samples within a batch. This represents the total number of negative sample (background) pixels; This represents the total number of pixels in the positive sample (crack). This represents the proportion of positive samples. Considering the extreme sparseness of positive samples in micro-crack detection tasks, the original calculation... The value may be too large, leading to unstable training. Therefore, [the value should be adjusted accordingly]. Limit it to a reasonable range [80, 2000].
[0120] This weighting mechanism increases the loss contribution of positive samples, forcing the model to pay more attention to sparse crack regions. This effectively alleviates the problem of the model being biased towards predicting the background class due to class imbalance, and improves the crack detection recall rate.
[0121] (2) Class imbalance loss , )
[0122] To further mitigate extreme class imbalance, Tversky and Focal losses are introduced on top of the BCE loss. The Tversky loss adjusts the weighting parameters for false positives and false negatives. and To control the severity of penalties for different error types, it is defined as:
[0123]
[0124] in, Indicates the predicted probability. Indicates the labeled value. Indicates a smoothing term to prevent division by zero; and These represent the penalty weights for controlling false positives and false negatives, respectively, and are typically set to... , This makes the model more focused on reducing false negatives (missed detections); molecular The result represents a true positive, and the denominator includes true positives, weighted false positives, and weighted false negatives, adjusted by... and Balance recall and precision.
[0125] Simultaneously, Focal loss is calculated to further suppress the contribution of easily separable samples. Focal loss is defined as:
[0126]
[0127] in, This represents the focusing parameter (usually set to 2). and Indicates the modulation factor. When the sample is correctly classified and the confidence level is high ( near When the modulation factor is close to 0, the sample contributes very little to the loss; when the sample is difficult to classify, the modulation factor is close to 1, and the contribution to the loss is normal. This mechanism makes the model focus more on learning difficult samples, improving the ability to detect small cracks.
[0128] (3) False positive penalty loss )
[0129] To address the high false positive rate caused by complex backgrounds in crack detection, a false positive penalty loss is designed. This loss applies an additional penalty only to pixels predicted as positive but actually negative, defined as follows:
[0130]
[0131] in, Indicates the predicted probability. Indicates the labeled value. Represents a negative sample mask (when When it is 1, (when it is 0) This represents the penalty strength coefficient (typically 5.0). This loss applies a squared penalty to false positive predictions, imposing a stronger penalty on high-confidence false positives, causing the model to output lower confidence values in background regions. The predicted probability is [value missing] when the model incorrectly predicts a crack in the background. The higher the value, the greater the loss, forcing the model to reduce the prediction confidence of the background region.
[0132] (4) Topological continuity loss )
[0133] To ensure topological integrity, clDice loss is introduced to supervise the continuity at the skeleton level. First, morphological skeletonization is performed on the predictions and annotations, extracting the centerline skeleton. Let... and The clDice coefficient is defined as follows: (This refers to the predicted and labeled skeletons, respectively.)
[0134]
[0135] in, Represents the number of pixels at the skeleton intersection (by element-wise multiplication). Calculation), | and | | indicates the total number of skeleton pixels. The smoothing term is represented. Skeleton extraction is achieved through iterative morphological refinement. This loss ensures the continuity of the predicted cracks in the topology, effectively avoiding breakage.
[0136] (5) Edge supervision loss )
[0137] The prediction of edge branches is supervised. First, boundary targets are dynamically generated from the segmentation label Y. :
[0138]
[0139] Wherein, Dilate and Erode represent morphological dilation and erosion operations (structural element size). Extract the crack boundaries. Then calculate the weighted BCE loss:
[0140]
[0141] in, Indicates the marginal prediction probability. This indicates that the edge branch outputs logits. Indicates the boundary target. Represents the boundary position weights, based on The ratio of positive to negative samples is calculated separately and capped at 50, where N is the total number of pixels. This loss condition enables the model to learn the edge features of the cracks, enhancing the boundary clarity of the segmentation results.
[0142] Finally, the losses of each component are summed according to their weighting coefficients to obtain the total loss:
[0143]
[0144] in, Traversal Six weights, This represents the corresponding weight coefficients. Furthermore, the Adam optimizer is used, with the learning rate set to... to The positional weights of BCE and edge loss are dynamically adjusted during training. and Each batch is recalculated based on the actual ratio of positive to negative samples to adapt to the sparsity of cracks in different images. An early stopping strategy is used to monitor the validation set loss; training stops when the validation loss does not decrease for 40 consecutive epochs to prevent overfitting.
[0145] Advantages of a multi-component hybrid loss function system: Existing crack segmentation methods mostly use BCE, Dice, or a simple weighted combination of the two as loss functions. Their core is still constraining the pixel overlap between the prediction and the label. In scenarios where crack pixels are extremely sparse, the model is prone to background bias, making it difficult to balance the recall of subtle cracks, topological continuity, and boundary realism, leading to problems such as missed detections and trunk breakage. To address this, this embodiment constructs a multi-component hybrid loss system: First, Tversky and Focal losses are introduced on top of weighted BCE. By differentially penalizing false positives and false negatives, dynamically adjusting the weight of positive samples, and focusing on difficult-to-distinguish samples, the model's recall rate for subtle cracks is enhanced. Second, to address the high false positive rate induced by complex backgrounds, a false positive penalty loss is designed. A squared penalty is applied to negative sample pixels in complex backgrounds that are mispredicted as cracks, suppressing false crack responses. Simultaneously, clDice is introduced to constrain the consistency between the predicted results and the real crack centerline at the skeleton level, ensuring the connectivity and integrity of the crack trunk. Finally, dynamically generated boundary targets are used to apply weighted BCE supervision to the edge branches, enabling edge learning and main segmentation learning to be optimized collaboratively. This comprehensive loss covers five aspects: pixel accuracy, class balance, false detection suppression, topology preservation, and boundary clarity, fundamentally ensuring the model's high accuracy and robustness in complex scenarios.
[0146] To objectively evaluate the performance of the proposed method in this embodiment, multiple independent and repeated experiments were conducted on the shale SEM microfracture dataset using four random seeds. The final results are reported in the form of mean ± standard deviation. A comprehensive comparison was made with five baseline models—HRNet-W18s, HRNet-W18-Attn, UNet, UNet++ Attn, and UNet++ Trans—at three dimensions: pixel level (mIoU, pixel accuracy), skeleton level (Skeleton F1), and boundary level (Boundary F1). The experimental results are shown in Table 1 and... Figure 6 As shown, Figure 6 In the diagram, yellow lines represent identification gaps, green lines represent missed detections, and red lines represent false detections.
[0147] Table 1. Comparison of segmentation performance of various comparative models on the shale SEM microfracture test set.
[0148]
[0149] The shale microcrack identification model training method based on scanning electron microscope images provided in this embodiment has the following beneficial effects:
[0150] (1) Overall performance is significantly superior
[0151] Quantitative experimental results show that, under cross-validation with multiple random number seeds, the model proposed in this embodiment (UNet++-Trans-Aspp-Edge) comprehensively and significantly outperforms existing mainstream baseline models in both cross-union ratio (mIoU) and boundary F1 score. Specifically, the mean mIoU of the model in this embodiment reaches 0.7662±0.0142, which is an improvement of approximately 9.93% compared to the best-performing baseline model UNet++ Attn and approximately 17.2% compared to the weakest baseline HRNet-W18; at the same time, the boundary F1 score reaches 0.8038±0.0076, which fully demonstrates that this edge guidance mechanism can greatly improve the fit and clarity of fracture boundaries in extremely complex rock backgrounds.
[0152] (2) The topological continuity of the skeleton is significantly improved.
[0153] Skeleton F1 is a core metric for measuring the connectivity of the centerline of a linear crack. In this embodiment, the mean Skeleton F1 score reaches 0.8123 ± 0.0109, an improvement of approximately 2.38% compared to the suboptimal baseline UNet++ Attn and approximately 10.7% compared to HRNet-W18s. This result demonstrates that this embodiment effectively suppresses topological fractures in the crack backbone and ensures the integrity of the crack network structure through the synergistic effect of clDice skeleton-level loss constraints and edge-guided attention mechanisms.
[0154] (3) Pixel-level prediction is stable and background suppression is strong.
[0155] In tests covering datasets of varying complexity, the model trained in this embodiment achieved the highest pixel accuracy of 0.9933 ± 0.0007, with an extremely low standard deviation demonstrating its high stability. This indicates that the model has a very low false negative rate and a low false positive rate, suggesting that its overall discrimination of background and crack regions is more stable.
[0156] (4) Excellent cross-seed stability
[0157] The method provided in this embodiment has a standard deviation of only 0.0142 for mIoU under random seeds, a standard deviation of 0.0109 for Skeleton F1, and a standard deviation of 0.0066 for Boundary F1. The overall variance level is lower than that of most baseline models (such as UNet++Trans, which has a seed-to-seed fluctuation of 0.0228 in mIoU). This indicates that the framework proposed in this embodiment has good training stability and reproducibility. It verifies that the model based on physical normalization and hybrid architecture has extremely high engineering application value and robustness when facing unknown data from different devices, different collection batches, and different magnifications.
[0158] In summary, this embodiment achieves consistent performance improvements across four dimensions: pixel-level accuracy, skeleton topological connectivity, boundary localization accuracy, and cross-seed stability, verifying the effectiveness of the shale microcrack identification model training method based on scanning electron microscope images proposed in this embodiment.
[0159] Example 2
[0160] Please see Figure 7 This embodiment provides a method for identifying microcracks in shale based on scanning electron microscopy images, including:
[0161] Step A: Acquire scanning electron microscope (SEM) images and divide the SEM images into grids according to block size;
[0162] Specifically, due to the large size of SEM images, this embodiment uses a sliding window method for block-based inference. This is done by block size. Divide the image into a grid, ensuring that image patches do not overlap (step size). To improve edge prediction quality, the width is expanded outwards when extracting image patches. As the context region, that is, the actual size of the input model is .
[0163] Step B: Input each image block after grid division into the shale microcrack identification model for identification, and stitch the prediction results of each image block together to obtain a complete identification image; the shale microcrack identification model is trained according to the shale microcrack identification model training method based on scanning electron microscope images provided in Example 1;
[0164] Specifically, this step inputs each image block after mesh division into the shale micro-fracture recognition model for inference and recognition. After inference, only the center is retained. The prediction results for each region are seamlessly stitched together according to their original locations to obtain a complete predicted logits map. .
[0165] Step C: Convert the recognition image into probabilities using the Sigmoid function, and binarize it according to a preset threshold to generate an initial mask;
[0166] Specifically, this step converts logits into probabilities using the Sigmoid function, expressed by the formula:
[0167] ;
[0168] Then set the threshold. Binarize to generate the initial mask:
[0169] .
[0170] Step D: Perform connected component analysis on the initial mask, remove connected components with an area smaller than a preset area threshold, and remove isolated noise points to obtain the area-filtered mask;
[0171] Specifically, this step performs the first stage of post-processing on the initial mask M, namely: performing connected component analysis on M and removing areas smaller than a preset area threshold. By removing isolated noise points from the connected components, we obtain the area-filtered mask. .
[0172] Step E: Morphological skeletonization is performed on the area-filtered mask, the centerline skeleton with a width of one pixel is extracted, the skeleton is labeled with connected components, short branches with a length less than a preset length threshold are removed, and the main cracks with significant lengths are retained to finally obtain the filtered segmentation mask.
[0173] Specifically, this step involves applying area-filtered masks. Morphological skeletonization is performed, a single-pixel wide centerline skeleton is extracted, connected component labeling is performed on the skeleton, and components with a length less than a preset length threshold are removed. The short branches are preserved, while the main crack of significant length is retained. The final filtered segmentation mask is obtained. The crack pixel value is 255 (white), the background pixel value is 0 (black), and it is saved as a PNG format.
[0174] This embodiment provides a method for identifying microcracks in shale based on scanning electron microscope images, which further includes: performing multi-dimensional quantitative evaluation and qualitative visualization analysis of the segmentation mask from three levels: pixel level, skeleton level, and boundary level.
[0175] Specifically, this step performs multi-dimensional quantitative evaluation and qualitative visualization analysis of the segmentation mask obtained from inference prediction at three levels: pixel level, skeleton level, and boundary level.
[0176] (1) Pixel-level index calculation (mIoU, Precision)
[0177] The final segmentation mask is compared pixel-level with the ground truth mask to calculate basic segmentation performance metrics. Four types of pixels are counted: true positive pixels (predicted as cracks and labeled as cracks), false positive pixels (predicted as cracks but labeled as background), true negative pixels (predicted as background and labeled as background), and false negative pixels (predicted as background but labeled as cracks), denoted as TP, FP, TN, and FN respectively. Based on these, the Intersection over Union (IoU) and precision are calculated. The IoU is defined as the ratio of the intersection to the union of predicted crack pixels and ground truth crack pixels, used to measure the degree of overlap between the predicted and ground truth regions. The calculation formula is:
[0178]
[0179] Precision is defined as the proportion of correctly predicted crack pixels out of all predicted crack pixels, and is used to measure the accuracy of crack prediction in the segmentation result. The calculation formula is:
[0180]
[0181] These two metrics comprehensively evaluate pixel-level segmentation performance from two dimensions: regional overlap and prediction reliability.
[0182] (2) Calculation of skeleton-level indicators )
[0183] Skeletonization of segmentation and annotation masks is crucial for evaluating the topological connectivity and structural integrity of fracture centerlines, and is essential for geological fracture network analysis. A morphological thinning algorithm is used to extract single-pixel-width centerline skeletons from the final segmentation mask and the ground truth annotation mask, yielding the predicted and ground truth skeletons. At the skeleton level, true positive skeleton pixels (the number of pixels at the intersection of the predicted and ground truth skeletons), false positive skeleton pixels (the number of pixels in the predicted skeleton that are not on the ground truth skeleton), and false negative skeleton pixels (the number of pixels in the ground truth skeleton that are not covered by the predicted skeleton) are statistically analyzed and denoted as follows: , , Based on this calculation The metric, the harmonic mean of precision and recall, is calculated using the following formula:
[0184]
[0185] Among them, accuracy ( Recall is defined as the proportion of correctly predicted skeleton pixels out of all predicted skeleton pixels. () is defined as the proportion of correctly predicted true skeleton pixels out of all true skeleton pixels.
[0186] (3) Calculation of boundary level indicators )
[0187] Assess the degree of agreement between the predicted crack boundary and the actual boundary. High This indicates a high degree of agreement between the predicted crack boundary and the actual boundary. First, boundary pixels are extracted from both the final segmentation mask and the ground truth labeled mask. A morphological gradient operator is then used to extract the boundaries; that is, morphological gradient operations are performed on the binary mask, using a 3×3 all-one matrix as the structuring element to obtain the predicted boundary pixel set and the actual boundary pixel set. To tolerate minor deviations in boundary localization, a tolerance distance parameter is set. Construct an elliptical structural element with dimensions of ( Tolerance expansion for boundary matching is used. Based on this, the boundary F1 is obtained by calculating the harmonic mean of precision and recall. The calculation formula is:
[0188]
[0189] in, This indicates the minimum value to prevent division by zero. Represents the set of true boundary pixels. Represents the set of pixels to be predicted as a boundary. It represents an elliptical, expanding core. This indicates a morphological dilation operation. Boundary accuracy ( Boundary recall is defined as follows: The number of matching pixels is obtained by performing a logical AND operation between the dilated true boundary and the predicted boundary, and then divided by the total number of pixels in the predicted boundary. The definition is: The predicted boundary dilatation is ANDed with the true boundary to obtain matching pixels, and the number of matching pixels is divided by the total number of pixels on the true boundary.
[0190] Finally, all the above metrics are summarized into metrics.cv, and a visual comparison of the label map and prediction map is created for the test set images to highlight the false positive and false negative areas of the model, which facilitates the analysis of model defects.
[0191] The technical features of the above embodiments can be combined in any way (as long as there is no contradiction in the combination of these technical features). For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described; these embodiments not explicitly written should also be considered to be within the scope of this specification.
Claims
1. A method for training a shale microcrack identification model based on scanning electron microscope images, characterized in that, include: Step 1: Obtain the scanning electron microscope (SEM) image dataset, perform multi-scale normalization preprocessing based on physical field of view on the SEM image dataset, and use a hierarchical sampling strategy to balance the positive and negative sample distribution of the SEM image dataset; Step 2: Input the preprocessed scanning electron microscope image dataset into the hybrid encoder architecture for multi-level feature extraction to obtain deep feature representations rich in multi-scale semantic information and global context; the hybrid encoder architecture includes a sequentially connected UNet++ encoder, an ASPP multi-scale enhancement module, and a Transformer global modeling module; Step 3: Generate a coarse edge prediction map through a convolutional layer based on the deep feature representation, and upsample the coarse edge prediction map to multiple different resolutions to obtain edge guidance maps of multiple scales; Step 4: Utilize the UNet++ decoder to progressively upsample at multiple levels and fuse the multi-scale semantic information and global context in the deep feature representation to generate decoding nodes from coarse to fine. Step 5: For each decoding node, take the edge guidance map of the corresponding scale, convert it into attention weights through an activation function, and use a multiplicative attention mechanism to spatially adaptively enhance the decoding features of the decoding node to obtain the enhanced decoding features; Step 6: The enhanced decoded features are passed through two independent convolutional layers to generate segmentation branch prediction and edge branch prediction, respectively; the segmentation branch prediction is used to output the crack region, and the edge branch prediction is used to output the crack boundary; Step 7: Construct a multi-component hybrid loss function, use the loss function to calculate the loss value between the segmentation branch prediction and the real annotation, and between the edge branch prediction and the boundary target extracted from the real annotation, and backpropagate to update the model parameters, thereby obtaining the trained shale microcrack identification model.
2. The method for training a shale microcrack identification model based on scanning electron microscope images according to claim 1, characterized in that, Step 1 specifically includes: Step 101: Obtain the pixel physical size of each image in the scanning electron microscope image dataset, and calculate the corresponding cropping window size based on the pixel physical size and the preset target physical field of view size; Step 102: Define the positive sample sampling ratio. For each scanning electron microscope image in the scanning electron microscope image dataset, generate a random number. If the random number is less than the positive sample sampling ratio, perform positive sample priority sampling; otherwise, perform normal random sampling. Step 103: Based on the Gaussian mixture model and the Bayesian information criterion, automatically cluster the pixel physical size of the images in the scanning electron microscope image dataset. Use K-means clustering to divide the images in the scanning electron microscope image dataset into at least two scale groups and assign different positive sample sampling ratios to each scale group. Step 104: Scale the image block obtained by cropping according to the cropping window size to a fixed output space size using bilinear interpolation, and scale the corresponding label mask block to the same output space size using nearest neighbor interpolation; Step 105: Perform data augmentation on the scaled image patch and maintain the spatial correspondence between the augmented image patch and the corresponding labeled mask block; the data augmentation includes random flipping, rotation, brightness and contrast jitter, adding Gaussian noise and Gaussian blur; Step 106: Normalize the pixel values of the enhanced image block to the [0, 1] interval, and convert the labeled mask block into tensor format after binarization.
3. The method for training a shale microcrack identification model based on scanning electron microscope images according to claim 2, characterized in that, In step 102, the positive sample priority sampling specifically includes: extracting all pixel positions with label values greater than zero from the label mask to form a positive sample coordinate set; performing morphological dilation on the positive sample region to increase the sampling hit probability; randomly selecting a pixel from the dilated positive sample region as the cropping center point; and calculating the starting coordinates of the cropping window based on the cropping center point to ensure that the cropping window contains a sufficient number of crack pixels.
4. The method for training a shale microcrack identification model based on scanning electron microscope images according to claim 1, characterized in that, In step 2, the UNet++ encoder adopts a five-layer encoder structure. The number of feature channels in each layer is 1, 2, 4, 8 and 16 times the number of basic channels, respectively. Each layer contains two main components: a feature extraction module and a downsampling module.
5. The method for training a shale microcrack identification model based on scanning electron microscope images according to claim 1, characterized in that, In step 2, the ASPP multi-scale enhancement module uses six parallel branches to capture feature information at different scales.
6. The SEM image-based shale microfracture identification model training method of claim 1, wherein, In step 2, the Transformer global modeling module uses a 3-layer coding block. Each coding block contains two sub-layers: a multi-head self-attention mechanism and a feedforward neural network. Both sub-layers are equipped with residual connections and layer normalization.
7. The SEM image-based shale microfracture identification model training method of claim 1, wherein, In step 5, if the spatial dimensions of the edge guide map are inconsistent with those of the decoding feature to be enhanced, bilinear interpolation is used to adjust the edge guide map to the same spatial dimensions as the decoding feature.
8. The method of claim 1, wherein the method is characterized by: In step 7, the hybrid loss function includes binary cross-entropy loss, class imbalance loss, false positive penalty loss, topological continuity loss, and edge supervision loss. 9.A shale micro-fracture identification method based on scanning electron microscope images, characterized in that, include: Step A: Acquire scanning electron microscope (SEM) images and divide the SEM images into grids according to block size; Step B: Input each image block after grid division into the shale microcrack identification model for identification, and stitch the prediction results of each image block together to obtain a complete identification image; the shale microcrack identification model is trained by the shale microcrack identification model training method based on scanning electron microscope images according to any one of claims 1-8; Step C: Convert the identified image into a probability using the Sigmoid function, and binarize it according to a preset threshold to generate an initial mask; Step D: Perform connected component analysis on the initial mask, remove connected components with an area smaller than a preset area threshold, and remove isolated noise points to obtain an area-filtered mask; Step E: Morphological skeletonization is performed on the area-filtered mask, the centerline skeleton with a width of one pixel is extracted, the skeleton is marked with connected components, short branches with a length less than a preset length threshold are removed, and the main crack with a significant length is retained, finally obtaining the filtered segmentation mask.
10. The method of claim 9, wherein, Also includes: The segmentation mask is evaluated quantitatively and visualized in multiple dimensions at three levels: pixel level, skeleton level, and boundary level.
Citation Information
Patent Citations
Shale electron microscope scanning graph crack extraction method based on deep learning segmentation network
CN115240041A