Concrete crack detection method based on computer vision
By enhancing visual detail features and simulating natural wind flow update parameters in the generative adversarial network, combining autoencoder and a support vector machine with proximal gradient optimization, the crack detection method in the prior art is solved in the overall situation of insufficient data and complex environments. The problem of insufficient chemical capability has achieved higher detection accuracy and efficiency.
Patent Information
- Application Number
- CN202411254977.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-09
- Publication Date
- 2024-12-20
AI Technical Summary
Existing crack detection methods based on computer vision show weak generalization ability and low detection efficiency when data quality and quantity are insufficient, especially in complex environments and multiple crack types, which are difficult to effectively detect.
Data expansion is adopted for generative adversarial network based on visual detail feature enhancement, and the neural network parameters are updated by simulating the flow and air pressure differences of natural wind, combined with autoencoder and a support vector machine with proximal gradient optimization to improve the model generalization ability and accuracy.
It significantly improves the generalization ability and accuracy of the model, avoids gradient vanishing and local optimization problems, accelerates the convergence speed of the model, and ensures high accuracy and stability in complex environments.
Smart Images

Figure CN119169364A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of machine learning, and in particular to a concrete crack detection method based on computer vision. Background Art
[0002] With the increasing importance of engineering structure safety, the requirements for crack detection technology are also constantly increasing, especially in the inspection and maintenance of large-scale infrastructure; previously, crack detection mostly relied on manual detection, which was time-consuming and labor-intensive. With the development and popularization of machine vision and neural network technology, crack detection methods based on computer vision have gradually become popular; for example, the existing invention patent with application number CN202010044919.6 proposes an automatic detection method for bridge cracks based on a generative adversarial network, the invention patent with application number CN202210947692.5 proposes a pipeline crack detection method based on a point-connected deep convolutional network, and the invention patent with application number CN202210767292.6 proposes a local feature enhanced Transformer road crack detection method. However, existing crack detection methods based on computer vision are often limited by the quality and quantity of data, and when faced with complex environments and crack types, they often show the shortcomings of weak generalization ability and low detection efficiency. Summary of the invention
[0003] In view of the above problems, an embodiment of the present invention provides a concrete crack detection method based on computer vision.
[0004] An embodiment of the present invention provides a concrete crack detection method based on computer vision, comprising:
[0005] S1. Data collection and annotation
[0006] Collect images in the actual engineering environment, and annotate the collected images to obtain the original training data set, where the annotated categories include cracks and non-cracks;
[0007] S2. Data expansion
[0008] Create a generative adversarial network based on visual detail feature enhancement, use the original training data set to train the generative adversarial network, and obtain an expanded training data set;
[0009] S3. Feature extraction model training
[0010] The feature extraction model uses a three-layer fully connected neural network and uses the expanded training data set to train the feature extraction model. During the training process, the model parameters are updated based on airflow dynamics by simulating wind flow and air pressure differences to complete the training and obtain the training data set after feature extraction.
[0011] S4. Feature dimensionality reduction model training
[0012] The feature dimension reduction model is implemented by an autoencoder, which includes an encoder and a decoder. The feature dimension reduction model is trained using the training data set after feature extraction, and a training data set after feature dimension reduction is obtained.
[0013] S5. Classifier model training
[0014] The classifier model uses a support vector machine optimized by proximal gradient, and the training data set after feature dimension reduction is input into the classifier model to complete the model training;
[0015] S6. Concrete crack detection
[0016] Collect images of the engineering environment to be detected to obtain new samples, input the new samples into the feature extraction model to obtain new samples after feature extraction, input the new samples after feature extraction into the feature dimension reduction model to obtain new samples after feature dimension reduction, and input the new samples after feature dimension reduction into the classifier model to obtain the concrete crack detection results.
[0017] Optionally, the training process of the generative adversarial network based on visual detail feature enhancement in S2 includes:
[0018] S201, initialize the network parameters of the generator G and the discriminator D, set θ g and θ d They are the network parameters of the generator G and the discriminator D respectively;
[0019] S202, generator G according to the current network parameters θ g Generate image It is expressed as:
[0020]
[0021] In the formula, z is derived from the prior noise distribution p z (z), G(z; θ g ) represents the output of the generator;
[0022] S203, the discriminator D classifies the generated image and the real image, and the training goal is to minimize the loss function L of the discriminator D d , expressed as:
[0023]
[0024] In the formula, x is the real image, p data is the distribution of data, D(x) represents the output of the discriminator D for the real image x, represents expectation, ~ represents compliance with a specific distribution, L noise represents the loss of noise immunity;
[0025] Define the noise vector as η fr , and its calculation method is expressed as:
[0026]
[0027] In the formula, is the standard deviation of the noise intensity, represents a normal distribution with a mean of 0 and a covariance of the unit matrix. The calculation method of the noise resistance loss is expressed as:
[0028]
[0029] Where, ∥∥2 is the norm of L2 regularization;
[0030] S204, the generator G adjusts the network parameters according to the feedback of the discriminator D. The training goal is to make the discriminator D judge the image generated by the generator G as a real image. The loss function L of the generator G is g The calculation method is expressed as:
[0031]
[0032] S205. After each training cycle, the generated image is processed using a visual detail enhancement module to improve the detail quality of the image, which is expressed as:
[0033]
[0034] In the formula, is the image after detail enhancement, Enhance() is the detail enhancement function, and p refers to the image Each pixel in
[0035] The implementation of the detail enhancement function Enhance() is expressed as:
[0036]
[0037] In the formula, C() is the contrast enhancement operation function, S() is the Laplace sharpening operation function, β re is the detail enhancement factor;
[0038] The calculation method of the contrast enhancement operation function C() is expressed as:
[0039]
[0040] In the formula, γ re is the contrast enhancement coefficient; for pixel p, calculate the average value μ of the pixels in window w re and standard deviation σ re ;
[0041] The calculation method of the Laplace sharpening operation function S() is expressed as:
[0042]
[0043] In the formula, α re is the coefficient that controls the sharpening strength, is the Laplacian value of pixel p;
[0044] S206, iterating the above steps S201-S205 until the preset stop iteration condition is met, which means that the model training is completed.
[0045] Optionally, the process of updating the model parameters in S3 based on airflow dynamics by simulating wind flow and pressure differences to complete the training includes:
[0046] S301, using the parameters of the feature extraction model as particles, initializing the position and velocity of the particles in the parameter space. Specifically, each parameter p in the feature extraction model i The corresponding particle position and velocity v i In the initial stage, it is randomly generated and the initialization process is expressed as:
[0047] p i (0) = p min +rand(0,1)×(p max -p min )
[0048] v i (0) = v min +rand(0,1)×(v max -v min )
[0049] In the formula, p min and p max Indicates the possible minimum and maximum values of the parameter, v min and v max Indicates the minimum and maximum values of the speed, rand(0,1) indicates a random number in the interval [0,1];
[0050] S302, calculate the fitness value for each particle. Specifically, the fitness function F(p) is the inverse of the error, the error is obtained based on a preset logistic regression classifier, and the fitness function is expressed as:
[0051]
[0052] Where E(p) is the error function;
[0053] The error function E(p) is further expressed as:
[0054]
[0055] Where N is the number of samples in the expanded training data set, y n is the actual label of the nth sample, is the prediction of the feature extraction model for the nth sample;
[0056] S303, simulating the pressure difference ΔP according to the fitness value, the pressure difference ΔP is determined by the fitness, based on the principle that high fitness corresponds to low pressure, specifically, setting a reference fitness F base , the pressure difference ΔP is expressed as:
[0057] ΔP(p i )=βe×(F base -F(p i ))
[0058] In the formula, βe is the adjustment factor;
[0059] S304, update the position and speed of each particle according to the pressure difference ΔP and wind speed, the wind speed is the update step, simulate the influence of wind flow on the particle position, update the new position p of the parameter affected by the pressure difference ΔP and wind speed i (t+1) and the new velocity v i The calculation method of (t+1) is expressed as:
[0060] p i (t+1)=p i (t)+v i (t+1)
[0061] v i (t+1)=w×v i (t)+c1×rand(0,1)×(ΔP(p i ))
[0062] Where w is the inertia weight, which controls the effect of the previous speed on the current speed; c1 is the learning factor, which controls the effect of the air pressure difference on the speed;
[0063] S305, dynamically adjust the wind speed to adapt to different regions and characteristics of the parameter space. Specifically, the wind speed is adjusted by dynamically adjusting the inertia weight w and the learning factor c1 to adapt to different stages of the search process, which is expressed as:
[0064]
[0065] Where e is the natural base in mathematics, t is the current number of iterations, T is the maximum number of iterations, γu and δu are adaptive environmental perception adjustment factors, ESF(t) is the environmental perception factor, and wmax and w min are the maximum and minimum values of the inertia weight w, c 1max and c 1min are the maximum and minimum values of the learning factor c1 respectively;
[0066] The environmental perception factor ESF(t) is calculated based on the rate of change of fitness in consecutive iterations to indicate the adjustment range required for the parameter update strategy. Specifically, F(p,t) is set as the fitness of parameter p at time t. The environmental perception factor is defined as the relative rate of fitness change between two consecutive iterations, expressed as:
[0067]
[0068] In addition, using e -γ×ESF(t) and e -δ×ESF(t) The wind speed is adjusted by introducing nonlinear adjustment through exponential decay function, ensuring significant adjustment range when the environment changes greatly;
[0069] S306, introduce variation by random or preset strategy to simulate the turbulence effect in natural wind to maintain the diversity of parameter population and avoid premature convergence. Specifically, each parameter p i There is a certain probability P mut Mutation occurs, and the parameter value after mutation is expressed as:
[0070] p' i =p i +δc×(p mutmax -p mutmin )×θ(t)
[0071] Where δc is a random number generated from the interval [-1, 1], and θ(t) is the wind direction variable of the tth iteration;
[0072] The wind direction variable θ is used to simulate the change of wind direction in the real world, thereby increasing the diversity of the search process, which is expressed as:
[0073]
[0074] In the formula, θ max is the maximum angle of change in wind direction;
[0075] S307, repeat the above steps S301-S306 until the preset stop iteration condition is met, and determine the particle with the highest fitness to complete the model training.
[0076] Optionally, the training process of the autoencoder in S4 includes:
[0077] S401, randomly initialize the weights of the encoder and decoder according to a preset distribution, and the weight pW and bias pb of the autoencoder are randomly initialized using a Gaussian distribution, expressed as:
[0078]
[0079] Where, pW (l) is the weight of the lth layer; pb (l) is the bias of the lth layer; Indicates that the mean is 0 and the variance is σ 2 Normal distribution, σ is the standard deviation;
[0080] S402, through the forward propagation method, the input data px is converted into a low-dimensional feature representation by the encoder, and then the low-dimensional feature representation is passed to the decoder to reconstruct the data. Specifically, the output pz of the encoder part and the output pz of the decoder part The calculation method is expressed as:
[0081] pz=Sig(pW enc ·px+pb enc )
[0082]
[0083] Where px is the input data; pz is the output of the encoder, i.e., the low-dimensional feature representation; is the data reconstructed by the decoder; pW enc and pb enc are the weight and bias of the encoder respectively; pW dec and pb dec are the weight and bias of the decoder respectively; Sig() is the Sigmoid activation function;
[0084] S403, using the mean square error based on L2 regularization to calculate the total loss to avoid overfitting and ensure that the feature dimensionality reduction model learns effective data compression. The calculation method of the loss function pL is expressed as:
[0085]
[0086] In the formula, is the reconstruction error, calculated using the Euclidean distance; λ is the regularization parameter; ∥pW enc ∥ 2 and ∥pW dec ∥ 2 is the L2 regularization term of the weight;
[0087] Reconstruction error term The calculation method is expressed as:
[0088]
[0089] In the formula, px i is the i-th element of the input data px; Reconstructing data The i-th element of ; n is the number of elements in the data vector;
[0090] Regularization term ∥pW enc ∥ 2 and ∥pW dec ∥ 2 are respectively expressed as the sum of the squares of all encoder and decoder weights, expressed as:
[0091]
[0092]
[0093] Where, pW enc,jk is the encoder weight matrix pW enc The element in row j and column k in pW dec,jk is the decoder weight matrix pW dec The element at row j and column k in ;
[0094] S404. During the back propagation process, the autoencoder weights are updated by the gradient descent algorithm according to the loss function pL, which is expressed as:
[0095]
[0096] In the formula, α cf is the learning rate; and They are the gradients of the loss function with respect to the encoder and decoder weights, respectively;
[0097] S405, adaptively adjust the learning rate α according to the training process cf , using the exponential decay strategy to optimize the learning process, the calculation method is expressed as:
[0098]
[0099] Where e is the base of natural logarithm; γ cfd is the decay rate; t is the number of iterations;
[0100] Decay rate γ cfd is the rate of change related to time, and is calculated as:
[0101]
[0102] In the formula, α initial is the initial learning rate, T cf Is to reach the specified learning rate αcf The number of iterations required;
[0103] S406: Repeat the above steps S401-S405 until the preset stop iteration condition is met, and the model training is completed.
[0104] Optionally, the training process of the support vector machine using proximal gradient optimization in S5 includes:
[0105] S501, setting the kernel function of the support vector machine based on proximal gradient optimization. Specifically, the radial basis function is used as the kernel function of the support vector machine, and the calculation method is:
[0106] K(qx i ,qx j )=exp(-γ qk ∥qx i -qx j ∥ 2 )
[0107] Where ∥∥ is the L1 norm, qx i is the feature vector of the i-th training sample in the training data after feature dimensionality reduction, qx j is the feature vector of the jth training sample, γ qk is the bandwidth parameter of the radial basis function kernel;
[0108] Initialize the classifier model parameters, including the weight vector w q and the bias term b q , weight vector w q Initialized by randomly assigning values, bias term b q Initially set to zero;
[0109] S502. In each iteration, calculate the gradient of the loss function L and q and the bias term b q Update, and consider a proximal operator to ensure that the update step does not deviate too far from the initial solution to maintain the stability of the model. The specific steps are expressed as:
[0110]
[0111] Where η q is the learning rate; q is the regularization parameter; It is a proximal operator used for L1 regularization to increase the sparsity of the model; and They are the loss function L versus w q and b q The partial derivative of
[0112] The calculation method of the loss function L is expressed as:
[0113]
[0114] And, the loss function L is about w q The calculation method of the partial derivative is expressed as:
[0115]
[0116] In the formula, 1 [co] is an indicator function, that is, when the condition co is true, the value is 1, otherwise it is 0; y i is the label of the i-th training sample; K(qx i ,qx) is the value calculated by the kernel function;
[0117] And, the loss function L is about b q The calculation method of the partial derivative is expressed as:
[0118]
[0119] S503, adjusting the regularization parameters and kernel function parameters of the support vector machine, and using the cross-validation method to select the best parameter combination γ qk and λ q , where the constraints are:
[0120]
[0121] In the formula, y i is the label of the i-th training sample; n is the total number of samples; the sign() function is used to determine the sign of the classification result;
[0122] S504: Repeat the above steps S501-S503 until the preset stop iteration condition is met, which means that the model training is completed.
[0123] Compared with the prior art, the present invention has the following beneficial effects:
[0124] 1. The present invention adopts a generative adversarial network based on visual detail feature enhancement, which particularly enhances the generation of visually realistic crack images, and uses an improved loss function to consider pixel-level errors and high-level content and structural features of the image, thereby increasing the diversity and quality of training data and improving the generalization ability and accuracy of the model.
[0125] 2. The present invention uses a method that simulates the flow of wind and air pressure differences in nature to update the parameters of the neural network. Different from the traditional gradient descent, it effectively improves the search capability in complex parameter space, avoids gradient vanishing and local optimal problems, and accelerates the convergence speed of the model.
[0126] 3. The present invention effectively compresses high-dimensional data through an autoencoder and performs loss calculation based on the mean square error of L2 regularization, thereby ensuring effective compression of data while avoiding overfitting and maintaining reconstruction quality.
[0127] 4. The present invention adopts a support vector machine algorithm based on proximal gradient optimization to process nonlinear separable data, and adopts a proximal gradient method to enhance stability and convergence speed, thereby improving the classifier's ability to process complex data and ensuring high accuracy and stability. BRIEF DESCRIPTION OF THE DRAWINGS
[0128] The drawings described herein are used to provide a further understanding of the present invention, constitute a part of the present application, and do not constitute a limitation of the present invention. In the drawings:
[0129] Figure 1 A schematic diagram of a concrete crack detection method based on computer vision provided by an embodiment of the present invention;
[0130] Figure 2 A functional block diagram of a feature dimension reduction model provided by an embodiment of the present invention;
[0131] Figure 3 A principle block diagram of a concrete crack detection method based on computer vision provided in an embodiment of the invention. DETAILED DESCRIPTION
[0132] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the embodiments and the accompanying drawings. Here, the illustrative embodiments of the present invention and their descriptions are used to explain the present invention, but are not intended to limit the present invention.
[0133] See also Figure 1 , the concrete crack detection method based on computer vision provided by the embodiment of the present invention includes:
[0134] S1. Data collection and annotation
[0135] Images in actual engineering environments are collected and annotated to obtain original training data sets, where the annotated categories include cracks and non-cracks.
[0136] In the implementation, the collected image data is stored in JPEG format, the pixel resolution is 1920x1080, and the channels of the image data are RGB three channels.
[0137] S2. Data expansion
[0138] A generative adversarial network based on visual detail feature enhancement is created, the generative adversarial network is trained using the original training dataset, and an expanded training dataset is obtained.
[0139] In practice, the acquisition, labeling and preprocessing of training data are time-consuming and labor-intensive, and insufficient training samples can easily lead to poor generalization ability of the model, while affecting the accuracy of the model. In view of the problem that traditional generative adversarial networks are prone to mode collapse, the present invention improves the loss function, not only considering pixel-level errors, but also considering high-level features of image content and structure. Specifically, the training process of a generative adversarial network based on visual detail feature enhancement includes:
[0140] S201, initialize the network parameters of the generator G and the discriminator D, set θ g and θ d They are the network parameters of the generator G and the discriminator D respectively;
[0141] S202, generator G according to the current network parameters θ g Generate image It is expressed as:
[0142]
[0143] In the formula, z is derived from the prior noise distribution p z (z), G(z; θ g ) represents the output of the generator;
[0144] S203, the discriminator D classifies the generated image and the real image, and the training goal is to minimize the loss function L of the discriminator D d , expressed as:
[0145]
[0146] In the formula, x is the real image, p data is the distribution of data, D(x) represents the output of the discriminator D for the real image x, represents expectation, ~ represents compliance with a specific distribution, L noise represents the loss of noise immunity;
[0147] Define the noise vector as η fr , and its calculation method is expressed as:
[0148]
[0149] In the formula, is the standard deviation of the noise intensity, represents a normal distribution with a mean of 0 and a covariance of the unit matrix. The calculation method of the noise resistance loss is expressed as:
[0150]
[0151] Where, ∥∥2 is the norm of L2 regularization;
[0152] S204, the generator G adjusts the network parameters according to the feedback of the discriminator D. The training goal is to make the discriminator D judge the image generated by the generator G as a real image. The loss function L of the generator G is g The calculation method is expressed as:
[0153]
[0154] S205. After each training cycle, the generated image is processed using a visual detail enhancement module to improve the detail quality of the image, which is expressed as:
[0155]
[0156] In the formula, is the image after detail enhancement, Enhance() is the detail enhancement function, and p refers to the image Each pixel in
[0157] The implementation of the detail enhancement function Enhance() is expressed as:
[0158]
[0159] In the formula, C() is the contrast enhancement operation function, S() is the Laplace sharpening operation function, β re is the detail enhancement coefficient; preferably, β re Set to 0.3.
[0160] The calculation method of the contrast enhancement operation function C() is expressed as:
[0161]
[0162] In the formula, γ re is the contrast enhancement coefficient; for pixel p, calculate the average value μ of the pixels in window w re and standard deviation σ re ; Preferably, the local window w is defined as 3×3, with a standard deviation σ re The value is 0.01.
[0163] The calculation method of the Laplace sharpening operation function S() is expressed as:
[0164]
[0165] In the formula, α re is the coefficient that controls the sharpening strength, is the Laplace value of pixel p; preferably, α re Set to 0.5.
[0166] S206, iterate the above steps S201-S205 until the preset stop iteration condition is met, which means that the model training is completed. In one embodiment, the preset stop iteration condition is reaching a preset maximum number of iterations, preferably, the preset maximum number of iterations is set to 1000 times.
[0167] S3. Feature extraction model training
[0168] The feature extraction model adopts a three-layer fully connected neural network, and the feature extraction model is trained using the expanded training data set. During the training process, the model parameters are updated based on airflow dynamics by simulating wind flow and air pressure differences to complete the training and obtain the training data set after feature extraction.
[0169] Traditional optimization methods based on gradient descent may encounter difficulties in complex parameter spaces, such as gradient vanishing, local minima, and other problems. The airflow dynamics optimization algorithm proposed in the present invention updates parameters by simulating wind flow and air pressure differences, and does not rely on gradient information. Therefore, it can search in a wider parameter space, improving the ability to avoid local optimality and accelerate convergence.
[0170] Specifically, the process of updating the model parameters to complete the training by simulating wind flow and air pressure differences based on airflow dynamics includes:
[0171] S301, using the parameters of the feature extraction model as particles, initializing the position and velocity of the particles in the parameter space. Specifically, each parameter p in the feature extraction model i The corresponding particle position and velocity v i In the initial stage, it is randomly generated and the initialization process is expressed as:
[0172] p i (0) = p min +rand(0,1)×(p max -p min )
[0173] v i (0) = v min +rand(0,1)×(v max -v min )
[0174] In the formula, p min and p max Indicates the possible minimum and maximum values of the parameter, v min and v max Indicates the minimum and maximum values of the speed, rand(0,1) indicates a random number in the interval [0,1];
[0175] S302, calculate the fitness value for each particle. Specifically, the fitness function F(p) is the inverse of the error, the error is obtained based on a preset logistic regression classifier, and the fitness function is expressed as:
[0176]
[0177] Where E(p) is the error function; in one implementation, a cross entropy loss function is used.
[0178] The error function E(p) is further expressed as:
[0179]
[0180] Where N is the number of samples in the expanded training data set, y n is the actual label of the nth sample, is the prediction of the feature extraction model for the nth sample;
[0181] S303, simulating the pressure difference ΔP according to the fitness value, the pressure difference ΔP is determined by the fitness, based on the principle that high fitness corresponds to low pressure, specifically, setting a reference fitness F base , the pressure difference ΔP is expressed as:
[0182] ΔP(p i )=βe×(F base -F(p i ))
[0183] Where βe is the adjustment factor; preferably, F base is set to the highest fitness value in the population. The adjustment factor βe is set to 1.5.
[0184] S304, update the position and speed of each particle according to the pressure difference ΔP and wind speed, the wind speed is the update step, simulate the influence of wind flow on the particle position, update the new position p of the parameter affected by the pressure difference ΔP and wind speed i (t+1) and the new velocity v i The calculation method of (t+1) is expressed as:
[0185] p i (t+1)=p i (t)+v i (t+1)
[0186] v i (t+1)=w×v i (t)+c1×rand(0,1)×(ΔP(p i ))
[0187] Wherein, w is the inertia weight, which controls the influence of the previous speed on the current speed; c1 is the learning factor, which controls the influence of the air pressure difference on the speed; preferably, w is set to 0.9 and c1 is set to 2.
[0188] S305, dynamically adjust the wind speed to adapt to different regions and characteristics of the parameter space. Specifically, the wind speed is adjusted by dynamically adjusting the inertia weight w and the learning factor c1 to adapt to different stages of the search process, which is expressed as:
[0189]
[0190] Where e is the natural base in mathematics, t is the current number of iterations, T is the maximum number of iterations, γu and δu are adaptive environmental perception adjustment factors, ESF(t) is the environmental perception factor, and w max and w min are the maximum and minimum values of the inertia weight w, c 1max and c 1min are the maximum and minimum values of the learning factor c1 respectively; preferably, w max Set to 0.9, w min Set to 0.4, c 1max Set to 2.5, c 1min Set to 0.5.
[0191] The environmental perception factor ESF(t) is calculated based on the rate of change of fitness in consecutive iterations to indicate the adjustment range required for the parameter update strategy. Specifically, F(p,t) is set as the fitness of parameter p at time t. The environmental perception factor is defined as the relative rate of fitness change between two consecutive iterations, expressed as:
[0192]
[0193] In addition, using e -γ×ESF(t) and e -δ×ESF(t) The wind speed is adjusted by introducing nonlinear adjustment through exponential decay function, ensuring significant adjustment range when the environment changes greatly;
[0194] S306, introduce variation by random or preset strategy to simulate the turbulence effect in natural wind to maintain the diversity of parameter population and avoid premature convergence. Specifically, each parameter p i There is a certain probability P mut Mutation occurs, and the parameter value after mutation is expressed as:
[0195] p' i =p i +δc×(p mutmax -p mutmin )×θ(t)
[0196] Where δc is a random number generated from the interval [-1, 1], and θ(t) is the wind direction variable of the tth iteration;
[0197] The wind direction variable θ is used to simulate the change of wind direction in the real world, thereby increasing the diversity of the search process, which is expressed as:
[0198]
[0199] In the formula, θ max is the maximum angle of change in wind direction;
[0200] S307, repeat the above steps S301-S306 until the preset stop iteration condition is met, and determine the particle with the highest fitness to complete the model training.
[0201] In one embodiment, the preset condition for stopping iteration is reaching a preset maximum number of iterations. Preferably, the preset maximum number of iterations is set to 1000 times.
[0202] S4. Feature dimensionality reduction model training
[0203] The feature dimensionality reduction model is implemented using an autoencoder, which includes an encoder and a decoder. The feature dimensionality reduction model is trained using the training data set after feature extraction, and a training data set after feature dimensionality reduction is obtained.
[0204] The present invention uses L2 regularized mean square error to calculate the total loss to avoid overfitting while ensuring that the model can learn effective data compression. Specifically, the training process of the autoencoder includes:
[0205] S401, randomly initialize the weights of the encoder and decoder according to a preset distribution, and the weight pW and bias pb of the autoencoder are randomly initialized using a Gaussian distribution, expressed as:
[0206]
[0207] Where, pW (l) is the weight of the lth layer; pb (l) is the bias of the lth layer; Indicates that the mean is 0 and the variance is σ 2 The normal distribution of , σ is the standard deviation; preferably, σ is set to 0.1.
[0208] S402, through the forward propagation method, the input data px is converted into a low-dimensional feature representation by the encoder, and then the low-dimensional feature representation is passed to the decoder to reconstruct the data. Specifically, the output pz of the encoder part and the output pz of the decoder part The calculation method is expressed as:
[0209] pz=Sig(pW enc ·px+pb enc )
[0210]
[0211] Where px is the input data; pz is the output of the encoder, i.e., the low-dimensional feature representation; is the data reconstructed by the decoder; pW enc and pb enc are the weight and bias of the encoder respectively; pW dec and pb dec are the weight and bias of the decoder respectively; Sig() is the Sigmoid activation function;
[0212] S403, using the mean square error based on L2 regularization to calculate the total loss to avoid overfitting and ensure that the feature dimensionality reduction model learns effective data compression. The calculation method of the loss function pL is expressed as:
[0213]
[0214] In the formula, is the reconstruction error, calculated using the Euclidean distance; λ is the regularization parameter; ∥pW enc ∥ 2 and ∥pW dec ∥ 2 is the L2 regularization term of the weight;
[0215] Reconstruction error term The calculation method is expressed as:
[0216]
[0217] In the formula, px i is the i-th element of the input data px; Reconstructing data The i-th element of ; n is the number of elements in the data vector;
[0218] Regularization term ∥pW enc ∥ 2 and ∥pW dec ∥ 2 are respectively expressed as the sum of the squares of all encoder and decoder weights, expressed as:
[0219]
[0220] Where, pW enc,jk is the encoder weight matrix pW enc The element in row j and column k in pW dec,jk is the decoder weight matrix pWdec The element at row j and column k in ;
[0221] S404. During the back propagation process, the autoencoder weights are updated by the gradient descent algorithm according to the loss function pL, which is expressed as:
[0222]
[0223] In the formula, α cf is the learning rate; and are the gradients of the loss function with respect to the encoder and decoder weights, respectively; preferably, α cf The adaptive adjustment method is set, and the initial learning rate is set to 0.01.
[0224] S405, adaptively adjust the learning rate α according to the training process cf , using the exponential decay strategy to optimize the learning process, the calculation method is expressed as:
[0225]
[0226] Where e is the base of natural logarithm; γ cfd is the decay rate; t is the number of iterations;
[0227] Decay rate γ cfd is the rate of change related to time, and is calculated as:
[0228]
[0229] In the formula, α initial is the initial learning rate, T cf Is to reach the specified learning rate α cf The number of iterations required; preferably, α initial Set to 0.01. cf Is to reach the specified learning rate α cf The number of iterations required.
[0230] S406, repeat the above steps S401-S405 until the preset stop iteration condition is met, and the model training is completed. In one embodiment, the preset stop iteration condition is reaching a preset maximum number of iterations, preferably, the preset maximum number of iterations is set to 1000 times.
[0231] S5. Classifier model training
[0232] The classifier model uses a support vector machine optimized by proximal gradient, and the training data set after feature dimension reduction is input into the classifier model to complete the model training.
[0233] In the implementation, a support vector machine classification algorithm based on proximal gradient optimization is adopted. The support vector machine maximizes the interval between data points of different categories by finding an optimal hyperplane, thereby achieving the purpose of classification. In view of the limitations of traditional support vector machines in processing nonlinear separable data, the present invention maps the data to a high-dimensional space and then applies the proximal gradient method for optimization, which not only enhances the classifier's ability to process complex data, but also improves the convergence speed and stability of the algorithm. Specifically, the training process of the support vector machine using proximal gradient optimization includes:
[0234] S501, setting the kernel function of the support vector machine based on proximal gradient optimization. Specifically, the radial basis function is used as the kernel function of the support vector machine, and the calculation method is:
[0235] K(qx i ,qx j )=exp(-γ qk ∥qx i -qx j ∥ 2 )
[0236] Where ∥∥ is the L1 norm, qx i is the feature vector of the i-th training sample in the training data after feature dimensionality reduction, qx j is the feature vector of the jth training sample, γ qk is the bandwidth parameter of the radial basis function kernel; preferably, γ qk Set to 0.1.
[0237] Initialize the classifier model parameters, including the weight vector w q and the bias term b q , weight vector w q Initialized by randomly assigning values, bias term b q Initially set to zero;
[0238] S502. In each iteration, calculate the gradient of the loss function L and q and the bias term b q Update, and consider a proximal operator to ensure that the update step does not deviate too far from the initial solution to maintain the stability of the model. The specific steps are expressed as:
[0239]
[0240] Where η q is the learning rate; q is the regularization parameter; It is a proximal operator used for L1 regularization to increase the sparsity of the model; and They are the loss function L versus wq and b q The partial derivative of q Set to 0.01, λ q Set to 0.1.
[0241] The calculation method of the loss function L is expressed as:
[0242]
[0243] And, the loss function L is about w q The calculation method of the partial derivative is expressed as:
[0244]
[0245] In the formula, 1 [co] is an indicator function, that is, when the condition co is true, the value is 1, otherwise it is 0; y i is the label of the i-th training sample; K(qx i ,qx) is the value calculated by the kernel function;
[0246] And, the loss function L is about b q The calculation method of the partial derivative is expressed as:
[0247]
[0248] S503, adjusting the regularization parameters and kernel function parameters of the support vector machine, and using the cross-validation method to select the best parameter combination γ qk and λ q , where the constraints are:
[0249]
[0250] In the formula, y i is the label of the i-th training sample; n is the total number of samples; the sign() function is used to determine the sign of the classification result;
[0251] With parameter γ qk For example, the optimization method can be expressed as:
[0252]
[0253] K(qx i ,qx j ;γ)=exp(-γ∥qx i -qx j ∥ 2 )
[0254] The above optimization is completed through cross-validation to find the γ that can minimize the error of the validation set qk value.
[0255] S504, repeat the above steps S501-S503 until the preset stop iteration condition is met, which means that the model training is completed. In one embodiment, the preset stop iteration condition is reaching a preset maximum number of iterations, preferably, the preset maximum number of iterations is set to 1000 times.
[0256] S6. Concrete crack detection
[0257] Collect images of the engineering environment to be detected to obtain new samples, input the new samples into the feature extraction model to obtain new samples after feature extraction, input the new samples after feature extraction into the feature dimension reduction model to obtain new samples after feature dimension reduction, and input the new samples after feature dimension reduction into the classifier model to obtain the concrete crack detection results.
[0258] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.
Claims
1. A concrete crack detection method based on computer vision, characterized in that: include: S1. Data collection and annotation Collect images in the actual engineering environment, and annotate the collected images to obtain the original training data set, where the annotated categories include cracks and non-cracks; S2. Data expansion Create a generative adversarial network based on visual detail feature enhancement, use the original training data set to train the generative adversarial network, and obtain an expanded training data set; S3. Feature extraction model training The feature extraction model uses a three-layer fully connected neural network and uses the expanded training data set to train the feature extraction model. During the training process, the model parameters are updated based on airflow dynamics by simulating wind flow and air pressure differences to complete the training and obtain the training data set after feature extraction. S4. Feature dimensionality reduction model training The feature dimension reduction model is implemented by an autoencoder, which includes an encoder and a decoder. The feature dimension reduction model is trained using the training data set after feature extraction, and a training data set after feature dimension reduction is obtained. S5. Classifier model training The classifier model uses a support vector machine optimized by proximal gradient, and the training data set after feature dimension reduction is input into the classifier model to complete the model training; S6. Concrete crack detection Collect images of the engineering environment to be detected to obtain new samples, input the new samples into the feature extraction model to obtain new samples after feature extraction, input the new samples after feature extraction into the feature dimension reduction model to obtain new samples after feature dimension reduction, and input the new samples after feature dimension reduction into the classifier model to obtain the concrete crack detection results.
2. The computer vision-based concrete crack detection method according to claim 1, characterized in that: The training process of the generative adversarial network based on visual detail feature enhancement in S2 includes: S201, initialize the network parameters of the generator G and the discriminator D, set θ g and θ d They are the network parameters of the generator G and the discriminator D respectively; S202, generator G according to the current network parameters θ g Generate image It is expressed as: In the formula, z is derived from the prior noise distribution p z (z), G(z; θ g ) represents the output of the generator; S203, the discriminator D classifies the generated image and the real image, and the training goal is to minimize the loss function L of the discriminator D d , expressed as: Where x is the real image, p data is the distribution of data, D(x) represents the output of the discriminator D for the real image x, represents expectation, ~ represents compliance with a specific distribution, L noise represents the loss of noise immunity; Define the noise vector as η fr , and its calculation method is expressed as: In the formula, is the standard deviation of the noise intensity, represents a normal distribution with a mean of 0 and a covariance of the unit matrix. The calculation method of the noise resistance loss is expressed as: Where, ∥∥2 is the norm of L2 regularization; S204, the generator G adjusts the network parameters according to the feedback of the discriminator D. The training goal is to make the discriminator D judge the image generated by the generator G as a real image. The loss function L of the generator G is g The calculation method is expressed as: S205. After each training cycle, the generated image is processed using a visual detail enhancement module to improve the detail quality of the image, which is expressed as: In the formula, is the image after detail enhancement, Enhance() is the detail enhancement function, and p refers to the image Each pixel in The implementation of the detail enhancement function Enhance() is expressed as: In the formula, C() is the contrast enhancement operation function, S() is the Laplace sharpening operation function, β re is the detail enhancement factor; The calculation method of the contrast enhancement operation function C() is expressed as: In the formula, γ re is the contrast enhancement coefficient; for pixel p, calculate the average value μ of the pixels in window w re and standard deviation σ re ; The calculation method of the Laplace sharpening operation function S() is expressed as: In the formula, α re is the coefficient that controls the sharpening strength, is the Laplacian value of pixel p; S206, iterating the above steps S201-S205 until the preset stop iteration condition is met, which means that the model training is completed.
3. The computer vision-based concrete crack detection method according to claim 1, characterized in that: The process of updating model parameters in S3 to complete training by simulating wind flow and air pressure differences based on airflow dynamics includes: S301, using the parameters of the feature extraction model as particles, initializing the position and velocity of the particles in the parameter space. Specifically, each parameter p in the feature extraction model i The corresponding particle position and velocity v i In the initial stage, it is randomly generated and the initialization process is expressed as: p i (0)=p min +rand(0,1)×(p max -p min ) v i (0)=v min +rand(0,1)×(v max -v min ) In the formula, p min and p max Indicates the possible minimum and maximum values of the parameter, v min and v max Indicates the minimum and maximum values of the speed, rand(0,1) indicates a random number in the interval [0,1]; S302, calculate the fitness value for each particle. Specifically, the fitness function F(p) is the inverse of the error, the error is obtained based on a preset logistic regression classifier, and the fitness function is expressed as: Where E(p) is the error function; The error function E(p) is further expressed as: Where N is the number of samples in the expanded training data set, y n is the actual label of the nth sample, is the prediction of the feature extraction model for the nth sample; S303, simulating the pressure difference ΔP according to the fitness value. The pressure difference ΔP is determined by the fitness, based on the principle that high fitness corresponds to low pressure. Specifically, a reference fitness F is set. base , the pressure difference ΔP is expressed as: ΔP(p i )=βe×(F base -F(p i )) In the formula, βe is the adjustment factor; S304, update the position and speed of each particle according to the pressure difference ΔP and wind speed, the wind speed is the update step, simulate the influence of wind flow on the particle position, update the new position p of the parameter affected by the pressure difference ΔP and wind speed i (t+1) and the new velocity v i The calculation method of (t+1) is expressed as: p i (t+1)=p i (t)+v i (t+1) v i (t+1)=w×v i (t)+c1×rand(0,1)×(ΔP(p i )) Where w is the inertia weight, which controls the effect of the previous speed on the current speed; c1 is the learning factor, which controls the effect of the air pressure difference on the speed; S305, dynamically adjust the wind speed to adapt to different regions and characteristics of the parameter space. Specifically, the wind speed is adjusted by dynamically adjusting the inertia weight w and the learning factor c1 to adapt to different stages of the search process, which is expressed as: Where e is the natural base in mathematics, t is the current number of iterations, T is the maximum number of iterations, γu and δu are adaptive environmental perception adjustment factors, ESF(t) is the environmental perception factor, and w max and w min are the maximum and minimum values of the inertia weight w, c 1max and c 1min are the maximum and minimum values of the learning factor c1 respectively; The environmental perception factor ESF(t) is calculated based on the rate of change of fitness in consecutive iterations to indicate the adjustment range required for the parameter update strategy. Specifically, F(p,t) is set as the fitness of parameter p at time t. The environmental perception factor is defined as the relative rate of fitness change between two consecutive iterations, expressed as: In addition, using e -γ×ESF(t) and e -δ×ESF(t) The wind speed is adjusted by introducing nonlinear adjustment through exponential decay function, ensuring significant adjustment range when the environment changes greatly; S306, introduce variation by random or preset strategy to simulate the turbulence effect in natural wind to maintain the diversity of parameter population and avoid premature convergence. Specifically, each parameter p i There is a certain probability P mut Mutation occurs, and the parameter value after mutation is expressed as: p′ i =p i +δc×(p mutmax -p mutmin )×θ(t) Where δc is a random number generated from the interval [-1, 1], and θ(t) is the wind direction variable of the tth iteration; The wind direction variable θ is used to simulate the change of wind direction in the real world, thereby increasing the diversity of the search process, which is expressed as: In the formula, θ max is the maximum angle of change in wind direction; S307, repeat the above steps S301-S306 until the preset stop iteration condition is met, and determine the particle with the highest fitness to complete the model training.
4. The computer vision-based concrete crack detection method according to claim 1, characterized in that: The training process of the autoencoder in S4 includes: S401, randomly initialize the weights of the encoder and decoder according to a preset distribution, and the weight pW and bias pb of the autoencoder are randomly initialized using a Gaussian distribution, expressed as: Where, pW (l) is the weight of the lth layer; pb (l) is the bias of the lth layer; Indicates that the mean is 0 and the variance is σ 2 Normal distribution, σ is the standard deviation; S402, through the forward propagation method, the input data px is converted into a low-dimensional feature representation by the encoder, and then the low-dimensional feature representation is passed to the decoder to reconstruct the data. Specifically, the output pz of the encoder part and the output pz of the decoder part The calculation method is expressed as: pz=Sig(pW enc ·px+pb enc ) Where px is the input data; pz is the output of the encoder, i.e., the low-dimensional feature representation; is the data reconstructed by the decoder; pW enc and pb enc are the weight and bias of the encoder respectively; pW dec and pb dec are the weight and bias of the decoder respectively; Sig() is the Sigmoid activation function; S403, using the mean square error based on L2 regularization to calculate the total loss to avoid overfitting and ensure that the feature dimensionality reduction model learns effective data compression. The calculation method of the loss function pL is expressed as: In the formula, is the reconstruction error, calculated using the Euclidean distance; λ is the regularization parameter; ∥pW enc ∥ 2 and ∥pW dec ∥ 2 is the L2 regularization term of the weight; Reconstruction error term The calculation method is expressed as: In the formula, px i is the i-th element of the input data px; Reconstructing data The i-th element of ; n is the number of elements in the data vector; Regularization term ∥pW enc ∥ 2 and ∥pW dec ∥ 2 are respectively expressed as the sum of the squares of all encoder and decoder weights, expressed as: Where, pW enc,jk is the encoder weight matrix pW enc The element in row j and column k in pW dec,jk is the decoder weight matrix pW dec The element at row j and column k in ; S404. During the back propagation process, the autoencoder weights are updated by the gradient descent algorithm according to the loss function pL, which is expressed as: In the formula, α cf is the learning rate; and They are the gradients of the loss function with respect to the encoder and decoder weights, respectively; S405, adaptively adjust the learning rate α according to the training process cf , using the exponential decay strategy to optimize the learning process, the calculation method is expressed as: Where e is the base of natural logarithm; γ cfd is the decay rate; t is the number of iterations; Decay rate γ cfd is the rate of change related to time, and is calculated as: In the formula, α initial is the initial learning rate, T cf Is to reach the specified learning rate α cf The number of iterations required; S406: Repeat the above steps S401-S405 until the preset stop iteration condition is met, and the model training is completed.
5. The computer vision-based concrete crack detection method according to claim 1, characterized in that: The training process of the support vector machine using proximal gradient optimization in S5 includes: S501, setting the kernel function of the support vector machine based on proximal gradient optimization. Specifically, the radial basis function is used as the kernel function of the support vector machine, and the calculation method is: K(qx i ,qx j )=exp(-γ qk ∥qx i -qx j ∥ 2 ) Where ∥∥ is the L1 norm, qx i is the feature vector of the i-th training sample in the training data after feature dimensionality reduction, qx j is the feature vector of the jth training sample, γ qk is the bandwidth parameter of the radial basis function kernel; Initialize the classifier model parameters, including the weight vector w q and the bias term b q , weight vector w q Initialized by randomly assigning values, bias term b q Initially set to zero; S502. In each iteration, calculate the gradient of the loss function L and q and the bias term b q Update, and consider a proximal operator to ensure that the update step does not deviate too far from the initial solution to maintain the stability of the model. The specific steps are expressed as: Where η q is the learning rate; q is the regularization parameter; It is a proximal operator used for L1 regularization to increase the sparsity of the model; and They are the loss function L versus w q and b q The partial derivative of The calculation method of the loss function L is expressed as: And, the loss function L is about w q The calculation method of the partial derivative is expressed as: In the formula, 1 [co] is an indicator function, that is, when the condition co is true, the value is 1, otherwise it is 0; y i is the label of the i-th training sample; K(qx i ,qx) is the value calculated by the kernel function; And, the loss function L is about b q The calculation method of the partial derivative is expressed as: S503, adjusting the regularization parameters and kernel function parameters of the support vector machine, and using the cross-validation method to select the best parameter combination γ qk and λ q , where the constraints are: In the formula, y i is the label of the i-th training sample; n is the total number of samples; the sign() function is used to determine the sign of the classification result; S504: Repeat the above steps S501-S503 until the preset stop iteration condition is met, which means that the model training is completed.
Citation Information
Patent Citations
Bridge crack automatic detection method based on generative adversarial network
CN111223087A
Transform road crack detection method based on local feature enhancement
CN115294541A
Pipeline crack detection method based on point connection deep convolutional network
CN115311523A
Cited By
Method and system for identifying apparent diseases of hydraulic concrete structure
CN120298746A
