PCB surface defect detection method, system and equipment based on improved YOLOv8 and medium

By designing efficient Powerful-IoU loss function in YOLOv8 and adopting a lightweight GhostConv module, the problems of low detection and recognition accuracy of PCB surface defects and complex model calculations in the prior art are solved, and more efficient defect detection accuracy and Regression rate.

CN119399140APending Publication Date: 2025-02-07SHAANXI UNIV OF SCI & TECH
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202411449968.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-17
Publication Date
2025-02-07

AI Technical Summary

Technical Problem

The existing single-stage object detection algorithm has low recognition accuracy in PCB surface defect detection, and has many model parameters and complex calculations, making it difficult to deploy to embedded devices with limited resources.

Method used

By designing an efficient Powerful-IoU loss function, combining the target size adaptive penalty factor and a gradient adjustment function based on anchor box quality, the anchor box is guided to regress along the effective path to solve the anchor box expansion problem. At the same time, lightweight GhostConv is used to replace standard convolution, and the GhostC2f module is designed to reduce the amount of model calculation and improve feature expression performance.

Benefits of technology

It significantly improves the accuracy and regression rate of PCB surface defect detection, solves the problem of anchor frame expansion, reduces the amount of model calculation, and is suitable for embedded devices with limited resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119399140A_ABST
    Figure CN119399140A_ABST
Patent Text Reader

Abstract

A PCB surface defect detection method based on improved YOLOv8 comprises the steps that pictures of PCB defects are obtained, labeling software is used for manual labeling and expansion processing, a data set of the PCB surface defects is made, and the data set is divided into a training set, a verification set and a test set; constructing a PCB surface defect detection network model based on the improved YOLOv8; using the training set to train the PCB surface defect detection network model based on the improved YOLOv8; evaluating the trained PCB surface defect detection network model based on the improved YOLOv8 by using a verification set and a test set; according to the invention, while the PCB surface defect detection precision is improved, the regression rate of defect detection can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of PCB defect detection, and in particular relates to a PCB surface defect detection method, system, equipment and medium based on improved YOLOv8. Background Art

[0002] As one of the important electronic components in the electronic information manufacturing industry, printed circuit board (PCB) is widely used in industries such as computers and communications. Almost all electronic devices need to use PCB. With the rapid development of the electronic manufacturing industry, the quality requirements for electronic equipment have gradually increased. As the core of electronic equipment, printed circuit board (PCB) is loaded with a variety of electronic components on its surface. In the assembly process of electronic components, common defects include loose soldering of components, solder leaks, wrong soldering, and position offset. These defects often affect the electrical performance of the entire printed circuit board, reduce equipment reliability, increase manufacturing costs, and even pose a threat to the personal safety of users. Therefore, PCB electronic component detection has extremely high application prospects and value in the PCB production process.

[0003] The target detection algorithm based on deep learning is divided into a two-stage target detection algorithm based on regional convolution and a single-stage target detection algorithm based on regression. The two-stage target detection algorithm mainly includes R-CNN, Fast R-CNN and Faster R-CNN. The recognition accuracy of the two-stage target detection algorithm is relatively high, but its detection process is carried out in two steps, so the detection speed is slow and it cannot perform real-time detection well. The single-stage target detection algorithm mainly includes YOLO (You Only LookOnce), YOLO9000, YOLOv3, YOLOv4, YOLOv5, etc. The core of the single-stage target detection algorithm is to treat the target detection problem as a regression problem, that is, to directly regress the positions of all bounding boxes and all possible categories, so the efficiency and detection speed of the single-stage target detection algorithm are relatively high, but the current single-stage target detection algorithm has relatively low recognition accuracy and cannot meet the actual PCB surface defect detection requirements. At the same time, most deep learning models have many parameters, large model size, complex calculations, and are not easy to deploy to embedded devices with limited resources.

[0004] The patent application document with publication number CN 118071733 A discloses a PCB bare board defect detection method based on an improved YOLOv8 neural network. By adopting a focus modulation module and using a BEMA attention module and an Inner-Shape-Iou loss function, the target in the image can be accurately located and the generalization ability of the model can be improved. However, due to the expansion of the anchor frame of the Inner-Shape-Iou loss function during the regression process, the convergence speed is significantly slowed down. Summary of the invention

