Crack detection model training method, device, electronic device and storage medium

By performing image segmentation, gamma transformation and Gaussian white noise enhancement on building images, a variety of training samples are generated and the optimal detection model is selected, which solves the problem of poor building crack detection accuracy and achieves higher crack detection. Recognition accuracy.

CN117333733BActive Publication Date: 2024-09-17CHINA MOBILE DIGITAL INTELLIGENCE TECH CO LTD +2
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311149010.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-09-06
Publication Date
2024-09-17
Estimated Expiration
2043-09-06

AI Technical Summary

Technical Problem

The accuracy of building crack detection in the existing technology is poor, resulting in inaccurate identification problems in building structural safety assessment and accident analysis.

Method used

By performing image segmentation, gamma transformation and Gaussian white noise enhancement on the original sample image carrying the crack label, a variety of training sample images are generated, and multiple detection models are obtained by training with the preset detection model, and the optimal one is selected through the verification results The detection model is used as the crack detection model.

Benefits of technology

It improves the identification accuracy of crack detection and ensures the accurate identification and safety assessment of building structural cracks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117333733B
    Figure CN117333733B
Patent Text Reader

Abstract

The present application relates to the field of image processing technology, and provides a method, device, electronic device and storage medium for training a crack detection model. The method includes: performing image segmentation on N original sample images carrying crack labels to obtain M first sample images, performing gamma transformation and Gaussian white noise enhancement processing on the M first sample images respectively, obtaining M second sample images after gamma transformation and M third sample images after Gaussian white noise enhancement; training a preset detection model through the first training sample image, the second training sample image and the third training sample image respectively, obtaining a first detection model, a second detection model and a third detection model; obtaining a first detection result, a second detection result and a third detection result through the first verification sample image, the second verification sample image and the third verification sample image; using the detection model corresponding to the target detection result as a crack detection model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image processing technology, and in particular to a crack detection model training method, device, electronic device and storage medium. Background Art

[0002] Cracks may appear in building structures due to temperature effects, fatigue, uneven foundation settlement, earthquakes, etc. Cracks in building structures are manifestations of structural damage. In the surface inspection and appraisal of industrial and civil buildings, crack damage is a major indicator of reliability appraisal. In the safety assessment of infrastructure engineering structures such as bridges and tunnels, cracks are an important indicator for regular or routine inspections. In laboratory structural stress performance tests, cracks are a key indicator for measuring the model loading process. In engineering accident investigations, cracks are an important basis for analyzing the causes of accidents.

[0003] In the related art, the building image is usually input into a classifier, and the classifier is used to identify cracks in the building image. However, this method is prone to poor detection accuracy. Therefore, how to better detect cracks in buildings has become a problem that needs to be urgently solved in the industry. Summary of the invention

[0004] The embodiments of the present application provide a crack detection model training method, device, electronic device and storage medium to solve the technical problem of poor crack detection accuracy.

[0005] In a first aspect, an embodiment of the present application provides a crack detection model training method, comprising:

[0006] Performing image segmentation on N original sample images carrying crack labels to obtain M first sample images, and performing gamma transformation and Gaussian white noise enhancement processing on the M first sample images to obtain M second sample images after gamma transformation and M third sample images after Gaussian white noise enhancement;

[0007] Respectively training the preset detection model by using a first training sample image among the M first sample images, a second training sample image among the M second sample images, and a third training sample image among the M third sample images to obtain a first detection model, a second detection model, and a third detection model;

[0008] The first detection model, the second detection model, and the third detection model are detected by using a first verification sample image among the M first sample images, a second verification sample image among the M second sample images, and a third verification sample image among the M third sample images, respectively, to obtain a first detection result of the first detection model, a second detection result of the second detection model, and a third detection result of the third detection model, where M and N are both positive integers;

[0009] The detection model corresponding to the target detection result is used as the crack detection model; the target detection result is the optimal detection result among the first detection result, the second detection result and the third detection result.

[0010] In one embodiment, after using the detection model corresponding to the target detection result as the crack detection model, the method further includes:

[0011] When the crack detection model is the second detection model, performing image segmentation and gamma transformation processing on the first image to be detected to obtain a plurality of second images to be detected;

[0012] Each of the second images to be detected is input into the crack detection model, and a crack detection result is output.

[0013] In one embodiment, after using the detection model corresponding to the target detection result as the crack detection model, the method further includes:

[0014] When the crack detection model is the third detection model, performing image segmentation and Gaussian white noise enhancement processing on the third image to be detected to obtain a plurality of fourth images to be detected;

[0015] Each of the fourth images to be detected is input into the crack detection model, and a crack detection result is output.

[0016] In one embodiment, after using the detection model corresponding to the target detection result as the crack detection model, the method further includes:

[0017] When the crack detection model is the first detection model, performing image analysis on the fifth image to be detected to obtain a plurality of sixth images to be detected;

[0018] Each of the sixth images to be detected is input into the crack detection model, and a crack detection result is output.

[0019] In one embodiment, the method for generating the M second sample images is specifically as follows:

[0020] For each of the first sample images, performing grayscale processing on the first sample image to obtain a first grayscale image;

[0021] Converting the first grayscale image into a first image matrix, and normalizing each element in the first image matrix to obtain a normalized second image matrix;

[0022] After performing a gamma transformation on the second image matrix, the second image matrix after the gamma transformation is converted into an image to obtain a second sample image; and the M first sample images are traversed to obtain M second sample images.

[0023] In one embodiment, the method for generating the M third sample images is specifically as follows:

[0024] For each first sample image, grayscale processing is performed on the first sample image to obtain a second grayscale image, and then the second grayscale image is converted into a second image matrix;

[0025] Generate a white noise matrix of the same size as the second image matrix, and obtain a third image matrix after white noise transformation according to the white noise matrix and the second image matrix;

[0026] The third image matrix is ​​converted into an image to obtain a third sample image; and the M first sample images are traversed to obtain M third sample images.

[0027] In one embodiment, the preset detection model is trained by respectively using a first training sample image among the M first sample images, a second training sample image among the M second sample images, and a third training sample image among the M third sample images to obtain a first detection model, a second detection model, and a third detection model, including:

