Steel surface corrosion degree classification and monitoring method based on improved UNet network

By combining macroscopic and microscopic features with an improved UNet network, introducing global attention and triple attention modules, and constructing a composite loss function, the problems of low automation and insufficient accuracy in steel corrosion detection are solved, achieving high-precision corrosion monitoring and accurate capture of early corrosion features.

CN121600325AActive Publication Date: 2026-03-03OCEAN UNIV OF CHINA
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202610011537.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-01-06
Publication Date
2026-03-03
Estimated Expiration
2046-01-06

AI Technical Summary

Technical Problem

Existing technologies for steel corrosion detection suffer from low automation, insufficient accuracy, loss of detail, and coarse classification granularity, making it difficult to achieve high-precision and refined corrosion monitoring.

Method used

An improved UNet network is adopted, which combines macroscopic and microscopic features, introduces a global attention module and a triple attention module, and constructs a composite loss function to classify and monitor the degree of corrosion on the steel surface. The model is trained through data augmentation and optimizer to generate a pixel-level corrosion stage segmentation mask.

Benefits of technology

It achieves high-precision, automated monitoring of the degree of corrosion on steel surfaces, accurately captures early corrosion characteristics, improves detection efficiency, reduces human error, and is suitable for large-scale, long-term continuous monitoring.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121600325A_ABST
    Figure CN121600325A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of metal corrosion detection, in particular to a steel surface corrosion degree classifying and monitoring method based on an improved UNet network. Constructing a data set, and performing staged classification on the corrosion region; an improved UNet network is constructed; constructing a composite loss function; dividing the constructed data set into a training set, a verification set and a test set according to a predetermined proportion, and training the improved UNet model by using a composite loss function; and inputting a to-be-monitored steel surface image into the trained model, and generating a visual monitoring report, so that the technical problems of detail loss, weak anti-interference capability, rough classification granularity and the like in corrosion detection of an existing deep learning model are solved, the corrosion detection technology is promoted to be upgraded from traditional manual and semi-automatic modes to intelligentization and precision modes, and the corrosion detection efficiency is improved. The method has important academic research value and remarkable industrial application benefits.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of metal corrosion detection technology, specifically to a method for classifying and monitoring the degree of corrosion on steel surfaces based on an improved UNet network. Background Technology

[0002] Metal corrosion, especially steel corrosion, is a serious challenge faced by industrial sectors such as marine engineering, bridge construction, and chemical equipment, causing huge economic losses and safety risks every year. Traditional corrosion detection methods mainly include manual visual inspection, electrochemical testing, and physicochemical analysis, but these methods all have obvious limitations.

[0003] Manual visual inspection relies heavily on the experience of the inspectors, lacks unified quantitative standards, is prone to missing early corrosion characteristics, and cannot achieve automated monitoring. Electrochemical testing methods (such as potentiodynamic polarization and electrochemical impedance spectroscopy) can provide quantitative data, but they are invasive and difficult to apply directly to in-situ monitoring of large structures. They also lack the ability to characterize the morphology and spatial distribution of local corrosion. Physicochemical analysis methods (such as gravimetric analysis and scanning electron microscopy) are accurate, but they are destructive, time-consuming, and expensive, making them unsuitable for rapid on-site surveys.

[0004] In recent years, corrosion detection methods based on digital image processing have gradually developed. However, traditional image processing algorithms (such as threshold segmentation and edge detection) have poor anti-interference ability and unstable corrosion feature extraction when faced with complex backgrounds such as reflections, scratches, and stains on steel surfaces. Although deep learning technology (such as convolutional neural networks) has made progress in the field of image recognition, standard models (such as UNet) still face three major challenges when directly applied to steel corrosion detection: First, the model is prone to losing tiny erosion points and fine boundary information during multiple downsampling processes, resulting in unclear segmentation boundaries. Second, standard convolution operations lack a focusing mechanism for eroded regions, making it difficult to effectively suppress background interference. Finally, existing methods have coarse classification granularity, often simply classifying into eroded and uneroded, which cannot meet the needs of fine-grained monitoring of the erosion process.

[0005] Therefore, there is an urgent need in this field for a technical solution for detecting corrosion on steel surfaces that can achieve automated, high-precision, and refined monitoring. Summary of the Invention

[0006] To address the problems existing in the prior art, this invention provides a method for classifying and monitoring the degree of corrosion on steel surfaces based on an improved UNet network, in order to solve the problems of insufficient detection accuracy and loss of detail in existing image processing methods.

