Glass substrate micro-crack segmentation method based on lightweight deep learning model

By using a lightweight deep learning model and attention mechanism, the accuracy and speed of microcrack detection in glass substrates have been improved, solving the problems of large number of parameters and long inference time in traditional models, and achieving efficient industrial inspection.

CN122134728APending Publication Date: 2026-06-02CHANGSHU INSTITUTE OF TECHNOLOGY

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
CHANGSHU INSTITUTE OF TECHNOLOGY
Filing Date
2026-05-07
Publication Date
2026-06-02

Smart Images

  • Figure CN122134728A_ABST
    Figure CN122134728A_ABST
Patent Text Reader

Abstract

This invention discloses a method for segmenting microcracks in glass substrates based on a lightweight deep learning model. The invention relates to the field of intelligent detection technology and includes the following steps: acquiring glass substrate crack images and performing multi-dimensional formulaic preprocessing to eliminate noise and enhance crack features; constructing a lightweight UNet++ model integrating a CBAM attention mechanism, achieving precise enhancement of microcrack features through a channel-spatial attention weighting formula, and combining depthwise separable convolution to achieve network lightweighting; accurately extracting the location, contour, and size information of microcracks through formulaic adaptive threshold binarization and geometric parameter calculation postprocessing; ensuring the scientific nature and repeatability of segmentation through full-process formulaic modeling, significantly improving overall efficiency and accuracy, and providing a more robust quality assurance for subsequent production processes.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of intelligent detection technology, specifically to a method for segmenting microcracks in glass substrates based on a lightweight deep learning model. Background Technology

[0002] As a crucial foundational material for high-end manufacturing industries such as photovoltaics, displays, and semiconductors, the quality of glass substrates directly impacts subsequent processing and product performance. However, the presence of microcracks on the surface and within the glass substrate during production severely threatens its mechanical strength, light transmittance, and impact resistance, ultimately leading to product scrap. Therefore, accurately detecting microcracks in glass substrates, especially those with a width of 5 micrometers or less and a length of 5 micrometers or more, has become a critical aspect of quality control.

[0003] Existing machine vision-based microcrack detection technologies, such as the traditional UNet and UNet++ convolutional neural network models, while achieving certain segmentation results, face several technical challenges in practical applications. These include: the accuracy of microcrack segmentation; the small, shallow features of microcracks are similar to those of scratches, dust, and reflections on the glass surface; existing models have failed to effectively implement formulaic methods for feature enhancement and lack a mechanism to distinguish between cracks and background using weighted formulas, resulting in serious false negatives and false positives; furthermore, current technologies rely heavily on fixed threshold binarization and simple morphological operations, without implementing post-processing optimization through adaptive threshold formulas and geometric parameter calculations, making them susceptible to the effects of glass surface reflection and light source brightness fluctuations, leading to poor robustness and repeatability of the segmentation results. Furthermore, the traditional UNet++ model uses ordinary convolutional blocks and dense skip connections, without introducing a lightweight convolution design, resulting in a model parameter count exceeding tens of millions and a single-frame inference time exceeding 100 milliseconds, which cannot meet the high-speed inspection requirements of industrial production lines that produce more than 300 pieces per minute.

[0004] Therefore, existing glass substrate microcrack detection technologies are insufficient in terms of accuracy, speed, and robustness. In-depth research and innovation are urgently needed in areas such as feature enhancement, model lightweighting, loss function design, preprocessing and postprocessing, and attention mechanisms to meet the needs of industrial production.

[0005] The information disclosed in the background section is only intended to enhance the understanding of the background of this disclosure, and therefore may include information that does not constitute prior art known to those skilled in the art. Summary of the Invention

[0006] The purpose of this invention is to provide a method for segmenting microcracks in glass substrates based on a lightweight deep learning model, so as to solve the problems mentioned in the background art.

[0007] To achieve the above objectives, the present invention provides the following technical solution: A method for segmenting microcracks in glass substrates based on a lightweight deep learning model, comprising the following steps: Several original images of glass substrates are acquired, preprocessing is performed on the original images to obtain standard glass substrate images, the microcrack contours of the standard glass substrate images are annotated, and corresponding crack probability mask images are generated. Based on the UNet++ network architecture, MobileNetV3 is used as the encoder backbone network in the UNet++ network. A depthwise separable convolution algorithm is designed to replace the convolution operation in the UNet++ network. The CBAM channel-spatial attention mechanism is integrated at the output of each layer of the encoder backbone network and at the decoder feature splicing node in the UNet++ network to construct a lightweight UNet++-CBAM segmentation model. The standard glass substrate image is used as the input to the segmentation model, the corresponding crack probability mask is used as the label, and a hybrid form of weighted Dice loss and binary cross-entropy loss is used as the loss function to train the segmentation model. The standard glass substrate image to be segmented is input into the trained segmentation model to obtain the crack probability mask of the image. The probability of each pixel in the image being a microcrack is extracted. The binarization threshold is calculated by the Otsu method adaptive threshold formula, and the crack probability mask is binarized based on the binarization threshold to obtain the crack binary image. Based on the binary image of the crack, candidate crack regions are identified by an eight-neighbor connected region labeling algorithm. Judgment criteria are formulated according to the geometric features of the candidate crack regions to eliminate interference regions and determine the accurate crack regions.