[0028] Input any training sample into the backbone network in the preset detection model, and output a multi-layer feature map corresponding to the training sample, wherein the training sample is: the first training sample image, the second training sample image, or the third training sample image;

[0029] Inputting the multi-layer feature map into the ACmix attention module in the preset detection model, so that the multi-layer feature map focuses on the crack position, and obtains a first intermediate result;

[0030] Inputting the first intermediate result into the Neck network in the preset detection model, performing multi-scale fusion on the feature map, and inputting the fusion result into the Head module in the preset detection model, and outputting the crack detection result corresponding to the training sample;

[0031] Calculating a loss value according to the crack detection result and the crack label corresponding to the training sample;

[0032] When the loss value is less than a preset threshold, the training is stopped to obtain the first detection model, the second detection model and the third detection model.

[0033] In one embodiment, when the first detection result includes a first detection accuracy, a first recall rate, and a first average accuracy, the second detection result includes a second detection accuracy, a second recall rate, and a second average accuracy, and the third detection result includes a third detection accuracy, a third recall rate, and a third average accuracy, the method for determining the target detection result includes:

[0034] Determining the optimal detection result according to the maximum value among the first detection accuracy, the second detection accuracy and the third detection accuracy;

[0035] When the first detection accuracy, the second detection accuracy and the third detection accuracy are all equal, determining the optimal detection result according to the maximum value among the first average accuracy, the second average accuracy and the third average accuracy;

[0036] When the first detection accuracy, the second detection accuracy and the third detection accuracy are all equal, and the first average accuracy, the second average accuracy and the third average accuracy are also equal, the optimal detection result is determined according to the maximum value of the first recall rate, the second recall rate and the third recall rate.

[0037] In a second aspect, an embodiment of the present application provides a crack detection model training device, comprising:

[0038] An image processing module, used to perform image segmentation on N original sample images carrying crack labels to obtain M first sample images, and perform gamma transformation and Gaussian white noise enhancement processing on the M first sample images to obtain M second sample images after gamma transformation and M third sample images after Gaussian white noise enhancement;

[0039] A training module, used to train a preset detection model through a first training sample image among the M first sample images, a second training sample image among the M second sample images, and a third training sample image among the M third sample images, respectively, to obtain a first detection model, a second detection model, and a third detection model;

[0040] a verification module, configured to detect the first detection model, the second detection model, and the third detection model respectively through a first verification sample image among the M first sample images, a second verification sample image among the M second sample images, and a third verification sample image among the M third sample images, to obtain a first detection result of the first detection model, a second detection result of the second detection model, and a third detection result of the third detection model, where M and N are both positive integers;

[0041] A determination module is used to use a detection model corresponding to a target detection result as a crack detection model; the target detection result is an optimal detection result among the first detection result, the second detection result and the third detection result.

[0042] In a third aspect, an embodiment of the present application provides an electronic device, comprising a processor and a memory storing a computer program, wherein when the processor executes the program, the steps of the crack detection model training method described in the first aspect are implemented.

[0043] In a fourth aspect, an embodiment of the present application provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements any of the above-described crack detection model training methods.

[0044] The crack detection model training method, device, electronic device and storage medium provided in the embodiments of the present application obtain a first sample image by performing image segmentation on the original sample image, and obtain a second sample image and a third sample image by performing gamma transform and Gaussian white noise enhancement processing respectively. After three detection models are obtained by training the training sample images in the first sample image, the second sample image and the third sample image respectively, the three detection models are verified by verification sample images in the first sample image, the second sample image and the third sample image respectively, and the optimal model is determined as the crack detection model from the three detection models based on the verification results. By selecting the model with the best detection results as the final crack detection model from the three detection models obtained by training the sample images using three different image processing methods, the recognition accuracy of the cracks can be effectively guaranteed. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] In order to more clearly illustrate the technical solutions in the present application or the prior art, a brief introduction will be given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0046] Figure 1It is a flowchart of a crack detection model training method provided in an embodiment of the present application;

[0047] Figure 2 A calculation diagram of the SIoU loss function provided in an embodiment of the present application;

[0048] Figure 3 A schematic diagram of the structure of a crack detection model training device provided in an embodiment of the present application;

[0049] Figure 4 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0050] In order to make the purpose, technical solutions and advantages of this application clearer, the technical solutions in this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the described embodiments are part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0051] Figure 1 Schematic diagram of the process of the crack detection model training method provided in the embodiment of the present application. Figure 1 , the present application embodiment provides a crack detection model training method, which may include:

[0052] Step 110, performing image segmentation on the N original sample images carrying crack labels to obtain M first sample images, performing gamma transformation and Gaussian white noise enhancement processing on the M first sample images respectively to obtain M second sample images after gamma transformation and M third sample images after Gaussian white noise enhancement;

[0053] The original sample image in the embodiment of the present application may specifically be a building image, such as an image of a bridge, tunnel or building, etc. The original sample image may include one or more building crack areas.

[0054] In the embodiment of the present application, each original sample image may carry a crack label, and the crack label is used to identify the crack area in the original sample image. The label may exist in the form of an image frame or a data identifier.

[0055] In the embodiment of the present application, each original sample image is subjected to image segmentation processing, that is, an original sample image can be segmented into multiple first sample images, and correspondingly, the crack labels in the original sample image will also be automatically associated with the first sample images.

[0056] In an optional embodiment, crack areas may be avoided during image segmentation.

[0057] In the embodiment of the present application, image segmentation can further refine the image content of crack detection, effectively improving the progress of detection.

[0058] After N original sample images are segmented, M first sample images can be obtained, and then each first sample image is subjected to Gaussian white noise enhancement processing and gamma transformation processing, and then the second sample image after gamma transformation and the third sample image after Gaussian white noise enhancement are traversed through the M first sample images to obtain M second sample images after gamma transformation and M third sample images after Gaussian white noise enhancement.

[0059] In the embodiment of the present application, the crack label carried by the first image sample will also be correspondingly associated with the second sample image and the third sample image, that is, the second sample image and the third sample image will also carry the crack label.

[0060] In the embodiment of the present application, the second sample image and the third sample image with different image enhancement effects can be obtained through gamma transformation and Gaussian white noise enhancement processing respectively, thereby providing diversified training samples.