[0007] To address the above problems, the technical solution of this invention is as follows: A method for classifying and monitoring the degree of corrosion on steel surfaces based on an improved UNet network, comprising: S1. Data acquisition and feature acquisition: High-resolution macroscopic and microscopic images of the steel surface are captured using an industrial camera and a laser confocal microscope. S2. Based on the macroscopic and microscopic images obtained in S1, a dataset is constructed, and a labeling method combining macroscopic and microscopic features is used to classify the eroded areas in stages. S3. Construct an improved UNet network, input macroscopic and microscopic images into the network, effectively learn and extract hierarchical features of erosion to generate highly discriminative feature maps and achieve accurate pixel-level classification; S4. Construct a composite loss function to simultaneously optimize the overall classification accuracy and the accuracy of erosion boundary segmentation during model training; S5. Divide the dataset constructed in S2 into training set, validation set and test set according to a predetermined ratio, and train the improved UNet model using a composite loss function. S6. Input the image of the steel surface to be monitored into the trained model. The model will automatically generate a pixel-level corrosion stage segmentation mask. Based on the mask, the area of ​​each corrosion stage is calculated, the corrosion progress and corrosion rate are calculated, and a visual monitoring report is generated.

[0008] Furthermore, in S3, the improved UNet network includes an improved backbone encoder, replacing the original dual convolution and max pooling feature extraction units with a global attention module, and dynamically adjusting the feature response intensity through channel attention and spatial attention mechanisms to improve the model's accuracy in recognizing eroded regions.

[0009] Furthermore, in S3, the global attention module includes: S311. Calculate global information, the expression is: , in, This is the feature vector obtained through global average pooling. For input weights, For the number of floors, For feature maps in Pixel value at; S312. Calculate the channel attention weights, the expression is: , in, Let be the channel attention weight vector. This serves as an index for intermediate layer neurons. This is the index of the output channel. For the Sigmoid function, The output dimension of the first fully connected layer. The index of the input element. The weight matrix is ​​the first... Line number Column elements, The weight matrix is ​​the first... Line number The elements of the column.

[0010] Furthermore, in S3, the improved UNet network also includes the introduction of a triple attention module in the skip connection part, which enhances the model's ability to recover eroded boundaries and local details.

[0011] Furthermore, in S3, the triple attention module includes: S321. Generate cross-dimensional attention maps: Using the Z-Pool mechanism, the input feature map is modeled with cross-dimensional dependencies in three-dimensional combinations, and three attention maps corresponding to different dimensions are generated through convolution and activation operations. S322. Apply the three attention maps corresponding to different dimensions to the corresponding feature views, perform attention weighting, and then aggregate the outputs of the three weighted branches to obtain the final feature output.

