Lightweight PCB welding spot defect detection method based on improved YOLOv8

By improving the structure and module of the YOLOv8 model, the problems of insufficient accuracy and high resource requirements in PCB board solder joint defect detection are solved, higher detection accuracy and lower computational complexity are achieved, and the generalization ability of the model is enhanced.

CN120198403APending Publication Date: 2025-06-24CHANGZHOU UNIV
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510325687.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-19
Publication Date
2025-06-24

AI Technical Summary

Technical Problem

The prior art lacks accuracy in PCB board solder joint defect detection, and the model deployment resource demand is high, and lacks strong generalization capabilities.

Method used

By improving the YOLOv8 model, including applying the Ghostmodule module in the CBS module to replace Conv and form the G2Conv module for PConv, improving the C2f module to add G2Conv and G2bottleneck modules to form the G2host module, introducing the EA attention mechanism to the SPPF module, and using shared convolution and lightweight detection head LD-Head module.

Benefits of technology

It significantly improves the average accuracy of PCB solder joint defect detection, reduces the calculation amount and parameter amount of the model, enhances the generalization ability of the model, makes the detection results more accurate and the model lighter.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120198403A_ABST
    Figure CN120198403A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of PCB welding spot defect detection, in particular to a lightweight PCB welding spot defect detection method based on improved YOLOv8, which comprises the following steps: S1, acquiring a PCB welding spot image, and carrying out image preprocessing, image enhancement, data expansion and defect labeling to obtain a required PCB welding spot defect data set; s2, a CBS module of the YOLOv8 is improved by introducing G2Conv convolution; s3, a G2host module is introduced to improve a C2f module of the YOLOv8; s4, introducing an EA attention mechanism to improve an SPPF module; s5, a self-developed lightweight detection head LD-Head module is applied to replace an original Detect module; s6, training the improved YOLOv8n model by adopting the PCB welding spot defect data set to obtain a PCB welding spot defect detection model; and S7, the PCB welding spot defect detection model is adopted to detect the defects of the PCB welding spots. According to the detection method provided by the invention, the model complexity and the calculation amount of PCB welding spot defect detection can be remarkably reduced, and the detection precision of the model is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of PCB solder joint defect detection, and particularly relates to a lightweight PCB solder joint defect detection method based on improved YOLOv8. Background Technique

[0002] Due to the complex manufacturing process of the PCB board, during the component soldering process on the PCB board, solder joints are prone to defects such as less solder, more solder, untrimmed pins, bridging, and missed soldering. The existence of these defects greatly increases the production cost of the PCB board, and the presence of these defects on the PCB board will also shorten the service life of the PCB board. Therefore, it is particularly important to detect the defects of PCB board solder joints before leaving the factory.

[0003] Currently, object detection algorithms based on deep learning include two types. One is a two-stage object detection algorithm. For the two-stage object detection algorithm, first, some sample candidate boxes are generated through the algorithm, and then the samples are classified through a convolutional neural network. Common two-stage object detection algorithms include R-CNN, Faster-R-CNN, etc. The other is a one-stage object detection algorithm. This algorithm directly transforms the problem of object localization into a regression problem. The difference from the two-stage object detection is that it does not require candidate boxes. Common one-stage object detection algorithms include the YOLO series, SSD, etc. Although the current networks can be applied to PCB board solder joint defect detection, there is still much room for improvement in their accuracy. Summary of the Invention

[0004] The technical problem to be solved by the present invention is: In order to solve the above problems, the present invention provides a lightweight PCB solder joint defect detection method based on improved YOLOv8, which improves the average accuracy of PCB solder joint defect detection by improving YOLOv8, improves the accuracy of PCB board solder joint defect detection, and makes the deployment resource requirements lower, and strengthens the generalization ability of the model.

[0005] The technical solution adopted by the present invention to solve its technical problems is: A lightweight PCB solder joint defect detection method based on improved YOLOv8, comprising the following steps:

[0006] S1: Obtain PCB solder joint images to obtain the required PCB solder joint data set;