[0061] Step 120, respectively training a preset detection model using a first training sample image among the M first sample images, a second training sample image among the M second sample images, and a third training sample image among the M third sample images to obtain a first detection model, a second detection model, and a third detection model;

[0062] In the embodiment of the present application, after obtaining M first sample images, the M first sample images can be divided into a training group and a verification group according to a first ratio to obtain at least one first training sample image and a first verification sample image.

[0063] In the embodiment of the present application, after obtaining M second sample images, the M second sample images can be divided into a training group and a verification group according to a second ratio to obtain at least one second training sample image and a second verification sample image.

[0064] In the embodiment of the present application, after obtaining M third sample images, the M third sample images can be divided into a training group and a verification group according to a third ratio to obtain at least one third training sample image and a third verification sample image.

[0065] The training group in the embodiment of the present application is used to perform model training, and the verification group is used to verify the model after model training.

[0066] The preset detection model described in the embodiment of the present application may specifically refer to a YOLO model, which may specifically include a Backbone network, an ACmix attention module, a Neck network, and a Head module. The preset detection model improves the Backbone network and Neck network in YOLOv5, adds a multi-scale target detection layer, and introduces an ACmix module. It can reduce the model calculation overhead, improve the speed, and make the feature extraction network pay more attention to the extraction of shallow features. It can more thoroughly extract shallow detail features and deep high-level semantic features, making the model more robust.

[0067] In the embodiment of the present application, the preset detection model is trained by the first training sample image among the M first sample images, and when the first preset training condition is met, the training is terminated to obtain the first detection model; the preset detection model is trained by the second training sample image among the M second sample images, and when the second preset training condition is met, the training is terminated to obtain the second detection model; the preset detection model is trained by the third training sample image among the M third sample images, and when the third preset training condition is met, the training is terminated to obtain the third detection model;

[0068] In an embodiment of the present application, the preset detection models can be trained separately using training sample images of three different image enhancement processing methods, thereby obtaining different first detection models, second detection models, and third detection models.

[0069] Step 130, respectively detecting the first detection model, the second detection model, and the third detection model through a first verification sample image among the M first sample images, a second verification sample image among the M second sample images, and a third verification sample image among the M third sample images, to obtain a first detection result of the first detection model, a second detection result of the second detection model, and a third detection result of the third detection model, where M and N are both positive integers;

[0070] In an embodiment of the present application, after a first verification sample image carrying a crack label is input into a first detection model, a first crack detection result is output, and then the first crack detection result is compared with the crack label to determine a first detection result of the first detection model.

[0071] After the second verification sample image carrying the crack label is input into the second detection model, a second crack detection result is output, and then the second crack detection result is compared with the crack label to determine the second detection result of the second detection model.

[0072] After the third verification sample image carrying the crack label is input into the third detection model, a third crack detection result is output, and then the third crack detection result is compared with the crack label to determine the third detection result of the third detection model.

[0073] In an embodiment of the present application, the first detection result, the second detection result and the third detection result include the detection accuracy, recall rate and average accuracy corresponding to the respective models.

[0074] Step 140: Use the detection model corresponding to the target detection result as the crack detection model; the target detection result is the optimal detection result among the first detection result, the second detection result and the third detection result.

[0075] In an embodiment of the present application, after obtaining the first detection result, the second detection result and the third detection result, the respective detection results can be further compared to determine the maximum value among the first detection result, the second detection result and the third detection result as the target detection result.

[0076] After determining the target detection result, the detection model corresponding to the target detection result is used as the final crack detection model.

[0077] The crack detection model in the embodiment of the present application is used to perform crack detection analysis on an input image to be detected and output a crack detection result.

[0078] In an optional embodiment, after the crack detection model is determined, when analyzing the image to be processed, the image to be processed can be processed according to the image processing method of the training sample corresponding to the detection model, and then input into the crack detection model to finally output the crack detection result.

[0079] In an embodiment of the present application, the first sample image is obtained by performing image segmentation on the original sample image, and the second sample image and the third sample image are obtained by performing gamma transform and Gaussian white noise enhancement processing respectively. Then, three detection models are obtained by training the training sample images in the first sample image, the second sample image and the third sample image respectively. Then, the three detection models are verified by verification sample images in the first sample image, the second sample image and the third sample image respectively, and the optimal model is determined as the crack detection model from the three detection models based on the verification results. By selecting the model with the best detection results as the final crack detection model from the three detection models obtained by training the sample images using three different image processing methods, the accuracy of crack recognition can be effectively guaranteed.

[0080] After the detection model corresponding to the target detection result is used as the crack detection model, it also includes:

[0081] When the crack detection model is the second detection model, performing image segmentation and gamma transformation processing on the first image to be detected to obtain a plurality of second images to be detected;

[0082] Each of the second images to be detected is input into the crack detection model, and a crack detection result is output.

[0083] In the embodiment of the present application, the first image to be detected may be an image of a building that requires crack detection.

[0084] In an embodiment of the present application, when the crack detection model is the second detection model, it means that the training samples corresponding to the crack model are all sample graphics processed by gamma transform. Therefore, in order to better fit the characteristics of the model and improve the accuracy of model detection, the first image to be detected can be subjected to the same image processing method.

[0085] Specifically, the first image to be detected may be subjected to image segmentation processing, and then each segmented image may be subjected to gamma transformation processing.

[0086] In an embodiment of the present application, the image segmentation processing may specifically be to segment an image according to a preset size to obtain multiple images. After obtaining the segmented images, each segmented image may be subjected to a gamma transform process to obtain multiple second images to be detected.

[0087] In an embodiment of the present application, after obtaining multiple second images to be detected, each second image to be detected is input into a crack detection model, and then the crack detection model outputs the crack detection results corresponding to each second image to be detected, and then based on each crack detection result, the crack detection result of the first image to be detected can be finally obtained.

[0088] In an optional embodiment, the crack detection result outputted finally can be mapping the detection result of the segmented small image to the original large image; or, screening out the detection frames whose recognition frame confidence score is greater than a specified confidence threshold, and summarizing the detection results. Alternatively, using a detection frame of a specified color to select the cracks on the building surface, and marking the confidence score in the upper left corner of the detection frame.

[0089] In an embodiment of the present application, when the crack detection model is the second detection model, the first image to be detected is segmented and gamma transformed in the same way as the training sample of the second detection model, so that the input image is closer to the second detection model, which can effectively improve the accuracy of crack detection.