[0005] In order to overcome the shortcomings of the above-mentioned prior art, the purpose of the present invention is to provide a PCB surface defect detection method, system, device and medium based on improved YOLOv8. An efficient Powerful-IoU loss function is designed by combining a target size adaptive penalty factor and a gradient adjustment function based on the quality of an anchor frame. The PIoU loss guides the anchor frame to regress along a valid path, thereby converging faster than the existing iou-based loss, and can solve the expansion problem of the anchor frame in the regression process. Secondly, a lightweight GhostConv is used to replace the standard convolution, and then a GhostC2f module is designed to replace part of the C2f module to reduce the amount of model calculation and improve the feature expression performance. After improving the traditional YOLOv8, the present invention improves the accuracy and regression rate of PCB surface defect detection, and is suitable for defect detection on the surface of PCB boards.

[0006] In order to achieve the above object, the technical solution adopted by the present invention is:

[0007] A PCB surface defect detection method based on improved YOLOv8 includes the following steps:

[0008] S1: Obtain images of PCB defects, and use annotation software to manually annotate and expand them to create a dataset of PCB surface defects, and divide the dataset into training set, validation set, and test set;

[0009] S2: Build a PCB surface defect detection network model based on improved YOLOv8;

[0010] S3: Use the training set obtained in step 1 to train the PCB surface defect detection network model based on improved YOLOv8 constructed in step S2;

[0011] S4: Use the validation set and test set obtained in step 1 to evaluate the PCB surface defect detection network model based on improved YOLOv8 trained in step S3.

[0012] The specific operation steps of step S2 include:

[0013] The original YOLOv8 network structure includes a backbone network (Backbone), a neck network (Neck), and a head network (Head). The backbone network (Backbone) layer uses the C2f module to reduce the network size. The neck network (Neck) layer uses the SPPF module to perform pooling operations of different scales. The head network (Head) layer includes a detection head and a classification head.

[0014] S21: Use lightweight GhostConv to replace standard convolution. Ghostbottleneck consists of a convolution layer coupled with multiple GhostConv layers. Design the GhostC2f module and use Ghostbottleneck to replace all bottlenecks in the C2f module in the original YOLOv8 network.

[0015] S22: Add SimAM attention mechanism in the neck network;

[0016] S23: Use the Powerful-IoU loss function to replace the IoU loss function in the original YOLOv8 network. The Powerful-IoU loss function guides the anchor box to regress along the effective path.

[0017] Furthermore, the GhostC2f module described in step S21 adopts an inter-layer feature fusion strategy and truncated gradient flow technology. The GhostC2f module uses the convolution method of GhostConv. The convolution method adopts a uniform mixing operation to penetrate the standard convolution information into the deeply generated information to separate the convolution. Ghostbottleneck is composed of a convolution layer coupled with multiple GhostConv layers. The GhostC2f module is designed to replace all bottlenecks in the C2f module in the original YOLOv8 network with Ghostbottleneck.

[0018] Furthermore, in step S22, the SimAM attention mechanism is added to the neck network (Neck) and connected to the three detection layers. Combining the spatial position features and channel information, the SimAM attention mechanism constructs an energy function e t (w t ,b t ,y,x i ), the specific formula of SimAM attention mechanism is as follows:

[0019]

[0020] Formula (1) is the priority using energy function expression e t (w t ,b t ,y,x i ) represents the scalar yt and y0 are represented by -1 and 1 respectively, and the regularization term λ is introduced, and formula (2) is obtained to represent the energy function, and formulas (3) and (4) are weights w t With deviation b t The calculation formula for the minimum energy is As shown in formula (5), formula (6) is the formula of SimAM;

[0021] Among them, w t is the weight, b t is the deviation, λ is the regular term, and Represent the target neuron t and other neurons x respectively i Linear transformation, i represents the spatial dimension index, M represents the number of neurons, μ t and They represent the mean and variance of all neurons in the channel except t, sigmoid is a unit function, X represents the input feature, and E represents the minimum energy.

[0022] Further, in step S23, the Powerful-IoU loss function is combined with a target size adaptive penalty factor and a gradient adjustment function based on the quality of the anchor box, and then a non-monotonic attention layer is introduced, and the non-monotonic attention layer is combined with the Powerful-IoU loss function, and the Powerful-IoU loss function guides the anchor box to regress along a valid path;