[0008] Furthermore, the preprocessing operation specifically refers to the sequential execution of a formulaic operation involving bilateral filtering for noise reduction, lens distortion correction, grayscale normalization, and Laplacian pyramid feature enhancement. The specific method for grayscale normalization includes: for the original image after lens distortion correction, extracting the maximum and minimum grayscale values ​​within it, and calculating the difference between the two as the normalization reference value; for any pixel in the original image after distortion correction, calculating the difference between its grayscale value and the minimum grayscale value, dividing the difference by the normalization reference value and multiplying by 255 to obtain the normalized pixel grayscale value of that pixel, whose value ranges from 0 to 255, thereby completing grayscale normalization; The Laplacian pyramid feature enhancement specifically includes: for the original image after grayscale normalization, for each Gaussian pyramid layer, the corresponding Laplacian pyramid layer is calculated. The specific technical method is as follows: the original image after the current layer Gaussian pyramid processing is determined as the Gaussian image, the upper layer Gaussian image corresponding to the current layer is upsampled, the upsampling result is convolved with a 5×5 Gaussian convolution kernel to obtain the convolution result, and the Gaussian image of the current layer is subtracted from the convolution result to obtain the corresponding Laplacian pyramid layer. Feature enhancement calculations are performed based on the obtained Laplacian pyramid layers. Specifically, the bottom image of the Gaussian pyramid is added to the weighted sum of all Laplacian pyramid layers. The weighted sum is obtained by multiplying the Laplacian image of each layer by an optimization coefficient and then accumulating the sums to obtain the standard glass substrate image. The optimization coefficient is set to a value between 0.8 and 1.2.

[0009] Furthermore, the computation process of the depthwise separable convolution algorithm consists of two main steps, as follows: 1) The input standard glass substrate image is processed by a depthwise convolution operation. Specifically, the input standard glass substrate image is convolved by a depthwise convolution kernel to generate an intermediate feature map, which is the depthwise convolution output feature map. The size of the depthwise convolution kernel is k×k, where k is the side length of the depthwise convolution kernel. 2) Perform point convolution operation on the intermediate feature map generated by depthwise convolution. Use a 1×1 point convolution kernel to convolve the intermediate feature map to generate a depthwise separable convolution point convolution output feature map, which is the final output of the depthwise separable convolution. The number of channels of the point convolution output feature map is determined by the number of output channels of the point convolution. The size of the point convolution output feature map is specifically composed of the number of channels, the number of output channels, the height, and the width of the standard glass substrate image.

[0010] Furthermore, the CBAM channel-spatial attention mechanism specifically includes a CBAM channel attention submodule and a CBAM spatial attention submodule; The CBAM channel attention submodule processes the point convolution output feature map as follows: 1) Perform global average pooling and global max pooling on the point convolution output feature map. The global average pooling calculates the average value of all spatial positions of each channel to obtain the first channel description vector; the global max pooling selects the maximum value of each channel to form the second channel description vector. 2) Input the first channel description vector and the second channel description vector into the set multilayer perceptron. The multilayer perceptron consists of two layers. The number of hidden layer nodes of the multilayer perceptron is set to one-eighth of the number of channels of the point convolution output feature map. The two channel description vectors are processed by the multilayer perceptron, the results are added together, and a nonlinear transformation is performed through the Sigmoid activation function to generate channel attention weight values. 3) The generated channel attention weight values ​​are applied to the point convolution output feature map. Specifically, the point convolution output feature map of each channel is multiplied with the corresponding attention weight through a channel-by-channel multiplication operation to obtain a weighted feature map, which is then used as the output of the CBAM channel attention submodule.

[0011] Furthermore, the CBAM spatial attention submodule processes the weighted feature map as follows: 1) Perform average pooling and max pooling on each channel of the weighted feature map in the spatial dimension. The average pooling is to generate an average phase feature map by calculating the average value of each channel in the spatial position within the weighted feature map. The max pooling is to select the maximum value of each channel to form a maximum phase feature map. The average phase feature map and the maximum phase feature map are concatenated in the channel dimension to obtain a spatially merged feature map. 2) Perform a 3×3 convolution operation on the spatial merged feature map, and apply the Sigmoid activation function to the convolution result for non-linear transformation to generate spatial attention weights; multiply the generated spatial attention weights with the weighted feature map pixel by pixel to finally obtain the channel-spatial weighted enhanced feature map output by the CBAM channel-spatial attention mechanism.

[0012] Furthermore, the specific method for constructing the loss function is as follows: a loss weight coefficient is introduced, the value of which is between 0.4 and 0.6. The loss function consists of a binary cross-entropy loss and a weighted Dice loss. The product of the loss weight coefficient and the binary cross-entropy loss is denoted as the first loss coefficient. Calculate the difference between constant 1 and the loss weight coefficient, and multiply the difference by the weighted Dice loss as the second loss coefficient. Use the sum of the second loss coefficient and the first loss coefficient as the loss function.

[0013] Furthermore, when training the segmentation model, a cosine annealing learning rate decay algorithm is introduced to adjust the learning rate during the training process. The specific adjustment method includes: the learning rate of the current training round is calculated by the initial learning rate and the decay factor. The decay factor is based on the cosine function. The cosine function is specifically expressed as: multiplying the ratio of the current training round number to the total training round number by pi as the independent variable of the cosine function, and using the output of the cosine function under the corresponding independent variable as the decay factor. The specific method for calculating the learning rate of the current training round based on the decay factor is as follows: add a constant 1 to the decay factor, divide the result by 2 to obtain the adjustment scaling factor, and use the product of the adjustment scaling factor and the initial learning rate as the learning rate of the current training round.