[0090] Optionally, after using the detection model corresponding to the target detection result as the crack detection model, the method further includes:

[0091] When the crack detection model is the third detection model, performing image segmentation and Gaussian white noise enhancement processing on the third image to be detected to obtain a plurality of fourth images to be detected;

[0092] Each of the fourth images to be detected is input into the crack detection model, and a crack detection result is output.

[0093] In the embodiment of the present application, the third image to be detected may be an image of a building that requires crack detection.

[0094] In the embodiment of the present application, when the crack detection model is the third detection model, it means that the training samples corresponding to the crack model at this time are all sample images after Gaussian white noise enhancement processing. Therefore, in order to better fit the characteristics of the model and improve the model detection accuracy, the third image to be detected can be subjected to the same image processing method.

[0095] Specifically, the third image to be detected is segmented, and then Gaussian white noise enhancement processing is performed on the segmented multiple images to be detected to obtain multiple fourth images to be detected.

[0096] In the embodiment of the present application, after obtaining a plurality of fourth images to be detected, each of the fourth images to be detected can be input into the crack detection model to obtain crack detection results of each of the fourth images to be detected.

[0097] In an optional embodiment, the crack detection result finally outputted may be mapping the detection result of the segmented fourth image to be detected to the original third image to be detected; or, screening out the detection frames whose recognition frame confidence score is greater than a specified confidence threshold, and summarizing the detection results. Alternatively, using a detection frame of a specified color to select the cracks on the surface of the building, and marking the confidence score in the upper left corner of the detection frame.

[0098] In an embodiment of the present application, when the crack detection model is the third detection model, the third image to be detected is segmented and Gaussian white noise enhanced in the same way as the training sample of the third detection model, so that the input image is closer to the third detection model, which can effectively improve the accuracy of crack detection.

[0099] Optionally, after using the detection model corresponding to the target detection result as the crack detection model, the method further includes:

[0100] When the crack detection model is the first detection model, performing image analysis on the fifth image to be detected to obtain a plurality of sixth images to be detected;

[0101] Each of the sixth images to be detected is input into the crack detection model, and a crack detection result is output.

[0102] In the embodiment of the present application, the fifth image to be detected may be an image of a building that requires crack detection.

[0103] In an embodiment of the present application, when the crack detection model is the first detection model, it means that the training samples corresponding to the crack model at this time are all sample images that have only undergone image segmentation processing. Therefore, for the fifth image to be detected input into the crack detection model, image segmentation processing can be performed to obtain multiple sixth images to be processed, and then they can be input into the crack detection model to output the crack detection results of each sixth image to be processed.

[0104] In an optional embodiment, the crack detection result finally outputted may be mapping the detection result of the segmented sixth image to be detected to the original fifth image to be detected; or, screening out the detection frames whose recognition frame confidence score is greater than a specified confidence threshold, and summarizing the detection results. Alternatively, using a detection frame of a specified color to select the cracks on the surface of the building, and marking the confidence score in the upper left corner of the detection frame.

[0105] When the crack detection model is the first detection model, the first image to be detected is segmented in the same way as the training sample of the first detection model, so that the input image is closer to the third detection model, which can effectively improve the accuracy of crack detection.

[0106] Optionally, the method for generating the M second sample images is specifically:

[0107] For each of the first sample images, performing grayscale processing on the first sample image to obtain a first grayscale image;

[0108] Converting the first grayscale image into a first image matrix, and normalizing each element in the first image matrix to obtain a normalized second image matrix;

[0109] After performing a gamma transformation on the second image matrix, the second image matrix after the gamma transformation is converted into an image to obtain a second sample image; and the M first sample images are traversed to obtain M second sample images.

[0110] In the embodiment of the present application, each first sample image may be traversed, and a gamma transformation enhancement process may be performed on each first sample image.

[0111] Specifically, the first sample image may be converted into a grayscale image to obtain a first grayscale image, and then each first grayscale image may be converted into a matrix to obtain each first image matrix, and then each element in the first image may be normalized to the range [0, 1] to obtain a second image matrix.

[0112] After obtaining the second image matrix, the matrix B can be gamma transformed, and the transformation result is recorded as B', b (i,j) represents the i-th row and j-th column element of B, b' (i,j) represents the i-th row and j-th column element of B', b' (i,j) =power(b (i,j), γ),0≤i<H,0≤j<W,power(b (i,j), γ) represents b (i,j) to the power of γ.

[0113] After obtaining the second image matrix B' after the gamma transformation, it can be converted into an image, completing the gamma transformation to obtain the second sample image, and traversing the M first sample images to obtain M second sample images.

[0114] In the embodiment of the present application, by performing a gamma transformation on the first sample image, a second sample image after gamma transformation can be obtained. Through image enhancement, more types of training samples can be provided, which can improve the accuracy of model recognition.

[0115] Optionally, the method for generating the M third sample images is specifically:

[0116] For each first sample image, grayscale processing is performed on the first sample image to obtain a second grayscale image, and then the second grayscale image is converted into a second image matrix;

[0117] Generate a white noise matrix of the same size as the second image matrix, and obtain a third image matrix after white noise transformation according to the white noise matrix and the second image matrix;

[0118] The third image matrix is ​​converted into an image to obtain a third sample image; and the M first sample images are traversed to obtain M third sample images.

[0119] In the embodiment of the present application, M first sample images are traversed, each first sample image is gray-scaled and converted into a gray-scale image to obtain a second gray-scale image.

[0120] The second grayscale image is then converted into a second image matrix B, and then a white noise matrix N of the same size as the second image matrix is ​​generated. According to the white noise matrix and the second image matrix, a third image matrix B'=N+B after white noise transformation is obtained.

[0121] In the embodiment of the present application, after the third image matrix is ​​obtained, it can be further converted into an image to obtain a third sample image, and all the M first sample images are traversed to obtain M third sample images.

[0122] In an embodiment of the present application, by performing Gaussian white noise enhancement processing on the first sample image, a third sample image after white noise enhancement can be obtained. Through image enhancement, more diverse training samples can be provided, which can improve the accuracy of model recognition.