[0007] S2: Improve the CBS module of the YOLOv8 model, apply the Ghostmodule module, replace Conv with PConv (PartialConv) to form the G2Conv module, enhance the model's ability to capture effective input features, and reduce the computational amount of model operations;

[0008] S3: Improve the C2f module in the YOLOv8 model's Backbone. Incorporate the G2Conv convolution and the G2bottleneck module to form the G2ghost module, and replace the C2f module with the G2ghost module to obtain a lightweight feature extraction structure and reduce the model's complexity.

[0009] S4: Improve the SPPF module in the YOLOv8 model. Introduce the EA (EfficientAttention) attention mechanism to form the SPPF-EA module, which improves the model's detection accuracy without increasing the model's computational complexity.

[0010] S5: Improve the YOLOv8 detection head Head module, including using shared convolution, the lightweight detection head LD-Head module, and introducing a Scale layer to the output of the regression branch.

[0011] S6: Use the PCB solder joint defect dataset to train the improved YOLOv8 model in steps S2 - S5 to obtain a PCB solder joint defect detection model.

[0012] S7: Use the PCB solder joint defect detection model to detect the defects of PCB solder joints.

[0013] In step S1, after obtaining the PCB solder joint image, perform image quantity enhancement and defect annotation to obtain the required PCB solder joint dataset.

[0014] In step S1, after obtaining the PCB board image, first perform preliminary cropping; then preprocess the image through the mirror flipping algorithm, add noise interference to expand the data, and manually annotate the defects on the image to obtain a suitable dataset.

[0015] The specific steps of step S1 are as follows:

[0016] S1.1: Take the required PCB board image and crop it into an image of 640 pixels * 640 pixels according to the requirements.

[0017] S1.2: Preprocess the cropped PCB board image through the mirror flipping algorithm, add noise interference to expand the data for data augmentation, and then perform solder joint defect annotation on the PCB solder joint defect image to obtain the PCB solder joint defect dataset.

[0018] S1.3: Divide the annotated dataset to obtain the training dataset, validation dataset, and test dataset.

[0019] The specific steps of step S2 are as follows:

[0020] S2.1: In the CBS part of the YOLOv8 model, the principle of the Ghost module is adopted, and the Conv in the Ghost module is replaced with PConv to form the G2Conv convolution module, which reduces the convolution calculation amount while increasing the model's attention to key features;

[0021] S2.2: First, perform partial convolution on the input feature image to enhance the attention to key features and obtain the input feature map; that is, G2Conv first uses PConv, batch normalization, and an activation function to compress the input image in channels, select the key information channels, and generate the intrinsic feature map;

[0022] S2.3: Then, perform a series of inexpensive linear transformations on the obtained feature map through DConv (DepthwiseConv) to obtain more feature maps and increase features;

[0023] S2.4: Finally, combine all the obtained feature maps through concat to form the final output feature map.

[0024] The specific steps of step S3 are as follows:

[0025] S3.1: Replace all C2f modules of the YOLOv8 model with G2host modules to lightweight the feature extraction structure;

[0026] S3.2: The G2host module replaces the CBS module and the BatchNorm2d module in the C2f module with G2Conv and G2bottleneck modules respectively; to improve the model's attention to effective features, the G2host module obtains a higher attention to effective features through fewer convolution operations, reduces the calculation amount and the number of parameters of the model, and ensures the lightweight of the model.

[0027] S3.3: Each G2bottleneck module is mainly composed of G2Conv convolutions. The first G2Conv convolution is used as an expansion layer to increase the number of channels, and the second G2Conv convolution reduces the number of channels of the output feature map to match the input channel number. This structure effectively reduces the parameters and calculation amount of the model and improves the model detection efficiency.

[0028] The specific steps of step S4 are as follows: Replace all general convolutions of the SPPF module of the YOLOv8 model with G2Conv, and introduce the EA attention mechanism after the third MaxPool2d layer to form the SPPF-EA module, which reduces the model complexity while increasing the detection accuracy of the model.