[0014] Furthermore, the specific method for calculating the binarization threshold includes: defining a candidate probability threshold; based on the candidate probability threshold, dividing the pixels in the crack probability mask into two categories: pixels with probability values ​​less than or equal to the candidate probability threshold and pixels with probability values ​​greater than the candidate probability threshold; counting the number of pixels in each category; calculating the inter-class variance of the candidate probability threshold based on the mean probability values ​​of the two categories of pixels; iterating through all candidate probability threshold values; and selecting the candidate probability threshold with the largest inter-class variance as the binarization threshold.

[0015] Furthermore, the geometric features of the candidate crack region include the total pixel area, aspect ratio, and skeleton length of the candidate crack region; The logic behind the determination criteria is as follows: for any candidate crack region, if any one of its total pixel area, aspect ratio, and skeleton length is not less than the corresponding set determination threshold, then the candidate crack region is determined to be a precise crack region.

[0016] Compared with the prior art, the beneficial effects of the present invention are: This solution significantly reduces the number of model parameters and computational complexity by replacing traditional convolution operations with a depthwise separable convolution algorithm, enabling high-speed inference in industrial inspection scenarios, improving production efficiency and reducing costs. At the same time, by introducing MobileNetV3 as the encoder backbone network, it fully utilizes its design concept optimized for mobile devices, achieving the best balance between lightweight and high performance, ensuring that the model still has good adaptability in resource-constrained industrial environments. Secondly, this scheme integrates the channel-space attention mechanism (CBAM) into the network structure, which effectively enhances the ability to capture microcrack features. Through detailed weighting of the feature map, the model can more accurately distinguish microcracks from the background, thereby improving the segmentation accuracy of microcracks. Furthermore, the binarization method based on Otsu's adaptive threshold, combined with the post-processing step of the eight-neighbor connected component labeling algorithm, further improves the accuracy of crack region identification and extraction. Interference regions are eliminated through geometric feature judgment criteria, resulting in higher reliability and accuracy of the final output crack region. In practical applications, this provides strong support for the quality control of glass substrates, ensuring product reliability and performance stability, and is of great significance for promoting the intelligent and automated development of the glass manufacturing industry. Through these comprehensive improvements, the overall efficiency and accuracy of glass substrate microcrack detection have been significantly improved, providing a more solid quality guarantee for subsequent production processes. Attached Figure Description

[0017] Figure 1 This is a schematic diagram of the overall method flow of the present invention; Figure 2 This is a classification diagram for judging the effectiveness of cracks. Detailed Implementation

[0018] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to specific embodiments.

[0019] It should be noted that, unless otherwise defined, the technical or scientific terms used in this invention should have the ordinary meaning understood by one of ordinary skill in the art to which this invention pertains. The terms "first," "second," and similar terms used in this invention do not indicate any order, quantity, or importance, but are merely used to distinguish different components. Terms such as "comprising" or "including" mean that the element or object preceding the word encompasses the elements or objects listed following the word and their equivalents, without excluding other elements or objects. Terms such as "connected" or "linked" are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect. Terms such as "upper," "lower," "left," and "right" are used only to indicate relative positional relationships; when the absolute position of the described object changes, the relative positional relationship may also change accordingly.

[0020] Example: Please see Figures 1-2 The present invention provides a technical solution: A method for segmenting microcracks in glass substrates based on a lightweight deep learning model, comprising the following steps: Step 1: Acquire several original images of glass substrates, perform preprocessing operations on the original images to obtain standard glass substrate images, annotate the microcrack contours of the standard glass substrate images, and generate corresponding crack probability mask maps.

[0021] The specific method for obtaining raw imaging data of glass substrates is as follows: An imaging system is set up at the glass substrate industrial inspection station, including a CCD area array camera / line array camera with a resolution of ≥4096×2048, 4 sets of high-brightness diffuse reflection cold light source groups, and an anti-reflective stage; the light source groups and the camera are arranged symmetrically at a 45° angle to avoid specular reflection on the glass surface, the camera optical axis is perpendicular to the glass substrate inspection surface, and the acquisition speed is matched with the production line conveying speed (≥300 pieces / minute); the acquired raw imaging data is an 8-bit grayscale image. If it is an RGB image, it is first converted to a grayscale image using a grayscale conversion formula to ensure data consistency.

[0022] Specifically, a 4096×2048 resolution area array CCD camera is used, paired with 4 sets of high-brightness diffuse reflection cold light sources. The light sources and the camera are arranged at a 45° angle. The camera optical axis is perpendicular to the detection surface of the photovoltaic glass substrate. The acquisition speed is 5 frames / second (matching the production line speed of 300 pieces / minute). The acquired raw imaging data is an 8-bit grayscale image with an image size of 4096×2048 pixels.