[0123] Optionally, respectively training a preset detection model by using a first training sample image among the M first sample images, a second training sample image among the M second sample images, and a third training sample image among the M third sample images to obtain a first detection model, a second detection model, and a third detection model, including:

[0124] Input any training sample into the backbone network in the preset detection model, and output a multi-layer feature map corresponding to the training sample, wherein the training sample is: the first training sample image, the second training sample image, or the third training sample image;

[0125] Inputting the multi-layer feature map into the ACmix attention module in the preset detection model, so that the multi-layer feature map focuses on the crack position, and obtains a first intermediate result;

[0126] Inputting the first intermediate result into the Neck network in the preset detection model, performing multi-scale fusion on the feature map, and inputting the fusion result into the Head module in the preset detection model, and outputting the crack detection result corresponding to the training sample;

[0127] Calculating a loss value according to the crack detection result and the crack label corresponding to the training sample;

[0128] When the loss value is less than a preset threshold, the training is stopped to obtain the first detection model, the second detection model and the third detection model.

[0129] In an embodiment of the present application, the set of the first training sample images, the set of the second training sample images, and the set of the third training sample images can be used as three groups of training sets and input into the preset model for training respectively, and then after the training is completed, the first detection model, the second detection model, and the third detection model are obtained.

[0130] In the embodiment of the present application, the training method of the first detection model may specifically include: inputting each first training sample image into a Backbone network to obtain a multi-layer feature map;

[0131] The multi-layer feature map is input into the ACmix attention module to focus on the crack position, capture key crack information, and improve the recognition rate of shallow cracks and contour information;

[0132] The results of the ACmix attention module are input into the Neck network to perform multi-scale fusion of feature maps;

[0133] Input the fusion result into the Head module to predict the recognition result;

[0134] The loss LSIoU is calculated by the angle cost, distance cost, and shape cost of the predicted recognition box and the original annotation box; the angle cost describes the minimum angle between the center point and the X and Y axes, the distance cost describes the distance between the center points, and the shape cost considers the aspect ratio between the two boxes, which is defined by calculating the difference in width between the two boxes and the ratio of the maximum width between the two boxes (the same applies to the length);

[0135] Determine whether the loss value loss is less than the preset threshold, that is, whether the loss value converges to the preset standard. If it does not reach the preset standard, adjust the model's hyperparameters and retrain the model; if it has reached the preset standard, end the training, obtain the first detection model, and derive the trained first detection model weight coefficient.

[0136] For the second detection model and the third detection model, the above training steps can be repeated based on the second training sample images and the third training sample images respectively. After the training of the second detection model and the third detection model is completed, the first detection model can be obtained, and the trained second detection model weight coefficient and the trained third detection model weight coefficient can be derived.

[0137] In an optional embodiment, after the training is completed, the first detection model can be evaluated using the first verification sample image to calculate the first detection result of the first detection model. If the first detection result exceeds the first detection threshold, the training of the first detection model is stopped. If the first detection result is less than or equal to the first detection threshold, it is necessary to adjust the hyperparameters of the first detection model and retrain the first detection model.

[0138] Similarly, the second detection model is evaluated through the second verification sample image, and the second detection result of the second detection model is calculated. When the second detection result exceeds the second detection threshold, the training of the second detection model is stopped. If the second detection result is less than or equal to the second detection threshold, it is necessary to adjust the hyperparameters of the second detection model and retrain the second detection model.

[0139] The third detection model is evaluated through the third verification sample image, and the third detection result of the third detection model is calculated. When the third detection result exceeds the third detection threshold, the training of the third detection model is stopped. If the third detection result is less than or equal to the third detection threshold, it is necessary to adjust the hyperparameters of the third detection model and retrain the third detection model.

[0140] In an optional embodiment, the calculation of the loss value in the embodiment of the present application may specifically be to use the SIoU loss function, taking into account the influence of the angle cost, and using the angle cost to redescribe the distance, so that the total degree of freedom of the loss function is reduced. Figure 2 The calculation diagram of the SIoU loss function provided in the embodiment of the present application is as follows: Figure 2 As shown,

[0141] (1) Angle cost

[0142] By confirming whether the angle is greater than 45 degrees, decide whether to use the minimized β or α, where α represents the angle between the center line of the target box and the predicted box and the x-axis, and β represents the angle with the y-axis;

[0143] The calculation formula of angle cost ∧ is shown in formula (1).

[0144]

[0145] in:

[0146]

[0147]

[0148]

[0149] c h represents the vertical distance from the center of the prediction box to the center of the target box, σ represents the straight-line distance from the center of the prediction box to the center of the target box, and b gt is the center point of the prediction box, c x is the horizontal distance between the right side of the prediction box and the left side of the target box; c y It is the vertical distance between the top of the prediction box and the bottom of the target box.

[0150] (2) Distance cost

[0151] The distance cost represents the distance between the center points of the predicted box and the real box. Combined with the angle cost, the distance cost Δ is redefined and the calculation formula is shown in formula (5).

[0152]

[0153] Among them, ρ t The distance loss is weighted using powers of 2:

[0154]

[0155]

[0156] γ = 2-∧ (8)

[0157] c wFor the horizontal distance between the center of the prediction box and the center of the target box, when α is close to 0, the contribution of the distance cost will be greatly reduced; on the contrary, when α is close to π / 4, the contribution of the distance cost will be greater. As the angle increases, γ obtains the time-first distance value.

[0158] (3) Shape cost

[0159] The calculation formula of shape cost Ω is shown in formula (9).

[0160]

[0161] in:

[0162]

[0163]

[0164] Here, θ is the degree of concern about shape loss. By setting θ to 1, the aspect ratio of the shape is optimized to restrict its free movement.

[0165] In summary, after combining angle cost, distance cost and shape cost, the expression of SIoU loss function is shown in formula (12).

[0166]

[0167] Among them, IoU is used to indicate the overlap between the target box and the predicted box.

[0168] In an embodiment of the present application, the loss value of each detection model is calculated by using the expression of the above-mentioned SIoU loss function. When the loss value of each detection model is less than the corresponding preset threshold, the training is stopped to obtain the first detection model, the second detection model and the third detection model.

[0169] In an embodiment of the present application, the preset detection model is trained using the first training sample image, the second training sample image, and the third training sample image, respectively, to obtain the first detection model, the second detection model, and the third detection model that can perform crack detection according to different enhanced image characteristics, thereby providing a variety of model choices for easy optimization.