[0023] The specific formula of the Powerful-IoU loss function is as follows:

[0024]

[0025]

[0026] Among them, w gt is the width of the real frame, h gt is the height of the real box, w is the width of the predicted box, and h is the height of the predicted box.

[0027] The specific method of step 4 is: using the validation set and the test set obtained in step 1 to test the PCB surface defect detection network model based on improved YOLOv8 constructed in step 2, and the evaluation indicators of the model detection accuracy are mean average precision (mAP), recall rate (R), precision (P) and F1 score;

[0028] The accuracy (P) is calculated as the ratio of the number of accurately predicted positive samples (TP) to the total number of predicted positive samples (TP+FP), as shown in formula (9);

[0029]

[0030] The recall rate is the ratio of correctly predicted TP to TP+FN, as shown in formula (10);

[0031]

[0032] Among them, TP and FP represent positive and negative samples predicted to be true, and FN represents positive samples predicted to be false.

[0033] In the average precision, m is the average value, N is the total number of categories, AP i represents the average accuracy of each category, and finally mAP can be obtained, as shown in formula (11);

[0034]

[0035] The F1 score represents the harmonic mean of precision P and recall R, as shown in formula (12);

[0036]

[0037] Among them, P is the precision rate and R is the recall rate.

[0038] The present invention also provides a PCB surface defect detection system based on improved YOLOv8, comprising:

[0039] The data set processing module is used to obtain pictures of PCB defects, and use annotation software to perform manual annotation and expansion processing to produce a data set of PCB surface defects, and divide the data set into a training set, a validation set, and a test set;

[0040] Network model building module, used to build a PCB surface defect detection network model based on improved YOLOv8;

[0041] A network model training module is used to train a PCB surface defect detection network model based on improved YOLOv8 using a training set;

[0042] The network model evaluation module is used to evaluate the trained PCB surface defect detection network model based on improved YOLOv8 using the validation set and the test set.

[0043] The present invention also provides a PCB surface defect detection device based on improved YOLOv8, comprising:

[0044] Memory: a computer program for storing the above-mentioned PCB surface defect detection method based on improved YOLOv8, which is a computer-readable device;

[0045] Processor: used to implement the PCB surface defect detection method based on improved YOLOv8 when executing the computer program.

[0046] The present invention also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it can implement the PCB surface defect detection method based on improved YOLOv8.

[0047] Compared with the prior art, the present invention has the following technical effects:

[0048] The present invention designs an efficient PIoU loss function by combining a target size adaptive penalty factor and a gradient adjustment function based on the quality of the anchor frame. The PIoU loss guides the anchor frame to regress along a valid path, thereby converging faster than the existing iou-based loss and solving the expansion problem of the anchor frame during the regression process. Secondly, the present invention adopts a lightweight GhostConv instead of the standard convolution, and then designs a GhostC2f module to replace part of the C2f module, thereby reducing the amount of model calculation and improving the feature expression performance.

[0049] In summary, the present invention has good performance in PCB surface defect detection, which not only ensures the improvement of PCB surface defect detection accuracy, but also improves the regression rate of defect detection. BRIEF DESCRIPTION OF THE DRAWINGS

[0050] Figure 1 It is a brief schematic diagram of the process of the present invention.

[0051] Figure 2 It is a schematic diagram of the GhostConv structure of the present invention.

[0052] Figure 3 It is a schematic diagram of the Ghostbottleneck structure of the present invention.

[0053] Figure 4 It is a schematic diagram of the GhostC2f module structure of the present invention.

[0054] Figure 5 Schematic diagram of the Powerful-IoU loss function of the present invention.

[0055] Figure 6 This is a network architecture diagram of the improved YOLOv8 of the present invention. DETAILED DESCRIPTION

[0056] The following will be combined with the accompanying drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. The described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. Under the premise of not departing from the design concept of the present invention, various modifications and improvements made by ordinary persons in the art to the technical solutions of the present invention should all fall within the protection scope of the present invention.

[0057] like Figure 1 As shown, a lightweight steel surface defect detection method based on improved YOLOv8n includes the following steps:

[0058] S1: Obtain images of PCB defects, and use annotation software to manually annotate and expand them to create a dataset of PCB surface defects, and divide the dataset into training set, validation set, and test set;

[0059] The PCB surface defect dataset of the embodiment of the present invention is a public synthetic dataset, released by Peking University, which contains 1,386 images for detection, classification and registration tasks. However, the dataset has few samples and unbalanced categories, so the dataset is expanded, mainly translating, rotating, mirroring, changing brightness and adding noise to the images in the dataset. The PCB defect images are manually labeled using the Label Img tool software, and the defect categories are divided into six types of defects: missing holes, mouse bites, open circuits, short circuits, strays and pseudo copper. The category and location of the defect in each image are marked, and stored in the YOLOv8 data format, and then the labeled PCB surface defect dataset is divided into a training set, a validation set and a test set in a ratio of 7:1:2. The training set is used for model training, the validation set is used for model verification, and the test set is used for model testing.

[0060] S2: Build a PCB surface defect detection network model based on improved YOLOv8;

[0061] The original YOLOv8 network structure includes a backbone network (Backbone), a neck network (Neck), and a head network (Head). The backbone network (Backbone) layer uses the C2f module to reduce the network size. The neck network (Neck) layer uses the SPPF module to perform pooling operations of different scales. The head network (Head) layer includes a detection head and a classification head.

[0062] S21: Use lightweight GhostConv to replace standard convolution. Ghostbottleneck consists of a convolution layer coupled with multiple GhostConv layers. Design GhostC2f module to replace all bottlenecks in the C2f module in the original YOLOv8 network with Ghostbottleneck. Use the designed GhostC2f module to replace some C2f modules in the YOLOv8 network structure to reduce the amount of model calculation and improve feature expression performance.

[0063] The GhostC2f module adopts the inter-layer feature fusion strategy and truncated gradient flow technology, which helps to amplify the changes in learning features between different network layers, effectively reduce the impact of redundant gradient information, and enhance the learning ability of the network. The GhostC2f module uses the convolution method of GhostConv, which uses a uniform mixing operation to infiltrate standard convolution information into the deeply generated information, so that the convolution can be separated; Ghostbottleneck consists of a convolution layer coupled with multiple GhostConv layers. This design combines the powerful feature extraction capability of traditional convolution with the efficient computing performance of GhostConv; the GhostC2f module is designed to replace all bottlenecks in the C2f module in the original YOLOv8 network with Ghostbottleneck.

[0064] The structure of GhostConv is as follows Figure 2 As shown in Figure 1, the core Ghost module of GhostConv generates feature maps through original convolution and cheap operations. The convolution method uses uniform mixing operations to penetrate the standard convolution information into the deeply generated information, making it separable.

[0065] Ghostbottleneck structure Figure 3 As shown in the figure, Ghostbottleneck consists of a convolutional layer coupled with multiple GhostConv layers; this design combines the powerful feature extraction capabilities of traditional convolution with the efficient computing performance of GhostConv. The structure is good at extracting rich features at different levels and scales, thereby improving the processing speed of redundant information.

[0066] GhostC2f structure is as follows Figure 4As shown in Figure 1, the GhostC2f module replaces all bottlenecks in the C2f module in the original network with Ghostbottleneck. The redesigned GhostC2f module adopts an inter-layer feature fusion strategy and truncated gradient flow technology, which helps to amplify the changes in learning features between different network layers, effectively reduce the impact of redundant gradient information, and enhance the learning ability of the network. The integration of GhostConv and GhostC2f modules greatly reduces the count of traditional 3×3 convolutions found in the original architecture, thereby greatly saving computing resources and training time, and reducing the overall model size.

[0067] S22: Add SimAM attention mechanism in the neck network to improve information capture capability and enhance the ability to locate small target defect features.

[0068] Furthermore, the SimAM attention mechanism does not increase the amount of additional parameters, ensuring the lightweight of the model while enhancing the model's ability to capture small target defect information.

[0069] The SimAM attention mechanism is added to the neck network (Neck) and connected to the three detection layers. Combining the spatial position features and channel information, the SimAM attention mechanism constructs the energy function e t (w t ,b t ,y,x i ), explore the importance of neurons, focus on neurons containing important information, and enhance the ability to locate small target defect features. The specific formula of SimAM attention mechanism is as follows:

[0070]

[0071] Formula (1) is the priority using energy function expression e t (w t ,b t ,y,x i ) represents the scalar y t and y0 are represented by -1 and 1 respectively, and the regularization term λ is introduced, and formula (2) is obtained to represent the energy function, and formulas (3) and (4) are weights w t With deviation b t The calculation formula for the minimum energy is As shown in formula (5), formula (6) is the formula of SimAM;

[0072] Among them, w t is the weight, b t is the deviation, λ is the regular term, and Represent the target neuron t and other neurons x respectively iLinear transformation, i represents the spatial dimension index, M represents the number of neurons, μ t and They represent the mean and variance of all neurons in the channel except t, sigmoid is a unit function, X represents the input feature, and E represents the minimum energy.

[0073] S23: The IoU loss function in the original YOLOv8 network is replaced by the Powerful-IoU loss function. The Powerful-IoU loss function guides the anchor box to regress along the effective path. By combining the penalty factor with ideal characteristics and the gradient adjustment function based on the quality of the anchor box, the anchor box expansion problem is effectively solved, the loss converges faster, and the regression performance of the network is improved.

[0074] Further, in step S23, the Powerful-IoU loss function combines the target size adaptive penalty factor and the gradient adjustment function based on the anchor box quality, and then introduces a non-monotonic attention layer, and combines the non-monotonic attention layer with the Powerful-IoU loss function. The Powerful-IoU loss function guides the anchor box to regress along the effective path, thereby recovering faster than the existing IOU-based loss.

[0075] like Figure 5 As shown, it is a schematic diagram of the loss factor of Powerful-IoU. The PIoU loss only uses the edge length of the target box as the denominator of the loss factor. The specific formula is as follows:

[0076]

[0077] Among them, w gt is the width of the real frame, h gt is the height of the real box, w is the width of the predicted box, and h is the height of the predicted box.

[0078] S3: Use the training set obtained in step 1 to train the PCB surface defect detection network model based on improved YOLOv8 constructed in step S2;

[0079] The specific method of step 3 is:

[0080] S31: The data set is divided into training set, test set and validation set in a ratio of 7:1:2. The initial learning rate is 0.01, the optimizer selects SGD, the momentum factor is 0.937, the weight decay coefficient is 0.0005, the training round epochs is 300, the training batch is 32, and the img-size is set to 640×640. The training set is used to train the improved YOLOv8 PCB surface defect detection network model;

[0081] The experimental hardware configuration uses an Intel Core i7-8750H CPU@2.20GHz processor, a 4G video memory GPU, 16G memory, the operating system is Windows 11, the development platform is Pycharm, the editing language is Python, the deep learning framework is Pytorch, and the GPU acceleration library is CUDA11.7.

[0082] S4: Use the validation set and test set obtained in step 1 to evaluate the PCB surface defect detection network model based on improved YOLOv8 trained in step S3. The improved YOLOv8 architecture is shown in the figure below: Figure 6 As shown, the improved YOLOv8 PCB surface defect detection network model includes input, backbone, neck and head. The original YOLOv8 is used as the basic model framework, and the network backbone is improved. All standard convolutions in the neck network are replaced by lightweight GhostConv. Ghostbottleneck consists of a convolution layer coupled with multiple GhostConv layers. Then, all bottlenecks in the C2f module in the original network are replaced by Ghostbottleneck. A GhostC2f module is designed. All C2f modules in the neck network are replaced by GhostC2f modules, which can effectively reduce the complexity of the neck network. A SimAM module is added to the neck network to improve the feature extraction efficiency of the improved model. The Powerful-IoU loss function is used to replace the initial YOLOv8 loss function to improve the regression performance of the network.

[0083] The specific method of step 4 is:

[0084] In order to evaluate the performance of the PCB defect detection algorithm proposed in this embodiment, the validation set and test set obtained in step 1 are used to test the PCB surface defect detection network model based on improved YOLOv8 constructed in step 2. The accuracy index mainly adopts the mean average precision (mAP), while considering the precision (P), recall (R), F1 score and average precision (AP). The expression is as follows:

[0085]

[0086] Among them, TP is the number of positive samples judged as positive samples by the model; FP is the number of negative samples judged as positive samples by the model; FN is the number of positive samples judged as negative samples by the model; n is the number of defect categories judged; AP is the average value of precision under recall rate, which means that P and R are the areas enclosed by the vertical and horizontal coordinates respectively; mAP is the mean of all APs, and the larger the mAP, the better the detection accuracy. In this embodiment, the PCB surface defect detection network model using the improved YOLOv8 is improved by 1.4% in precision, 2.3% in recall, and 1.4% in average accuracy (mAP). It is significantly better than other comparison models.

[0087] The present invention also provides a PCB surface defect detection system based on improved YOLOv8, comprising:

[0088] The data set processing module is used to obtain the images of PCB defects in step 1, and use the annotation software to perform manual annotation and expansion processing to produce a data set of PCB surface defects, and divide the data set into a training set, a validation set, and a test set;

[0089] A network model building module is used to implement the construction of a PCB surface defect detection network model based on improved YOLOv8 in step 2;

[0090] A network model training module is used to implement step 3 to train the PCB surface defect detection network model based on improved YOLOv8 constructed in step S2 using the training set obtained in step 1;

[0091] The network model evaluation module is used to implement the evaluation of the PCB surface defect detection network model based on the improved YOLOv8 trained in step S3 using the verification set and test set obtained in step 1 in step 4.

[0092] The present invention also provides a PCB surface defect detection device based on improved YOLOv8, comprising:

[0093] Memory: a computer program for storing the above-mentioned PCB surface defect detection method based on improved YOLOv8, which is a computer-readable device;

[0094] Processor: used to implement the PCB surface defect detection method based on improved YOLOv8 when executing the computer program.

[0095] The present invention also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it can implement the PCB surface defect detection method based on improved YOLOv8.

[0096] The above embodiments are only for illustrating the technical concept and features of the present invention, and their purpose is to enable people familiar with the technology to understand the content of the present invention and implement it accordingly, and they cannot be used to limit the protection scope of the present invention. Any equivalent transformation or modification made according to the spirit of the present invention should be included in the present invention.

Claims

1. A PCB surface defect detection method based on improved YOLOv8, characterized in that: The following steps are involved: S1: Obtain images of PCB defects, and use annotation software to manually annotate and expand them to create a dataset of PCB surface defects, and divide the dataset into training set, validation set, and test set; S2: Build a PCB surface defect detection network model based on improved YOLOv8; S3: Use the training set obtained in step 1 to train the PCB surface defect detection network model based on improved YOLOv8 constructed in step S2; S4: Use the validation set and test set obtained in step 1 to evaluate the PCB surface defect detection network model based on improved YOLOv8 trained in step S3.

2. According to a PCB surface defect detection method based on improved YOLOv8 according to claim 1, it is characterized in that: The specific operation steps of step S2 include: The original YOLOv8 network structure includes a backbone network (Backbone), a neck network (Neck), and a head network (Head). The backbone network (Backbone) layer uses the C2f module to reduce the network size. The neck network (Neck) layer uses the SPPF module to perform pooling operations of different scales. The head network (Head) layer includes a detection head and a classification head. S21: Use lightweight GhostConv to replace standard convolution. Ghostbottleneck consists of a convolution layer coupled with multiple GhostConv layers. Design the GhostC2f module and use Ghostbottleneck to replace all bottlenecks in the C2f module in the original YOLOv8 network. S22: Add SimAM attention mechanism in the neck network; S23: Use the Powerful-IoU loss function to replace the IoU loss function in the original YOLOv8 network. The Powerful-IoU loss function guides the anchor box to regress along the effective path.

3. A PCB surface defect detection method based on improved YOLOv8 according to claim 2, characterized in that: The GhostC2f module described in step S21 adopts an inter-layer feature fusion strategy and truncated gradient flow technology. The GhostC2f module uses the convolution method of GhostConv. The convolution method adopts a uniform mixing operation to penetrate the standard convolution information into the deeply generated information to separate the convolution. Ghostbottleneck is composed of a convolution layer coupled with multiple GhostConv layers. The GhostC2f module is designed to replace all bottlenecks in the C2f module in the original YOLOv8 network with Ghostbottleneck.