[0023] The preprocessing operation specifically refers to the sequential execution of a formulaic operation involving bilateral filtering for noise reduction, lens distortion correction, grayscale normalization, and Laplacian pyramid feature enhancement. Bilateral filtering is an effective image denoising technique designed to reduce image noise while preserving edge details. The specific steps are as follows: First, determine the neighborhood size and two important parameters: spatial range and intensity range. The spatial range determines the distance between neighboring pixels, while the intensity range determines the similarity of pixel values. For each pixel in the image, define a window containing that pixel and its surrounding neighboring pixels as the neighborhood window. The size of this window should be consistent with the previously selected neighborhood size. For each pixel in the neighborhood, calculate its spatial weight and intensity weight relative to the current pixel. The spatial weight depends on the distance between pixels; closer pixels have higher weights. The intensity weight is based on the similarity of pixel values; pixels with higher similarity have higher weights. Multiply the gray values ​​of all pixels in the neighborhood by their corresponding weights and then perform a weighted average to obtain the new gray value of the current pixel. In this way, noise is effectively removed only while preserving edges and details.

[0024] The lens distortion correction is used to correct image distortion caused by lens characteristics. The specific steps are as follows: 1. Acquire correction images: Multiple images are taken using a specific correction pattern (such as a checkerboard pattern), ensuring they are taken from different angles and positions to obtain comprehensive data for correction. 2. Detect corner points: In each correction image, a corner detection algorithm is used to find the corner positions of the checkerboard pattern; these corner points will be used for subsequent camera calibration. 3. Calculate distortion parameters: Using the detected corner points and the known actual size of the correction pattern, the lens's intrinsic parameters and distortion coefficients are calculated using a camera calibration algorithm. These parameters define the lens's characteristics and degree of distortion. 4. Perform correction: The calculated distortion parameters are used to correct the original image. Specifically, each pixel position in the original image is remapped to the corrected image, thereby eliminating geometric distortion.

[0025] The specific method for grayscale normalization includes: for the original image after lens distortion correction, extracting the maximum and minimum grayscale values, and calculating the difference between them as the normalization reference value; for any pixel in the original image after distortion correction, calculating the difference between its grayscale value and the minimum grayscale value, dividing this difference by the normalization reference value, and multiplying by 255 to obtain the normalized pixel grayscale value, which ranges from 0 to 255, thus completing the grayscale normalization; the specific formula used is: In the formula, The normalized pixel grayscale value. This represents the minimum grayscale value of the image after distortion correction. This represents the maximum grayscale value of the image after distortion correction. This represents the grayscale value of a single pixel in the image after distortion correction.

[0026] The Laplacian pyramid feature enhancement specifically includes: for the original image after grayscale normalization, for each Gaussian pyramid layer, the corresponding Laplacian pyramid layer is calculated. The specific technical method is as follows: the original image after the current layer Gaussian pyramid processing is determined as the Gaussian image, the upper layer Gaussian image corresponding to the current layer is upsampled, the upsampling result is convolved with a 5×5 Gaussian convolution kernel to obtain the convolution result, and the Gaussian image of the current layer is subtracted from the convolution result to obtain the corresponding Laplacian pyramid layer. Feature enhancement calculations are performed based on the obtained Laplacian pyramid layers. Specifically, the image of the lowest layer of the Gaussian pyramid is added to the weighted sum of all Laplacian pyramid layers. This weighted sum is obtained by multiplying the Laplacian image of each layer by an optimization coefficient and then accumulating the results. The final image is a standard glass substrate image. The optimization coefficient is set between 0.8 and 1.2. The specific formula used for Laplacian pyramid feature enhancement is as follows: In the formula, For the image of the Laplacian pyramid layer, For the image of the Gaussian pyramid layer, Image of the Gaussian pyramid layer, It uses a 5×5 Gaussian convolution kernel. Indicates an upsampling operation. For convolution operations, i is the index of the pyramid level. This represents the total number of levels in the Pyramid of Laplace. For the image of the Laplacian pyramid The optimization coefficients for the layer are set between 0.8 and 1.2. This is the bottom layer image of the Gaussian pyramid, which represents the normalized image of the original imaging data of the glass substrate. This represents an image of a standard glass substrate.

[0027] Use image annotation tools, such as LabelMe, Labelbox, or custom annotation software, to annotate the image. Open the standard glass substrate image in the annotation tool and use drawing tools, such as polygons, curves, or freehand brushes, to manually draw the outline of the microcracks. After completing the annotation, save the annotation results in the appropriate format, such as JSON or XML, for later use. These annotation results will contain the coordinate information of the cracks. Based on the previous annotation results, the annotated crack contours are filled onto the mask image. For each crack contour, the corresponding pixel value is set to a higher value, such as 255, to indicate that a crack exists in that area. The probability mask is generated by processing the mask image using Gaussian blur or other smoothing techniques to generate a smooth probability distribution map, thus forming the crack probability mask image.

[0028] Step 2: Based on the UNet++ network architecture, MobileNetV3 is used as the encoder backbone network in the UNet++ network. A depthwise separable convolution algorithm is designed to replace the convolution operation in the UNet++ network. The CBAM channel-spatial attention mechanism is integrated at the output of each layer of the encoder backbone network and at the feature splicing node of the decoder in the UNet++ network to build a lightweight UNet++-CBAM segmentation model.