[0170] Optionally, when the first detection result includes a first detection accuracy, a first recall rate, and a first average accuracy, the second detection result includes a second detection accuracy, a second recall rate, and a second average accuracy, and the third detection result includes a third detection accuracy, a third recall rate, and a third average accuracy, the method for determining the target detection result includes:

[0171] Determining the optimal detection result according to the maximum value among the first detection accuracy, the second detection accuracy and the third detection accuracy;

[0172] When the first detection accuracy, the second detection accuracy and the third detection accuracy are all equal, determining the optimal detection result according to the maximum value among the first average accuracy, the second average accuracy and the third average accuracy;

[0173] When the first detection accuracy, the second detection accuracy and the third detection accuracy are all equal, and the first average accuracy, the second average accuracy and the third average accuracy are also equal, the optimal detection result is determined according to the maximum value of the first recall rate, the second recall rate and the third recall rate.

[0174] In an embodiment of the present application, after obtaining the first test result, the second test result and the third test result, the three test results can be further compared, which can be specifically a comprehensive comparison of the detection accuracy, recall rate and average accuracy.

[0175] Since the detection accuracy, recall rate and average accuracy are often related data, it is easier to determine the optimal detection result with the largest value among the first detection result, the second detection result and the third detection result.

[0176] In some special cases, the first detection accuracy, the second detection accuracy and the third detection accuracy are all equal. In this case, it is necessary to further compare the first average accuracy, the second average accuracy and the third average accuracy to determine the optimal detection result.

[0177] When the first detection accuracy rate, the second detection accuracy rate and the third detection accuracy rate are all equal, and the first average accuracy rate, the second average accuracy rate and the third average accuracy rate are also equal, the optimal detection result can be finally determined based on the first recall rate, the second recall rate and the third recall rate.

[0178] In an embodiment of the present application, by comparing the various parameters in the first detection result, the second detection result and the third detection result, the final crack detection model can be effectively selected from the first detection model, the second detection model and the third detection model according to the detection results, thereby effectively ensuring the accuracy of the crack model detection.

[0179] In the embodiment of the present application, compared with the existing single model crack recognition method, the present application adopts a preprocessing method of performing multiple enhancement processing on crack features and training multiple target detection models, selecting the optimal target detection model and image feature enhancement;

[0180] Compared with existing data processing or crack identification methods focusing on models, the solution of the present application realizes a complete building surface crack detection method from data preprocessing, data set division, model training, model optimization, model reasoning, to post-processing of identification results.

[0181] The following is a description of a crack detection model training device provided in an embodiment of the present application. The crack detection device described below and the crack detection method described above can be referenced to each other.

[0182] Figure 3 A structural diagram of a crack detection model training device provided in an embodiment of the present application is shown in FIG. Figure 3 As shown, including:

[0183] The image processing module 310 is used to perform image segmentation on the N original sample images carrying crack labels to obtain M first sample images, and perform gamma transformation and Gaussian white noise enhancement processing on the M first sample images to obtain M second sample images after gamma transformation and M third sample images after Gaussian white noise enhancement;

[0184] The training module 320 is used to train the preset detection model through the first training sample image in the M first sample images, the second training sample image in the M second sample images, and the third training sample image in the M third sample images, respectively, to obtain the first detection model, the second detection model, and the third detection model;

[0185] The verification module 330 is used to detect the first detection model, the second detection model and the third detection model respectively through the first verification sample image among the M first sample images, the second verification sample image among the M second sample images and the third verification sample image among the M third sample images, to obtain a first detection result of the first detection model, a second detection result of the second detection model and a third detection result of the third detection model, where M and N are both positive integers;

[0186] The determination module 340 is used to use the detection model corresponding to the target detection result as the crack detection model; the target detection result is the optimal detection result among the first detection result, the second detection result and the third detection result.

[0187] The device is also used for:

[0188] When the crack detection model is the second detection model, performing image segmentation and gamma transformation processing on the first image to be detected to obtain a plurality of second images to be detected;

[0189] Each of the second images to be detected is input into the crack detection model, and a crack detection result is output.

[0190] The device is also used for:

[0191] When the crack detection model is the third detection model, performing image segmentation and Gaussian white noise enhancement processing on the third image to be detected to obtain a plurality of fourth images to be detected;

[0192] Each of the fourth images to be detected is input into the crack detection model, and a crack detection result is output.

[0193] The device is also used for:

[0194] When the crack detection model is the first detection model, performing image analysis on the fifth image to be detected to obtain a plurality of sixth images to be detected;

[0195] Each of the sixth images to be detected is input into the crack detection model, and a crack detection result is output.

[0196] The device is also used for:

[0197] For each of the first sample images, performing grayscale processing on the first sample image to obtain a first grayscale image;

[0198] Converting the first grayscale image into a first image matrix, and normalizing each element in the first image matrix to obtain a normalized second image matrix;

[0199] After performing a gamma transformation on the second image matrix, the second image matrix after the gamma transformation is converted into an image to obtain a second sample image; and the M first sample images are traversed to obtain M second sample images.

[0200] The device is also used for:

[0201] For each first sample image, grayscale processing is performed on the first sample image to obtain a second grayscale image, and then the second grayscale image is converted into a second image matrix;

[0202] Generate a white noise matrix of the same size as the second image matrix, and obtain a third image matrix after white noise transformation according to the white noise matrix and the second image matrix;

[0203] The third image matrix is ​​converted into an image to obtain a third sample image; and the M first sample images are traversed to obtain M third sample images.

[0204] The device is also used for:

[0205] Input any training sample into the backbone network in the preset detection model, and output a multi-layer feature map corresponding to the training sample, wherein the training sample is: the first training sample image, the second training sample image, or the third training sample image;

[0206] Inputting the multi-layer feature map into the ACmix attention module in the preset detection model, so that the multi-layer feature map focuses on the crack position, and obtains a first intermediate result;

[0207] Inputting the first intermediate result into the Neck network in the preset detection model, performing multi-scale fusion on the feature map, and inputting the fusion result into the Head module in the preset detection model, and outputting the crack detection result corresponding to the training sample;