[0029] The specific steps of step S5 are as follows: Improve the Detect module of YOLOv8. By referring to the principle of shared convolution, use the lightweight detection head LD-Head module, which avoids the computational redundancy of the model convolution operation and lightens the detection head module of the model.

[0030] The specific steps of step S5 are as follows:

[0031] S5.1: Reduce the three Detect modules of YOLOv8 to one LD-Head module;

[0032] S5.2: After the LD-Head module receives the three different-scale features output by the neck, first pass through a convolutional layer with a size of 1×1 to adjust the number of channels and unify the input number of channels;

[0033] S5.3: Then pool all the feature layers into a shared convolutional layer with a size of 3×3. After passing through two shared convolutional layers, extract the target category features and spatial feature branches.

[0034] Finally, in order to adapt to the differences in the target scales of different detection heads, after step S5.3, step S5.4 is also included: Introduce a Scale layer to perform feature scaling on the output of the regression branch.

[0035] The beneficial effects of the present invention are as follows. The lightweight PCB solder joint defect detection method based on the improved YOLOv8 of the present invention has the following remarkable effects:

[0036] 1. Through the self-made dataset, the PCB solder joint defect data required for the experiment can better meet the experimental environment, which is conducive to the improvement of detection accuracy;

[0037] 2. Improve the CBS module of the YOLOv8 model, apply the Ghostmodule module, replace Conv with PConv to form the G2Conv module, enhance the model's ability to capture effective input features, and reduce the computational amount of model operations. Compared with the original model, the improved YOLOv8 model has an increase of 1.6% in mAP@0.5 without increasing the model depth, and the number of parameters P, the computational amount Flops, and the size Size are reduced by 31.3%, 36.0%, and 29.0% respectively;

[0038] 3. Improve the C2f module of the YOLOv8 model by adding the G2Conv convolution and the G2bottleneck module to form the G2ghost module. Replace the C2f module with the G2ghost module to obtain a lightweight feature extraction structure and reduce the complexity of the model. Compared with the original model, the improved YOLOv8 model increases the mAP@0.5 by 2.9% without increasing the model depth, and reduces the number of parameters P, the amount of computation Flops, and the size Size by 46.9%, 43.8%, and 40.3% respectively.

[0039] 4. Improve the SPPF module in the YOLOv8 model by introducing the EA attention mechanism to form the SPPF-EA module, which improves the detection accuracy of the model without increasing the computational complexity of the model. Compared with the original model, the improved YOLOv8 model increases the mAP@0.5 by 2.3%, and the changes in the amount of computation, the number of parameters, and the size are almost zero.

[0040] 5. Improve the Head module of the YOLOv8 detector by adopting the concept of shared convolution, using the lightweight detector head LD-Head module, and introducing a Scale layer to the output of the regression branch to increase the model's detection ability for features of different scales. Compared with the original model, the improved YOLOv8 model increases the mAP@0.5 by 2%, and reduces the number of parameters P, the amount of computation Flops, and the size Size by 28.1%, 25.8%, and 24.2% respectively. Description of the Drawings

[0041] The present invention will be further described below in conjunction with the drawings and embodiments.

[0042] Figure 1 is the flowchart of the lightweight PCB solder joint defect detection method based on the improved YOLOv8 of the present invention.

[0043] Figure 2 are examples of the original PCB board images taken by the camera and the PCB solder joint defect datasets made by cropping, preprocessing, and noise interference at two different parts.

[0044] Figure 3 is the overall structure diagram of the improved YOLOv8 model of the present invention.

[0045] Figure 4 is the structure diagram of the G2Conv module in the present invention.

[0046] Figure 5 is the structure diagram of the G2ghost module in the present invention.

[0047] Figure 6 is the structure diagram of the SPPF-EA module in the present invention.

[0048] Figure 7 It is the structural diagram of the LD-Head module in the present invention.

[0049] Figure 8 It is the detection result diagram of the improved YOLOv8 model of the present invention. Specific implementation manners