[0029] Instead of using traditional UNet++ convolutional blocks, MobileNetV3 is adopted as the encoder backbone network. Combined with depthwise separable convolutions, lightweight feature extraction is achieved, reducing the number of model parameters by more than 70% while maintaining feature extraction capabilities. The encoder consists of an initial convolutional layer and four bottleneck convolutional blocks. Initial convolutional layer: Consists of 3×3 ordinary convolution, batch normalization (BN), and HSwish activation function, which maps the single-channel normalized image into a 16-channel feature map; Bottleneck convolutional blocks: All adopt the inverse residual structure of MobileNetV3, with depthwise separable convolution as the core. Downsampling is achieved through depthwise separable convolution with a stride of 2. The number of output channels of the four bottleneck convolutional blocks are 32, 64, 128 and 256 respectively, and the spatial resolution is reduced to 1 / 2, 1 / 4, 1 / 8 and 1 / 16 of the input image respectively, realizing hierarchical extraction of microcrack features.

[0030] The computation process of the depthwise separable convolution algorithm consists of two main steps, as follows: 1) The input standard glass substrate image is processed by a depthwise convolution operation. Specifically, the input standard glass substrate image is convolved by a depthwise convolution kernel to generate an intermediate feature map, which is the depthwise convolution output feature map. The size of the depthwise convolution kernel is k×k, where k is the side length of the depthwise convolution kernel. 2) Perform point convolution on the intermediate feature map generated by depthwise convolution. Use a 1×1 point convolution kernel to convolve the intermediate feature map, generating a depthwise separable point convolution output feature map, which is the final output of the depthwise separable convolution. The number of channels in the point convolution output feature map is determined by the number of output channels of the point convolution. The size of the point convolution output feature map is specifically composed of the number of channels, the number of output channels, the height, and the width of the standard glass substrate image; the specific formula is expressed as: In the formula, The input is a standard glass substrate image. For depthwise convolution kernels, , This refers to the number of channels in a standard glass substrate image. It is a 1×1 point convolution kernel. , Number of output channels This is an intermediate feature map. The point convolution outputs a feature map.

[0031] It should be noted that the initial convolutional layer maps a single-channel image into a 16-channel feature map; 4 bottleneck convolutional blocks use depthwise separable convolutions, and the output channel numbers are 32, 64, 128, and 256 in sequence; The CBAM channel-spatial attention mechanism specifically includes a CBAM channel attention sub-module and a CBAM spatial attention sub-module; The processing of the point convolutional output feature map by the CBAM channel attention sub-module is as follows: 1) Global average pooling and global max pooling are performed on the point convolutional output feature map. The global average pooling calculates the average value of all spatial positions in each channel to obtain the first channel description vector; the global max pooling selects the maximum value in each channel to form the second channel description vector; 2) The first channel description vector and the second channel description vector are respectively input into the set multi-layer perceptron. The multi-layer perceptron is composed of two layers of perceptrons. The number of hidden layer nodes of the multi-layer perceptron is set to one-eighth of the channel number of the point convolutional output feature map. The two channel description vectors are processed by the multi-layer perceptron, the obtained results are added, and a non-linear transformation is performed through the Sigmoid activation function to generate the channel attention weight value; 3) The generated channel attention weight value is applied to the point convolutional output feature map. Specifically, through the per-channel multiplication operation, the point convolutional output feature map of each channel is multiplied by the corresponding attention weight to obtain the weighted feature map, which is used as the output of the CBAM channel attention sub-module. The specific formula is: In the formula, is the channel attention weight value, represents the first channel description vector, represents the second channel description vector, represents the global average pooling operation, represents the global max pooling operation, represents the per-channel multiplication operation, represents the Sigmoid activation function, represents the perceptron structure of the multi-layer perceptron, is the weighted feature map.

[0032] The processing of the weighted feature map by the CBAM spatial attention sub-module is as follows: 1) Perform average pooling and max pooling on each channel of the weighted feature map in the spatial dimension. The average pooling is to generate an average phase feature map by calculating the average value of each channel in the spatial position within the weighted feature map. The max pooling is to select the maximum value of each channel to form a maximum phase feature map. The average phase feature map and the maximum phase feature map are concatenated in the channel dimension to obtain a spatially merged feature map. 2) Perform a 3×3 convolution operation on the spatial merged feature map, and apply a Sigmoid activation function to the convolution result for non-linear transformation to generate spatial attention weights. Multiply the generated spatial attention weights pixel-by-pixel with the weighted feature map to obtain the channel-spatial weighted enhanced feature map output by the CBAM channel-spatial attention mechanism; the specific formula is as follows: In the formula, Spatial attention weights, This represents a 3×3 convolution operation. This represents the average pooling operation along the channel dimension. Represents the average phase characteristic diagram. This represents the max pooling operation at the channel level. Represents the maximum phase characteristic map. This refers to the spatial merging feature map. Channel-spatial weighted enhanced feature map; It should be noted that the last layer of the decoder is connected to a 1×1 convolutional layer, which maps the 16-channel feature map into a single-channel feature map, which is then activated by the Sigmoid function. Output a crack probability map ranging from 0 to 1 to achieve pixel-level micro-crack probability determination.

