Industrial product surface nondestructive testing method and system based on improved YOLOv8

By introducing the SCKConv and CCSA modules into the YOLOv8 model, and combining high-resolution feature fusion and post-processing optimization, the problems of insufficient feature extraction and unstable detection of small defects in complex backgrounds are solved, and high-precision and robust surface defect detection of industrial products is achieved.

CN121962086APending Publication Date: 2026-05-01SHANGHAI JINGYI IND CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SHANGHAI JINGYI IND CO LTD
Filing Date
2026-01-19
Publication Date
2026-05-01

AI Technical Summary

Technical Problem

The existing YOLOv8 model has problems such as insufficient feature extraction ability in complex texture backgrounds, low detection rate of small defects and unstable detection results in the detection of surface defects of industrial products, making it difficult to achieve high-precision and high-robust detection.

Method used

In the YOLOv8 model, a spatial channel-selective kernel convolution module (SCKConv) and a coordinate-channel-spatial joint attention module (CCSA) are introduced. The network architecture is improved by fusing high-resolution P2 layer features to enhance feature extraction and small defect detection. Non-maximum suppression and weighted box fusion (WBF) are combined to optimize the detection results.

Benefits of technology

The model's feature extraction capability and small defect detection accuracy under complex backgrounds have been improved, and the stability and robustness of the detection results have been enhanced, achieving high-precision surface defect detection of industrial products.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121962086A_ABST
    Figure CN121962086A_ABST
Patent Text Reader

Abstract

The invention discloses an industrial product surface nondestructive testing method and system based on improved YOLOv8, and relates to the technical field of computer vision and image processing. In a YOLOv8 backbone network, standard 3 * 3 convolution is replaced by a space channel selective kernel convolution module, and the nondestructive testing of the surface of an industrial product is realized by performing space and channel reconstruction on features and dynamically adjusting a receptive field. Redundant features are suppressed, and the modeling capability for complex textures is enhanced; a coordinate-channel-space joint attention module is embedded in front of a detection head classification branch, and extraction and focusing of small defect features are enhanced through coordinate, channel and space attention mechanisms; structural upgrading is carried out on the feature fusion part of the network, the detection scale is expanded to a P2 layer, and the capacity of capturing tiny targets is improved. In addition, multi-scale feature fusion and non-maximum suppression and weighted frame fusion in a post-processing stage are combined, so that the positioning precision and the result stability of the detection frame are further improved.
Need to check novelty before this filing date? Find Prior Art

Description

A method and system for non-destructive testing of industrial product surfaces based on an improved YOLOv8 Technical Field

[0001] This invention relates to the field of computer vision and image processing technology, and more specifically to a method and system for non-destructive testing of industrial product surfaces based on an improved YOLOv8. Background Technology

[0002] Currently, in industrial manufacturing processes, surface defects (such as missing holes, rodent bites, open circuits, short circuits, stray copper, etc. on PCBs) directly affect product performance and reliability. Traditional manual inspection methods are inefficient and inaccurate, making it difficult to meet the demands of modern large-scale production. With the development of deep learning, target detection methods based on convolutional neural networks have gradually become an important means of non-destructive surface inspection, among which the YOLO series algorithms are widely used due to their advantages of fast detection speed and end-to-end training.

[0003] However, the existing YOLOv8 model still has the following shortcomings in the detection of surface defects in industrial products: insufficient feature extraction capability against complex texture backgrounds; and it is easy to confuse small defects with background noise, leading to missed detections or false detections.

[0004] Insufficient attention is paid to small defects: Small defects are often submerged in the process of multi-scale feature fusion, resulting in a decrease in detection accuracy.

[0005] Tiny defects have very few pixels: In the traditional deep downsampling process of YOLOv8, their original resolution features are over-compressed and completely disappeared.

[0006] Limited stability of detection results: Traditional nonmaximum suppression (NMS) is prone to losing true defects when deduplicating candidate boxes, resulting in unstable results.

[0007] Therefore, there is an urgent need for a non-destructive testing method and system for industrial product surfaces based on the improved YOLOv8, in order to solve the problems of insufficient feature extraction, low detection rate of small defects and unstable detection results in complex backgrounds, so as to achieve high-precision and high-robustness detection of surface defects in industrial products. Summary of the Invention

[0008] In view of this, the present invention provides a method and system for non-destructive testing of industrial product surfaces based on an improved YOLOv8, in order to solve the problems in the background art.