[0050] Now, the present invention will be further described in detail with reference to the accompanying drawings. These drawings are all simplified schematic diagrams, only illustrating the basic structure of the present invention in a schematic manner, so they only show the components related to the present invention.

[0051] As Figure 1 shown, a lightweight PCB solder joint defect detection method based on the improved YOLOv8 of the present invention includes the following steps:

[0052] S1: Obtain PCB solder joint images to obtain the required PCB solder joint data set;

[0053] S2: Improve the CBS module of the YOLOv8 model, apply the Ghostmodule module, replace Conv with PConv (PartialConv) to form the G2Conv module, enhance the model's ability to capture effective input features, and reduce the computational complexity of the model operation;

[0054] S3: Improve the C2f module in the Backbone of the YOLOv8 model, add the G2Conv convolution and the G2bottleneck module to form the G2host module, replace the C2f module with the G2host module, and obtain a lightweight feature extraction structure to reduce the complexity of the model;

[0055] S4: Improve the SPPF module in the YOLOv8 model, introduce the EA (EfficientAttention) attention mechanism to form the SPPF-EA module, and improve the detection accuracy of the model without increasing the computational complexity of the model;

[0056] S5: Improve the YOLOv8 detection head Head module, including using shared convolution, using the lightweight detection head LD-Head module, and introducing a Scale layer to the output of the regression branch;

[0057] S6: Use the PCB solder joint defect data set to train the improved YOLOv8 model in steps S2-S5 to obtain a PCB solder joint defect detection model, and obtain the best training weight after training; in fact, steps S2-S5 are to construct an improved YOLOv8 object detection model to improve the accuracy of PCB solder joint defect detection.

[0058] S7: Use the PCB solder joint defect detection model to detect the defects of PCB solder joints, that is, put the best weights trained in step S6 into the test program to detect the test set, and finally compare the detection results with the original target detection results.

[0059] In step S1, after obtaining the PCB solder joint image, perform image quantity enhancement and defect annotation, and then obtain the required PCB solder joint data set.

[0060] In step S1, after obtaining the PCB board image, first perform preliminary cropping; then preprocess the image through the mirror flipping algorithm, add noise interference to expand the data, and manually annotate the defects on the image to obtain a suitable data set.

[0061] The specific steps of step S1 are as follows:

[0062] S1.1: Take the required PCB board image from the PCB board production workshop and crop it into an image of 640 pixels * 640 pixels according to the requirements;

[0063] S1.2: Preprocess the cropped PCB board image through the mirror flipping algorithm, add noise interference to expand the data for data enhancement, and then perform solder joint defect annotation on the PCB solder joint defect image to obtain the PCB solder joint defect data set;

[0064] S1.3: Divide the labeled data set to obtain the training data set, validation data set and test data set.

[0065] The specific steps of step S2 are as follows:

[0066] S2.1: In the CBS part of the YOLOv8 model, adopt the principle of the Ghostmodule module, and replace the Conv in the Ghostmodule with PConv to form the G2Conv convolution module, which can reduce the convolution calculation amount while improving the model's attention to key features;

[0067] S2.2: First perform partial convolution on the input feature image to strengthen the attention to key features and obtain the input feature map; that is, G2Conv first uses PConv, batch normalization and an activation function to compress the input image in channels, select the key information channels, and generate the inherent feature map;

[0068] S2.3: Then perform a series of cheap linear transformations on the obtained feature map through DConv (DepthwiseConv) to obtain more feature maps and increase features;

[0069] S2.4: Finally, all the obtained feature maps are combined through concat to form the final output feature map.

[0070] The specific steps of step S3 are as follows:

[0071] S3.1: Replace all C2f modules of the YOLOv8 model with G2host modules to lightweight the feature extraction structure;

[0072] S3.2: The G2host module replaces the CBS module and BatchNorm2d module in the C2f module with G2Conv and G2bottleneck modules respectively; to improve the model's attention to effective features, the G2host module obtains a higher attention to effective features through fewer convolution operations, reducing the computational amount and the number of parameters of the model, and ensuring the lightweight of the model.