[0033] Step 3: Use the standard glass substrate image as input to the segmentation model, the corresponding crack probability mask as label, and a hybrid form of weighted Dice loss and binary cross-entropy loss as the loss function to train the segmentation model. The standardized glass substrate image and the corresponding mask image are input into the lightweight UNet++-CBAM segmentation model. When training the segmentation model, the loss function is specifically constructed as follows: a loss weight coefficient is introduced, the value of which is between 0.4 and 0.6. The loss function consists of binary cross-entropy loss and weighted Dice loss. The product of the loss weight coefficient and the binary cross-entropy loss is denoted as the first loss coefficient. The difference between the constant 1 and the loss weight coefficient is calculated, and the product of this difference and the weighted Dice loss is denoted as the second loss coefficient. The sum of the second loss coefficient and the first loss coefficient is used as the loss function. Since the binary cross-entropy loss and the weighted Dice loss are both conventional existing techniques, their specific expressions are not elaborated here. A cosine annealing learning rate decay algorithm is introduced to adjust the learning rate during training. The specific adjustment method includes: the learning rate for the current training epoch is calculated jointly by the initial learning rate and a decay factor. The decay factor is based on a cosine function, specifically expressed as: the ratio of the current training epoch to the total number of training epochs multiplied by pi as the independent variable of the cosine function, and the output of the cosine function under the corresponding independent variable as the decay factor. The cosine annealing learning rate decay mechanism ensures that the learning rate is relatively high in the early stages of training, then gradually decreases, eventually approaching zero at the end of training. This smoothly guides the model to converge gradually, avoiding oscillations caused by excessively high learning rates in the later stages of training. The characteristics of the cosine function make the learning rate change adaptive, better adapting to the training process. The gradual decrease in the learning rate due to cosine annealing maintains a certain learning capacity, helping the model escape local optima, further optimizing global search capabilities, and increasing the probability of finding the global optimum.

[0034] The specific method for calculating the learning rate of the current training epoch based on the decay factor is as follows: Add a constant 1 to the decay factor, divide the result by 2 to obtain the adjustment scaling factor, and use the product of the adjustment scaling factor and the initial learning rate as the learning rate of the current training epoch; the specific formula used is: In the formula, The learning rate for the current training round. This represents the initial learning rate. The total number of training rounds. This is the current training round number; The AdamW optimizer is used for parameter updates, and the learning rate is adjusted using the cosine annealing learning rate decay formula described above, with an initial learning rate of... Total number of training rounds Batch size is set to 16; Step 4: Input the standard glass substrate image to be segmented into the trained segmentation model to obtain the crack probability mask of the image. Extract the probability of each pixel in the image being a microcrack. Calculate the binarization threshold using the Otsu method adaptive threshold formula, and perform binarization operation on the crack probability mask based on the binarization threshold to obtain the crack binary image.

[0035] The specific method for calculating the binarization threshold includes: defining a candidate probability threshold; based on the candidate probability threshold, dividing the pixels in the crack probability mask into two categories: pixels with probability values ​​less than or equal to the candidate probability threshold and pixels with probability values ​​greater than the candidate probability threshold, and counting the number of pixels in each category; calculating the inter-class variance of the candidate probability threshold based on the mean probability values ​​of the two categories of pixels; iterating through all candidate probability threshold values, and selecting the candidate probability threshold with the largest inter-class variance as the binarization threshold; the specific formula used to determine the binarization threshold is as follows: In the formula, To represent the inter-class variance corresponding to the candidate probability threshold, This represents the proportion of pixels whose probability value is less than or equal to the candidate probability threshold. This represents the proportion of pixels whose probability value is greater than the candidate probability threshold. This represents the mean probability of pixels whose probability value is less than or equal to the candidate probability threshold. This represents the average probability of pixels whose probability value is greater than the candidate probability threshold.

[0036] Step 5: Based on the binary image of the crack, candidate crack regions are identified by the eight-neighbor connected component labeling algorithm, and judgment criteria are formulated according to the geometric features of the candidate crack regions to eliminate interference regions and determine the precise crack regions.

[0037] The specific method for identifying candidate crack regions using the eight-neighbor connected component labeling algorithm is as follows: Prepare a labeling matrix of the same size as the crack binary image to store the labeling value of each connected component; initialize the labeling matrix to zero, traverse each pixel of the crack binary image, starting from the top left corner, scan the entire binary image row by row and column by column, check the current pixel, for each pixel, if its value is 1, it means that it belongs to the crack and has not been labeled in the labeling matrix, then the connected component needs to be labeled; Assign a unique label value to the newly identified crack region, for example, starting from 1 and incrementing; The labeling process begins with either Depth-First Search (DFS) or Breadth-First Search (BFS) algorithms to identify connected components. Taking DFS as an example: a stack or queue is created, and the coordinates of the current pixel are pushed onto the stack. The following process is repeated until the stack is empty: a pixel coordinate is popped from the stack; this pixel is then marked as the current label value in the labeling matrix; the eight neighbors of this pixel (top, bottom, left, right, and four diagonals) are checked: for each neighboring pixel, its coordinates are checked to see if they are within the image range, have a value of 1, and are not yet labeled in the labeling matrix. If these conditions are met, the coordinates of this neighboring pixel are pushed onto the stack for further labeling. After traversing the entire image, the next unlabeled pixel is checked until all pixels have been checked.

[0038] The geometric features of the candidate crack region include the total pixel area, aspect ratio, and skeleton length of the candidate crack region; The logic behind the determination criteria is as follows: for any candidate crack region, if any one of its total pixel area, aspect ratio, and skeleton length is not less than the corresponding set determination threshold, then the candidate crack region is determined to be a precise crack region.

[0039] It should be noted that microcracks usually have specific geometric features. Therefore, a judgment criterion is constructed based on the specific geometric features of the crack structure. If the geometric features of the candidate crack region do not meet the judgment criterion, it means that the probability of the defect in the candidate crack region being a crack is small. Therefore, it is discarded as an interference region. The candidate crack regions that meet the judgment criterion are retained as accurate crack regions to provide a reference for subsequent detection.