4. A PCB surface defect detection method based on improved YOLOv8 according to claim 2, characterized in that: In step S22, the SimAM attention mechanism is added to the neck network (Neck) and connected to the three detection layers. Combining the spatial position features and channel information, the SimAM attention mechanism constructs an energy function e t (w t ,b t ,y,x i ), the specific formula of SimAM attention mechanism is as follows: Formula (1) is the priority using energy function expression e t (w t ,b t ,y,x i ) represents the scalar y t and y0 are represented by -1 and 1 respectively, and the regularization term λ is introduced, and formula (2) is obtained to represent the energy function, and formulas (3) and (4) are weights w t With deviation b t The calculation formula for the minimum energy is As shown in formula (5), formula (6) is the formula of SimAM; Among them, w t is the weight, b t is the deviation, λ is the regular term, and Represent the target neuron t and other neurons x respectively i Linear transformation, i represents the spatial dimension index, M represents the number of neurons, μ t and They represent the mean and variance of all neurons in the channel except t, sigmoid is a unit function, X represents the input feature, and E represents the minimum energy.

5. A PCB surface defect detection method based on improved YOLOv8 according to claim 2, characterized in that: In step S23, the Powerful-IoU loss function combines the target size adaptive penalty factor and the gradient adjustment function based on the anchor box quality, and then introduces a non-monotonic attention layer, and combines the non-monotonic attention layer with the Powerful-IoU loss function, and the Powerful-IoU loss function guides the anchor box to regress along the effective path; The specific formula of the Powerful-IoU loss function is as follows: Among them, w gt is the width of the real frame, h gt is the height of the real box, w is the width of the predicted box, and h is the height of the predicted box.

6. A PCB surface defect detection method based on improved YOLOv8 according to claim 1, characterized in that: The specific method of step 4 is: using the validation set and the test set obtained in step 1 to test the PCB surface defect detection network model based on improved YOLOv8 constructed in step 2, and the evaluation indicators of the model detection accuracy are mean average precision (mAP), recall rate (R), precision (P) and F1 score; The accuracy (P) is calculated as the ratio of the number of accurately predicted positive samples (TP) to the total number of predicted positive samples (TP+FP), as shown in formula (9); The recall rate is the ratio of correctly predicted TP to TP+FN, as shown in formula (10); Among them, TP and FP represent positive and negative samples predicted to be true, and FN represents positive samples predicted to be false. In the average precision, m is the average value, N is the total number of categories, AP i represents the average accuracy of each category, and finally mAP can be obtained, as shown in formula (11); The F1 score represents the harmonic mean of precision P and recall R, as shown in formula (12); Among them, P is the precision rate and R is the recall rate.

7. A PCB surface defect detection system based on improved YOLOv8 based on the method according to any one of claims 1 to 6, characterized in that: include: The data set processing module is used to obtain pictures of PCB defects, and use annotation software to perform manual annotation and expansion processing to produce a data set of PCB surface defects, and divide the data set into a training set, a validation set, and a test set; Network model building module, used to build a PCB surface defect detection network model based on improved YOLOv8; A network model training module is used to train a PCB surface defect detection network model based on improved YOLOv8 using a training set; The network model evaluation module is used to evaluate the trained PCB surface defect detection network model based on improved YOLOv8 using the validation set and the test set.

8. A PCB surface defect detection device based on improved YOLOv8, characterized in that: include: Memory: a computer program storing a PCB surface defect detection method based on improved YOLOv8 as described in any one of claims 1 to 6, which is a computer-readable device; Processor: used to implement a PCB surface defect detection method based on improved YOLOv8 as described in any one of claims 1-6 when executing the computer program.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, it can implement a PCB surface defect detection method based on improved YOLOv8 as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • PCB bare board defect detection method based on improved YOLOv8 neural network

    CN118071733A

  • System and method for detecting surface defects of lithium battery pole piece

    CN116934762A

  • Traffic sign detection method and system based on YOLOv5

    CN116977976A

  • Method, system and equipment for detecting flaws of YOLOv7 fancy cloth

    CN118485628A

  • Lightweight PCB defect detection method based on improved YOLOv8 algorithm

    CN118608509A