[0073] S3.3: Each G2bottleneck module is mainly composed of G2Conv convolutions. The first G2Conv convolution is used as an expansion layer to increase the number of channels, and the second G2Conv convolution reduces the number of channels of the output feature map to match the number of input channels. This structure effectively reduces the parameters and computational amount of the model and improves the detection efficiency of the model.

[0074] The specific steps of step S4 are as follows: Replace all the general convolutions of the SPPF module of the YOLOv8 model with G2Conv, and introduce the EA attention mechanism after the third MaxPool2d layer to form the SPPF-EA module, reducing the model complexity while increasing the detection accuracy of the model.

[0075] The specific steps of step S5 are as follows: Improve the Detect module of YOLOv8. By referring to the principle of shared convolution, use the lightweight detection head LD-Head module to avoid the computational redundancy of the model convolution operation and lightweight the detection head module of the model.

[0076] The specific steps of step S5 are as follows:

[0077] S5.1: Reduce the three Detect modules of YOLOv8 to one LD-Head module;

[0078] S5.2: After the LD-Head module receives the three different-scale features output by the neck, first pass through a 1×1 convolutional layer to adjust the number of channels and unify the number of input channels;

[0079] S5.3: Then pool all the feature layers into a 3×3 shared convolutional layer. After two shared convolutional layers, extract the target category features and spatial feature branches.

[0080] Finally, in order to adapt to the different target scales of different detection heads, after step S5.3, step S5.4 is further included: introducing a Scale layer to the output of the regression branch for feature scaling.

[0081] The technical concept of the present invention is as follows: First, the Ghostmodule module is adopted, and the PConv is added to improve the original convolution combination of the Ghostmodule to form a new G2Conv convolution module and G2host module. These two modules are used to replace the original CBS module and C2f module of YOLOv8 respectively, strengthening the model's ability to capture effective feature information, reducing the computational complexity and the number of parameters of the model, and making the model more lightweight. Then, an EA attention mechanism is added to the model's SPPF module to improve the detection accuracy of the model. Finally, the LD-Head module is used to further reduce the computational complexity of the model and improve the detection ability for different-scale features.

[0082] The following are the specific implementation steps:

[0083] 1. Collect the original PCB board images;

[0084] Use a Hikvision camera to take pictures of the PCB boards produced in the PCB production workshop, and capture the original PCB images to obtain a preliminary set of original PCB board images.

[0085] 2. Perform data augmentation on the image set;

[0086] Crop the images in the image set. The original image size is a PCB board image of 4043 pixels * 3036 pixels. Since the original image is rectangular and has a long length and width, and there are some unnecessary parts in the picture content, randomly crop the picture to separately crop out the defective parts to be detected. The cropped size is uniformly 640 pixels * 640 pixels. The cropped images are enhanced through the mirror flipping algorithm and noise interference is added as Figure 2 shown.

[0087] 3. Label the defects in the enhanced images and divide them into a training set, a validation set, and a test set. Here, the LabelImg tool is used to label the defects in the enhanced images. There are a total of 1224 images, which are increased to 4896 images after mirror processing. They are divided into a training set and a test set according to a ratio of 9:1, obtaining a total of 4406 training set images and 490 test set images.

[0088] 4. Construct the overall structure of the improved YOLOv8 detection model;

[0089] The overall structure of the improved YOLOv8 detection model is as Figure 3As shown in the figure, first, all the CBS modules and C2f modules of the model are replaced with G2Conv modules and G2host modules to improve the model's attention to effective features and reduce the complexity of the model. Then, an EA attention mechanism is added to the SPPF module of the model to improve the detection accuracy of the model without increasing the computational load. Finally, the Head part of the model is replaced with an LD-Head module to further reduce the convolution computational load of the model and improve the model's detection ability for features of different scales.

[0090] This step specifically includes the following steps:

[0091] 4.1. Add G2Conv module