[0040] The specific geometric features and their significance are as follows: the total pixel area represents the overall size of the candidate crack region; the aspect ratio describes the shape features of the candidate crack region, which is the ratio of the long side to the short side of its smallest bounding rectangle; and the skeleton length is the length of the centerline of the candidate region, representing the main structure inside the region. Microcracks are usually caused by stress concentration inside or on the surface of a material, and they are characterized by a slender and extended shape. This shape determines that microcracks often have a relatively large aspect ratio and skeleton length, so the area where microcracks exist has a certain area. At the same time, if the total pixel area, aspect ratio and skeleton length of the candidate crack area are all greater than the corresponding judgment threshold, it indicates that the candidate crack area may contain structural cracks caused by microcracks. Therefore, it is also judged as a precise crack area for subsequent analysis.

[0041] The specific thresholds for judgment include the area threshold, aspect ratio threshold, and skeleton length threshold, among which the area threshold is generally set to... The aspect ratio threshold is generally set to The skeleton length threshold is generally set to The area threshold, aspect ratio threshold, and skeleton length threshold can be further adjusted based on specific detection accuracy requirements and expert experience.

[0042] By setting area thresholds, aspect ratio thresholds, and skeleton length thresholds, candidate crack regions with a low probability of cracking are eliminated, further improving detection accuracy.

[0043] The above formulas are all dimensionless calculations. The formulas are derived from software simulations based on a large amount of collected data to obtain the most recent real-world results. The preset parameters in the formulas are set by those skilled in the art according to the actual situation.

[0044] The above embodiments can be implemented, in whole or in part, by software, hardware, firmware, or any other combination thereof. When implemented in software, the above embodiments can be implemented, in whole or in part, as a computer program product. Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented by electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution.

[0045] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment, depending on actual needs.

[0046] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application.

Claims

1. A method for segmenting microcracks in glass substrates based on a lightweight deep learning model, characterized in that, The specific steps include: Several original images of glass substrates are acquired, preprocessing is performed on the original images to obtain standard glass substrate images, the microcrack contours of the standard glass substrate images are annotated, and corresponding crack probability mask images are generated. Based on the UNet++ network architecture, MobileNetV3 is used as the encoder backbone network in the UNet++ network. A depthwise separable convolution algorithm is designed to replace the convolution operation in the UNet++ network. The CBAM channel-spatial attention mechanism is integrated at the output of each layer of the encoder backbone network and at the decoder feature splicing node in the UNet++ network to construct a lightweight UNet++-CBAM segmentation model. The standard glass substrate image is used as the input to the segmentation model, the corresponding crack probability mask is used as the label, and a hybrid form of weighted Dice loss and binary cross-entropy loss is used as the loss function to train the segmentation model. The standard glass substrate image to be segmented is input into the trained segmentation model to obtain the crack probability mask of the image. The probability of each pixel in the image being a microcrack is extracted. The binarization threshold is calculated by the Otsu method adaptive threshold formula, and the crack probability mask is binarized based on the binarization threshold to obtain the crack binary image. Based on the binary image of the crack, candidate crack regions are identified by an eight-neighbor connected region labeling algorithm. Judgment criteria are formulated according to the geometric features of the candidate crack regions to eliminate interference regions and determine the accurate crack regions.

2. The method for segmenting microcracks in glass substrates based on a lightweight deep learning model according to claim 1, characterized in that: The preprocessing operation specifically refers to the sequential execution of a formulaic operation involving bilateral filtering for noise reduction, lens distortion correction, grayscale normalization, and Laplacian pyramid feature enhancement. The specific method for grayscale normalization includes: for the original image after lens distortion correction, extracting the maximum and minimum grayscale values ​​within it, and calculating the difference between the two as the normalization reference value; for any pixel in the original image after distortion correction, calculating the difference between its grayscale value and the minimum grayscale value, dividing the difference by the normalization reference value and multiplying by 255 to obtain the normalized pixel grayscale value of that pixel, whose value ranges from 0 to 255, thereby completing grayscale normalization; The Laplacian pyramid feature enhancement specifically includes: for the original image after grayscale normalization, for each Gaussian pyramid layer, the corresponding Laplacian pyramid layer is calculated. The specific technical method is as follows: the original image after the current layer Gaussian pyramid processing is determined as the Gaussian image, the upper layer Gaussian image corresponding to the current layer is upsampled, the upsampling result is convolved with a 5×5 Gaussian convolution kernel to obtain the convolution result, and the Gaussian image of the current layer is subtracted from the convolution result to obtain the corresponding Laplacian pyramid layer. Feature enhancement calculations are performed based on the obtained Laplacian pyramid layers. Specifically, the bottom image of the Gaussian pyramid is added to the weighted sum of all Laplacian pyramid layers. The weighted sum is obtained by multiplying the Laplacian image of each layer by an optimization coefficient and then accumulating the sums to obtain the standard glass substrate image. The optimization coefficient is set to a value between 0.8 and 1.

2.