[0208] Calculating a loss value according to the crack detection result and the crack label corresponding to the training sample;

[0209] When the loss value is less than a preset threshold, the training is stopped to obtain the first detection model, the second detection model and the third detection model.

[0210] The device is also used for:

[0211] Determining the optimal detection result according to the maximum value among the first detection accuracy, the second detection accuracy and the third detection accuracy;

[0212] When the first detection accuracy, the second detection accuracy and the third detection accuracy are all equal, determining the optimal detection result according to the maximum value among the first average accuracy, the second average accuracy and the third average accuracy;

[0213] When the first detection accuracy, the second detection accuracy and the third detection accuracy are all equal, and the first average accuracy, the second average accuracy and the third average accuracy are also equal, the optimal detection result is determined according to the maximum value of the first recall rate, the second recall rate and the third recall rate.

[0214] In an embodiment of the present application, the first sample image is obtained by performing image segmentation on the original sample image, and the second sample image and the third sample image are obtained by performing gamma transform and Gaussian white noise enhancement processing respectively. Then, three detection models are obtained by training the training sample images in the first sample image, the second sample image and the third sample image respectively. Then, the three detection models are verified by verification sample images in the first sample image, the second sample image and the third sample image respectively, and the optimal model among the three detection models is determined as the crack detection model based on the verification results. By selecting the model with the best detection result as the final crack detection model from the three detection models obtained by training the sample images of three different image processing methods, the accuracy of crack recognition can be effectively guaranteed.

[0215] Figure 4 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application, such as Figure 4 As shown, the electronic device may include: a processor 410, a communication interface 420, a memory 430 and a communication bus 440, wherein the processor 410, the communication interface 420 and the memory 430 communicate with each other through the communication bus 440. The processor 410 may call a computer program in the memory 430 to execute the steps of the crack detection model training method, for example including:

[0216] Performing image segmentation on N original sample images carrying crack labels to obtain M first sample images, and performing gamma transformation and Gaussian white noise enhancement processing on the M first sample images to obtain M second sample images after gamma transformation and M third sample images after Gaussian white noise enhancement;

[0217] Respectively training the preset detection model by using a first training sample image among the M first sample images, a second training sample image among the M second sample images, and a third training sample image among the M third sample images to obtain a first detection model, a second detection model, and a third detection model;

[0218] The first detection model, the second detection model, and the third detection model are detected by using a first verification sample image among the M first sample images, a second verification sample image among the M second sample images, and a third verification sample image among the M third sample images, respectively, to obtain a first detection result of the first detection model, a second detection result of the second detection model, and a third detection result of the third detection model, where M and N are both positive integers;

[0219] The detection model corresponding to the target detection result is used as the crack detection model; the target detection result is the optimal detection result among the first detection result, the second detection result and the third detection result.

[0220] In addition, the logic instructions in the above-mentioned memory 430 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art, and the computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk.

[0221] On the other hand, an embodiment of the present application further provides a computer program product, the computer program product comprising a computer program, the computer program may be stored on a non-transitory computer-readable storage medium, and when the computer program is executed by a processor, the computer can perform the steps of the crack detection model training method provided in the above embodiments, for example, including:

[0222] Performing image segmentation on N original sample images carrying crack labels to obtain M first sample images, and performing gamma transformation and Gaussian white noise enhancement processing on the M first sample images to obtain M second sample images after gamma transformation and M third sample images after Gaussian white noise enhancement;

[0223] Respectively training the preset detection model by using a first training sample image among the M first sample images, a second training sample image among the M second sample images, and a third training sample image among the M third sample images to obtain a first detection model, a second detection model, and a third detection model;

[0224] The first detection model, the second detection model, and the third detection model are detected by using a first verification sample image among the M first sample images, a second verification sample image among the M second sample images, and a third verification sample image among the M third sample images, respectively, to obtain a first detection result of the first detection model, a second detection result of the second detection model, and a third detection result of the third detection model, where M and N are both positive integers;

[0225] The detection model corresponding to the target detection result is used as the crack detection model; the target detection result is the optimal detection result among the first detection result, the second detection result and the third detection result.

[0226] On the other hand, an embodiment of the present application further provides a processor-readable storage medium, wherein the processor-readable storage medium stores a computer program, wherein the computer program is used to enable the processor to execute the steps of the methods provided in the above embodiments, for example, including:

[0227] Performing image segmentation on N original sample images carrying crack labels to obtain M first sample images, and performing gamma transformation and Gaussian white noise enhancement processing on the M first sample images to obtain M second sample images after gamma transformation and M third sample images after Gaussian white noise enhancement;

[0228] Respectively training the preset detection model by using a first training sample image among the M first sample images, a second training sample image among the M second sample images, and a third training sample image among the M third sample images to obtain a first detection model, a second detection model, and a third detection model;

[0229] The first detection model, the second detection model, and the third detection model are detected by using a first verification sample image among the M first sample images, a second verification sample image among the M second sample images, and a third verification sample image among the M third sample images, respectively, to obtain a first detection result of the first detection model, a second detection result of the second detection model, and a third detection result of the third detection model, where M and N are both positive integers;

[0230] The detection model corresponding to the target detection result is used as the crack detection model; the target detection result is the optimal detection result among the first detection result, the second detection result and the third detection result.

[0231] The processor-readable storage medium can be any available medium or data storage device that can be accessed by the processor, including but not limited to magnetic storage (such as floppy disks, hard disks, magnetic tapes, magneto-optical disks (MO), etc.), optical storage (such as CD, DVD, BD, HVD, etc.), and semiconductor storage (such as ROM, EPROM, EEPROM, non-volatile memory (NANDFLASH), solid-state drive (SSD)), etc.

