Object crack detection method based on self-attention mechanism optimization generative adversarial network
Through the self-attention mechanism, optimize the generation of adversarial network, train the GAN network in groups and add adaptive Gaussian noise to generate diversified crack images, solving the problem of YOLOv8-seg generalization capability and traditional data enhancement methods that destroy crack characteristics, improve the accuracy and robustness of crack detection, and are suitable for infrastructure maintenance and security inspection.
Patent Information
- Application Number
- CN202510369587.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-27
- Publication Date
- 2025-08-15
AI Technical Summary
The existing crack detection technology faces the problems of limited generalization ability of YOLOv8-seg, traditional data enhancement methods that easily destroy fracture characteristics and insufficient diversity of generated samples, resulting in a decrease in detection accuracy.
The self-attention mechanism is used to optimize the generation adversarial network, group the data sets and train independent GAN networks for each group, generate diversified crack images, and add adaptive Gaussian noise to non-crack areas to form a new training data set, and train with YOLOv8-seg-P6.
It significantly improves the generalization capability and detection accuracy of the model, improves the accuracy and robustness of crack detection, and is suitable for infrastructure maintenance and safety inspection.
Smart Images

Figure CN120495162A_ABST
Abstract
Description
Technical Field
[0001] The present invention is a method for detecting cracks in objects using a self-attention mechanism-optimized generative adversarial network, specifically a data enhancement method for improving crack detection accuracy. This relates to the field of object detection. Background Art
[0002] In the field of computer vision, the performance of object detection models is highly dependent on the scale and quality of training data. For crack detection tasks, traditional methods are mainly based on the following technical frameworks:
[0003] YOLOv8-seg, a unique version of the YOLOv8 family, combines object detection and instance segmentation capabilities. Through its efficient network structure and loss function optimization, it can not only detect cracks on object surfaces but also outline their contours, achieving excellent performance in real-time detection tasks. Its core architecture includes Backbone (CSPDarknet), Neck (PAN-FPN), and Head (detection and segmentation head), which improves detection accuracy through multi-scale feature fusion. However, when faced with small-scale or insufficiently diverse crack datasets, YOLOv8-seg's generalization ability is significantly limited, making it prone to overfitting, resulting in reduced detection accuracy in complex backgrounds or under noise interference.
[0004] Existing data augmentation techniques mainly include geometric transformations (such as rotation, cropping, and scaling), color space adjustments (such as brightness and contrast perturbations), and noise addition (such as Gaussian noise and salt and pepper noise). However, existing data augmentation methods generally fail to fully consider the different contributions of different regions (crack areas and non-crack areas) to the final classification results. Global noise or transformations may destroy the continuity characteristics of cracks (such as the structural integrity of fine cracks), reduce the model's sensitivity to key features, and thus make it difficult to further enhance the data and improve network performance.
[0005] Traditional generative adversarial networks (GANs) synthesize new samples through adversarial training between a generator and a discriminator, and have demonstrated significant potential in image generation tasks. However, when applied to crack detection, traditional GAN methods have exposed several limitations: First, due to the problem of encountering local optimal solutions during the optimization process of the generator and discriminator, the diversity of generated samples is low, resulting in a significant discrepancy between the generated images and the actual data distribution. Second, traditional GANs lack differentiated processing strategies for crack and non-crack regions. This "one-size-fits-all" generation approach may destroy the structural characteristics of cracks, reducing the realism and practicality of the generated images. Therefore, new samples generated by traditional GANs are often difficult to directly integrate into existing datasets, limiting their application value in enhancing training datasets and improving model performance.
[0006] In summary, existing crack detection technologies face the following core challenges: 1. YOLOv8-seg has limited generalization capabilities; 2. Traditional methods rely on global transformations and noise addition, which easily destroy crack features and lack sample diversity; 3. New samples generated by a single GAN network are difficult to directly integrate into existing datasets. Summary of the Invention
[0007] The purpose of this invention is to provide a method for object crack detection using a self-attention mechanism to optimize a generative adversarial network. This method addresses the issues of existing traditional data augmentation methods, which have limited data enhancement and may damage the integrity of existing features. It can further improve network performance while maintaining the integrity of existing features.
[0008] In order to achieve the above objectives, the present invention adopts the following technical solution: a method for detecting cracks in an object using a self-attention mechanism-optimized generative adversarial network:
[0009] Step 1: Group GAN network generation: The original Crack-seg training set is grouped according to image features. Each group corresponds to an improved GAN network. By training an independent GAN network for each group, diversified crack images are generated. The GAN loss function L is optimized by the following formula:
[0010] L=Loriginal+λLregularization
[0011] Among them, Loriginal is the original GAN loss function, Lregularization is the regularization term, and λ is the adjustment weight. The improvement method of the GAN network is as follows:
[0012] Grouping the data set will result in less data in each group. The self-attention mechanism is introduced in the GAN network, and its formula is:
[0013]
[0014] Assume that the input sequence X={x1,x2,...,x n}, where each x u Is a d-dimensional vector. Q, K, and V are query, key, and value matrices respectively; d k is the dimension of the key.
[0015] Step 2: Adaptive Gaussian noise addition: Analyze each image generated by GAN to distinguish crack areas from non-crack areas. Use this image as a template to distinguish crack areas and non-crack areas for all images in the group, and add Gaussian noise only in the non-crack areas. The noise intensity σ is determined by the following formula:
[0016] σ=f(image_feature)
[0017] Among them, f is a function that dynamically adjusts the noise intensity according to image characteristics.
[0018] Each image generated by the GAN network is labeled in its corresponding group, and data annotation is performed on each image to distinguish crack areas from non-crack areas. Using each generated image as a template, data annotation is performed on all images in the group to distinguish crack areas from non-crack areas, and Gaussian noise is added to the non-crack areas of each image.
[0019] Step 3: Dataset expansion strategy: Merge the images generated by GAN and processed with noise with the original dataset to form a new training dataset. The number of samples Nnew after the dataset expansion is calculated by the following formula:
[0020] Nnew=Crack-seg+Ngenerated
[0021] Among them, α is the adjustment weight, and Ngenerated is a dataset formed by images generated by GAN and processed with noise addition.
[0022] Step 4: Add Gaussian noise to all images in the training set of the Crack-seg dataset, concatenate the generated images with the training set and validation set of the Crack-seg dataset to form the Crack-seg-Gaussian dataset, and merge the Crack-seg-Gaussian dataset with the Crack-seg dataset to form a new dataset named Crack-new.
[0023] Step 5: Select YOLOv8-seg-YOLOV8-SEG-P6 and initialize it with its pre-trained weights. This model supports higher-resolution feature fusion by adding a P6 layer.
[0024] Step 6: Construct three types of data sets: traditional Gaussian enhancement Crack-seg-Gaussian, traditional enhancement + original data Crack-new, and this method enhancement + original data Nnew, and train YOLOv8-seg and YOLOv8-seg-YOLOV8-SEG-P6 respectively, and use Crack-seg to train YOLOv8-seg and YOLOv8-seg-YOLOV8-SEG-P6 for comparison;
[0025] Step 6.1: Combine the original dataset with the YOLOv8 model for training;
[0026] Step 6.2: Combine the original data augmentation method with the YOLOv8 model for training and compare the experimental results.
[0027] Step 6.3: Combine the dataset enhanced by this method with the YOLOv8 model for training and compare the experimental results;
[0028] Step 6.4: Combine the original dataset with YOLOv8-seg-P6 for training;
[0029] Step 6.5: Combine the original data augmentation method with the enhanced dataset and train it with YOLOv8-seg-P6, and compare the experimental results.
[0030] Step 6.6: Combine the dataset enhanced by this method with YOLOv8-seg-P6 for training and compare the experimental results;
[0031] Step 6.7: Combine the traditional Gaussian enhancement dataset with the YOLOv8 model for training and compare the experimental results.
[0032] Step 6.8: Combine the traditional Gaussian enhancement dataset with YOLOv8-seg-P6 for training and compare the experimental results.
[0033] Step 7: Based on the experimental comparison results in Step 6, select the model with the best performance for deployment so that users can call the model to perform surface crack detection tasks.
[0034] Step 7.1: Based on the experimental comparison results in Step 6, determine the model with the best overall performance using the mAP@0.5 and mAP@0.5:0.95 values;
[0035] Step 7.2: Configure the deployment environment that meets the requirements of the model and deploy the system to the local device;
[0036] Step 7.3: Start the model call to verify the compatibility and actual performance between the model and the system. After successful verification, the model can be used to detect cracks on the surface of objects.
[0037] The beneficial effects of the present invention are:
[0038] 1) By grouping the original crack dataset and training a separate GAN network for each group, realistic and diverse crack images are generated. This not only increases the diversity of the dataset but also ensures that the generated samples retain the integrity of crack features, significantly improving the model's generalization ability. In each generated image, adaptive Gaussian noise is added only to non-crack regions, avoiding damage to crack features while increasing the complexity of non-crack regions and improving the model's learning performance.
[0039] 2) The noise-adding images generated by the GAN are merged with the original dataset to form a new, richer training dataset. This new dataset not only increases the number of samples but also improves their diversity, helping the model learn a wider range of crack feature representations, thereby improving generalization and detection accuracy.
[0040] 3) The original YOLOv8 model and the improved P6 network were trained using the augmented dataset, and then combined with the original dataset for comprehensive training. This hybrid training approach ensures that the model can learn from both the original and augmented data, further improving overall performance and increasing model accuracy.
[0041] 4) This invention is particularly suitable for fields such as infrastructure maintenance and safety inspections, providing more reliable technical support for these areas. Through efficient and accurate crack detection, while freeing up manpower and achieving higher economic benefits, it can promptly identify potential safety hazards, reduce accident risks, and ensure public safety. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] Figure 1 :A step-by-step diagram of the object crack detection method using self-attention mechanism to optimize the generative adversarial network;
[0043] Figure 2 : Experimental steps diagram;
[0044] Figure 3 : Schematic diagram of the self-attention mechanism;
[0045] Figure 4 : Overall flow chart of this method;
[0046] Figure 5 :Crack Detection Example Figure 1 ;
[0047] Figure 6 :The detection results of surface cracks in heat exchanger pipes using this method in an actual heat exchange station environment. DETAILED DESCRIPTION
[0048] In order to make the purpose, technical solutions and advantages of this application clearer, this application is further described in detail below with reference to the accompanying drawings and embodiments.
[0049] Figure 1 The object crack detection method using the self-attention mechanism to optimize the generative adversarial network is presented. The steps are as follows:
[0050] Step 1: The images in the crack training set are divided into multiple subsets based on their feature differences. Each subset of images is used as a dataset, and a dedicated generative adversarial network (GAN) is trained separately. Each GAN introduces a self-attention mechanism to capture the unique properties of the images in that subset. For each subset, a synthetic image is generated using its corresponding GAN as a template, and then the template image is divided into crack and non-crack areas. Figure 3 This shows the logic of the self-attention mechanism.
[0051] Step 2: For each group of images, use GAN to generate a template, and then perform noise processing on all images in the group.
[0052] 2.1: Calculate M(x,y) according to the following formula, where 1 represents the crack area and 0 represents the non-crack area;
[0053]
[0054] 2.2: Use M(x,y) to extract the crack area in the original image and calculate R_crack(x,y), as shown in the following formula, where R_crack(x,y) represents the crack area.
[0055] R_crack(x,y)=I(x,y)×M(x,y)
[0056] Similarly, calculate the non-crack area R_noncrack(x,y)
[0057] R_noncrack(x,y)=I(x,y)×(1-M(x,y))
[0058] 2.3: Generate Gaussian noise and enhance the data, adding noise to the non-crack area, as shown in the following formula:
[0059] R_noncrack_aug(x,y)=R_noncrack(x,y)×N(x,y)
[0060] Among them, the noise is N(x,y), which conforms to the Gaussian distribution Then the pixel values are truncated to make them valid, as shown in the following formula, where R_noncrack_aug(x,y) represents adding noise to the non-crack area.
[0061] R_noncrack_aug(x,y)=max(0,min(255,R_noncrack(x,y)))
[0062] Step 3: Merge the crack area and the enhanced non-crack area, that is, merge R_noncrack_aug(x,y) and R_noncrack(x,y) according to the M(x,y) method, as shown in the following formula:
[0063] I_aug(x,y)=R_crack(x,y)+R_noncrack_aug(x,y)×(1-M(x,y))
[0064] This formula indicates that I_aug(x,y) is combined into a new enhanced dataset for subsequent experimental verification.
[0065] Step 4: First, name each image in the training set of the original dataset Crack-seg as I(x,y), where (x,y) represents the position of the image pixel. Then, add Gaussian noise to each image using the following formula:
[0066] I aug (x,y)=I(x,y)+η(x,y)
[0067] In this formula, η(x,y) is derived from a Gaussian distribution The random noise extracted from each image is added to the noise to generate a new image I aug , mean μ=0, the overall brightness of the image remains unchanged, variance σ 2 To control the noise intensity, the pixel range of all images is [0, 255]. All images are truncated according to the following formula to ensure that the pixel values of the enhanced images are within the valid range.
[0068] (x,y)=max(0,min(255,I aug (x,y)))
[0069] After the new images are generated, the new images are combined into a new training set, and the new training set and the original validation set and test set are merged into a new dataset Crack-seg-Gaussian. The Crack-seg-Gaussian dataset is also merged with the Crack-seg dataset to form a new dataset named Crack-new.
[0070] Step 5: Introduce the YOLOv8-seg-P6 network, which borrows the idea of CSP and divides one training into two times, which alleviates overfitting to a certain extent.
[0071] Step 6: Put the generated new dataset into the YOLOv8-seg and YOLOv8-seg-P6 networks for experiments and evaluation. This paper uses the mean average precision as the evaluation indicator, and the indicators involved are:
[0072] 6.1: Average Precision (AP) measures the performance of a model for a single category and is calculated by calculating the area under the precision-recall curve at different confidence thresholds. The calculation steps are as follows: First, all prediction results are sorted from high to low according to the confidence of the predicted box. Then, TP and FP are calculated. For each predicted box, if the intersection-over-union ratio with the ground-truth box is greater than a set threshold, it is considered True Positive (YP), otherwise it is False Positive (FP). Then, Precision and Recall are calculated as follows:
[0073]
[0074] 6.2: Plotting the Precision-Recall Curve: With Recall as the x-axis and Precision as the y-axis, plot the precision-recall curve. Finally, calculate the area under the curve, which is the AP, and can be calculated using integration or interpolation.
[0075] The mean average precision (mAP) is the average of all class APs. For multi-class problems, the AP of each class is calculated and averaged. The mathematical formula is defined as follows:
[0076]
[0077] mAP@50 refers to the mAP calculated with an Intersection over Union (IoU) threshold of 0.5. The formula is defined as follows:
[0078]
[0079] mAP@50:95 refers to the mAP calculated within a range of IoU thresholds (from 0.5 to 0.95 with a step size of 0.05)
[0080] The specific formula is as follows:
[0081]
[0082] 6.3: mAP@50 and mAP@50.95 are used as the main evaluation indicators to measure the detection accuracy of the model.
[0083] Step 7: Based on the experimental comparison results in Step 6, select the model with the best performance. The model selected in this method is YOLOv8-seg-P6+Nnew. Then, configure the corresponding deployment environment according to the requirements of the selected model to ensure that it has sufficient security and stability. Then, perform necessary conversions and optimizations on the selected model to adapt to the requirements of the production environment. Then, call the model to verify the compatibility of the model with the existing system and its performance in real scenarios. After confirmation, smoothly deploy the model to the production environment, and users can directly call the model to detect cracks on the surface of objects.
[0084] Example 1:
[0085] A method for object crack detection using a self-attention mechanism-optimized generative adversarial network, the specific embodiment of which is as follows:
[0086] (1) Preprocess the image dataset: Copy the original dataset and divide the desired images in the training set of the copied dataset into subsets S1, S2, S3, …, Sn. The dataset used in this paper is the public dataset Crack-seg, which contains more than 4,000 images and their corresponding pixel-level labels. It integrates images from multiple sub-datasets and covers different crack types and background conditions. All images and labels are resized to a uniform size of 400×400 pixels to facilitate model training and comparison.
[0087] (2) Improve the GAN network: Introduce the self-attention mechanism to construct the GAN network model. Each subset S1, S2, S3, ..., Sn corresponds to a GAN network. Each subset is used as the data set of the corresponding GAN network. After each GAN network is trained, an image is generated. The image and its corresponding group are labeled. Analyze the image generated by each GAN to distinguish between crack areas and non-crack areas. Label the crack areas. Using the crack and non-crack areas distinguished by each group of corresponding images as a model, add Gaussian noise to the non-crack areas corresponding to all images in the training set. Assume that the original image is I and the image after adding Gaussian noise is I′:
[0088] I′(x,y)=I(x,y)+N(0,σ 2 )
[0089] Where (x, y) is the pixel coordinate of the image, N(0, σ^2) means the mean is 0 and the variance is σ 2 Gaussian random number. For each pixel position (x, y), from N(0,σ 2 ) extracts a random number as the noise value of the position, adds the generated Gaussian noise value to the pixel value of the original image, and obtains the new pixel value I′(x,y). Figure 3This is a schematic diagram of the self-attention mechanism. The hyperparameters of GAN are shown in Table 1.
[0090] Table 1: GAN hyperparameters
[0091]
[0092] (3) Based on step (2), after all noises are added, S1, S2, S3, …, Sn are merged into a new enhanced image set. The validation set and the test set remain unchanged and are merged into a new dataset Ngenerated. The original dataset Noriginal is then merged with Ngenerated to generate a new expanded dataset Nnew.
[0093] Nnew=Noriginal+Ngenerated
[0094] (4) Import the Crack-seg-Gaussian and Crack-new datasets generated by conventional Gaussian enhancement into the YOLOv8 model for the next comparative experiment.
[0095] (5). Introduce YOLOv8-seg-P6 to combine different data sets for the next comparative experiment.
[0096] (6) Ngenerated and Nnew are put into different YOLOv8 networks for training respectively. For the dataset enhanced by the general method, it is named Crack-seg-Gaussian, and for the expanded dataset obtained by the general method, it is named Crack-new. mAP@50 and mAP@50:95 are used as the main evaluation indicators to measure the detection accuracy of the model and conduct experimental comparison.
[0097] (7) Based on the comparison results of (6), the mAP@0.5 and mAP@0.5:0.95 of YOLOv8-seg-P6+Nnew increased to 0.834 and 0.653 respectively, which are 6.9% and 10.8% higher than the baseline model respectively; compared with the traditional Gaussian enhancement method (Crack-seg-Gaussian), the enhanced dataset of this method increased the mAP@0.5 of YOLOv8-seg-P6 by 5.25% and mAP@0.5:0.95 by 0.98%. Therefore, this model was selected as the final deployment solution. The best weight file of this model is best.pt. A series of instructions for starting the model have been encapsulated in the automatic operation and maintenance.bat. At this time, the model will be deployed locally. The following operations should be performed:
[0098] ① Prepare a computer running Windows. Install a camera in a location that effectively covers the target device.
[0099] ② Copy all the model files required by this system to the target computer, and place the best.pt file and the automatic operation and maintenance .bat file on the system desktop.
[0100] ③ After the above preparations are completed, the user can start the system by double-clicking the automatic operation and maintenance .bat script on the desktop to start executing the preset automatic operation and maintenance tasks.
[0101] ④ After deployment is complete, users should receive appropriate training: Before use, they should carefully check the camera's operating status to ensure a stable connection and clear images. Any anomalies should be reported immediately to the system administrator for prompt resolution. Once the hardware is confirmed to be functioning properly, maintenance personnel can initiate automated maintenance by double-clicking the automated maintenance .bat file on the desktop. To ensure the integrity and traceability of all operational records, maintenance personnel should promptly submit test results and related information to the relevant management personnel for final approval after each test.
[0102] After completing the above steps, users can directly call the local model to detect cracks on the object surface.
[0103] Figure 2 The experimental steps of the method are shown.
[0104] This paper uses the public datasets Crack-seg and YOLOv8-seg network and YOLOv8-seg-P6 to conduct experimental evaluation of this method. Figure 4 The overall flow chart of this method.
[0105] As for the experimental results:
[0106] (1) Comparing the training results of YOLOv8-seg and YOLOv8-seg-P6 on the original dataset, mAP@0.5 and mAP@0.5:0.95 are improved by 2% and 1.6% respectively, which shows that YOLOv8-seg-P6 can be used as a control network for the experiments in this paper.
[0107] (2) Based on (1), YOLOv8-seg+Crack-seg-Gaussian and YOLOv8-seg-P6+Crack-seg-Gaussian are compared. Compared with the original Crack-seg, mAP@0.5 and mAP@0.5:0.95 are improved by 4.8%, 9.6% and 3.6%, 6.9% respectively. The experimental results show that YOLOv8-seg-P6 achieves further performance improvement on the conventional Gaussian augmented dataset.
[0108] (3) Based on (2), this experiment further expands the dataset. Comparing YOLOv8-seg+Crack-new and YOLOv8-seg-P6+Crack-new, compared with the original Crack-seg, mAP@0.5 and mAP@0.5:0.95 increased by -0.5%, -0.6% and 6.0%, 9.7% respectively. This shows that the performance of the YOLOv8-seg network has declined when dealing with more complex datasets due to performance limitations. The YOLOv8-seg-P6 network with stronger performance performs better in complex datasets.
[0109] (4) YOLOv8-seg and YOLOv8-seg-P6 were trained on the Ngenerated dataset enhanced by this method. Compared with the original Crack-seg, mAP@0.5 and mAP@0.5:0.95 increased by 5.6%, 9.3% and 3.9%, 7.7%, respectively. The experimental results show that although the network performance is improved compared with the original Crack-seg, the improvement is not as great as that of YOLOv8-seg-P6+Crack-new mentioned in (3). Therefore, we continue to expand the dataset to achieve further improvement in network performance.
[0110] (5) YOLOv8-seg and YOLOv8-seg-P6 were trained on the further expanded dataset Nnew. Compared with the original Crack-seg, mAP@0.5 and mAP@0.5:0.95 increased by 5.1%, 5.4%, 6.9%, and 10.8%, respectively. Experimental results show that YOLOv8-seg and YOLOv8-seg-P6 perform better in the further expanded dataset, and mAP@0.5 and mAP@0.5:0.95 have achieved further improvement over all previous experimental results.
[0111] Table 2: Overall experimental table
[0112]
[0113] (6) The ablation experiment results show that on all tested datasets, compared with the original YOLOv8-seg model, the mAP@0.5 and mAP@0.5:0.95 indicators are significantly improved after using YOLOv8-seg-P6 combined with a specific data enhancement method, proving the effectiveness of the proposed improvement measures in improving model accuracy.
[0114] Table 3: Comparison of ablation experiment results
[0115]
[0116] For real applications:
[0117] With authorization, this article conducted a detailed on-site investigation of multiple heat exchange stations in a city in North China. Figure 5 The results of detecting cracks on the surface of the heat exchanger base using this system in an actual heat exchange station environment were demonstrated; Figure 6 The results of the system's detection of surface cracks in heat exchanger pipes in an actual heat exchange station environment are presented. These results demonstrate that this method can be used to detect various equipment in a heat exchange station and has both practical value and practical significance.
Claims
1. A method for object crack detection using a self-attention mechanism-optimized generative adversarial network, characterized by: Step 1: Group GAN network generation: The original Crack-seg training set is grouped according to image features. Each group corresponds to an improved GAN network. By training an independent GAN network for each group, diversified crack images are generated. The GAN loss function L is optimized by the following formula: L=Loriginal+λLregularization Among them, Loriginal is the original GAN loss function, Lregularization is the regularization term, and λ is the adjustment weight; Step 2: Adaptive Gaussian noise addition: Analyze each image generated by GAN to distinguish crack areas from non-crack areas. Use this image as a template to distinguish crack areas and non-crack areas for all images in the group, and add Gaussian noise only in the non-crack areas. The noise intensity σ is determined by the following formula: σ=f(image_feature) Among them, f is a function that dynamically adjusts the noise intensity according to image characteristics; Step 3: Dataset expansion strategy: Merge the images generated by GAN and processed with noise with the original dataset to form a new training dataset. The number of samples Nnew after the dataset expansion is calculated by the following formula: Nnew=Crack-seg+Ngenerated Among them, α is the adjustment weight, Ngenerated is a dataset formed by images generated by GAN and processed with noise; Step 4: Add Gaussian noise to all images in the training set of the Crack-seg dataset, concatenate the generated images with the training set and validation set of the Crack-seg dataset to form the Crack-seg-Gaussian dataset, and merge the Crack-seg-Gaussian dataset with the Crack-seg dataset to form a new dataset named Crack-new. Step 5: Select YOLOV8-SEG-P6 and initialize it with its pre-trained weights. This model supports higher-resolution feature fusion by adding P6 layers. Step 6: Construct three types of data sets: traditional Gaussian enhancement Crack-seg-Gaussian, traditional enhancement + original data Crack-new, and this method enhancement + original data Nnew, train YOLOv8-seg and YOLOV8-SEG-P6 respectively, and use Crack-seg to train YOLOv8-seg and YOLOV8-SEG-P6 for comparison; Step 7: Based on the experimental comparison results in Step 6, select the model with the best performance for deployment so that users can call the model to perform surface crack detection tasks.
2. The object crack detection method using a self-attention mechanism optimized generative adversarial network according to claim 1, characterized in that: In step 1, the improvement method of the GAN network is as follows: Grouping the data set will result in less data in each group. The self-attention mechanism is introduced in the GAN network, and its formula is: Assume that the input sequence X={x1,x2,...,x n }, where each x i Is a d-dimensional vector. Q, K, and V are query, key, and value matrices respectively; d k is the dimension of the key.
3. The object crack detection method using a self-attention mechanism optimized generative adversarial network according to claim 1, characterized in that: In step 2, each image generated by the GAN network is labeled in its corresponding group, and each image is annotated to distinguish crack areas from non-crack areas; using each generated image as a template, all images in the group are annotated to distinguish crack areas from non-crack areas, and Gaussian noise is added to the non-crack areas of each image.
4. The object crack detection method using a self-attention mechanism optimized generative adversarial network according to claim 1, characterized in that: In the step 6), the specific method is: Step 6.1: Combine the original dataset with the YOLOv8 model for training; Step 6.2: Combine the original data augmentation method with the YOLOv8 model for training and compare the experimental results. Step 6.3: Combine the dataset enhanced by this method with the YOLOv8 model for training and compare the experimental results; Step 6.4: Combine the original dataset with YOLOv8-seg-P6 for training; Step 6.5: Combine the original data augmentation method with the enhanced dataset and train it with YOLOv8-seg-P6, and compare the experimental results. Step 6.6: Combine the dataset enhanced by this method with YOLOv8-seg-P6 for training and compare the experimental results; Step 6.7: Combine the traditional Gaussian enhancement dataset with the YOLOv8 model for training and compare the experimental results. Step 6.8: Combine the traditional Gaussian enhancement dataset with YOLOv8-seg-P6 for training and compare the experimental results.
5. The object crack detection method using a self-attention mechanism optimized generative adversarial network according to claim 1, characterized in that: In the step 7), the specific method is: Step 7.1: Based on the experimental comparison results in Step 6, determine the model with the best overall performance using the mAP@0.5 and mAP@0.5:0.95 values; Step 7.2: Configure the deployment environment that meets the requirements of the model and deploy the system to the local device; Step 7.3: Start the model call to verify the compatibility and actual performance between the model and the system. After successful verification, the user uses this model to detect cracks on the surface of an object.