3. The method for segmenting microcracks in glass substrates based on a lightweight deep learning model according to claim 2, characterized in that: The computation process of the depthwise separable convolution algorithm consists of two main steps, as follows: 1) The input standard glass substrate image is processed by a depthwise convolution operation. Specifically, the input standard glass substrate image is convolved by a depthwise convolution kernel to generate an intermediate feature map, which is the depthwise convolution output feature map. The size of the depthwise convolution kernel is k×k, where k is the side length of the depthwise convolution kernel. 2) Perform point convolution operation on the intermediate feature map generated by depthwise convolution. Use a 1×1 point convolution kernel to convolve the intermediate feature map to generate a depthwise separable convolution point convolution output feature map, which is the final output of the depthwise separable convolution. The number of channels of the point convolution output feature map is determined by the number of output channels of the point convolution. The size of the point convolution output feature map is specifically composed of the number of channels, the number of output channels, the height, and the width of the standard glass substrate image.

4. The method for segmenting microcracks in glass substrates based on a lightweight deep learning model according to claim 3, characterized in that: The CBAM channel-spatial attention mechanism specifically includes a CBAM channel attention submodule and a CBAM spatial attention submodule; The CBAM channel attention submodule processes the point convolution output feature map as follows: 1) Perform global average pooling and global max pooling on the point convolution output feature map. The global average pooling calculates the average value of all spatial positions of each channel to obtain the first channel description vector; the global max pooling selects the maximum value of each channel to form the second channel description vector. 2) Input the first channel description vector and the second channel description vector into the set multilayer perceptron. The multilayer perceptron consists of two layers. The number of hidden layer nodes of the multilayer perceptron is set to one-eighth of the number of channels of the point convolution output feature map. The two channel description vectors are processed by the multilayer perceptron, the results are added together, and a nonlinear transformation is performed through the Sigmoid activation function to generate channel attention weight values. 3) The generated channel attention weight values ​​are applied to the point convolution output feature map. Specifically, the point convolution output feature map of each channel is multiplied with the corresponding attention weight through a channel-by-channel multiplication operation to obtain a weighted feature map, which is then used as the output of the CBAM channel attention submodule.

5. The method for segmenting microcracks in glass substrates based on a lightweight deep learning model according to claim 4, characterized in that, The CBAM spatial attention submodule processes the weighted feature map as follows: 1) Perform average pooling and max pooling on each channel of the weighted feature map in the spatial dimension. The average pooling is to generate an average phase feature map by calculating the average value of each channel in the spatial position within the weighted feature map. The max pooling is to select the maximum value of each channel to form a maximum phase feature map. The average phase feature map and the maximum phase feature map are concatenated in the channel dimension to obtain a spatially merged feature map. 2) Perform a 3×3 convolution operation on the spatial merged feature map, and apply the Sigmoid activation function to the convolution result for non-linear transformation to generate spatial attention weights; multiply the generated spatial attention weights with the weighted feature map pixel by pixel to finally obtain the channel-spatial weighted enhanced feature map output by the CBAM channel-spatial attention mechanism.

6. The method for segmenting microcracks in glass substrates based on a lightweight deep learning model according to claim 1, characterized in that, The specific method for constructing the loss function is as follows: a loss weight coefficient is introduced, the value of which is between 0.4 and 0.

6. The loss function consists of a binary cross-entropy loss and a weighted Dice loss. The product of the loss weight coefficient and the binary cross-entropy loss is denoted as the first loss coefficient. Calculate the difference between constant 1 and the loss weight coefficient, and multiply the difference by the weighted Dice loss as the second loss coefficient. Use the sum of the second loss coefficient and the first loss coefficient as the loss function.

7. The method for segmenting microcracks in glass substrates based on a lightweight deep learning model according to claim 6, characterized in that: When training the segmentation model, a cosine annealing learning rate decay algorithm is introduced to adjust the learning rate during the training process. The specific adjustment method includes: the learning rate of the current training round is calculated by the initial learning rate and the decay factor. The decay factor is based on the cosine function. The cosine function is specifically expressed as: multiplying the ratio of the current training round number to the total training round number by pi as the independent variable of the cosine function, and using the output of the cosine function under the corresponding independent variable as the decay factor. The specific method for calculating the learning rate of the current training round based on the decay factor is as follows: add a constant 1 to the decay factor, divide the result by 2 to obtain the adjustment scaling factor, and use the product of the adjustment scaling factor and the initial learning rate as the learning rate of the current training round.

8. The method for segmenting microcracks in glass substrates based on a lightweight deep learning model according to claim 7, characterized in that, The specific method for calculating the binarization threshold includes: defining a candidate probability threshold; based on the candidate probability threshold, dividing the pixels in the crack probability mask into two categories: pixels with probability values ​​less than or equal to the candidate probability threshold and pixels with probability values ​​greater than the candidate probability threshold, and counting the number of pixels in each category; calculating the inter-class variance of the candidate probability threshold based on the mean of the probability values ​​of the two categories of pixels; iterating through all candidate probability threshold values ​​and selecting the candidate probability threshold with the largest inter-class variance as the binarization threshold.

9. The method for segmenting microcracks in glass substrates based on a lightweight deep learning model according to claim 8, characterized in that, The geometric features of the candidate crack region include the total pixel area, aspect ratio, and skeleton length of the candidate crack region; The logic behind the determination criteria is as follows: for any candidate crack region, if any one of its total pixel area, aspect ratio, and skeleton length is not less than the corresponding set determination threshold, then the candidate crack region is determined to be a precise crack region.