Steel wire surface corrosion identification method based on deep learning
By constructing an improved U-Net model, introducing the SE attention mechanism and upsampling structure optimization, and combining the Dice loss and cross entropy loss functions, the problems of low efficiency and low precision in traditional detection methods are solved, and high-precision automatic recognition and clear segmentation of rusted areas on the steel wire surface are achieved.
Patent Information
- Application Number
- CN202510747568.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-05
- Publication Date
- 2025-09-26
AI Technical Summary
Traditional steel wire corrosion detection methods have the problems of strong subjectivity, low efficiency and low precision, making it difficult to automatically identify rust patches on the steel wire surface.
A deep learning-based method was used to construct an improved U-Net model. The SE attention mechanism and upsampling structure optimization were introduced. The Dice loss and cross entropy loss functions were combined for supervised optimization. Automatic identification of rusted areas was achieved through image acquisition, preprocessing, model training and deployment.
It significantly improves the recognition accuracy and edge segmentation clarity of rusted areas on the steel wire surface, enhances the perception of complex corrosion morphologies such as small-scale pitting and flake corrosion, and improves the robustness and generalization ability of the model, making it suitable for automatic identification of bridge steel wire corrosion in actual engineering scenarios.
Smart Images

Figure CN120707931A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a method for identifying steel wire surface corrosion based on deep learning, which belongs to the field of computer vision and material detection, and is particularly suitable for automatic identification and evaluation of steel wire surface corrosion conditions during industrial production and quality control processes. Background Art
[0002] Steel wire is susceptible to surface corrosion during long-term use due to environmental factors. Traditional corrosion detection methods rely mainly on manual inspection or simple image processing technology, which has problems such as strong subjectivity, low efficiency, and low accuracy. Summary of the Invention
[0003] In response to the above-mentioned problems, the present invention proposes a steel wire surface rust identification method based on deep learning, which aims to solve the problem of automatic identification of black rust patches on the steel wire surface and improve the accuracy and efficiency of detection.
[0004] The above purpose is achieved through the following technical solutions:
[0005] A method for identifying steel wire surface corrosion based on deep learning of the present invention comprises the following steps:
[0006] Step 1: Image acquisition: Capture images of the surface of bridge steel wires that have undergone alternating dry-wet corrosion. The captured images must cover typical corrosion types, including pitting, flake corrosion, and surface rust film. Build a database of original images containing images of defective and non-defective steel wires.
[0007] Step 2: Image preprocessing and dataset construction: After image denoising and image enhancement, the corroded areas are finely labeled and the dataset is divided into 80% for training and 20% for testing.
[0008] Step 3: Build an improved U-Net model: Introduce the SE attention mechanism and insert an SE module at the end of each encoder block to enhance network channel selectivity. Optimize the upsampling structure, replace the transposed convolution of the original U-Net, and introduce a semantic alignment module at the skip connection to perform channel matching and fusion to reduce semantic bias.
[0009]
[0010] s=σ(W2·δ(W1·z))
[0011]
[0012] Among them, X c (i, j) represents the value of the element with coordinates (i, j) in the cth channel of the input feature map; H and W represent the height and width of the input feature map respectively; zc represents the scalar value corresponding to the cth channel after global average pooling; W1 and W2 represent the weight matrices of the two fully connected layers respectively; δ represents the ReLU activation function; σ represents the Sigmoid activation function; s c Represents the weight value of the cth channel obtained after the Excitation operation; represents the feature map of the cth channel after channel weighting; s represents the vector output after full connection;
[0013] Step 4: Model training: During the model training phase, cross entropy loss and Dice loss function are used together for supervised optimization.
[0014] Step 5: Model evaluation and saving;
[0015] Step 6: Model deployment and inference: Deploy the trained model to the image detection system, receive the input image and output the pixel-level segmentation mask.
[0016] Furthermore, the specific method of step 2 is as follows:
[0017] S2.1, Image denoising: Use the neighborhood weighted average algorithm to remove background interference while keeping the erosion edge information clear. The filtering calculation formula is as follows:
[0018]
[0019] Where w(i,j) represents the weight matrix in the weighted kernel, f(x,y) represents the grayscale value of the current pixel; M represents the width of the filter window; N represents the height of the filter window;
[0020] S2.2, Image enhancement: Amplify image data by rotation, scaling, and flipping;
[0021] S2.3. Labeling and segmentation: Use tools such as Labelme to finely label the rusted areas and divide the dataset into 80% of the training set and 20% of the test set.
[0022] Furthermore, the specific method of step three is as follows:
[0023] S3.1, Squeeze operation, that is, global average pooling:
[0024]
[0025] S3.2, Excitation operation, that is, full connection + activation:
[0026] s=σ(W2·δ(W1·z))
[0027] Where δ is ReLU, σ is Sigmoid activation function; z represents the global feature vector obtained after the operation;
[0028] S3.3, Scale operation, that is, channel weighting:
[0029]
[0030] S3.4, upsampling structure optimization:
[0031] S3.4.1. Replace the original Unet transposed convolution with the following process:
[0032] First perform bilinear interpolation upsampling: F up =BilinearInterpolate(F,scale=2), where F up Represents the feature map obtained after bilinear interpolation upsampling, BilinearInterpolate represents the bilinear interpolation operation, F represents the original input feature map, and scale represents the upsampling scaling factor, that is, the height and width of the output feature map are both twice that of the input feature map;
[0033] Then use 1×1 convolution to compress the channel: F compressed =W*F up +b where Among them F compressed represents the feature map obtained after the 1×1 convolution compression channel, b represents the bias vector, C in Denotes the input feature map F up The number of channels, C out Indicates the number of channels of the output feature map after compression;
[0034] S3.5 feature fusion optimization:
[0035] The semantic alignment module Conv-BN-ReLU combination is introduced at the jump connection to perform channel matching and fusion to reduce semantic deviation.
[0036] Furthermore, the specific method of step four is as follows:
[0037] Loss function design: Combine cross entropy loss and Dice loss function for optimization:
[0038] Cross Entropy Loss:
[0039]
[0040] Dice loss function:
[0041]
[0042] Total loss function:
[0043]
[0044] Where α represents the weight coefficient of cross entropy loss, which is used to control L CE The contribution to the total loss; β represents the weight coefficient of Dice loss, which is used to control L Dice The contribution degree to the total loss is α=β=0.5;
[0045] Training parameter settings:
[0046] Optimizer: Adam, initial learning rate is 1e-5
[0047] Learning rate strategy: StepLR (step = 1, gamma = 0.92) is used for the first 50 rounds, and cosine annealing is used thereafter;
[0048] Number of training rounds: 100 rounds, batch size: 8.
[0049] Furthermore, the model evaluation and preservation described in step 5 specifically outputs the current average loss and F-score value in real time during each round of training and validation, and saves the model with the lowest validation set loss. The F-score indicator is defined as follows:
[0050]
[0051] β1 represents the weight parameter in the F-score calculation, which is used to adjust the relative importance of precision and recall. Precision represents precision, that is, the proportion of samples predicted by the model as positive that are actually positive. Recall represents recall, that is, the proportion of samples that are actually positive that are correctly predicted by the model. The final training F-score is 0.916.
[0052] Furthermore, in the model deployment and reasoning process described in step 6, the model input Output segmentation map The corresponding pixel value indicates whether the pixel is a rust area. After post-processing operations, including threshold processing and connected area screening, a clear defect contour map is finally obtained.
[0053] The beneficial effects of the present invention compared to the prior art are:
[0054] Compared to existing technologies, the present invention significantly improves the recognition accuracy and edge segmentation clarity of rusted areas on bridge steel wire surfaces by constructing an improved U-Net network model that incorporates the SE attention mechanism and optimizes the upsampling structure. Compared to traditional U-Net methods, the present invention enhances the perception of complex corrosion morphologies such as small-scale pitting and flake corrosion, maintaining good segmentation performance, particularly in situations with strong background interference or blurred corrosion boundaries. The introduced SE module enables the model to adaptively adjust channel weights, effectively suppressing irrelevant features and improving the targeted nature of feature expression. Furthermore, the incorporation of a semantic alignment structure into the skip connection addresses semantic bias in the fusion of high- and low-level features, enhancing the model's robustness and generalization capabilities. The combined optimization method of Dice loss and cross-entropy loss, along with a collaborative learning rate scheduling mechanism combining StepLR and cosine annealing strategies, results in more stable model training and faster convergence. The overall network structure has a moderate computational footprint and good deployment adaptability, making it effectively applicable to the automatic identification of bridge steel wire corrosion in real-world engineering scenarios, demonstrating significant practical value and promising prospects for widespread adoption. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] Figure 1 It is a network structure diagram of the present invention;
[0056] Figure 2 The original image processed for the imported model;
[0057] Figure 3 The image after model processing. DETAILED DESCRIPTION
[0058] The present invention provides an image recognition method for accurately segmenting bridge steel wire corrosion areas. The specific implementation method is as follows:
[0059] Step 1: Image Acquisition: High-definition microscopy equipment was used to capture images of the surface of bridge steel wires undergoing alternating dry-wet corrosion. The images were sized at 1920×1080 and covered typical corrosion types (pitting, flake corrosion, and surface rust films). Finally, a database of raw images containing a large number of images of both defective and non-defective steel wires was constructed to provide real-world sample support for model training.
[0060] In this embodiment, high-definition microscopic photography equipment is used to capture images of the surface of bridge steel wires after they have undergone alternating dry-wet corrosion in a natural environment. The image resolution is not less than 1024×1024 to ensure that typical corrosion types such as pitting corrosion, flake corrosion, and surface rust film are included, and an original database of corrosion images is constructed.
[0061] Step 2: Image preprocessing and dataset construction:
[0062] To improve the robustness and generalization of model recognition, a series of preprocessing operations were performed on the collected images, including image denoising using the neighborhood weighted average algorithm, which effectively removes background interference while preserving eroded edge information. Image enhancement strategies such as rotation, scaling, and horizontal or vertical flipping were also used to expand the sample size. Labelme tools were used for refined annotation, and the dataset was divided into a training set and a test set (with a ratio of 8:2), providing a reliable foundation for subsequent model training. The details are as follows:
[0063] Image denoising: A neighborhood weighted average algorithm is used to remove background interference while keeping the erosion edge information clear. The filter calculation formula is as follows:
[0064]
[0065] Where w(i,j) represents the weight matrix in the weighted kernel, and f(x,y) represents the current pixel grayscale value.
[0066] Image enhancement: Image data is augmented by methods such as rotation (±90°), scaling (0.8–1.2), and flipping to improve the model's generalization ability.
[0067] Labeling and segmentation: Use tools such as Labelme to finely label the rusted areas and divide the dataset into a training set (80%) and a test set (20%).
[0068] Step 3: Build an improved U-Net model:
[0069] This example uses U-Net as a basis and combines the following improvements to build a deep network suitable for steel wire corrosion segmentation:
[0070] During the model construction phase, the present invention makes structural improvements based on the U-Net architecture, introduces the Squeeze-and-Excitation (SE) attention module, and assigns dynamic weights to each feature channel through global average pooling and inter-channel dependency modeling, thereby improving the network's ability to discriminate against corroded areas. At the same time, the upsampling structure in the original U-Net is optimized, bilinear interpolation is used instead of transposed convolution, and the number of channels is compressed through 1×1 convolution, effectively avoiding artifacts and overfitting risks. In addition, a convolution-normalization-ReLU combination module is introduced in the jump connection to achieve semantic alignment and enhance the fusion effect of high- and low-level features. The above improvements ensure the performance advantages of the model in fine-grained corrosion boundary recognition. The details are as follows:
[0071] Introducing SE attention mechanism (Squeeze-and-Excitation Module):
[0072] Insert the SE module at the end of each encoder block to enhance the network channel selectivity. The calculation is as follows:
[0073] Squeeze operation (global average pooling):
[0074]
[0075] Excitation operation (full connection + activation):
[0076] s=σ(W2·δ(W1·z))
[0077] Where δ is ReLU and σ is the Sigmoid activation function.
[0078] Scale operation (channel weighting):
[0079]
[0080] Upsampling structure optimization:
[0081] The transposed convolution that replaces the original Unet is as follows:
[0082] First perform bilinear interpolation upsampling: F up =BilinearInterpolate(F,scale=2)
[0083] Then use 1×1 convolution to compress the channel: F compressed =W*F up +b where
[0084] Feature fusion optimization:
[0085] A semantic alignment module (such as the Conv-BN-ReLU combination) is introduced at the jump connection to perform channel matching and fusion to reduce semantic deviation.
[0086] See the attached network structure diagram Figure 1 .
[0087] Step 4: Model training
[0088] During the model training phase, the cross entropy loss and Dice loss functions are used together for supervised optimization. Cross entropy focuses on global pixel classification accuracy, while Dice loss focuses on the degree of regional overlap between categories. The two are weighted equally (α = β = 0.5), improving the ability to detect rust in small areas. The Adam optimizer is used for training, with an initial learning rate of 1e-5. The StepLR strategy (step_size = 1, gamma = 0.92) is used for coarse tuning in the first 50 rounds, followed by fine tuning using the CosineAnnealingLR strategy to ensure smoother model convergence. The total number of training rounds is 200, with a batch size of 8. The details are as follows:
[0089] Loss function design: Combined use of cross entropy loss (CE Loss) and Dice loss function for optimization:
[0090] Cross Entropy Loss:
[0091]
[0092] Dice Loss:
[0093]
[0094] Total loss function:
[0095]
[0096] Among them, α=β=0.5 is commonly used
[0097] Training parameter settings:
[0098] Optimizer: Adam, initial learning rate is 1e-5
[0099] Learning rate strategy: StepLR (step=1, gamma=0.92) is used for the first 50 rounds, and Cosine AnnealingLR is used thereafter.
[0100] Number of training rounds: 100, batch size: 8
[0101] Step 5: Model evaluation and saving
[0102] During each round of training and validation, the current average loss and F-score value are output in real time, and the model with the lowest validation set loss is saved. The F-score indicator is defined as follows:
[0103]
[0104] In this embodiment, β1=1, that is, F1-score, is used to measure the comprehensive ability of the model's precision and recall rate under the condition of imbalanced positive and negative samples.
[0105] The final training F-score of this model is about 0.916.
[0106] Step 6: Model deployment and inference
[0107] In the inference phase, the trained model is deployed in the image detection system. The input image size is C×H×W, and the model outputs the corresponding single-channel rust segmentation map Y∈R 1 ×H×W, indicating whether the pixel belongs to the rust area. The rust area boundary is further optimized through post-processing operations (such as threshold screening and connected domain extraction), and finally a clear corrosion contour map is generated. Specifically, the trained model is deployed in the image detection system, which receives the input image and outputs the pixel-level segmentation mask map. Output segmentation map The corresponding pixel value indicates whether the pixel is a rust area. After post-processing operations (such as threshold processing and connected area screening), a clear defect contour map is finally obtained. Figure 2 (Model import diagram) and attached Figure 3 (Processing result diagram).
[0108] The key innovation of this invention lies in combining the SE attention mechanism with an improved upsampling structure, significantly improving the segmentation accuracy of rusted areas. Its flexible structure is compatible with other lightweight encoder architectures (such as MobileNetV2 and EfficientNet), allowing for replacement based on actual deployment scenarios, thereby achieving lightweight model deployment requirements. Furthermore, if some scenarios require higher detection speed, depthwise separable convolution or ShuffleNet modules can be used equivalently instead of standard convolutional architectures to further reduce the computational load.
[0109] Experiments have shown that the proposed method achieves an F1 score of 91.6% on a typical bridge steel wire corrosion dataset, outperforming traditional U-Net (85.6%) and FCN (81.2%) models. It also demonstrates greater stability in identifying complex backgrounds and small areas of corrosion. This method has excellent adaptability and application prospects in engineering applications such as bridge inspections and cable safety assessments.
Claims
1. A method for identifying steel wire surface corrosion based on deep learning, characterized in that: The method comprises the following steps: Step 1: Image acquisition: Capture images of the surface of bridge steel wires that have undergone alternating dry-wet corrosion. The captured images must cover typical corrosion types, including pitting, flake corrosion, and surface rust film. Build a database of original images containing images of defective and non-defective steel wires. Step 2: Image preprocessing and dataset construction: After image denoising and image enhancement, the corroded areas are finely labeled and the dataset is divided into 80% for training and 20% for testing. Step 3: Build an improved U-Net model: Introduce the SE attention mechanism and insert an SE module at the end of each encoder block to enhance network channel selectivity. Optimize the upsampling structure, replace the transposed convolution of the original U-Net, and introduce a semantic alignment module at the skip connection to perform channel matching and fusion to reduce semantic bias. s=σ(W2·δ(W1·z)) Among them, X c (i, j) represents the value of the element with coordinates (i, j) in the cth channel of the input feature map; H and W represent the height and width of the input feature map respectively; z c Represents the scalar value corresponding to the cth channel after global average pooling; W1 and W2 represent the weight matrices of the two fully connected layers respectively; δ represents the ReLU activation function; σ represents the Sigmoid activation function; s c Represents the weight value of the cth channel obtained after the Excitation operation; represents the feature map of the cth channel after channel weighting; s represents the vector output after full connection; Step 4: Model training: During the model training phase, cross entropy loss and Dice loss function are used together for supervised optimization. Step 5: Model evaluation and saving; Step 6: Model deployment and inference: Deploy the trained model to the image detection system, receive the input image and output the pixel-level segmentation mask.
2. The method for identifying steel wire surface corrosion based on deep learning according to claim 1, characterized in that: The specific method of step 2 is as follows: S2.
1. Image denoising: A neighborhood weighted average algorithm is used to remove background interference while keeping the erosion edge information clear. The filtering calculation formula is as follows: Where w(i,j) represents the weight matrix in the weighted kernel, f(x,y) represents the grayscale value of the current pixel; M represents the width of the filter window; N represents the height of the filter window; S2.2, Image enhancement: Amplify image data by rotation, scaling, and flipping; S2.
3. Labeling and segmentation: Use tools such as Labelme to finely label the rusted areas and divide the dataset into 80% of the training set and 20% of the test set.
3. The method for identifying steel wire surface corrosion based on deep learning according to claim 1, characterized in that: The specific method of step three is as follows: S3.1, Squeeze operation, that is, global average pooling: S3.2, Excitation operation, that is, full connection + activation: s=σ(W2·δ(W1·z)) Where δ is ReLU, σ is Sigmoid activation function; z represents the global feature vector obtained after the operation; S3.3, Scale operation, that is, channel weighting: S3.4, upsampling structure optimization: S3.4.
1. Replace the original Unet transposed convolution with the following process: First perform bilinear interpolation upsampling: F up =BilinearInterpolate(F,scale=2), where F up Represents the feature map obtained after bilinear interpolation upsampling, BilinearInterpolate represents the bilinear interpolation operation, F represents the original input feature map, and scale represents the upsampling scaling factor, that is, the height and width of the output feature map are both twice that of the input feature map; Then use 1×1 convolution to compress the channel: F compressed =W*F up +b where Among them F compressed represents the feature map obtained after the 1×1 convolution compression channel, b represents the bias vector, C in Denotes the input feature map F up The number of channels, C out Indicates the number of channels of the output feature map after compression; S3.5 feature fusion optimization: The semantic alignment module Conv-BN-ReLU combination is introduced at the jump connection to perform channel matching and fusion to reduce semantic deviation.
4. The method for identifying steel wire surface corrosion based on deep learning according to claim 1, characterized in that: The specific method of step four is as follows: Loss function design: Combine cross entropy loss and Dice loss function for optimization: Cross Entropy Loss: Dice loss function: Total loss function: Where α represents the weight coefficient of cross entropy loss, which is used to control L CE The contribution to the total loss; β represents the weight coefficient of Dice loss, which is used to control L Dice The contribution degree to the total loss is α=β=0.5; Training parameter settings: Optimizer: Adam, initial learning rate is 1e-5 Learning rate strategy: StepLR (step = 1, gamma = 0.92) is used for the first 50 rounds, and cosine annealing is used thereafter; Number of training rounds: 100 rounds, batch size:
8.
5. The method for identifying steel wire surface corrosion based on deep learning according to claim 1, characterized in that: The model evaluation and saving described in step 5 specifically involves outputting the current average loss and F-score value in real time during each round of training and validation, and saving the model with the lowest validation set loss. The F-score indicator is defined as follows: β1 represents the weight parameter in the F-score calculation, which is used to adjust the relative importance of precision and recall. Precision represents precision, that is, the proportion of samples predicted by the model as positive that are actually positive. Recall represents recall, that is, the proportion of samples that are actually positive that are correctly predicted by the model. The final training F-score is 0.
916.
6. The method for identifying steel wire surface corrosion based on deep learning according to claim 1, characterized in that: During the model deployment and inference process described in step 6, the model input Output segmentation map The corresponding pixel value indicates whether the pixel is a rust area. After post-processing operations, including threshold processing and connected area screening, a clear defect contour map is finally obtained.
Citation Information
Cited By
Liquid level measurement system and method based on deep learning image recognition
CN121363995A