[0009] To achieve the above objectives, the present invention adopts the following technical solution: On one hand, the present invention discloses a non-destructive testing method for industrial product surfaces based on an improved YOLOv8, comprising: acquiring surface defect images of industrial products and constructing a dataset; performing data preprocessing on the industrial product surface images; constructing an improved YOLOv8 network model, introducing a spatial channel-selective kernel convolution module into the YOLOv8 backbone network to dynamically enhance channel and spatial feature representation, adaptive receptive field, and dynamic selection and dual reconstruction of features; introducing a coordinate-channel-space joint attention module into the classification branch of the YOLOv8 detection head, enhancing the model's attention to small defect regions through a joint attention mechanism of feature coordinates, feature channels, and feature space; in the feature fusion part of the network, improving to a four-scale detection architecture by fusing high-resolution P2 layer features from the backbone; training the constructed dataset using the improved YOLOv8 model; validating the improved model on a test set to evaluate its detection performance in small defects and complex backgrounds; and post-processing the detection results to obtain the final industrial product surface defect detection results.

[0010] Preferably, in the above-mentioned non-destructive testing method for industrial product surfaces based on improved YOLOv8, the specific steps for acquiring surface defect images of industrial products and constructing a dataset are as follows: Prepare a printed circuit board surface defect dataset, including images of multiple types of defects such as missing holes, rodent bites, open circuits, short circuits, stray wires, and pseudo-copper. Divide the images into a training set of 70%, a validation set of 20%, and a test set of 10%. The objective function for constructing the dataset is expressed as: In the formula, For the input image, For defect category labels, This is a set of defect categories.

[0011] Preferably, in the above-mentioned method for non-destructive testing of industrial product surfaces based on improved YOLOv8, data preprocessing of the industrial product surface image includes image normalization, size scaling, and data augmentation; wherein, the normalization formula is: In the formula, For pixel values, , The minimum and maximum pixel values ​​for the image are set; the input image size is adjusted uniformly; data enhancements include rotation, translation, flipping, brightness adjustment, and Mosaic stitching.