[0012] Furthermore, in S321, the expression for the Z-Pool mechanism is: , in, For pooling operation functions, [ , [] indicates a splicing operation along the channel dimension. For the input branch tensor, This represents the max pooling operation performed along the 0th dimension of tensor X. This indicates that average pooling is performed along the 0th dimension of the input tensor X.

[0013] Furthermore, in S321, the expression for the attention map is: , in, For tensor transpose, For activation function, This represents the input tensor after channel transformation. , , Attention maps for CH, CW, and HW dimensions. and To be The operations that transpose the dimension from (C,H,W) to (H,C,W) and (W,H,C) respectively. for Convolution operation.

[0014] Furthermore, in S322, the final feature output is: , in, , The overline indicates the operation of restoring the tensor dimensions to their original order (C, H, W). , , It is a convolutional layer.

[0015] Furthermore, in S4, the expression for the composite loss function is: , , , in, For image batches, For the number of tag categories, For the true result, For the predicted results, This refers to the number of edge pixels. For the true label edge, For edge weights, Let cross-entropy be the loss function. This is a reinforcement loss function based on Canny edges.

[0016] Furthermore, in S2, the corrosion area is classified into stages, including: no corrosion stage, early pitting corrosion stage, mild corrosion stage, moderate corrosion stage, severe corrosion stage, and complete corrosion stage.

[0017] Compared with existing technologies, the present invention has the following advantages: by combining the macroscopic and microscopic features of the steel surface to construct and label a dataset, the degree of corrosion is subdivided into six stages. Compared with the traditional binary classification method of "corroded / non-corroded", the classification granularity is more in line with the actual corrosion evolution law, and can accurately capture the slight corrosion features that are easily missed, such as early pitting corrosion, providing earlier signal support for corrosion prevention and intervention.

[0018] A Global Attention (GAM) module is introduced into the UNet backbone encoder. Through channel attention and spatial attention mechanisms, the feature response intensity is dynamically adjusted to effectively suppress non-corrosive texture interference such as background reflection, scratches, and stains, and significantly improve the recognition accuracy of large connected eroded regions. A Triple Attention module is introduced into the skip connection layer. Through the Z-Pool mechanism, the cross-dimensional dependency relationship of CH, CW, and HW is modeled, and local details such as erosion boundaries, pitting protrusions, and accumulated crown edges are accurately captured. This solves the problems of detail loss and blurred segmentation boundaries in the downsampling process of traditional UNet networks.

[0019] Combining the cross-entropy loss function with the Canny edge loss function not only ensures the classification accuracy of different corrosion stages, but also strengthens the error constraint of corrosion boundaries, so that the segmented corrosion regions have better closure and continuity, avoiding the defects of "accurate classification but blurry boundaries" or "clear boundaries but incorrect classification" caused by a single loss function.

[0020] From steel surface image acquisition, dataset construction, and model training, to corrosion area segmentation, stage classification, and parameter calculation of the image to be monitored, and finally to the generation of a visualization report, the entire process is automated. It does not rely on the experience and judgment of the inspectors, effectively avoiding problems such as subjective errors, missed detections, and false detections caused by manual visual inspection. It is especially suitable for large-scale, long-term continuous monitoring scenarios.

[0021] By expanding the training sample size through data augmentation techniques and combining the Adam optimizer with the early stopping mechanism of moving average loss, the model is ensured to converge quickly and is not prone to overfitting during training. The trained model can quickly process input images, automatically generate pixel-level corrosion stage segmentation masks, and calculate corrosion progress and corrosion rate in real time. Compared with traditional electrochemical testing and laboratory analysis, which are time-consuming and inefficient, the detection efficiency is improved by several times, which can meet the needs of real-time on-site monitoring. Attached Figure Description

[0022] Figure 1 This is a logic flowchart of the classification and monitoring method of the present invention; Figure 2 This is a diagram of the improved UNet network structure of the present invention; Figure 3 The images show the corrosion rate and corrosion area variation predicted by the improved UNet network model of this invention. Figure 4 This is a graph showing the area change during the corrosion stage of the present invention. In the graph, a represents the area distribution during the corrosion stage at 720 minutes, b represents the area distribution during the corrosion stage at 1080 minutes, and c represents the area distribution during the corrosion stage at 1800 minutes. Detailed Implementation

[0023] This application presents an improved UNet network-based method for classifying and monitoring the degree of corrosion on steel surfaces, such as... Figure 1 , 2 As shown, by fusing macroscopic and microscopic image features, an improved UNet network is constructed, and combined with a composite loss function, high-precision and automated classification and monitoring of steel surface corrosion is achieved, including the following steps: S1. Data acquisition and feature acquisition: High-resolution macroscopic and microscopic images of the steel surface are captured using an industrial camera and a laser confocal microscope. S2. Based on the macroscopic and microscopic images obtained in S1, a dataset is constructed, and a labeling method combining macroscopic and microscopic features is used to classify the eroded areas in stages. S3. Construct an improved UNet network, input macroscopic and microscopic images into the network, effectively learn and extract hierarchical features of erosion to generate highly discriminative feature maps and achieve accurate pixel-level classification; S4. Construct a composite loss function to simultaneously optimize the overall classification accuracy and the accuracy of erosion boundary segmentation during model training; S5. Divide the dataset constructed in S2 into training set, validation set and test set according to a predetermined ratio, and train the improved UNet model using a composite loss function. S6. Input the image of the steel surface to be monitored into the trained model. The model will automatically generate a pixel-level corrosion stage segmentation mask. Based on the mask, the area of ​​each corrosion stage is calculated, the corrosion progress and corrosion rate are calculated, and a visual monitoring report is generated.

[0024] Using traditional marine steel Q420 and improved low-alloy steel Q420RE immersed in 3.5% NaCl solution at room temperature as monitoring objects, this paper elaborates on the classification and monitoring method of steel surface corrosion degree based on the improved UNet network.

[0025] Experimental materials: Three sets of traditional marine engineering steel Q420 samples with consistent specifications and three sets of improved low alloy steel Q420RE samples were selected. The sample size was uniformly processed to 100mm×50mm×5mm. The surface was ground, polished, cleaned and dried to remove surface oxide scale and impurities to ensure the consistency of the initial surface state.

[0026] Corrosion environment simulation: Prepare a 3.5% NaCl aqueous solution at room temperature (25℃) to simulate the marine corrosion environment. Immerse the sample completely in the solution and continuously monitor the corrosion process.

[0027] Equipment selection: An industrial camera with a resolution of 2048×1536 is selected to capture macroscopic images of the steel surface; a laser confocal microscope (scanning range 50μm×50μm, resolution 0.1μm) is selected to acquire surface 3D images, roughness data, and microscopic feature images; a high-performance computer is configured with an Intel Core i9-13900K CPU, an NVIDIA RTX 4090 GPU, and 64GB of memory for model training and data processing.

[0028] The specific steps are as follows: S1. Data Acquisition and Feature Extraction: Every 2 hours, the soaked sample is removed, and the surface residual solution is quickly cleaned with anhydrous ethanol. After drying, image acquisition is performed. An industrial camera captures macroscopic images of the sample surface, covering the entire sample area, and records the color, distribution range, macroscopic morphology, and other characteristics of the corroded area. A laser confocal microscope is used to scan typical areas of the sample surface (including uncorroded areas, corroded areas, and corrosion boundaries) to obtain three-dimensional morphology images, surface roughness parameters (Ra, Rz), and microscopic feature images. Microscopic information such as the accumulation state of corrosion products, the size of pitting protrusions, and the retention of polishing scratches is recorded.

[0029] S2. Dataset Construction and Labeling: Data preprocessing: The acquired macroscopic and microscopic images were formatted (converted to PNG format) and their sizes were normalized. Macroscopic images were scaled to 512×512 pixels and microscopic images were scaled to 256×256 pixels. Invalid images such as blurry or overexposed images were removed. Finally, a dataset containing 1200 valid samples was constructed, with 600 images each for Q420 and Q420RE, covering six erosion stages.

[0030] Annotation Method: A combined macroscopic and microscopic feature annotation strategy is adopted. For each macroscopic image region, its corresponding high-resolution microscopic image obtained by laser confocal microscopy is found. The features of the microscopic image (such as feature vectors extracted through a pre-trained network) or the image itself after registration and upsampling are used as auxiliary information and provided to the annotators along with the macroscopic image for comprehensive judgment. Following the principle of "upward compatibility," when a region simultaneously exhibits multiple corrosion stage features, it is labeled according to the higher-level stage. The LabelMe annotation tool is used to perform pixel-level annotation on the image. Non-corrosion stage: The surface is uniform and without marks; Early pitting stage: macroscopic white dots, microscopic pitting protrusions; Mild corrosion stage: Macroscopic white edges, microscopic corrosion products cover scratches; Moderate corrosion stage: Macroscopically pale yellow and brown, microscopically thick corrosion products accumulated at the boundaries; Severe corrosion stage: macroscopic deep black edges + orange-yellow interior, microscopic large precipitates + dense corrosion products; Complete corrosion stage: macroscopically, the corrosion is completely covered, while microscopically, only dense corrosion products are visible.

[0031] The combination of macroscopic and microscopic feature annotation avoids the shortcomings of single macroscopic annotation being unable to identify early pitting corrosion and single microscopic annotation being unable to reflect the global distribution. It achieves accurate definition and pixel-level localization of corrosion stages. The constructed dataset covers the complete corrosion stages and two typical steel materials, with strong sample diversity, which can provide rich learning materials for model training and ensure that the model learns the essential features of different corrosion stages.

[0032] S3. Improved UNet network construction and network structure building: Based on the PyTorch framework, an improved UNet network is built, mainly consisting of three parts: encoder, decoder, and skip connections, as detailed below: Encoder (backbone): The Global Attention Module (GAM) is used to replace the traditional UNet's double convolution and max pooling feature extraction units. There are a total of 4 encoding blocks. After each encoding block, downsampling (stride 2) is performed to gradually extract high-level global features. The Global Attention Module (GAM) includes: Fully connected layer dimension settings: The output dimension d of the first fully connected layer is equal to the number of input channels / 4. The activation function is Sigmoid (σ), and the channel and spatial attention weights are dynamically adjusted.

[0033] The global information is calculated using the following expression: , in, This is the feature vector obtained through global average pooling. For input weights, For the number of floors, For feature maps in Pixel value at; The channel attention weights are calculated using the following expression: , in, Here is the channel attention weight vector. This serves as an index for intermediate layer neurons. This is the index of the output channel. For the Sigmoid function, The output dimension of the first fully connected layer. The index of the input element. The weight matrix is ​​the first... Line number Column elements, The weight matrix is ​​the first... Line number The elements of the column.

[0034] Skip connections: Three attention modules are introduced in the skip connections between each level of coding blocks and decoding blocks. These modules filter and enhance the low-level features output from the coding end before passing them to the decoding end. The triple attention module includes: The convolutional kernel size is set to 3×3 (Conv_{3×3})), padding=1, the activation function is Sigmoid(σ), and the output feature map has the same dimension as the input. The expression for the Z-Pool mechanism is: , in, For pooling operation functions, [ , [] indicates a splicing operation along the channel dimension. For the input branch tensor, This represents the max pooling operation performed along the 0th dimension of tensor X. This indicates that average pooling is performed along the 0th dimension of the input tensor X.

[0035] The expression for the attention map is: , in, For tensor transpose, For activation function, This represents the input tensor after channel transformation. , , Attention maps for CH, CW, and HW dimensions. and To be The operations that transpose the dimension from (C,H,W) to (H,C,W) and (W,H,C) respectively. for Convolution operation.

[0036] Final feature output: , in, , The overline indicates the operation of restoring the tensor dimensions to their original order (C, H, W). , , It is a convolutional layer that achieves accurate extraction of cross-dimensional detailed features through three-branch feature aggregation.

[0037] Decoder: It uses upsampling (transposed convolution, stride 2) and feature concatenation to gradually restore the image resolution. Finally, it outputs a 6-channel feature map (corresponding to 6 erosion stages) through a 1×1 convolutional layer to achieve pixel-level classification.

[0038] The GAM module calculates global feature vectors through global average pooling and dynamically adjusts the response intensity of each channel by combining the channel attention weight formula. This enhances feature extraction of large connected eroded regions while suppressing interference from non-eroded textures such as background reflections and scratches, thus solving the problem of insufficient global feature capture by traditional convolution.

[0039] The triple attention module integrates feature extrema and mean through the Z-Pool mechanism, models the cross-dimensional dependencies of the three dimensions with the attention map generation formula, and then achieves three-branch aggregation through the feature output formula. This accurately captures local details such as erosion boundaries and pitting protrusions, avoids the impact of low-level noise on the segmentation results, and makes up for the loss of details caused by direct splicing of traditional skip connections.

[0040] S4. Construct a composite loss function. The cross-entropy loss function quantifies the difference between the predicted probability and the true label through logarithmic operations, effectively optimizing the accuracy of category classification and ensuring that the model correctly distinguishes the six erosion stages, meeting the requirements of refined classification. The Canny edge loss function strengthens the error constraint of the erosion boundary by weighting the loss of edge pixels, guiding the model to learn boundary features, solving the problem of insufficient attention to boundary segmentation by the single cross-entropy loss function, and improving the closure and continuity of the eroded region. Edge detection optimization enhances edge features through preprocessing, improving... To further optimize the boundary segmentation effect and improve sensitivity to boundary differences, the following steps are taken: The expression for the composite loss function is: , Cross-entropy loss function The formula for calculating the difference between the predicted category and the true category is as follows: , Canny edge loss function The difference between the predicted boundary and the actual boundary is calculated using the following formula: , in, For image batches, For the number of tag categories, For the true result, For the predicted results, This refers to the number of edge pixels. For the true label edge, For edge weights, Let cross-entropy be the loss function. This is a reinforcement loss function based on Canny edges.

[0041] Edge detection optimization: using grayscale transformation and Gaussian blur operator ( Extract image grayscale features and adjust the Canny edge detection threshold (low threshold 50, high threshold 150) to ensure clear and complete detection of metal outer edges and corrosion area edges, for optimization. The calculation accuracy.

[0042] The composite loss function achieves dual optimization of "classification accuracy" and "boundary accuracy", avoiding the defects of "accurate classification but blurry boundary" or "clear boundary but incorrect classification" caused by a single loss function. It makes the segmentation results both conform to the category definition and have clear boundaries. The setting of edge weights enhances the importance of boundary loss, so that the model focuses on the accurate segmentation of corrosion boundaries during training, which is suitable for the key requirement of "boundary localization" in steel corrosion monitoring.

[0043] S5. Dataset Partitioning and Model Training: Dataset partitioning: The constructed dataset is randomly divided into a training set (960 images), a validation set (120 images), and a test set (120 images) in an 8:1:1 ratio to ensure that each set contains balanced samples of two types of steel and six corrosion stages.

[0044] Data augmentation: Random augmentation operations are performed on the training set, including horizontal flipping (probability 0.5), vertical flipping (probability 0.5), and random rotation (0°, 90°, 180°, 270°, each with a probability of 0.25), to expand the training sample size and avoid model overfitting.

[0045] Optimizer: Adam optimizer, initial learning rate 1e-4, learning rate decay 1e-5 (decays once every 10 epochs).

[0046] Training epochs: Maximum training epochs: 100. Early stopping mechanism using moving average loss (window size 5, training stops when the validation set loss does not decrease for 5 consecutive epochs).

[0047] batchsize: 8 (based on GPU memory capacity setting).

[0048] Training process: The training set is input into the improved UNet network, and the network parameters (including those of the GAM module) are adjusted using the backpropagation algorithm with the composite loss function as the optimization objective. , (e.g., convolutional layer parameters of the triple attention module), evaluate model performance using a validation set after each training epoch (calculate mIoU and mAP), and record the optimal model parameters.

[0049] By precisely optimizing the parameters of the improved modules, the performance advantages of the GAM module and the triple attention module are fully utilized, enabling the model to gradually learn the macroscopic and microscopic features of erosion during training, and continuously improving the classification and segmentation accuracy.

[0050] S6. Ablation experiments and model performance evaluation: Ablation experiment design: To verify the effectiveness of each improved module, five models were trained and their performance was evaluated on the test set, including: Model 1: Basic UNet network (without any improvements); Model 2: UNet+GAM module (only the global attention module is introduced, and the global information and channel attention weight calculation formula are applied). Model 3: UNet + Triple Attention Module (only the triple attention module is introduced, applying Z-Pool, attention map generation, and feature output formula); Model 4: UNet+Canny edge loss (using only the composite loss function); Model 5: Improved UNet (GAM + Triple Attention + Composite Loss, all formulas applied); Performance evaluation metrics: The mean intersection-over-union ratio (mIoU), mean average precision (mAP), precision, recall, F1 score, and images processed per second (FPS) were calculated for each model. The evaluation results are shown in Table 1 below. Table 1

[0051] Ablation experiments, by adding or removing improvement modules and corresponding formula calculations one by one, compared the performance indicators of different models. This allowed for the quantification of the contribution of each module and formula application to model performance, and the verification of the effectiveness of module design and formula derivation. The ablation experiments clarified the core role of each module's formula: the formula calculation of the GAM module mainly improves the global recognition accuracy, while the formula calculation of the triple attention module focuses on optimizing details and boundary capture, providing clear data support for subsequent technology iterations.

[0052] Multi-dimensional evaluation metrics (mIoU, mAP, Precision, Recall, F1, FPS) are used to comprehensively evaluate the model's segmentation accuracy, classification performance, and inference speed, ensuring that the model is both accurate and efficient in practical applications.

[0053] Experimental results show that the improved UNet model significantly outperforms other models in all performance metrics, with mIoU reaching 53% and mAP reaching 56%, representing improvements of 18% and 15% respectively compared to the basic UNet. This verifies the synergistic optimization effect of the GAM module formula, the triple attention module formula, and the composite loss function formula.

[0054] S7. Corrosion Monitoring and Result Output The surface image (macro + micro) of the steel to be monitored is input into the trained improved UNet model. The model outputs a pixel-level corrosion stage segmentation mask (each pixel corresponds to a corrosion stage label) through semantic segmentation.

[0055] Based on the segmentation mask, the total area of ​​steel is calculated. Calculate the area S1-S6 of each corrosion stage: Corrosion progress: Corrosion progress at a certain stage i = 1-6, corresponding to the six stages respectively.

[0056] Corrosion rate: The increase in corrosion area per unit time , unit: mm² / h, or equivalent corrosion rate based on weight loss.

[0057] Visualization output: Use Matplotlib to plot the erosion rate change curve, such as... Figure 3 As shown, the horizontal axis represents time, the vertical axis represents corrosion rate, and there is a graph showing the area change during the corrosion stages. Figure 4 As shown, the X-axis represents five stages: early pitting corrosion (Stage 1), mild corrosion (Stage 2), moderate corrosion (Stage 3), severe corrosion (Stage 4), and complete corrosion (Stage 5), while the Y-axis represents the area ratio, generating a visual monitoring report.

[0058] The trained model can automatically identify and classify corroded areas in the image to be monitored based on the learned corrosion features. The output segmentation mask provides an accurate basis for region division for parameter calculation. The calculation of corrosion progress and corrosion rate is based on quantified area data, which can objectively reflect the severity and development trend of corrosion. The visualization report transforms complex corrosion data into easy-to-understand information through intuitive images and curves. It realizes fully automated reasoning and calculation without human intervention. Compared with traditional manual detection methods, the detection efficiency is improved by more than 80%, while avoiding human error and improving the reliability of monitoring results.

[0059] S8. Model Prediction Result Verification Multiple traditional detection methods were used to cross-validate the model prediction results: Weight loss test method: Periodically remove the sample, clean and dry it, weigh it, and calculate the weight loss. The actual corrosion rate is calculated based on weight loss and corrosion area. , The density of the steel is compared with the corrosion rate predicted by the model.

[0060] Electrochemical experimental method: A three-electrode system was adopted, with the working electrode being the sample, the reference electrode being a saturated calomel electrode, and the auxiliary electrode being a platinum electrode. Potentiodynamic polarization curves and electrochemical impedance spectroscopy were tested, and parameters such as corrosion current density and polarization resistance were analyzed to verify the rationality of the corrosion stage predicted by the model.

[0061] SEM and XRD analysis: The microstructure of corrosion products was observed using scanning electron microscopy (SEM), and the phase composition of corrosion products (such as FeO(OH), Fe3O4, etc.) was analyzed using X-ray diffraction (XRD), and compared with the classification results of the model based on microstructure characteristics.

[0062] Laser confocal analysis: Surface roughness parameters and three-dimensional morphology obtained by laser confocal microscopy are used to verify the consistency between the boundary and microscopic features of the corrosion region segmented by the model.

[0063] Weight loss experiments are a classic method for measuring corrosion rates, directly reflecting the degree of corrosion in steel and providing an absolute calibration standard for model-predicted rates. Electrochemical parameters (corrosion current density and polarization resistance) are directly related to the corrosion rate; the higher the corrosion current density and the lower the polarization resistance, the faster the corrosion rate, which can indirectly verify the accuracy of the corrosion stages predicted by the model. SEM and XRD analyses can reveal the microstructure and phases of corrosion products, corresponding to the microscopic features captured by the model, thus verifying the scientific validity of the classification results.

[0064] Cross-validation using multiple methods ensured the reliability of the model's prediction results. Experiments showed that the corrosion stage predicted by the model was in agreement with the results of electrochemical experiments and SEM / XRD analysis by more than 92%, and the relative error between the predicted corrosion rate and the weight loss experiment results was less than 8%. The verification results proved the scientific nature of the formula application and the rationality of the model design in the method of this invention, providing solid experimental support for its application in actual industrial scenarios.

[0065] Corrosion monitoring experiments on Q420 and Q420RE steels in 3.5% NaCl solution successfully achieved accurate classification and pixel-level segmentation of six corrosion stages, with mIoU reaching 53% and mAP reaching 56%, significantly improving performance compared to the traditional UNet model. This effectively captures easily missed minor corrosion features such as early pitting corrosion. The fully automated monitoring process improves detection efficiency by over 80% compared to traditional methods, reducing human error to below 5%, making it suitable for large-scale, long-term continuous monitoring scenarios. It achieves non-destructive monitoring, requiring no damage to the sample structure, and can be applied to in-situ monitoring of non-removable structures such as marine infrastructure and chemical equipment. Quantitative output of key parameters such as corrosion progress and corrosion rate, combined with visualized reports, provides a scientific basis for corrosion protection and maintenance decisions. Verification shows that protection schemes based on this method can reduce the corrosion rate of steel by more than 30%.

[0066] This application deeply integrates the attention mechanism and composite loss function design in deep learning with the engineering requirements of steel corrosion detection, and proposes a six-stage classification scheme that integrates macroscopic and microscopic features. It solves the technical problems of existing deep learning models in corrosion detection, such as loss of details, weak anti-interference ability, and coarse classification granularity. It provides new technical ideas and methods for the field of metal corrosion detection, and promotes the upgrading of corrosion detection technology from traditional manual and semi-automated to intelligent and precise. It has both important academic research value and significant industrial application benefits.

[0067] The above specific embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to examples, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the scope of the technical solutions of the present invention, and all such modifications or substitutions should be covered within the scope of the claims of the present invention.

Claims

1. A method for classifying and monitoring the degree of corrosion on steel surfaces based on an improved UNet network, characterized in that, include: S1. Data acquisition and feature acquisition: High-resolution macroscopic and microscopic images of the steel surface are captured using an industrial camera and a laser confocal microscope. S2. Based on the macroscopic and microscopic images obtained in S1, a dataset is constructed, and a labeling method combining macroscopic and microscopic features is used to classify the eroded areas in stages. S3. Construct an improved UNet network, input macroscopic and microscopic images into the network, effectively learn and extract hierarchical features of erosion to generate highly discriminative feature maps and achieve accurate pixel-level classification; S4. Construct a composite loss function to simultaneously optimize the overall classification accuracy and the accuracy of erosion boundary segmentation during model training; S5. Divide the dataset constructed in S2 into training set, validation set and test set according to a predetermined ratio, and train the improved UNet model using a composite loss function. S6. Input the image of the steel surface to be monitored into the trained model. The model will automatically generate a pixel-level corrosion stage segmentation mask. Based on the mask, the area of ​​each corrosion stage is calculated, the corrosion progress and corrosion rate are calculated, and a visual monitoring report is generated.

2. The classification and monitoring method according to claim 1, characterized in that: In S3, the improved UNet network includes an improved backbone encoder, replacing the original double convolution and max pooling feature extraction units with a global attention module, and dynamically adjusting the feature response intensity through channel attention and spatial attention mechanisms to improve the model's accuracy in recognizing eroded regions.

3. The classification and monitoring method according to claim 2, characterized in that: In S3, the global attention module includes: S311. Calculate global information, the expression is: , in, This is the feature vector obtained through global average pooling. For input weights, For the number of floors, For feature maps in Pixel value at; S312. Calculate the channel attention weights, the expression is: , in, Let be the channel attention weight vector. This serves as an index for intermediate layer neurons. This is the index of the output channel. For the Sigmoid function, The output dimension of the first fully connected layer. The index of the input element. The weight matrix is ​​the first... Line number Column elements, The weight matrix is ​​the first... Line number The elements of the column.

4. The classification and monitoring method according to claim 3, characterized in that: In S3, the improved UNet network also includes the introduction of a triple attention module in the skip connection part, which enhances the model's ability to recover eroded boundaries and local details.

5. The classification and monitoring method according to claim 4, characterized in that: In S3, the triple attention module includes: S321. Generate cross-dimensional attention maps: Using the Z-Pool mechanism, the input feature map is modeled with cross-dimensional dependencies in three-dimensional combinations, and three attention maps corresponding to different dimensions are generated through convolution and activation operations. S322. Apply the three attention maps corresponding to different dimensions to the corresponding feature views, perform attention weighting, and then aggregate the outputs of the three weighted branches to obtain the final feature output.

6. The classification and monitoring method according to claim 5, characterized in that: In S321, the expression for the Z-Pool mechanism is: , in, For pooling operation functions, [ , [] indicates a splicing operation along the channel dimension. For the input branch tensor, This represents the max pooling operation performed along the 0th dimension of tensor X. This indicates that average pooling is performed along the 0th dimension of the input tensor X.

7. The classification and monitoring method according to claim 6, characterized in that: In S321, the expression for the attention map is: , in, For tensor transpose, For activation function, This represents the input tensor after channel transformation. , , Attention maps for CH, CW, and HW dimensions. and To be The operations that transpose the dimension from (C,H,W) to (H,C,W) and (W,H,C) respectively. for Convolution operation.

8. The classification and monitoring method according to claim 7, characterized in that: In S322, the final feature output is: , in, , The overline indicates the operation of restoring the tensor dimensions to their original order (C, H, W). , , It is a convolutional layer.

9. The classification and monitoring method according to claim 8, characterized in that: In S4, the expression for the composite loss function is: , , , in, For image batches, For the number of tag categories, For the true result, For the predicted results, This refers to the number of edge pixels. For the true label edge, For edge weights, Let cross-entropy be the loss function. This is a reinforcement loss function based on Canny edges.

10. The classification and monitoring method according to claim 1, characterized in that: In S2, the corrosion area is classified into stages, including: no corrosion stage, early pitting corrosion stage, light corrosion stage, moderate corrosion stage, heavy corrosion stage, and complete corrosion stage.

Citation Information

Patent Citations

  • Propeller cavitation corrosion area monitoring method and system and acquisition device

    CN117788380A

  • MFL signal reconstruction method based on channel interfusion and global attention mechanism

    CN120892787A

  • Steel surface defect detection method and system based on RDDW-YOLO

    CN121236059A

  • Method for detecting infrared ship target based on improved yolov7

    US20250078541A1