[0092] As Figure 4 shown in the overall structure diagram of the G2Conv module, applying the principle of the Ghostmodule module, replacing Conv with PConv to form the G2Conv module, to enhance the model's ability to capture effective input features and reduce the computational load of model operations. G2Conv first uses PConv to perform feature extraction on some input channels using Conv, avoiding the increase in FLOPs caused by frequent memory access. The FLOPs of PConv is F p :

[0093]

[0094] where h is the height of the output feature map, w is the width of the output feature map, k is the size of the convolution kernel, and c p is the number of output channels to which the convolution kernel belongs. When c p is only one-quarter of the regular c, the FLOPs of PConv is only one-sixteenth of the regular Conv, and the memory access volume G p of PConv is:

[0095]

[0096] At this time, the memory access volume G p of PConv is only one-quarter of the regular Conv. PConv only uses c p channels for spatial feature extraction, batch normalization, and an activation function to compress the input image channels, select key information channels, generate some intrinsic feature maps, and then the second step of G2Conv convolution performs a lightweight linear transformation on the feature map output in the first step, as shown in the formula:

[0097]

[0098] In the formula: Y i is the i-th feature map, Y ijThe j-th feature map obtained through the linear transformation operation of the i-th feature map, Φ ij represents a linear operation. m and s are randomly valued, but both m and s are smaller than n, where n is the number of input channels.

[0099] Assume the size of the input feature map is h×w×c, the size of the output feature map is h`×w`×n, the size of the ordinary convolution kernel is k×k, and the size of each linear convolution kernel is d×d, which is similar to k×k. The computational cost of ordinary convolution is h·w·n·c·k·k, and the computational cost of G2Conv is n / s·h`·w`·c p ·k·k + n / s·h`·w`·(s - 1)·d·d. By taking the ratio of the computational costs of ordinary convolution and G2Conv convolution, the theoretical ratio r can be calculated:

[0100]

[0101] In the formula: s is the number of linear transformations and s << c. It can be seen that the computational cost of ordinary convolution is s times that of G2Conv convolution. The application of G2Conv can reduce the computational cost and the number of parameters of the model, ensuring the lightweight of the model.

[0102] 4.2. Improved C2f module

[0103] Replace the C2f module in the YOLOv8 model with the G2host module. While retaining the effective information, it reduces the computational complexity of the model and saves additional computational expenses. The G2host module designed based on G2Conv convolution is as Figure 5 shown. This module consists of a G2Conv convolutional layer and n linearly stacked G2bottlenecks. This structure retains the effective information of the image, enhances the model's attention to the effective information, and greatly reduces the amount of computation of convolution, reducing the computational redundancy of the model.

[0104] 4.3. Improved SPPF module

[0105] The improved SPPF-EA module is formed by replacing the CBS module with the G2Conv module and adding the EA attention mechanism on the basis of the original SPPF module structure. The EA attention mechanism effectively improves the defect of the too high computational cost of dot product attention. The structure of the EA attention mechanism is as Figure 6 shown.

[0106] First, the feature vector X forms three projection matrices (Q, K, V) through three linear transformation layers. Q is the query matrix, K is the key matrix, and V is the value matrix. Then, the K matrix and the V matrix are first aggregated to form a global context vector. Next, the Q matrix is used to weight and extract values from the context vector to obtain the output vector. The EA attention mechanism does not generate corresponding attention maps for each position, but applies the K matrix as a feature mapping matrix to map global attention features, rather than just the attention map of a specific position. The application of the EA attention mechanism improves the model detection accuracy while not incurring excessive computational costs, ensuring the lightweight of the model.

[0107] 4.4. Improvement of the Head Module

[0108] Improve the Head module of YOLOv8, adopt the concept of shared convolution, and use the lightweight detection head LD-Head module; and introduce a Scale layer to the output of the regression branch.