[0012] Preferably, in the above-mentioned non-destructive testing method for industrial product surfaces based on improved YOLOv8, in the optimization of the backbone network, the original standard 3×3 convolutional layer in the YOLOv8 backbone is replaced with a spatial channel-selective kernel convolution module; input feature X inThe structure is divided into a main branch and a side branch: the main branch retains the original Bottleneck structure; the side branch performs dynamic feature reconstruction using SCKConv; and finally, the features are fused through concatenation and 1×1 convolution. ;in, Input features for the main branch; Input features for bypass branches; To perform residual bottleneck transformation on the main branch; To perform dynamic multi-scale feature reconstruction of bypass branches; ( This involves concatenating the feature maps output from the two branches along the channel dimension. The number of channels is merged into the target output channel.

[0013] Preferably, in the above-mentioned method for non-destructive testing of industrial product surfaces based on improved YOLOv8, the specific steps of dynamic feature selection and dual reconstruction are as follows: The basic convolutional layer performs channel transformation and downsampling on the input feature F to obtain the depth feature Y to be refined: ;feature The data is sent to a spatial reconstruction unit to obtain preliminary reconstruction features. : Where SRU stands for Spatial Reconstruction Operation; Reconstruction Features Through selective kernel convolution refiner By utilizing a multi-scale dynamic receptive field mechanism, spatial augmentation features are generated. : Spatial enhancement features Reconstruction unit via channel The relationship between channels is modeled, and the data is decomposed into high-frequency and low-frequency channels. Compressed features are obtained through 1×1 convolution. : High-frequency characteristics after compression The data is fed into a grouped convolutional layer centered on selective kernel convolution (SKConv) and a pointwise convolutional layer (PwC) for dynamic interaction to generate the data. Low-frequency characteristics Supplement and reconstruct to generate : ; In the formula, Indicates splicing; Point convolution operation; reconstructing features and After concatenation, global average pooling is used. The generated adaptive weights are weighted to complete the information fusion between channels: In the formula, Use the Sigmoid activation function; This is a global average pooling operation; For concatenation; indicates element-wise multiplication; weighted features Through the split summation operation The channel dimensions are restored and normalized to obtain the final output features. ; In the formula, This is a normalization operation; This is a splitting and summing operation.

[0014] Preferably, in the above-mentioned non-destructive testing method for industrial product surfaces based on improved YOLOv8, during the optimization of the detection head, the original structure of the decoupled detection head in YOLOv8 includes a classification branch, a regression branch, and a confidence branch. A CCSA module is embedded before the classification branch. CCSA combines attention mechanisms in three dimensions: feature coordinates, feature channels, and feature space. The definitions of coordinate attention, channel attention, and spatial attention are as follows: Coordinate attention mechanism: Global average pooling is performed on the input feature F in the horizontal and vertical directions respectively to generate direction-aware features. Then, through weight transformation and element-wise multiplication, the coordinate attention weights are obtained. ; In the formula, This represents the generated coordinate attention map. The horizontal direction (feature encoding function, followed by a 1×1 convolution and a sigmoid composite function) The vertical feature encoding function consists of a feature splitting operation followed by a 1×1 convolution and a Sigmoid activation function; the other part is an element-wise multiplication operation. This is the normalization coefficient for the width direction of the feature map; Let represent the normalization coefficient in the height direction of the feature map; ... In the formula, This represents the generated channel attention map. For the input feature map, It is a multilayer perceptron. Use the Sigmoid activation function; This is a global average pooling operation; For max-average pooling operation; spatial attention mechanism: In the formula, This represents the generated spatial attention map; This represents a 7×7 convolution operation. These are the characteristics after channel weighting; This is a global average pooling operation; This involves a max pooling operation; global average pooling and max pooling are used to generate feature descriptions in the spatial dimension, which are then processed by a 7×7 convolution to obtain a spatial attention map; the feature-weighted output is as follows: In the formula, represents element-wise multiplication; This represents the generated coordinate attention map; This represents the generated channel attention map; This represents the generated spatial attention map; after fusing the feature maps from Backbone and CSSA optimization, they are respectively fed into the classification branch and regression branch in the YOLOv8 decoupled detection head, and finally output the defect category and bounding box prediction results.

[0015] Preferably, in the above-mentioned non-destructive testing method for industrial product surfaces based on improved YOLOv8, in the feature fusion process, the present invention expands the detection scale from the original three-scale output to a four-scale output. The specific steps are as follows: fusing features in layer P3. Upsampling is used to amplify the P2 feature to match its spatial dimensions; ; magnified features Compared to early P2 features from Backbone Perform concat stitching and merging; The fused features are processed by the C2f module to generate the final P2-scale features. ; .

[0016] Preferably, in the above-mentioned method for non-destructive testing of industrial product surfaces based on improved YOLOv8, the improved YOLOv8 model is used to train the constructed dataset, and the performance is compared with the training results of the original YOLOv8 model. The improved YOLOv8 model is used to train the constructed dataset, and the performance is compared with the training results of the original YOLOv8 model. During training, cross-entropy loss and regression loss are jointly optimized. In the formula, For classifying losses, For bounding box regression loss, The target confidence loss.

[0017] Performance metrics include precision, recall, and mean precision (mAP): Precision: Recall rate: mAP: Where APi is the average precision of the i-th class.

[0018] Furthermore, the improved model was validated on a test set to evaluate its detection performance in small defects and complex backgrounds; the overlap between the predicted bounding boxes and the ground truth bounding boxes was measured using IoU (Intersection over Union). In the formula, A is the predicted bounding box and B is the ground truth bounding box. When the IoU is greater than the threshold (0.5), the prediction is considered correct.

[0019] Preferably, in the above-mentioned non-destructive testing method for industrial product surfaces based on improved YOLOv8, the specific steps to obtain the final industrial product surface defect detection result are as follows: This step includes two processes: Non-maximum suppression (NMS) and weighted bounding box fusion (WBF). Non-maximum suppression (NMS) removes redundant candidate boxes by setting an IoU threshold and a confidence threshold, retaining only the detection boxes with the highest confidence. The specific formula is: Weighted bounding box fusion (WBF) further fuses overlapping candidate boxes after NMS filtering, using a weighted average method to enhance the stability of bounding box localization; the specific formula is as follows: In the formula, Indicates the candidate box. This indicates the corresponding confidence level. The weights are used as the basis for calculation; the final detection box positions are obtained by weighting and summing the results using confidence scores. ; i represents the index of the i-th candidate box participating in the fusion, and n represents the total number of candidate boxes participating in the weighted box fusion.

[0020] On the other hand, this invention discloses an industrial product surface non-destructive testing system based on improved YOLOv8. Applying the aforementioned industrial product surface non-destructive testing method based on improved YOLOv8, the system is characterized by comprising: an acquisition module for acquiring surface defect images of industrial products and constructing a dataset; a preprocessing module for preprocessing the surface images of industrial products; a YOLOv8 network model improvement module for constructing an improved YOLOv8 network model, improving the backbone network, detection head, and feature fusion part respectively; a training module for training the constructed dataset using the improved YOLOv8 model; a validation module for validating the improved model on a test set and evaluating its detection performance under small defects and complex backgrounds; and an output module for post-processing the detection results to obtain the final industrial product surface defect detection results.

[0021] Preferably, in the above-mentioned industrial product surface non-destructive testing system based on improved YOLOv8, the YOLOv8 network model improvement module includes: a backbone network improvement unit, which introduces a spatial channel-selective kernel convolution module into the YOLOv8 backbone network and performs dynamic selection and dual reconstruction of features; a detection head improvement unit, which introduces a coordinate-channel-space joint attention module into the classification branch of the YOLOv8 detection head, and enhances the model's attention to small defect areas through the joint attention mechanism of feature coordinates, feature channels, and feature space; and a feature fusion improvement unit, which improves the network's feature fusion part by fusing high-resolution P2 layer features from the backbone to a four-scale detection architecture.

[0022] As can be seen from the above technical solutions, compared with the prior art, this invention discloses a method and system for non-destructive testing of industrial product surfaces based on an improved YOLOv8. This invention introduces a Spatial Channel Selective Kernel Convolution (SCKConv) module into the YOLOv8 backbone network to dynamically enhance channel and spatial feature representation and adapt the receptive field, thereby improving the model's feature extraction capability in complex backgrounds. A Coordinate-Channel-Spatial Joint Attention (CCSA) module is introduced into the classification branch of the YOLOv8 detection head to enhance the model's attention to small defect regions through a joint attention mechanism of coordinates, channels, and space, thus improving the detection accuracy of small defects. The feature fusion part of the network is upgraded with an architecture that integrates high-resolution P2 layer features from the backbone to achieve a four-scale detection architecture, solving the problem of insufficient resolution for small targets. In the post-processing stage, non-maximum suppression and weighted bounding box fusion (WBF) are combined to improve the stability and robustness of the detection results while maintaining detection speed. In summary, this invention addresses the problems of insufficient feature extraction, low detection rate of small defects, and unstable detection results in complex backgrounds, thereby achieving high-precision and highly robust surface defect detection of industrial products. Attached Figure Description

[0023] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.

[0024] Figure 1 is a flowchart of the implementation of the method of the present invention; Figure 2 is a schematic diagram of the original YOLOv8 structure; Figure 3 is a schematic diagram of the improved YOLOv8 backbone network structure of the present invention (embedded with SCKConv); Figure 4 is a schematic diagram of the improved YOLOv8 detection head structure of the present invention (with CCSA added); Figure 5 is the improved four-scale feature fusion architecture of the present invention. Detailed Implementation

[0025] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0026] This invention discloses a non-destructive testing method for industrial product surfaces based on an improved YOLOv8. Referring to Figure 1, the method includes: acquiring and preprocessing images of surface defects in industrial products; introducing the SCKConv module into the YOLOv8 backbone network and embedding the CCSA module in the detection head to expand the three-scale output to a four-scale output; training and validating the improved model; and finally optimizing the detection results by combining non-maximum suppression (NMS) and weighted bounding box fusion (WBF) to output the category and location results of surface defects in industrial products. The specific implementation steps of this invention are as follows: Step 1: Acquire images of surface defects in industrial products and construct a dataset; Step S101: Prepare a dataset of surface defects on printed circuit boards (PCBs), including images of various defects such as missing holes, rodent bites, open circuits, short circuits, stray wires, and fake copper. The images are divided into a training set (70%), a validation set (20%), and a test set (10%) according to the proportions.