[0232] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0233] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0234] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. A crack detection model training method, characterized in that: include: Performing image segmentation on N original sample images carrying crack labels to obtain M first sample images, and performing gamma transformation and Gaussian white noise enhancement processing on the M first sample images to obtain M second sample images after gamma transformation and M third sample images after Gaussian white noise enhancement; Respectively training the preset detection model by using a first training sample image among the M first sample images, a second training sample image among the M second sample images, and a third training sample image among the M third sample images to obtain a first detection model, a second detection model, and a third detection model; The first detection model, the second detection model, and the third detection model are detected by using a first verification sample image among the M first sample images, a second verification sample image among the M second sample images, and a third verification sample image among the M third sample images, respectively, to obtain a first detection result of the first detection model, a second detection result of the second detection model, and a third detection result of the third detection model, where M and N are both positive integers; Using the detection model corresponding to the target detection result as the crack detection model; the target detection result is the optimal detection result among the first detection result, the second detection result and the third detection result; The preset detection model is trained by respectively using a first training sample image among the M first sample images, a second training sample image among the M second sample images, and a third training sample image among the M third sample images to obtain a first detection model, a second detection model, and a third detection model, including: Input any training sample into the backbone network in the preset detection model, and output a multi-layer feature map corresponding to the training sample, wherein the training sample is: the first training sample image, the second training sample image, or the third training sample image; Inputting the multi-layer feature map into the ACmix attention module in the preset detection model, so that the multi-layer feature map focuses on the crack position, and obtains a first intermediate result; Inputting the first intermediate result into the Neck network in the preset detection model, performing multi-scale fusion on the feature map, and inputting the fusion result into the Head module in the preset detection model, and outputting the crack detection result corresponding to the training sample; Calculating a loss value according to the crack detection result and the crack label corresponding to the training sample; When the loss value is less than a preset threshold, the training is stopped to obtain the first detection model, the second detection model and the third detection model.

2. The crack detection model training method according to claim 1, characterized in that: After the detection model corresponding to the target detection result is used as the crack detection model, it also includes: When the crack detection model is the second detection model, performing image segmentation and gamma transformation processing on the first image to be detected to obtain a plurality of second images to be detected; Each of the second images to be detected is input into the crack detection model, and a crack detection result is output.

3. The crack detection model training method according to claim 1, characterized in that: After the detection model corresponding to the target detection result is used as the crack detection model, it also includes: When the crack detection model is the third detection model, performing image segmentation and Gaussian white noise enhancement processing on the third image to be detected to obtain a plurality of fourth images to be detected; Each of the fourth images to be detected is input into the crack detection model, and a crack detection result is output.

4. The crack detection model training method according to claim 1, characterized in that: After the detection model corresponding to the target detection result is used as the crack detection model, it also includes: When the crack detection model is the first detection model, performing image analysis on the fifth image to be detected to obtain a plurality of sixth images to be detected; Each of the sixth images to be detected is input into the crack detection model, and a crack detection result is output.

5. The crack detection model training method according to claim 1, characterized in that: The method for generating the M second sample images is specifically as follows: For each of the first sample images, performing grayscale processing on the first sample image to obtain a first grayscale image; Converting the first grayscale image into a first image matrix, and normalizing each element in the first image matrix to obtain a normalized second image matrix; After performing a gamma transformation on the second image matrix, the second image matrix after the gamma transformation is converted into an image to obtain a second sample image; and the M first sample images are traversed to obtain M second sample images.

6. The crack detection model training method according to claim 1, characterized in that: The method for generating the M third sample images is specifically as follows: For each first sample image, grayscale processing is performed on the first sample image to obtain a second grayscale image, and then the second grayscale image is converted into a second image matrix; Generate a white noise matrix of the same size as the second image matrix, and obtain a third image matrix after white noise transformation according to the white noise matrix and the second image matrix; The third image matrix is ​​converted into an image to obtain a third sample image; and the M first sample images are traversed to obtain M third sample images.

7. The crack detection model training method according to claim 1, characterized in that: In the case where the first detection result includes a first detection accuracy, a first recall rate, and a first average accuracy, the second detection result includes a second detection accuracy, a second recall rate, and a second average accuracy, and the third detection result includes a third detection accuracy, a third recall rate, and a third average accuracy, the method for determining the target detection result includes: Determining the optimal detection result according to the maximum value among the first detection accuracy, the second detection accuracy and the third detection accuracy; When the first detection accuracy, the second detection accuracy and the third detection accuracy are all equal, determining the optimal detection result according to the maximum value among the first average accuracy, the second average accuracy and the third average accuracy; When the first detection accuracy, the second detection accuracy and the third detection accuracy are all equal, and the first average accuracy, the second average accuracy and the third average accuracy are also equal, the optimal detection result is determined according to the maximum value of the first recall rate, the second recall rate and the third recall rate.

8. A crack detection model training device, characterized in that: include: An image processing module, used to perform image segmentation on N original sample images carrying crack labels to obtain M first sample images, and perform gamma transformation and Gaussian white noise enhancement processing on the M first sample images to obtain M second sample images after gamma transformation and M third sample images after Gaussian white noise enhancement; A training module, used to train a preset detection model through a first training sample image among the M first sample images, a second training sample image among the M second sample images, and a third training sample image among the M third sample images, respectively, to obtain a first detection model, a second detection model, and a third detection model; a verification module, configured to detect the first detection model, the second detection model, and the third detection model respectively through a first verification sample image among the M first sample images, a second verification sample image among the M second sample images, and a third verification sample image among the M third sample images, to obtain a first detection result of the first detection model, a second detection result of the second detection model, and a third detection result of the third detection model, where M and N are both positive integers; A determination module, configured to use a detection model corresponding to a target detection result as a crack detection model; the target detection result is an optimal detection result among the first detection result, the second detection result and the third detection result; Wherein, the device is also used for: Input any training sample into the backbone network in the preset detection model, and output a multi-layer feature map corresponding to the training sample, wherein the training sample is: the first training sample image, the second training sample image, or the third training sample image; Inputting the multi-layer feature map into the ACmix attention module in the preset detection model, so that the multi-layer feature map focuses on the crack position, and obtains a first intermediate result; Inputting the first intermediate result into the Neck network in the preset detection model, performing multi-scale fusion on the feature map, and inputting the fusion result into the Head module in the preset detection model, and outputting the crack detection result corresponding to the training sample; Calculating a loss value according to the crack detection result and the crack label corresponding to the training sample; When the loss value is less than a preset threshold, the training is stopped to obtain the first detection model, the second detection model and the third detection model.

9. An electronic device comprising a processor and a memory storing a computer program, characterized in that: When the processor executes the computer program, the steps of the crack detection model training method according to any one of claims 1 to 7 are implemented.

10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the crack detection model training method according to any one of claims 1 to 7 are implemented.