[0109] Because the convolutional layer is frequently used to exchange channel information, the computational amount of the convolutional layer increases significantly. In this specific embodiment, a shared convolutional layer is introduced to reduce the model complexity of the detection head, reduce the computational amount and the number of parameters of the detection head, and without reducing the detection accuracy of the model. As Figure 7 shown, after the LD-Head module receives the three different-scale features output from the neck, it first passes through a convolutional layer with a size of 1×1 to adjust the number of channels and unify the input channel number. Then, all feature layers are pooled into a shared convolutional layer with a size of 3×3. After passing through two shared convolutional layers, the target category features and spatial feature branches are extracted. And in order to adapt to the different target scales of different detection heads, a Scale layer is introduced to the output of the regression branch for feature scaling to strengthen the detection ability for multi-scale features.

[0110] The application of the shared convolutional layer can avoid the problem of a sudden increase in computational amount caused by frequent calls to the convolutional layer, reduce the complexity of the model, improve the running speed of the model, make the model lightweight, facilitate the wide application of the model, and can further improve the classification and localization capabilities of the detection head. The application of the LD-Head module can not only reduce the computational amount of the model, improve the network running speed, but also improve the detection accuracy of the model and strengthen the multi-scale feature detection ability for PCB solder joints.

[0111] 5. Put the training set into the improved YOLOv8 object detection model for training;

[0112] The obtained PCB solder joint defect dataset is placed into the improved YOLOv8 model for training and run in Pycharm. For multiple improvements, multiple separate trainings are conducted to obtain ablation experiments. The experimental data is shown in Table 1. Table 1 is the experimental data on the effectiveness of the improved module of the YOLOv8 detection model. mAP@0.5 represents the performance index of the detection model, P represents the number of parameters, Flops represents the computational volume, and Size represents the size. From the experimental results in Table 1, it can be seen that compared with the mainstream module, the improved module of the present invention has a better improvement effect on the detection accuracy of PCB solder joint defects. The computational volume and the number of parameters of the model are both greatly reduced, and the model size is smaller, and the generalization ability of the model is stronger.

[0113] 6. Compare the performance of the improved YOLOv8 model with the original detection model;

[0114] To further verify the detection performance of the model, under the condition of keeping the training platform configuration information unchanged and the dataset the same, a performance comparison is made with the YOLOv8 detection model.

[0115] Table 2 shows the comparison of the experimental data of the ablation experiment on the effectiveness of the improved YOLOv8 model and the original YOLOv8 model of the present invention. It can be seen from Table 2 that compared with the original YOLOv8 detection model, the mAP@0.5 of the improved YOLOv8 detection model has increased by 3.4% respectively, and the number of parameters P, the computational volume Flops, and the size Size have decreased by 65.6%, 60.7%, and 62.9% respectively. By comparing with the original model, it fully shows that the improved model has stronger performance in detecting PCB solder joint defects, and the model is lighter and more convenient to be deployed on resource-constrained devices.

[0116] 7. Result diagram of the improved YOLOv8 model

[0117] Figure 8 The figure shows the detection results of the improved YOLOv8 model of the present invention. It can be seen that the improved detection model has converged and has practical application value.

[0118] Table 1 Ablation experiment on module effectiveness

[0119]

[0120] Table 2 Model comparison experiment

[0121]

[0122] Inspired by the above-described ideal embodiments of the present invention, through the above description, relevant staff can completely make various changes and modifications without departing from the technical idea of this invention. The technical scope of this invention is not limited to the content in the specification, and its technical scope must be determined according to the scope of the claims.

Claims

1. A lightweight PCB solder joint defect detection method based on improved YOLOv8, characterized in that: The following steps are involved: S1: Acquire PCB solder joint images to obtain the required PCB solder joint data set; S2: Improve the CBS module of the YOLOv8 model, apply the Ghostmodule module, and replace Conv with PConv to form a G2Conv module; S3: Improve the C2f module of Backbone in the YOLOv8 model, add G2Conv convolution and G2bottleneck modules to form the G2host module, and use the G2host module to replace the C2f module to obtain a lightweight feature extraction structure; S4: Improve the SPPF module in the YOLOv8 model and introduce the EA attention mechanism to form the SPPF-EA module; S5: Improve the YOLOv8 detection head module, including using shared convolution and lightweight detection head LD-Head module; S6: Use the PCB solder point defect dataset to train the improved YOLOv8 model in steps S2-S5 to obtain a PCB solder point defect detection model; S7: Detect defects in PCB solder joints using a PCB solder joint defect detection model.