[0027] Step S102: The objective function for constructing the dataset can be expressed as: In the formula, For the input image, For defect category labels, This is a set of defect categories.

[0028] The label files in the original dataset are usually saved in VOC XML format, while YOLO series models require the label files to be stored in YOLO format (one .txt file per image, containing the class number and normalized bounding box coordinates). Therefore, a script needs to be written to batch convert the XML annotation files into a YOLO-compatible text format.

[0029] The conversion format is as follows: Assume the image width is W and the height is H; the coordinates of the top left corner of the original annotation box are ( , The coordinates of the top left corner of the original annotation box are ( , The converted YOLO format is: ; In the formula, ( , () represents the normalized coordinates of the center point of the bounding box. These are the normalized values ​​for the width and height of the bounding box, respectively.

[0030] Step 2: Perform data preprocessing on the surface image of the industrial product; Step S201: Normalize, scale and augment the image.

[0031] Wherein, the normalization formula is: In the formula, For pixel values, , These are the minimum and maximum pixel values ​​for the image.

[0032] Step S202: Adjust the input image size to 640×640 to ensure consistent input size.

[0033] Step S203: Data enhancement includes rotation, translation, flipping, brightness adjustment, and Mosaic stitching.

[0034] Step S204: The preprocessed image maintains a one-to-one correspondence with the defect category label.

[0035] Step 3: Improve the YOLOv8 network model; Step S301: Backbone network optimization (YOLOv8+SCKConv).

[0036] In the YOLOv8 backbone, the standard 3×3 convolutional layers are replaced with Spatial Channel Selective Kernel Convolution (SCKConv). The input feature Xin is divided into a main branch and a side branch: the main branch retains the original Bottleneck structure; the side branch performs dynamic feature reconstruction using SCKConv; finally, the features are fused through concatenation and a 1×1 convolution. This improvement reduces redundant feature representations and enhances the model's feature extraction capabilities in complex texture backgrounds.

[0037] Step S302: Dynamic selection of features and dual reconstruction.

[0038] To further compress redundant features, the base convolutional layer ( The input feature F is subjected to channel transformation and downsampling to obtain the depth feature Y to be refined: ;feature The data is fed into a spatial reconstruction unit (SRU) to obtain preliminary reconstruction features. : Reconstruction features Refining via selective kernel convolution ( ), utilizing a multi-scale dynamic receptive field mechanism to generate spatially enhanced features. : Spatial enhancement features Through channel reconstruction unit ( The channel relationships are modeled, and the data is decomposed into high-frequency and low-frequency channels. Compressed features are obtained through 1×1 convolution. : High-frequency characteristics after compression It is fed into a grouped convolutional layer with selective kernel convolution (SKConv) as its core and pointwise convolution (PWC) for dynamic interactive generation. Low-frequency characteristics Supplement and reconstruct to generate : ; In the formula Indicates splicing.

[0039] Reconstructed features and After concatenation, global average pooling is used ( The generated adaptive weights are then used for weighting to complete the information fusion between channels. Weighted features Through the split summation operation ( The channel dimensions are restored and normalized to obtain the final output features. .

[0040] This improvement effectively enhances feature representation, enabling the network to more clearly distinguish between background textures and real defect areas.

[0041] Step S303: Detection head optimization (YOLOv8+CCSA).

[0042] In the decoupled detection head of YOLOv8, the original structure includes a classification branch, a regression branch, and a confidence branch. This invention embeds a CCSA module before the classification branch. CCSA combines attention mechanisms across three dimensions: feature coordinates, feature channels, and feature space. The definitions of coordinate attention, channel attention, and spatial attention are as follows: Coordinate attention mechanism: Global average pooling is performed on the input feature F in both the horizontal and vertical directions to generate orientation-aware features. Subsequently, coordinate attention weights are obtained through weight transformation and element-wise multiplication. .

[0043] In the formula, in the formula, This represents the generated coordinate attention map. This is the horizontal feature encoding function, which is a composite function of a 1×1 convolution and a sigmoid function following feature splitting. The vertical feature encoding function consists of a feature splitting operation followed by a 1×1 convolution and a Sigmoid activation function; the other part is an element-wise multiplication operation. This is the normalization coefficient for the width direction of the feature map; Let represent the normalization coefficient in the height direction of the feature map; ... In the formula, This represents the generated channel attention map. For the input feature map, It is a multilayer perceptron. This is the Sigmoid activation function.

[0044] Spatial attention mechanism: In the formula, This represents a 7×7 convolution operation. These are the characteristics after channel weighting.

[0045] Global average pooling and max pooling are used to generate feature descriptions in the spatial dimension, and a spatial attention map is obtained by 7×7 convolution.

[0046] Feature-weighted output: The final output enhanced features are represented as follows: In the formula, represents element-wise multiplication.

[0047] After the feature maps from Backbone and CCSA are fused, they are fed into the classification branch and regression branch in the YOLOv8 decoupled detection head, respectively, and finally the defect category and bounding box prediction results are output.

[0048] Step S304: Feature fusion optimization.

[0049] In feature fusion, this invention expands the detection scale from the original three-scale output to a four-scale output, introducing high-resolution features to address the insufficient resolution of small targets. First, features from layer P3 are fused. Upsampling is used to amplify the data and match the spatial size of the P2 feature.

[0050] ; magnified features Compared to early P2 features from Backbone Perform concat stitching and merging.

[0051] The fused features are processed by the C2f module to generate the final P2-scale features. .

[0052] This improvement introduces high-resolution features, enhancing the network's ability to extract features from minute defects.

[0053] Step 4: Train the constructed dataset using the improved YOLOv8-PCS model and compare the performance metrics with the training results of the original YOLOv8 model; Step S401: Input the datasets obtained in Step 1 and Step 2 into the improved YOLOv8-PCS model described in Step 3, train the constructed dataset using the improved YOLOv8-PCS model, set the training epochs to 100, disable Mosaic enhancement in the last 10 epochs, use stochastic gradient descent (SGD) as the optimizer, and set the initial learning rate to 0.01.

[0054] During training, cross-entropy loss and regression loss are jointly optimized: In the formula, For classifying losses, For bounding box regression loss, The target confidence loss.

[0055] For performance evaluation, precision, recall, and mean precision (mAP@0.5 and mAP@0.5:0.95) were used as indicators. Under the same training strategy, YOLOv8, YOLOv8+CBAM, and YOLOv8-PCS were trained respectively.

[0056] The formulas for precision, recall, and mean precision (mAP) are as follows: Precision: Recall rate: mAP: ;in, Let be the average precision of the i-th class.

[0057] Table 1 shows that the improved models outperform the basic models in detection accuracy. Among them, YOLOv8+CBAM improves the overall accuracy by about 2.0% compared with the basic model, while YOLOv8-PCS performs best in complex backgrounds, with an overall mAP50 of 0.939, an improvement of 4.8%, and an mAP50-95 improvement of 7.4%.

[0058] The comparison results with the improved YOLOv8 model are shown in Table 1 below.

[0059] Step 5: Validate the improved model on the test set to evaluate its detection performance in small defects and complex backgrounds; Step S501: Measure the overlap between the predicted bounding box and the ground truth bounding box using IoU (Intersection over Union). In the formula, A is the predicted bounding box and B is the ground truth bounding box. When the IoU is greater than the threshold (0.5), the prediction is considered correct.

[0060] Table 2 shows that YOLOv8-PCS achieves a significant advantage in small defects (open circuit, spurious copper), especially in the "open circuit" category, where the mAP50 is improved by 12.2% to 0.958. CBAM, on the other hand, performs best in the "pseudo copper" category, which has strong texture interference, achieving an mAP50 of 0.926. In contrast, the basic model's detection performance degrades significantly in complex backgrounds. The improved YOLOv8-PCS model performs best in most defect categories, making it particularly suitable for complex backgrounds and scenes with subtle defects.

[0061] Table 2 Comparison of different models across major defect categories (mAP50)

[0062] Step 6: Post-process the test results to obtain the final surface defect test results for industrial products.

[0063] Step S601: After completing the prediction using the improved YOLOv8-PCS model, the output results need to be post-processed to obtain the final industrial product surface defect detection results. This step includes two processes: Non-maximum suppression (NMS) and weighted bounding box fusion (WBF). Step S602: Non-maximum suppression (NMS) removes redundant candidate boxes by setting IoU and confidence thresholds, retaining only the detection boxes with the highest confidence. The specific formula is: Step S603: When the IoU between candidate boxes is greater than the threshold θ=0.5 and the confidence level is lower than the threshold δ=0.4, discard candidate boxes with high overlap or low confidence.

[0064] Step S604: Weighted Boundary Fusion (WBF). After the candidate boxes are filtered by NMS, overlapping candidate boxes are further fused using a weighted average method to enhance the stability of bounding box localization. The specific formula is as follows: In the formula, Indicates the candidate box. This indicates the corresponding confidence level. The weights are calculated by summing the confidence scores to obtain the final bounding box positions. .

[0065] This step effectively solves problems such as blurred boundaries of small defects and too many overlapping candidate boxes, improving the robustness and accuracy of defect detection results while maintaining real-time performance.

[0066] After post-processing, the improved YOLOv8-PCS model further enhances the overall accuracy, with a final mAP50 of 0.942 and mAP50-95 of 0.515, indicating that the method can effectively eliminate redundant boxes and enhance the robustness and accuracy of detection.

[0067] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section.

[0068] The above description of the disclosed embodiments enables those skilled in the art to make or use the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the invention is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A non-destructive testing method for industrial product surfaces based on an improved YOLOv8, characterized in that, include: Images of surface defects in industrial products were acquired and a dataset was constructed. Data preprocessing was performed on the industrial product surface images. An improved YOLOv8 network model was constructed, introducing a spatial channel-selective kernel convolution module into the YOLOv8 backbone network to dynamically enhance channel and spatial feature representation, adapt the receptive field, and dynamically select and dual-reconstruct features. A coordinate-channel-space joint attention module was introduced into the classification branch of the YOLOv8 detection head to enhance the model's attention to small defect regions through a joint attention mechanism of feature coordinates, feature channels, and feature space. In the feature fusion part of the network, a four-scale detection architecture was improved by fusing high-resolution P2 layer features from the backbone. The improved YOLOv8 model was trained on the constructed dataset. The improved model was validated on the test set to evaluate its detection performance in small defects and complex backgrounds. The detection results were post-processed to obtain the final industrial product surface defect detection results.

2. The method for non-destructive testing of industrial product surfaces based on an improved YOLOv8 according to claim 1, characterized in that, The specific steps for acquiring surface defect images of industrial products and constructing a dataset are as follows: Prepare a printed circuit board surface defect dataset, including images of various defect types such as missing holes, mouse bites, open circuits, short circuits, stray wires, and pseudo-copper. Divide the images into a training set (70%), a validation set (20%), and a test set (10%). The objective function for constructing the dataset is expressed as: In the formula, For the input image, For defect category labels, This is a set of defect categories.

3. The method for non-destructive testing of industrial product surfaces based on an improved YOLOv8 according to claim 1, characterized in that, Data preprocessing for images of industrial product surfaces includes image normalization, resizing, and data augmentation; the normalization formula is as follows: In the formula, For pixel values, , The minimum and maximum pixel values ​​for the image are set; the input image size is adjusted uniformly; data enhancements include rotation, translation, flipping, brightness adjustment, and Mosaic stitching.

4. The method for non-destructive testing of industrial product surfaces based on an improved YOLOv8 according to claim 1, characterized in that, In optimizing the backbone network, the standard 3×3 convolutional layer in the YOLOv8 backbone is replaced with a spatial channel-selective kernel convolutional module; input feature X in The structure is divided into a main branch and a side branch: the main branch retains the original Bottleneck structure; the side branch performs dynamic feature reconstruction using SCKConv; and finally, the features are fused through concatenation and 1×1 convolution. ;in, Input features for the main branch; Input features for bypass branches; To perform residual bottleneck transformation on the main branch; To perform dynamic multi-scale feature reconstruction of bypass branches; ( This involves concatenating the feature maps output from the two branches along the channel dimension. The number of channels is merged into the target output channel.

5. The method for non-destructive testing of industrial product surfaces based on an improved YOLOv8 according to claim 1, characterized in that, The specific steps of dynamic feature selection and dual reconstruction are as follows: The base convolutional layer performs channel transformation and downsampling on the input feature F to obtain the depth feature Y to be refined: ;feature The data is sent to a spatial reconstruction unit to obtain preliminary reconstruction features. : Where SRU stands for Spatial Reconstruction Operation; Reconstruction Features Through selective kernel convolution refiner By utilizing a multi-scale dynamic receptive field mechanism, spatial augmentation features are generated. : Spatial enhancement features Reconstruction unit via channel The relationship between channels is modeled, and the data is decomposed into high-frequency and low-frequency channels. Compressed features are obtained through 1×1 convolution. : High-frequency characteristics after compression The data is fed into a grouped convolutional layer centered on selective kernel convolution (SKConv) and a pointwise convolutional layer (PwC) for dynamic interaction to generate the data. Low-frequency characteristics Supplement and reconstruct to generate : ; In the formula, Indicates splicing; Point convolution operation; reconstructing features and After concatenation, global average pooling is used. The generated adaptive weights are weighted to complete the information fusion between channels: In the formula, Use the Sigmoid activation function; This is a global average pooling operation; For splicing; Indicates element-wise multiplication; weighted feature Through the split summation operation The channel dimensions are restored and normalized to obtain the final output features. ; In the formula, This is a normalization operation; This is a splitting and summing operation.

6. The method for non-destructive testing of industrial product surfaces based on an improved YOLOv8 according to claim 1, characterized in that, In the optimization of the detection head, the original structure of the decoupled detection head in YOLOv8 includes a classification branch, a regression branch, and a confidence branch. A CCSA module is embedded before the classification branch. CCSA combines attention mechanisms across three dimensions: feature coordinates, feature channels, and feature space. The definitions of coordinate attention, channel attention, and spatial attention are as follows: Coordinate attention mechanism: Global average pooling is performed on the input feature F in both the horizontal and vertical directions to generate orientation-aware features. Subsequently, coordinate attention weights are obtained through weight transformation and element-wise multiplication. ; In the formula, This represents the generated coordinate attention map. This is the horizontal feature encoding function, which is a composite function of a 1×1 convolution and a sigmoid function following feature splitting. The vertical feature encoding function consists of a feature splitting operation followed by a 1×1 convolution and a Sigmoid activation function; the other part is an element-wise multiplication operation. This is the normalization coefficient for the width direction of the feature map; Let represent the normalization coefficient in the height direction of the feature map; ... In the formula, This represents the generated channel attention map. For the input feature map, It is a multilayer perceptron. Use the Sigmoid activation function; This is a global average pooling operation; For max-average pooling operation; spatial attention mechanism: In the formula, This represents the generated spatial attention map; This represents a 7×7 convolution operation. These are the characteristics after channel weighting; This is a global average pooling operation; This involves a max pooling operation; global average pooling and max pooling are used to generate feature descriptions in the spatial dimension, which are then processed by a 7×7 convolution to obtain a spatial attention map; the feature-weighted output is as follows: In the formula, represents element-wise multiplication; This represents the generated coordinate attention map; This represents the generated channel attention map; This represents the generated spatial attention map; After the feature maps from Backbone and CSSA are fused, they are fed into the classification branch and regression branch in the YOLOv8 decoupled detection head, respectively, and finally the defect category and bounding box prediction results are output.

7. The method for non-destructive testing of industrial product surfaces based on an improved YOLOv8 according to claim 1, characterized in that, In feature fusion, this invention expands the detection scale from the original three-scale output to a four-scale output. The specific steps are as follows: fusing features from the P3 layer. Upsampling is used to amplify the P2 feature to match its spatial dimensions; ; magnified features Compared to early P2 features from Backbone Perform concat stitching and merging; The fused features are processed by the C2f module to generate the final P2-scale features. ; 。 8. The method for non-destructive testing of industrial product surfaces based on an improved YOLOv8 according to claim 1, characterized in that, The specific steps to obtain the final surface defect detection results for industrial products are as follows: This step includes two processes: Non-maximum suppression (NMS) and weighted bounding box fusion (WBF). Non-maximum suppression (NMS) removes redundant candidate boxes by setting IoU and confidence thresholds, retaining only the detection boxes with the highest confidence. The specific formula is: Weighted bounding box fusion (WBF) further fuses overlapping candidate boxes after NMS filtering, using a weighted average method to enhance the stability of bounding box localization; the specific formula is as follows: In the formula, Indicates the candidate box. This indicates the corresponding confidence level. The weights are used as the basis for calculation; the final detection box positions are obtained by weighting and summing the results using confidence scores. ; i represents the index of the i-th candidate box participating in the fusion, and n represents the total number of candidate boxes participating in the weighted box fusion.

9. A surface non-destructive testing system for industrial products based on an improved YOLOv8, employing the surface non-destructive testing method for industrial products based on an improved YOLOv8 as described in any one of claims 1-8, characterized in that, include: The acquisition module acquires images of surface defects in industrial products and constructs a dataset. The system comprises the following modules: a preprocessing module for preprocessing images of industrial product surfaces; a YOLOv8 network model improvement module for constructing an improved YOLOv8 network model, with improvements made to the backbone network, detection head, and feature fusion components; a training module for training the constructed dataset using the improved YOLOv8 model; a validation module for validating the improved model on a test set and evaluating its detection performance in small defects and complex backgrounds; and an output module for post-processing the detection results to obtain the final industrial product surface defect detection results.

10. The industrial product surface non-destructive testing system based on the improved YOLOv8 according to claim 9, characterized in that, The YOLOv8 network model improvement module includes: a backbone network improvement unit, which introduces a spatial channel-selective kernel convolution module into the YOLOv8 backbone network and performs dynamic feature selection and dual reconstruction; a detection head improvement unit, which introduces a coordinate-channel-space joint attention module into the classification branch of the YOLOv8 detection head, enhancing the model's attention to small defect regions through a joint attention mechanism of feature coordinates, feature channels, and feature space; and a feature fusion improvement unit, which improves the network's feature fusion part by fusing high-resolution P2 layer features from the backbone to a four-scale detection architecture.