U-Net neural network analysis method for defect surface leakage magnetic field signal
By applying the U-Net neural network and channel attention mechanism in magnetic leakage detection, the magnetic field distribution characteristics are directly extracted from the magnetic permeability data, and the problems of large computing resources and insufficient accuracy in the existing technology are solved, and efficient and fast magnetic leakage detection is achieved.
Patent Information
- Application Number
- CN202510114796.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-24
- Publication Date
- 2025-05-16
AI Technical Summary
Existing magnetic leakage detection technology consumes a lot of computing resources and takes a long time to deal with complex geometric shapes and material characteristics, and traditional machine learning methods rely on manual feature extraction, which lacks accuracy and speed.
U-Net neural network combined with channel attention mechanism is used to expand the receptive field through the superposition of multi-layer convolution, and directly learn and extract magnetic field distribution characteristics from the magnetic permeability data to reduce computing resource consumption and computing time.
It significantly reduces computing time and resource consumption, improves the efficiency and accuracy of leakage detection, and can quickly and accurately identify complex defect features.
Smart Images

Figure CN120012509A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of steel surface defect detection, and in particular to a U-Net neural network analysis method for defect surface leakage magnetic field signals. Background Art
[0002] With the development of industry, the demand for non-destructive testing of materials and structures is growing. The continuous development of non-destructive testing technology provides important support for ensuring product quality, extending equipment service life and ensuring safe operation. Among the many non-destructive testing methods, magnetic flux leakage testing is widely used in defect detection in metal structures due to its high efficiency and accuracy. However, how to improve the accuracy and speed of detection has become an important issue that researchers at home and abroad are eager to tackle.
[0003] Current magnetic flux leakage detection technology mainly relies on the finite element method (FEM) and machine learning algorithms. As a mature numerical simulation technology, the finite element method has been widely used in the computational analysis of electromagnetic fields. However, the finite element method usually requires a lot of computing resources for image processing, and there are still challenges in simulating complex geometric shapes and material properties. The calculation time is long, which is not conducive to real-time detection and analysis; the accuracy is low and the time is long when solving inverse problems and fast calculations; in addition, in traditional machine learning methods, such as support vector machines, decision trees, and random forests, it is usually necessary to first extract features from the input data, and then classify and train the model. The decision-making process is relatively intuitive and easy to understand. However, traditional machine learning relies on manual feature extraction and requires high domain knowledge and experience.
[0004] In recent years, the field of deep learning, especially convolutional neural networks (CNNs), has made remarkable progress in image processing and pattern recognition. As a special CNN architecture, U-Net has attracted widespread attention due to its excellent performance in image segmentation tasks. As a deep learning model, it is mainly divided into two parts: encoder and decoder. The encoder-decoder structure of U-Net can not only effectively maintain the high-resolution information of the image, but also learn the deep semantic features of the image. However, it is currently mostly used for image data processing, and direct application in fields such as magnetic flux leakage detection still faces challenges.
[0005] In summary, developing a new fast and high-precision analysis method for defect surface magnetic flux leakage detection signals based on the U-Net deep learning algorithm is still one of the difficult issues in magnetic flux leakage detection research. Summary of the invention
[0006] In order to overcome the defects of the above prior art, the purpose of the present invention is to provide a U-Net neural network analysis method for defect surface leakage magnetic field signals, which improves efficiency by reducing computing resource consumption and operation time. The present invention introduces a channel attention mechanism to enable the algorithm to process feature information more accurately and enhance sensitivity to complex signals; by superimposing multiple layers of U-Net convolution to expand the receptive field, the algorithm can recognize and learn complex features, and achieve effective prediction of magnetic field distribution, thereby greatly improving the performance and reliability of the algorithm.
[0007] In order to achieve the above object, the technical solution adopted by the present invention is:
[0008] A U-Net neural network analysis method for defect surface leakage magnetic field signals comprises the following steps:
[0009] Step 1: Use the finite element method to simulate or conduct detection experiments to obtain the leakage magnetic field signal, and establish the magnetic permeability distribution and leakage magnetic field data set required for U-Net neural network training;
[0010] Step 2: Rotate, crop and standardize the magnetic permeability distribution and leakage magnetic field data set to obtain a processed data set to enhance sample diversity and improve the effect and accuracy of model training;
[0011] Step 3: Based on the processed data set, a U-Net model is constructed with the permeability data as input and the y-component of the magnetic field distribution as output;
[0012] Step 4: Use RMSProp optimizer to train the U-Net model and save the weights;
[0013] Step 5: Use the weights saved in step 4 to predict the magnetic field distribution of the test set, and use structural similarity (SSIM) to evaluate the accuracy of the prediction results.
[0014] The step 1 is specifically as follows:
[0015] The data set is prepared by experimental methods or finite element simulation. The data set contains the permeability data as input and the y-direction component of the magnetic field distribution as output. One part of the data set is divided into a test set and the other part is divided into a training set to ensure the effectiveness of the model. The defects are set as rectangular defects of different sizes. This provides the model with a variety of training samples, which helps to improve its ability to identify and predict various defects in practical applications.
[0016] The specific steps of step 1 are:
[0017] Finite element method is used for simulation to establish the data set required for U-Net neural network training, and finite element numerical calculation of two-dimensional magnetic flux leakage detection system is carried out. The coil is used as the magnetic field source, the defect is set as a rectangle, and free triangle units are used. The magnetic field distribution is numerically calculated based on Maxwell's equations, and a data set is established;
[0018] The electromagnetic field was analyzed based on Maxwell's problem. The differential form of Maxwell's equations is shown below:
[0019]
[0020] In the formula, H is the magnetic field intensity, D is the electric flux density, J is the current density, E is the electric field intensity, B is the magnetic induction intensity, and ρ is the charge density;
[0021] Maxwell's equations were supplemented with differential forms and the following formula was given:
[0022]
[0023] When using the finite element method to perform finite element calculations on electromagnetic fields of anisotropic media, the following relationship exists:
[0024]
[0025] In the formula, ε represents the dielectric constant, μ represents the magnetic permeability, and σ represents the electrical conductivity;
[0026] In a linear homogeneous medium, ε, μ and σ are constants, and equations (1), (2) and (5) are abbreviated as:
[0027]
[0028] By using equations (4) and (10), the magnetic flux density is described as:
[0029]
[0030] In the above formula, A is the magnetic vector potential. Substituting formula (7) and formula (11) into formula (10), we get the following formula:
[0031]
[0032] The above equations are numerically calculated by the finite element method to obtain the data set required for model training and verification of U-Net deep learning. The specific steps of step 2 are:
[0033] The data preprocessing process includes cropping and rotation; the cropping step aims to extract the area of interest in the image to remove unnecessary background, thereby enhancing the focusing ability of the model; the rotation operation is used to randomly change the direction of the image to improve the adaptability of the model to various postures.
[0034] These preprocessing steps combined together provide the model with more diverse training samples.
[0035] Then, the data set is normalized to be centered around 0 by adjusting the mean, and then the data is scaled by the standard deviation. This normalization method can usually improve the stability and convergence speed of model training.
[0036] The data after standardization will have the following characteristics: the mean of all data will be approximately 0; the standard deviation of all data will be approximately 1. This helps to improve the convergence speed and stability of the machine learning model.
[0037] The specific process of the standardization process is as follows:
[0038] First, calculate the mean and standard deviation. For each feature in the training data set, first calculate its mean μ and standard deviation σ;
[0039]
[0040] Where N is the number of samples, X i is the value of the i-th sample on this feature;
[0041] Then, using the calculated mean and standard deviation, each data point is standardized and the following formula is used to convert the original data point X into the standardized data point Z
[0042]
[0043] For the test set, the mean and standard deviation calculated on the training set are used for standardization to ensure that the test data has the same distribution as the training data, that is, the test data points are applied
[0044]
[0045] After standardization, check whether the mean and standard deviation of the standardized data set meet expectations, that is, the mean is close to 0 and the standard deviation is close to 1.
[0046] The step three is specifically as follows:
[0047] Based on the data preprocessed in step 2, a U-Net network with magnetic permeability data as input is constructed to predict the y-component of the magnetic field distribution;
[0048] The U-Net model includes a shallow multi-convolutional layer module and a channel attention module;
[0049] The shallow multi-convolutional layer module expands the receptive field to a larger size by stacking multiple small-size convolutional layers to capture subtle changes and local relationships in the input magnetic permeability data;
[0050] The channel attention module adaptively adjusts the contribution of feature channels by calculating channel importance weights, highlighting the features that are important for predicting the distribution of magnetic flux leakage signals;
[0051] The shallow multi-convolutional layer module significantly expands the range of the receptive field by stacking multiple small-sized convolutional layers. This design enables the network to capture features in a larger area, improving the effect of feature extraction and learning ability. Specifically, the combination of multiple small convolutional layers not only maintains computational efficiency, but also enhances the expressiveness of the model by introducing nonlinear activation functions. In addition, by properly using padding and downsampling strategies, the size adaptability of the feature map is ensured, thereby better retaining important feature information. Ultimately, this modular design provides deep learning models with richer feature representations, which are suitable for processing complex data sets.
[0052] The core of the channel attention mechanism is to extract features through maximum pooling and average pooling, and then learn channel weights through the fully connected layer to emphasize important channel features. Finally, the weights are converted into attention weights through the logistic function to achieve adaptive adjustment of the channel. The spatial attention mechanism focuses on capturing important spatial information in the feature map. It first performs channel dimensionality reduction on the input feature map, and then performs maximum pooling and average pooling operations on the reduced feature map.
[0053] The specific steps are:
[0054] The shallow multi-convolutional layer module contains two convolutional layers and corresponding batch normalization layers and activation functions, and extracts features by using a 3×3 convolution kernel;
[0055] Each convolutional layer is followed by a batch normalization layer, and the LeakyReLU activation function is used to introduce nonlinear features. Assuming the lth layer is a convolutional layer and the l+1th layer is a subsampling layer, the calculation formula for the jth feature map of the lth layer is as follows:
[0056]
[0057] Among them, f is the activation function, M j represents the choice of input mapping, x i l is the output of the i-th neuron in the l-th layer, X i l-1 is the i-th input feature map in the il-th layer, Kij l is the convolution kernel of the lth layer, b j l is the bias term of the j-th output of the l-th layer, and * is the convolution operation;
[0058] A batch normalization layer (BN) needs to be connected after the convolution layer. The operation of the batch normalization layer is expressed as
[0059]
[0060] Where E is the expectation, Var is the variance, and the scale factor γ (k) and the translation factor β (k) is a learnable parameter;
[0061] In the channel attention mechanism:
[0062] First, two different channel descriptors are generated by global average pooling and global maximum pooling respectively. Then, these two descriptors are processed by two fully connected layers to generate channel attention weights. The weights output by the Sigmoid activation function are used to weight the input feature map, thereby highlighting the feature channels that are most important to the model task.
[0063] Then, the upsampling and downsampling modules are defined. First, the input feature map is spatially downsampled through the maximum pooling layer to reduce the spatial dimension of the feature map. Then, the double convolution module is applied for feature extraction. Finally, the channel attention mechanism is introduced to dynamically adjust the importance of the feature channel.
[0064] Upsample the input feature map by bilinear interpolation (or transposed convolution), and then calculate the difference of the feature map to be concatenated;
[0065] After concatenation, a double convolution module is used for further feature extraction, and a channel attention mechanism is added on this basis. Then, the feature map is mapped to the final number of output channels through a 1×1 convolution, which usually corresponds to the number of task categories.
[0066] Finally, the U-Net architecture is constructed. By combining the above modules, the layer-by-layer encoding and decoding of the input image are realized. The downsampling module is used in the first half of the model (encoder) to gradually extract features, while the upsampling module is used in the second half (decoder) to gradually restore the spatial dimension of the image. Finally, the output is generated through 1×1 convolution.
[0067] The step 4 is specifically as follows:
[0068] The U-Net model is trained using the RMSprop optimizer with the goal of minimizing the mean square error loss function as the loss function;
[0069] The formula for the mean square error loss function is:
[0070]
[0071] In the above formula, n is the number of samples, y is i is the true label, is the model prediction value;
[0072] During each training cycle, the model is placed in training mode and traverses the training dataset for forward and backward propagation. In each iteration, the optimizer's gradients are first cleared, and then the input image and label are transferred to the computing device used. The model output is calculated through forward propagation, and backpropagation is performed based on the calculated loss value to update the model parameters. At the same time, the training loss of each cycle is recorded, and the best model weights are continuously monitored for saving during the training process.
[0073] After each cycle, the validation loss is calculated by calling the function to ensure the stability of the model's performance on the validation dataset. During the entire training process, the curves of training and validation loss are plotted to intuitively show the changes in model performance.
[0074] Finally, save the change graph of training loss and validation loss as an image file for subsequent analysis and display.
[0075] Because it can effectively measure the gap between the predicted value and the true label, it has a large penalty for outliers, which helps to improve the robustness of the model. With the learning rate decay strategy, after several cycles, the learning rate gradually decreases, which helps the model converge;
[0076] The training configuration is 1 sample per batch, and the training data set is randomly generated before each cycle to enhance the randomness and diversity of training.
[0077] The step five is specifically as follows:
[0078] Using the pre-trained U-Net model and its weights, the test data is standardized and preprocessed to be consistent with the training data, and then the preprocessed test data is input into the model to generate the prediction results of the magnetic field distribution; in addition, the output prediction results are post-processed for visualization and analysis; finally, the structural similarity (SSIM) index is used to compare the prediction results with the actual magnetic field distribution to evaluate the prediction accuracy of the model on the test set. The structural similarity index (SSIM) is used to evaluate the similarity between the finite element method results and the deep learning neural network prediction results; where μ and σ are the mean and standard deviation of the pixel intensity in the comparison image, C1 and C2 are two constant values, and the structural similarity index formula is
[0079] C1=(k1L) 2(twenty one)
[0080] C2=(k2L) 2 (twenty two)
[0081]
[0082] Among them, x and y represent two images or matrix data to be compared, μ x and μ y Represents the mean value of image or matrix x and y, σ x 2 and σ y 2 denote the variance of the image or matrix x and y respectively, and L is the dynamic range of the pixel values.
[0083] Beneficial effects of the present invention:
[0084] The present invention adopts neural network for magnetic flux leakage detection, and realizes direct learning and extraction of defect characteristics from magnetic permeability data to magnetic field components based on experiments or finite element simulations through U-Net, avoiding tedious grid division and numerical solution process, significantly reducing calculation time and resource consumption, and realizing efficient prediction capability.
[0085] The present invention utilizes the design of shallow multi-convolutional layers to enlarge the receptive field in disguise, save computing resources, increase the network depth, and enhance nonlinear expression. During data processing, the data is normalized to avoid data flooding.
[0086] The present invention adds a channel attention mechanism to adapt to the U-Net algorithm, highlights the key areas in the data, improves the expressiveness of features, and can effectively capture the correlation between feature channels, enhance the model's sensitivity to important features, help reduce the impact of noise, and improve model performance. BRIEF DESCRIPTION OF THE DRAWINGS
[0087] Figure 1 Graph for constructing the U-Net model of the present invention.
[0088] Figure 2 Schematic diagram for comparing the U-Net prediction results of the present invention with the numerical simulation results. DETAILED DESCRIPTION
[0089] The present invention will be further described in detail below in conjunction with the accompanying drawings.
[0090] The present invention discloses a U-Net neural network analysis method for defect surface leakage magnetic field signals, and realizes accurate prediction of magnetic field distribution through the U-Net deep learning model.
[0091] The following is a detailed description of the present invention in steps. The specific execution process is as shown in the attached Figure 1As shown:
[0092] The implementation steps of the present invention are as follows:
[0093] Step 1: Use finite element method to simulate or conduct detection experiments to obtain leakage magnetic field signals and establish the data set required for U-Net neural network training;
[0094] Here, the finite element method is used for simulation to establish the data set required for U-Net neural network training. The finite element numerical calculation of the two-dimensional magnetic flux leakage detection system is carried out. The coil is used as the magnetic field source, which is convenient for controlling the magnitude and direction of the current to achieve the repeatability of the magnetic field and ensure stable magnetic field output under the same conditions. The defect is set as a rectangle, and a free triangle unit is used. The magnetic field distribution is numerically calculated based on the Maxwell equations, and a data set is established.
[0095] The finite element method no longer relies on the assumption of magnetic charge distribution for the distribution of defect leakage magnetic field. The defect leakage magnetic field can be obtained by calculating the entire magnetic field. If the shape of the defect is complex, the size of the leakage magnetic field generated at the defect can be obtained by approximating it with units of different shapes and sizes.
[0096] The electromagnetic field was analyzed based on Maxwell's problem. The differential form of Maxwell's equations is shown below:
[0097]
[0098] In the formula, H is the magnetic field intensity, D is the electric flux density, J is the current density, E is the electric field intensity, B is the magnetic induction intensity, and ρ is the charge density;
[0099] Maxwell's equations were supplemented with differential forms and the following formula was given:
[0100]
[0101] In formulas (1) to (5), only three equations are independent of each other. Since there are more unknowns than equations, the solution of the equation cannot be determined. When the finite element method is used to calculate the electromagnetic field of anisotropic media, the following relationship exists:
[0102]
[0103] In the formula, ε represents the dielectric constant, μ represents the magnetic permeability, and σ represents the electrical conductivity;
[0104] In a linear homogeneous medium, ε, μ and σ are constants. Since the field quantity does not change with time, equations (1), (2) and (5) can be abbreviated as:
[0105]
[0106] By using equations (4) and (10), the magnetic flux density is described as:
[0107]
[0108] In the above formula, A is the magnetic vector potential. Substituting formula (7) and formula (11) into formula (10), we get the following formula:
[0109]
[0110] Based on the above equation, it is combined with certain boundary conditions to form a boundary value problem, thereby obtaining a mathematical model to be solved. The above equation is numerically calculated by the finite element method to obtain the data set required for model training and verification of U-Net deep learning.
[0111] Step 2: Rotate, crop, and standardize the data in the dataset to enhance sample diversity and improve the effect and accuracy of model training. In data preprocessing, operations such as cropping, rotation, horizontal flipping, and vertical flipping are used to achieve diversified enhancement of image data, thereby improving the generalization ability of the model. The cropping operation is used to extract key information areas in the image, remove irrelevant background, and focus the model on valid data. The rotation operation randomly adjusts the direction of the image, usually ranging from -45° to 45°, to enhance the adaptability of the model to different perspectives. In addition, random horizontal flipping and vertical flipping randomly transform the image left and right and up and down, respectively, to make the dataset more diverse in sample direction. The combination of these operations increases the variability of data samples, enabling the model to more effectively process images of different orientations and perspectives in practical applications, further improving its robustness and recognition capabilities.
[0112] The rotated and cropped dataset is then standardized to eliminate the dimensional differences between features in order to improve the efficiency and accuracy of model training.
[0113] The specific process of the standardization process is as follows:
[0114] First, calculate the mean and standard deviation. For each feature in the training data set, first calculate its mean μ and standard deviation σ;
[0115]
[0116] Where N is the number of samples, X i is the value of the i-th sample on this feature;
[0117] Then, using the calculated mean and standard deviation, each data point is standardized and the following formula is used to convert the original data point X into the standardized data point Z
[0118]
[0119] After this treatment, each feature in the standardized data set will have a mean of 0 and a standard deviation of 1, so that all features are on the same scale. For the test set, the mean and standard deviation calculated on the training set are used for standardization to ensure that the test data has the same distribution as the training data, that is, the test data points are applied
[0120]
[0121] After standardization, check whether the mean and standard deviation of the standardized data set meet expectations, that is, the mean is close to 0 and the standard deviation is close to 1; this step is to ensure that there are no abnormalities in the standardization process to avoid affecting the subsequent model training. After standardization is completed, prepare to divide the data into a training set and a validation set, usually with an 80 / 20 ratio, to ensure that the model can fully learn during training, and at the same time, its generalization ability can be evaluated through the validation set.
[0122] Step 3: Construct a U-Net model with permeability data as input and the y-component of the magnetic field distribution as output, and make it have the following two modules: a shallow multi-convolutional layer module, which expands the range of the receptive field to a larger size by stacking multiple small-sized convolutional layers; an attention module, which combines the use of a channel attention mechanism.
[0123] The constructed U-Net model has the following feature modules:
[0124] First, define a double convolution module, which contains two convolutional layers and corresponding batch normalization layers and activation functions, and extract features by using a 3×3 convolution kernel. Each convolutional layer is followed by a batch normalization layer to improve training stability, and a LeakyReLU activation function is used to introduce nonlinear features. The output of this class is used to capture local patterns in feature maps and provide rich feature information for subsequent downsampling and upsampling. Assuming the lth layer is a convolutional layer and the l+1th layer is a subsampling layer, the calculation formula for the jth feature map of the lth layer is as follows:
[0125]
[0126] Among them, f is the activation function, M j represents the choice of input mapping, x i l is the output of the jth neuron in the lth layer, X i l-1 is the i-th input feature map in the il-th layer, K ij l is the convolution kernel of the lth layer, bj l is the bias term of the j-th output of the l-th layer, and * is the convolution operation;
[0127] A batch normalization layer (BN) needs to be connected after the convolution layer to alleviate the "gradient dispersion" problem in the deep network and accelerate the convergence of the model. The operation of the batch normalization layer is expressed as
[0128]
[0129] Where E is the expectation, Var is the variance, and the scale factor γ (k) and the translation factor β (k) is a learnable parameter;
[0130] In the implementation of the channel attention mechanism, the module first generates two different channel descriptors through global average pooling and global maximum pooling respectively. Then, these two descriptors are processed through two fully connected layers to generate channel attention weights. These weights can reflect the importance of different channels to the feature map. The weights output by the Sigmoid activation function are used to weight the input feature map, thereby highlighting the feature channels that are most important to the model task. This mechanism effectively improves the network's ability to focus on important features.
[0131] Then, upsampling and downsampling modules are defined. First, the input feature map is spatially downsampled through the maximum pooling layer to reduce the spatial dimension of the feature map. Subsequently, the double convolution module is applied for feature extraction, and finally the channel attention mechanism is introduced to dynamically adjust the importance of the feature channel. The purpose of this step is to gradually extract higher-level features while reducing the spatial dimension of the feature map. The purpose of the upsampling operation is to restore the spatial dimension of the feature map. The input feature map is upsampled by bilinear interpolation (or transposed convolution), and then the difference of the feature maps to be spliced is calculated to ensure that they are aligned in the spatial dimension. After splicing, the double convolution module is used for further feature extraction, and the channel attention mechanism is added on this basis to enhance the effectiveness of the merged feature map. The goal of this process is to gradually restore the spatial resolution of the image while maintaining the feature details.
[0132] The feature map is then mapped to the final number of output channels through a 1×1 convolution, which usually corresponds to the number of task categories;
[0133] This process implements the final mapping between feature maps and target outputs, ensuring that the model can generate the required output format.
[0134] Finally, the U-Net architecture is constructed. By combining the above modules, layer-by-layer encoding and decoding of the input image are realized. The downsampling module is used in the first half of the model (encoder) to gradually extract features, while the upsampling module is used in the second half (decoder) to gradually restore the spatial dimension of the image. Finally, the output is generated through 1×1 convolution. The entire model structure enables the full integration of low-level features and high-level features, thereby improving the performance of image segmentation or reconstruction.
[0135] Step 4: Use the RMSProp optimizer to train the U-Net model and save the weights. During the training of the deep learning model, the RMSprop optimizer is used to ensure efficient convergence. The initial learning rate is set to 0.0001, and the learning rate decay strategy is used: after every 10 cycles, the learning rate is reduced by 0.1, and it is gradually reduced. The training configuration is 1 sample per batch. The entire training process lasts for 300 cycles. The mean square error loss function (MSELoss) is introduced to measure the difference between the model prediction and the true label. The learning rate scheduler is introduced to dynamically adjust the learning rate to further improve the training efficiency.
[0136] The formula for the mean square error loss function is:
[0137]
[0138] In the above formula, n is the number of samples, y is i is the true label, is the model prediction value;
[0139] During each training cycle, the model is placed in training mode and traverses the training dataset for forward and backward propagation. In each iteration, the optimizer's gradients are first cleared, and then the input image and label are transferred to the computing device used. The model output is calculated through forward propagation, and backpropagation is performed based on the calculated loss value to update the model parameters. At the same time, the training loss of each cycle is recorded, and the best model weights are continuously monitored for saving during the training process.
[0140] After each cycle, the validation loss is calculated by calling the function to ensure the stability of the model's performance on the validation data set. During the entire training process, the curves of training and validation loss are plotted to intuitively show the changes in model performance. Finally, the change graphs of training loss and validation loss are saved as image files for subsequent analysis and presentation. This methodology ensures the effective training and evaluation of the hyperelastic material constitutive model and lays a solid foundation for the subsequent application of the model.
[0141] Step 5: Use the weights saved in step 4 to predict the magnetic field distribution of the test set, and use structural similarity (SSIM) to evaluate the accuracy of the prediction results.
[0142] In the model prediction stage, the trained weights are first loaded and the U-Net model is called to preprocess the test data in step 2 to ensure that its format is consistent with the training data. Then, the preprocessed test data is input into the model and forward propagation is performed to generate the prediction results of the magnetic field distribution. After the prediction results are generated, the output is post-processed as necessary and compared with the true label using the structural similarity (SSIM) indicator to quantify the accuracy of the prediction. Finally, the prediction results and SSIM values are recorded and visualized to comprehensively evaluate the performance of the model on the test set and provide a basis for further analysis and application.
[0143] The structural similarity index (SSIM) is used to evaluate the similarity between the finite element method results and the deep learning neural network prediction results. Where μ and σ are the mean and standard deviation of the pixel intensity in the comparison image, and C1 and C2 are two constant values that are small enough to avoid division instability. The structural similarity index value varies between 0 and 1. A higher structural similarity index value indicates that the prediction result has a higher similarity with the reference matrix, indicating that the model performs well in capturing the data characteristics and structure. Through the structural similarity index evaluation, the performance of the model can be quantitatively measured to help optimize and improve the model. The formula for the structural similarity index is
[0144] C1=(k1L) 2 (twenty one)
[0145] C2=(k2L) 2 (twenty two)
[0146]
[0147] Where x and y represent two images or matrix data to be compared. x and μ y Represents the mean value of image or matrix x and y respectively. x 2 and σ y 2 Denotes the variance of the image or matrix x and y respectively. L is the dynamic range of the pixel value. k1 = 0.01, k2 = 0.03.
[0148] In summary, the U-Net neural network analysis method of defect surface leakage magnetic field signal proposed in the present invention uses the magnetic permeability distribution data as the input of the U-Net model, and outputs the prediction result of the y component of the magnetic field distribution. Combined with the channel attention mechanism, the prediction of the leakage magnetic signal is successfully realized.
[0149] Example:
[0150] The present invention discloses an application of a U-Net neural network analysis method of defect surface leakage magnetic field signals on a certain ferromagnetic material.
[0151] A two-dimensional magnetic flux leakage detection model was constructed using finite element software. The geometric dimensions of the test piece to be inspected were set to 150 mm in length and 5 mm in width, and the internal defects contained various sizes. Subsequently, simulation calculations were performed to generate a magnetic flux leakage signal data set, and the corresponding magnetic permeability distribution data and its corresponding magnetic field distribution y component (H y ). Figure 1 As shown in Figure 2, the permeability distribution data is used as the input of the U-Net model, and the label is the corresponding magnetic field distribution y component (H y ), which provides an important data foundation for subsequent model training.
[0152] The dataset is divided into a test set, a validation set, and a training set in a ratio of 1:1:8, and the data is rotated, cropped, and standardized. Rotation and cropping enrich sample diversity, and standardization accelerates training convergence. Then a U-Net model with a shallow multi-convolutional layer module and a channel attention mechanism is constructed. The convolutional layer expands the receptive field, and the channel attention enhances the ability to capture key features.
[0153] U-Net was trained using the RMSProp optimizer to minimize the MSE loss, with an initial learning rate of 0.0001 and decayed by 0.1 every 10 epochs. The training process lasted for 300 epochs to ensure robust convergence of the model.
[0154] Finally, the pre-trained weights are loaded, the validation set is input to predict the magnetic field distribution, and the SSIM indicator is used to evaluate the prediction accuracy.
[0155] Table 1 shows that in the validation set, the magnetic field distribution maps of 100 different defects were predicted, which took 10.281 seconds, while the finite element method took 976.25 seconds. In terms of the prediction or calculation time of a single data, the U-Net model only took 0.091 seconds, while the finite element method took 9.61 seconds, which shows the significant advantage of U-Net in computing speed.
[0156] Table 1. Comparison of computational time between U-Net and finite element method
[0157]
[0158] Figure 2 The figure shows the comparison between the finite element simulation results and the U-Net prediction results of an example data in the validation set under three different lift-off values. It can be seen that the U-Net model is effective in predicting the y component of the magnetic field (H y ) are highly consistent with the finite element simulation results with a small error, and the structural similarity index (SSIM) reaches 0.9791, which shows that the U-Net model can accurately capture the magnetic field distribution characteristics.
Claims
1. A U-Net neural network analysis method for defect surface leakage magnetic field signals, characterized in that: The steps include: Step 1: Use the finite element method to simulate or conduct detection experiments to obtain the leakage magnetic field signal, and establish the magnetic permeability distribution and leakage magnetic field data set required for U-Net neural network training; Step 2: rotating, cropping and standardizing the magnetic permeability distribution and leakage magnetic field data set to obtain a processed data set; Step 3: Based on the processed data set, a U-Net model is constructed with the permeability data as input and the y-component of the magnetic field distribution as output; Step 4: Use RMSProp optimizer to train the U-Net model and save the weights; Step 5: Use the weights saved in step 4 to predict the magnetic field distribution of the test set, and use structural similarity to evaluate the accuracy of the prediction results.
2. The U-Net neural network analysis method for defect surface leakage magnetic field signal according to claim 1 is characterized in that: A data set is prepared by experimental methods or finite element simulation, wherein the data set includes magnetic permeability data as input and a y-direction component of magnetic field distribution as output, wherein a part of the data set is divided into a test set and the other part is divided into a training set; The specific steps of step 1 are: Finite element method is used for simulation to establish the data set required for U-Net neural network training, and finite element numerical calculation of two-dimensional magnetic flux leakage detection system is carried out. The coil is used as the magnetic field source, the defect is set as a rectangle, and free triangle units are used. The magnetic field distribution is numerically calculated based on Maxwell's equations, and a data set is established; The electromagnetic field was analyzed based on Maxwell's problem. The differential form of Maxwell's equations is shown below: In the formula, H is the magnetic field intensity, D is the electric flux density, J is the current density, E is the electric field intensity, B is the magnetic induction intensity, and ρ is the charge density; Maxwell's equations were supplemented with differential forms and the following formula was given: When using the finite element method to perform finite element calculations on electromagnetic fields of anisotropic media, the following relationship exists: In the formula, ε represents the dielectric constant, μ represents the magnetic permeability, and σ represents the electrical conductivity; In a linear homogeneous medium, ε, μ and σ are constants, and equations (1), (2) and (5) are abbreviated as: By using equations (4) and (10), the magnetic flux density is described as: In the above formula, A is the magnetic vector potential. Substituting formula (7) and formula (11) into formula (10), we get the following formula: The above equations are numerically calculated using the finite element method to obtain the data set required for model training and verification of U-Net deep learning.
3. The U-Net neural network analysis method for defect surface leakage magnetic field signal according to claim 1 is characterized in that: The step 2 is specifically as follows: The data preprocessing process includes cropping and rotation; cropping is used to extract the area of interest in the image and to remove unnecessary background; the rotation operation is used to randomly change the direction of the image; Then the data set is normalized to be centered around 0 by adjusting the mean, and then the data is scaled by the standard deviation; The data after standardization will have the following characteristics: the mean of all data will be approximately 0; the standard deviation of all data will be approximately 1.
4. The U-Net neural network analysis method for defect surface leakage magnetic field signal according to claim 3 is characterized in that: The specific process of the standardization process is as follows: First, calculate the mean and standard deviation. For each feature in the training data set, first calculate its mean μ and standard deviation σ; Where N is the number of samples, X i is the value of the i-th sample on this feature; Then, using the calculated mean and standard deviation, each data point is standardized and the following formula is used to convert the original data point X into the standardized data point Z For the test set, the mean and standard deviation calculated on the training set are used for standardization to ensure that the test data has the same distribution as the training data, that is, the test data points are applied After standardization, check whether the mean and standard deviation of the standardized data set meet expectations, that is, the mean is close to 0 and the standard deviation is close to 1.
5. The U-Net neural network analysis method of defect surface leakage magnetic field signal according to claim 4 is characterized in that: The step three is specifically as follows: Based on the data preprocessed in step 2, a U-Net network with magnetic permeability data as input is constructed to predict the y-component of the magnetic field distribution; The U-Net model includes a shallow multi-convolutional layer module and a channel attention module; Shallow multi-convolutional layer module, by stacking multiple small-size convolutional layers, expands the range of the receptive field to a larger size, capturing subtle changes and local relationships in the input permeability data; The channel attention module adaptively adjusts the contribution of feature channels by calculating channel importance weights, highlighting the features that are important for predicting the distribution of magnetic flux leakage signals.
6. The U-Net neural network analysis method for defect surface leakage magnetic field signal according to claim 5 is characterized in that: The specific steps are: The shallow multi-convolutional layer module contains two convolutional layers and corresponding batch normalization layers and activation functions, and extracts features by using a 3×3 convolution kernel; Each convolutional layer is followed by a batch normalization layer, and the LeakyReLU activation function is used to introduce nonlinear features; Assuming the lth layer is a convolutional layer and the l+1th layer is a subsampling layer, the calculation formula for the jth feature map of the lth layer is as follows: Among them, f is the activation function, M j represents the choice of input mapping, x i l is the output of the jth neuron in the lth layer, X i l-1 is the i-th input feature map in the ll-th layer, K ij l is the convolution kernel of the lth layer, b j l is the bias term of the j-th output of the l-th layer, and * is the convolution operation; A batch normalization layer (BN) needs to be connected after the convolution layer. The operation of the batch normalization layer is expressed as Where E is the expectation, Var is the variance, and the scale factor γ (k) and the translation factor β (k) is a learnable parameter; In the channel attention mechanism: First, two different channel descriptors are generated by global average pooling and global maximum pooling respectively. Then, these two descriptors are processed through two fully connected layers to generate channel attention weights. The weights output by the Sigmoid activation function are used to weight the input feature map. Then, the upsampling and downsampling modules are defined. First, the input feature map is spatially downsampled through the maximum pooling layer. Then, the double convolution module is applied for feature extraction. Finally, the channel attention mechanism is introduced to dynamically adjust the importance of feature channels. Upsample the input feature map by bilinear interpolation, and then calculate the difference of the feature map to be spliced; After concatenation, a double convolution module is used for further feature extraction, and a channel attention mechanism is added on this basis. Then, the feature map is mapped to the final number of output channels through a 1×1 convolution, which usually corresponds to the number of task categories. Finally, the U-Net architecture is constructed. By combining the above modules, the layer-by-layer encoding and decoding of the input image is realized. In the first half of the model, the downsampling module is used to gradually extract features, while in the second half, the upsampling module is used to gradually restore the spatial dimension of the image. Finally, the output is generated through 1×1 convolution.
7. The U-Net neural network analysis method for defect surface leakage magnetic field signal according to claim 6 is characterized in that: The step 4 is specifically as follows: The U-Net model is trained using the RMSprop optimizer by minimizing the mean square error loss function, which is used as the loss function; The formula for the mean square error loss function is: In the above formula, n is the number of samples, y is i is the true label, is the model prediction value; In each training cycle, the model is put into training mode and iterates over the training dataset for forward and backward propagation; In each iteration, the optimizer gradients are first cleared, and then the input image and label are transferred to the computing device used; the model output is calculated through forward propagation, and backpropagation is performed based on the calculated loss value; at the same time, the training loss of each cycle is recorded, and the best model weights are continuously monitored to be saved during the training process; After each cycle, the validation loss is calculated by calling the function to ensure that the model performs stably on the validation dataset. During the entire training process, plot the curves of training and validation loss to visually show the changes in model performance; Finally, save the change graph of training loss and validation loss as an image file; The training configuration is 1 sample per batch, and the training data set is randomly generated before each cycle.
8. The U-Net neural network analysis method for defect surface leakage magnetic field signal according to claim 7 is characterized in that: The step five is specifically as follows: Using the pre-trained U-Net model and its weights, the test data are standardized and preprocessed to be consistent with the training data, and then the preprocessed test data are input into the model to generate the prediction results of the magnetic field distribution. In addition, the output prediction results are post-processed for visualization and analysis. Finally, the structural similarity index is used to compare the prediction results with the actual magnetic field distribution to evaluate the prediction accuracy of the model on the test set.
9. The U-Net neural network analysis method for defect surface leakage magnetic field signal according to claim 8, characterized in that: The structural similarity index is used to evaluate the similarity between the finite element method results and the deep learning neural network prediction results; where μ and σ are the mean and standard deviation of the pixel intensity in the comparison image, C1 and C2 are two constant values, and the structural similarity index formula is: C1=(k1L) 2 (21) C2=(k2L) 2 (22) Among them, x and y represent two images or matrix data to be compared, μ x and μ y Represents the mean value of image or matrix x and y, σ x 2 and σ y 2 denote the variance of the image or matrix x and y respectively, and L is the dynamic range of the pixel values.
Citation Information
Cited By
Magnetic field super-resolution imaging training method and imaging system based on physical information
CN120876233A