2. The lightweight PCB solder joint defect detection method based on improved YOLOv8 as claimed in claim 1, characterized in that: In step S1, after acquiring the PCB solder joint image, image quantity enhancement and defect annotation are performed to obtain the required PCB solder joint data set.

3. The lightweight PCB solder joint defect detection method based on improved YOLOv8 as claimed in claim 2 is characterized in that: In step S1, after obtaining the PCB board image, it is first cropped; then the image is preprocessed by a mirror flip algorithm, and noise interference expansion data is added, and the defects on the image are manually marked to obtain a suitable data set.

4. The lightweight PCB solder joint defect detection method based on improved YOLOv8 as claimed in claim 3 is characterized in that: The specific steps of step S1 are: S1.1: Take the required PCB board image and crop it into an image of 640 pixels * 640 pixels as required; S1.2: The cropped PCB board image is preprocessed by using a mirror flip algorithm, and noise interference expansion data is added for data enhancement. Then, the PCB solder point defect image is annotated for solder point defects to obtain a PCB solder point defect dataset. S1.3: Divide the labeled data set into training data set, validation data set and test data set.

5. The lightweight PCB solder joint defect detection method based on improved YOLOv8 as claimed in claim 1, characterized in that: The specific steps of step S2 are: S2.1: In the CBS part of the YOLOv8 model, the principle of the Ghostmodule module is adopted, and the Conv in the Ghostmodule is replaced with PConv to form a G2Conv convolution module; S2.2: First, perform partial convolution on the input feature image to increase the focus on key features and obtain the input feature map; S2.3: Then DConv is used to perform a cheap linear transformation on the obtained feature maps to obtain more feature maps; S2.4: Finally, all obtained feature maps are combined through concat to form the final output feature map.

6. The lightweight PCB solder joint defect detection method based on improved YOLOv8 as claimed in claim 1, characterized in that: The specific steps of step S3 are: S3.1: Replace all C2f modules of the YOLOv8 model with G2host modules to lighten the feature extraction structure; S3.2: The G2host module replaces the CBS module and BatchNorm2d module in the C2f module with the G2Conv and G2bottleneck modules respectively; S3.3: Each G2bottleneck module is mainly composed of G2Conv convolutions. The first G2Conv convolution acts as an expansion layer to increase the number of channels, and the second G2Conv convolution reduces the number of channels of the output feature map to match the number of input channels.

7. The lightweight PCB solder joint defect detection method based on improved YOLOv8 as claimed in claim 1, characterized in that: The specific steps of step S4 are: replacing all the general convolutions of the SPPF module of the YOLOv8 model with G2Conv, introducing the EA attention mechanism after the third MaxPool2d layer, and combining them into an SPPF-EA module.

8. The lightweight PCB solder joint defect detection method based on improved YOLOv8 as claimed in claim 1, characterized in that: The specific steps of step S5 are: improving the Detect module of YOLOv8, by referring to the principle of shared convolution, and using a lightweight detection head LD-Head module.

9. The lightweight PCB solder joint defect detection method based on improved YOLOv8 as claimed in claim 8, characterized in that: The specific steps of step S5 are: S5.1: Reduce the three Detect modules of YOLOv8 to one LD-Head module; S5.2: After the LD-Head module receives the features of three different scales output by the neck, it first passes through a 1×1 convolutional layer to adjust the number of channels and unify the number of input channels; S5.3: Then all feature layers are pooled into a 3×3 shared convolutional layer. After two shared convolutional layers, the target category features and spatial feature branches are extracted.

10. The lightweight PCB solder joint defect detection method based on improved YOLOv8 as claimed in claim 9, characterized in that: After step S5.3, step S5.4 is also included: introducing a Scale layer into the output of the regression branch to perform feature scaling.

Citation Information

Cited By

  • Soldering tin defect detection method and device, electronic equipment and storage medium

    CN120411109A