Lightweight PCB defect detection method and device based on improved YOLOv8n and storage medium
By improving the YOLOv8n model, the Ghost-HGNetV2 network, C2f-Faster module, GCDetect module and Inner-MPDIoU loss function are adopted, and combined with channel pruning technology, the problems of large model calculation and slow inference speed in PCB defect detection are solved, and efficient and accurate defect detection is achieved.
Patent Information
- Application Number
- CN202510126144.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-27
- Publication Date
- 2025-03-04
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
When existing PCB defect detection technology is applied in embedded systems with resource-constrained resources, the model calculation is large and the inference speed is slow, making it difficult to meet the multiple requirements of modern industrial environments for efficiency, accuracy and real-time.
By improving the YOLOv8n model, Ghost-HGNetV2 network, C2f-Faster module, GCDetect module and Inner-MPDIoU loss function are used, combined with channel pruning technology, the model calculation amount and the inference speed are reduced.
The accuracy and inference speed of PCB defect detection are improved, and the contradiction between detection accuracy and inference speed is solved, making the model suitable for embedded devices with resource-constrained.
Smart Images

Figure CN119559178A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure belongs to the field of computer vision technology, and in particular to a lightweight PCB defect detection method, device and storage medium based on improved YOLOv8n. Background Art
[0002] As a core component of electronic devices, PCB directly affects the performance, stability and safety of products. Therefore, PCB quality inspection plays a vital role in the production process of electronic products. As electronic devices continue to develop towards high performance, low power consumption and miniaturization, the design and production of PCBs are becoming more and more complex, which makes their quality inspection more difficult and important. Traditional inspection methods usually rely on manual inspection or automated inspection based on classic image processing algorithms.
[0003] Although manual inspection can find some obvious defects, its main problem is that it is time-consuming, labor-intensive, and easily affected by human factors. The operator's experience and judgment ability directly determine the accuracy of the detection results, and there is a large instability. In addition, although traditional image processing methods, such as edge detection, threshold segmentation, and morphological operations, can play a certain role in the detection of some simple defects, their limitations are also obvious. These methods usually require manual setting of rules and parameters, and cannot flexibly cope with complex production environments. For example, the detection accuracy of the template matching-based method is significantly reduced when faced with complex backgrounds and large defect changes. In addition, these classic methods have a slow processing speed and are difficult to meet the multiple requirements of efficiency, accuracy, and real-time performance in modern industrial environments. Especially in the scenarios of mass production and rapid detection, there are significant performance bottlenecks.
[0004] With the rapid development of deep learning technology, methods based on convolutional neural networks (CNNs) have made significant progress in the field of PCB defect detection. In particular, the YOLO (You Only Look Once) series of algorithms can achieve fast and accurate image detection through end-to-end training, greatly improving the efficiency and accuracy of automated detection. The advantages of the YOLO series of algorithms lie in their efficient detection speed and high accuracy, which have made them widely used in the field of industrial automation. As an optimized version of the YOLO series, YOLOv8n improves the detection accuracy and processing speed of the model, and is particularly suitable for the accurate identification of image defects, and can quickly and accurately identify various defects on the PCB surface. However, due to the large model structure and high computational complexity of YOLOv8n, it still faces certain challenges when applied in resource-constrained embedded systems.
[0005] In view of this, a lightweight PCB defect detection method that can effectively reduce the amount of model calculation and improve the reasoning speed needs to be developed urgently. Summary of the invention
[0006] The present invention provides a lightweight PCB defect detection method, device and storage medium based on improved YOLOv8n, which combines the Ghost-HGNetV2 network, C2f-Faster module, GCDetect module and Inner-MPDIoU loss function. By optimizing the structure of the YOLOv8n model, the present invention not only improves the accuracy of PCB defect detection, but also effectively reduces the amount of model calculation and improves the reasoning speed. In addition, the channel pruning technology is also used to further compress the model size, making it suitable for resource-constrained embedded devices, and solving the contradiction between detection accuracy and reasoning speed in the current PCB defect detection technology.
[0007] The specific technical solutions disclosed in this disclosure are as follows:
[0008] A lightweight PCB defect detection method based on improved YOLOv8n, comprising:
[0009] Obtain a PCB surface defect dataset, preprocess the dataset, and convert the preprocessed dataset into YOLO format;
[0010] Improve the YOLOv8n model to obtain an improved YOLOv8n model;
[0011] The improved YOLOv8n model is trained using a YOLO format dataset to obtain a trained YOLOv8n model;
[0012] Perform channel pruning on the trained YOLOv8n model to obtain a channel pruned model;
[0013] Using the channel pruned model, defect detection and classification are performed on the image to be tested;
[0014] The improved YOLOv8n model is improved to obtain an improved YOLOv8n model, including:
[0015] Use the Ghost-HGNetV2 network to replace the backbone network in the YOLOv8n model;
[0016] Replace the C2f module in the neck network of the YOLOv8n model with the C2f-Faster module;
[0017] Integrate GroupConv into the head network of the YOLOv8n model through the GCDetect module;
[0018] The CIoU loss function in the YOLOv8n model is replaced with the Inner-MPDIoU loss function.
[0019] The Ghost-HGNetV2 network is used to replace the backbone network in the YOLOv8n model, including:
[0020] The Ghost-HGNetV2 network uses a multi-level feature extraction method to effectively capture local details and global semantic context at different scales; and introduces the GhostConv structure to generate feature maps by decomposing standard convolutions, where part of the features are generated by standard convolutions and the other part is generated by linear transformation to generate Ghost feature maps, thereby reducing redundant features and reducing computational complexity.
[0021] The method of replacing the C2f module in the neck network of the YOLOv8n model with the C2f-Faster module includes:
[0022] Use PConv for feature extraction and apply standard convolution operations to generate output feature maps;
[0023] In PConv, the input feature map is represented as a three-dimensional tensor with height h, width w, and number of channels c. In the convolution operation, PConv only performs convolution on one quarter of the channels of the input feature, while the remaining feature channels are retained through residual connections, effectively reducing the computational burden while ensuring the smooth flow of information in the network.
[0024] The method of fusing GroupConv into the head network of the YOLOv8n model through the GCDetect module includes:
[0025] The GCDetect uses two consecutive 3×3 GroupConvs, and the two GroupConvs are used together for classification and regression tasks;
[0026] The GroupConv minimizes the number of parameters by dividing the input feature map into groups and performing convolution operations on each group separately.
[0027] The step of replacing the CIoU loss function in the YOLOv8n model with the Inner-MPDIoU loss function includes:
[0028] Introduced in the Inner-MPDIoU loss function Scaling the image width and height to more accurately measure the difference between the predicted and true boxes and adapt to images with different sizes and aspect ratios, thereby improving the model's performance in detecting and localizing small objects.
[0029] The Inner-MPDIoU loss function is defined as follows:
[0030] ;
[0031] Among them, InnerMPDIoU is the loss function, InnerIoU is the intersection-over-union ratio between the real box and the predicted box, and are the upper left corner distance and lower right corner distance between the real box and the predicted box, respectively. and are the height and width of the image respectively;
[0032] ;
[0033] Among them, inter represents the intersection area of the real box and the predicted box, and union represents the union area of the real box and the predicted box;
[0034] ;
[0035] in, and Represent the right boundary coordinates of the real box and the predicted box respectively; and Represent the left boundary coordinates of the real box and the predicted box respectively; and Represent the lower boundary coordinates of the real box and the predicted box respectively; and Represent the upper boundary coordinates of the real box and the predicted box respectively;
[0036] ;
[0037] in, Indicates the width of the real box; Indicates the height of the real frame; Indicates the width of the prediction box; Indicates the height of the prediction box; Indicates the zoom ratio.
[0038] The preprocessing of the data set includes:
[0039] One or more of image scaling, random flipping, center cropping, color conversion, and adding random noise.
[0040] The channel pruning of the trained YOLOv8n model includes:
[0041] The trained YOLOv8n model is processed using the LAMP channel pruning algorithm.
[0042] An electronic device for lightweight PCB defect detection, comprising:
[0043] Storage medium for storing computer programs;
[0044] The processing unit exchanges data with the storage medium, and is used to execute the computer program through the processing unit when performing PCB defect detection, and perform the steps of the lightweight PCB defect detection method based on improved YOLOv8n as described above.
[0045] A readable storage medium, characterized in that:
[0046] The readable storage medium stores a computer program;
[0047] When the computer program is running, it executes the steps of the lightweight PCB defect detection method based on improved YOLOv8n as described above.
[0048] Beneficial effects:
[0049] The beneficial effects of the present disclosure include at least:
[0050] The present invention adopts Ghost-HGNetV2 network in the backbone network of the improved YOLOv8n model. The network structure has fewer parameters and can extract multi-level semantic features, thereby accurately identifying PCB defects and improving the computational efficiency of the model. At the same time, a lightweight C2f-Faster module is introduced in the neck network of the improved YOLOv8n model to replace the C2f module to enhance multi-scale feature fusion and improve the accuracy and efficiency of defect detection. Moreover, a GCDetect module is adopted in the head network of the improved YOLOv8n model. This module integrates GroupConv into the head network of YOLOv8n, allowing the bounding box and category prediction to share the weight of GroupConv, and simultaneously completes the regression and classification tasks by minimizing the group convolution, significantly reducing the number of parameters while maintaining the detection accuracy; finally, the present disclosure replaces the CIoU loss function in the YOLOv8n model with the Inner-MPDIoU loss function, and optimizes the matching between the real box and the predicted box through a more refined overlap metric, thereby improving the model's ability to detect and locate small targets; the present disclosure performs channel pruning on the trained YOLOv8n model; wherein, channel pruning uses the LAMP channel pruning algorithm, which selectively removes redundant channels or channels that contribute less to performance by evaluating the importance of each channel, thereby reducing the complexity of the model. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure or the prior art, the drawings required in the embodiments or the prior art are briefly described below. Obviously, the drawings described below are only embodiments of the present disclosure, and those skilled in the art can deduce other related drawings based on the provided drawings without creative work.
[0052] Figure 1 The network structure diagram of the improved YOLOv8n lightweight model disclosed in the present invention;
[0053] Figure 2 This is the network structure diagram of Ghost-HGNetV2 disclosed in the present invention;
[0054] Figure 3 It is a structural diagram of the HGStem module disclosed in the present invention;
[0055] Figure 4 It is a structural diagram of the Ghost-HGBlock module disclosed in the present invention;
[0056] Figure 5 This is a structural diagram of the C2f-Faster module disclosed in the present invention;
[0057] Figure 6 This is a structural diagram of the FasterBlock module disclosed in the present invention;
[0058] Figure 7 This is a structural diagram of the GCDetect module disclosed in the present invention;
[0059] Figure 8 This is a diagram of PCB image defect detection results before the present disclosure improvement;
[0060] Fig. 9 This is the improved PCB image defect detection result diagram disclosed in the present invention. DETAILED DESCRIPTION
[0061] In the following, various embodiments of the present disclosure will be described more fully. The present disclosure may have various embodiments, and adjustments and changes may be made therein. However, it should be understood that there is no intention to limit the various embodiments of the present disclosure to the specific embodiments disclosed herein, but rather the present disclosure should be understood to cover all adjustments, equivalents and / or alternatives that fall within the spirit and scope of the various embodiments of the present disclosure.
[0062] Hereinafter, the terms "include" or "may include" that may be used in various embodiments of the present disclosure indicate the presence of disclosed functions, operations, or elements, and do not limit the addition of one or more functions, operations, or elements. In addition, as used in various embodiments of the present disclosure, the terms "include", "have", and their cognates are intended only to indicate specific features, numbers, steps, operations, elements, components, or a combination of the foregoing, and should not be understood as first excluding the presence of one or more other features, numbers, steps, operations, elements, components, or a combination of the foregoing or the possibility of adding one or more features, numbers, steps, operations, elements, components, or a combination of the foregoing.
[0063] In various embodiments of the present disclosure, the expression "or" or "at least one of A or / and B" includes any combination or all combinations of the words listed at the same time. For example, the expression "A or B" or "at least one of A or / and B" may include A, may include B, or may include both A and B.
[0064] The expressions (such as "first", "second", etc.) used in the various embodiments of the present disclosure may modify the various constituent elements in the various embodiments, but may not limit the corresponding constituent elements. For example, the above expressions do not limit the order and / or importance of the elements. The above expressions are only used for the purpose of distinguishing one element from other elements. For example, the first user device and the second user device indicate different user devices, although both are user devices. For example, without departing from the scope of the various embodiments of the present disclosure, the first element may be referred to as the second element, and similarly, the second element may also be referred to as the first element.
[0065] It should be noted that if it is described that one component element is “connected” to another component element, the first component element may be directly connected to the second component element, and a third component element may be “connected” between the first component element and the second component element. Conversely, when one component element is “directly connected” to another component element, it can be understood that there is no third component element between the first component element and the second component element.
[0066] The term “user” used in various embodiments of the present disclosure may indicate a person using an electronic device or a device (eg, an artificial intelligence electronic device) using the electronic device.
[0067] The terms used in the various embodiments of the present disclosure are only used for the purpose of describing specific embodiments and are not intended to limit the various embodiments of the present disclosure. As used herein, the singular form is intended to also include the plural form, unless the context clearly indicates otherwise. Unless otherwise defined, all terms (including technical terms and scientific terms) used herein have the same meaning as the meanings commonly understood by ordinary technicians in the field to which the various embodiments of the present disclosure belong. The terms (such as the terms defined in the generally used dictionary) will be interpreted as having the same meaning as the contextual meaning in the relevant technical field and will not be interpreted as having an idealized meaning or an overly formal meaning, unless clearly defined in the various embodiments of the present disclosure. Specific embodiment 1:
[0069] This embodiment provides a lightweight PCB defect detection method based on improved YOLOv8n, including the following steps:
[0070] S1: Obtain PCB surface defect dataset, preprocess the dataset, and convert the preprocessed dataset into YOLO format;
[0071] S2: Improve the YOLOv8n model;
[0072] Among them, the improvements to the YOLOv8n model include:
[0073] Use Ghost-HGNetV2 network to replace the backbone network of YOLOv8n;
[0074] Replace the C2f module in the neck network with the C2f-Faster module;
[0075] Use the GCDetect module, which integrates GroupConv into the head network of YOLOv8n;
[0076] Replace the CIoU loss function in the YOLOv8n model with the Inner-MPDIoU loss function;
[0077] S3: Use the YOLO format dataset to train the improved YOLOv8n model;
[0078] S4: Prune the channels of the trained YOLOv8n model;
[0079] S5: Use the model after channel pruning to perform defect detection and classification on the image to be tested;
[0080] Specifically, in S1:
[0081] The dataset is preprocessed, including image scaling, random flipping, center cropping, color transformation, and adding random noise, and the processed dataset is finally converted into YOLO format.
[0082] The embodiment improves the YOLOv8n lightweight network structure as shown in the attached Figure 1 As shown, it includes a backbone network, a neck network, and a head network.
[0083] This embodiment uses Ghost-HGNetV2 as the backbone network for improving YOLOv8n. Figure 2 , using a multi-level feature extraction method, effectively captures local details and global semantic context at different scales, thereby showing excellent performance in small target detection and target recognition in complex and cluttered environments. Compared with the original network, Ghost-HGNetV2 has been optimized in many aspects. In the HGStem module, a small 2×2 convolution kernel is used to capture local features, and the inference speed is improved by reducing the number of channels, which optimizes the computational efficiency of the model. The module structure is shown in the attached Figure 3 In the Ghost-HGBlock module, the GhostConv structure is introduced to generate feature maps by decomposing standard convolution. Part of the features are generated by standard convolution, and the other part is generated by linear transformation to generate Ghost feature maps, thereby reducing redundant features, reducing computational complexity, and improving inference speed. The module structure is shown in the attached Figure 4 .
[0084] In this embodiment, all C2f modules in the YOLOv8n neck network are replaced with C2f-Faster modules. Figure 5 The FasterBlock module is the key element of the C2f-Faster module. Its module structure is shown in the attached Figure 6 , a combined operation is used to generate the output feature map. The process starts with feature extraction using PConv, and then a standard convolution operation is applied to generate the output feature map. In PConv, the input feature map is represented as a three-dimensional tensor with height h, width w, and number of channels c. In the convolution operation, PConv only convolves one quarter of the channels of the input features, while the remaining feature channels are retained through residual connections. This approach effectively reduces the computational burden while ensuring a smooth flow of information in the network.
[0085] This embodiment uses the GCDetect module as the head network of the improved YOLOv8n. GCDetect uses two consecutive 3×3 GroupConvs to replace multiple convolutional layers in the original detection head. GroupConv minimizes the number of parameters by dividing the input feature map into smaller groups and performing convolution operations on each group separately.
[0086] In this embodiment, the feature map is divided into 16 groups, and two GroupConvs are used together for classification and regression tasks, which effectively reduces the number of parameters and computational complexity, thereby improving the detection speed. Figure 7 .
[0087] In this embodiment, the CIoU loss function in the YOLOv8n model is replaced by the Inner-MPDIoU loss function. The Inner-MPDIoU loss function is introduced Scaling ratio can more accurately measure the difference between the predicted box and the true box. In addition, by adding the width and height of the image, the Inner-MPDIoU loss function can adapt to images with different sizes and aspect ratios, thereby improving the performance of the model in detecting and locating small objects.
[0088] The Inner-MPDIoU loss function is defined as follows:
[0089]
[0090] Among them, InnerMPDIoU is the loss function, InnerIoU is the intersection-over-union ratio between the real box and the predicted box, and are the upper left corner distance and lower right corner distance between the real box and the predicted box, respectively. and are the height and width of the image respectively;
[0091] ;
[0092] Among them, inter represents the intersection area of the real box and the predicted box, and union represents the union area of the real box and the predicted box;
[0093] ;
[0094] in, and Represent the right boundary coordinates of the real box and the predicted box respectively; and Represent the left boundary coordinates of the real box and the predicted box respectively; and Represent the lower boundary coordinates of the real box and the predicted box respectively; and Represent the upper boundary coordinates of the real box and the predicted box respectively;
[0095] ;
[0096] in, Indicates the width of the real box; Indicates the height of the real frame; Indicates the width of the prediction box; Indicates the height of the prediction box; Indicates the zoom ratio, Take 1.15;
[0097] This embodiment uses the preprocessed YOLO format data set to train the improved YOLOv8n model. The training parameter configuration and software and hardware configuration are shown in Table 1.
[0098] Table 1 Parameter unified configuration
[0099] Configuration items Configuration parameters operating system Ubuntu 20.04 CPU Intel(R) Xeon(R) Silver 4214R GPU NVIDIA RTX 3080 Ti (12GB) programming language Python 3.8 frame PyTorch 1.10.0 CUDA CUDA version: 11.3 Training rounds 100 Batch size 16 Image size 640#timg#640
[0100] This embodiment uses commonly used indicators such as accuracy P, recall R, map@0.5, map@0.5:0.95, parameter quantity Params and computational quantity FLOPs to judge the network detection results. The experimental results are compared in Table 2.
[0101] Table 2 Comparison of detection effects of common target detection networks under PCB dataset
[0102] Model P (%) R(%) mAP@0.5 (%) mAP@0.5:0.95 (%) Params(M) FLOPs (G) SSD300 91.31 90.13 93.20 46.61 24.40 30.70 Faster-RCNN 89.12 95.80 92.41 45.21 137.10 370.20 YOLOv3-tiny 95.04 93.13 96.09 47.32 8.70 12.90 YOLOv4-tiny 95.81 79.65 89.66 34.91 6.10 16.50 YOLOv5n 96.72 96.33 98.14 58.19 1.80 4.20 YOLOv6n 98.16 95.52 98.73 57.01 4.70 11.40 YOLOv7-tiny 95.98 91.71 96.22 48.63 6.00 13.10 YOLOv9-c 98.38 99.31 99.32 68.70 25.30 102.10 YOLOv8n 98.44 99.05 99.16 65.05 3.00 8.10 This embodiment model 98.91 99.41 99.32 75.18 0.67 2.40
[0103] The results show that the lightweight PCB defect detection method based on the improved YOLOv8n in this embodiment shows significant advantages in multiple common target detection algorithms. Compared with classic target detection models such as SSD300 and Faster-RCNN, this embodiment has greatly improved the accuracy, recall and mAP indicators. In particular, in terms of detection accuracy and recall, this embodiment reached 98.91% and 99.41% respectively, which is significantly better than lightweight models such as YOLOv8n and YOLOv5n, and is better than traditional algorithms such as SSD300 and Faster-RCNN. In terms of mAP@0.5 indicators, the value of this embodiment is 99.32%, which is the same as YOLOv9-c, and better than YOLOv8n and YOLOv7-tiny. In addition, this embodiment achieves 75.18% in the comprehensive performance of mAP@0.5:0.95, which is much higher than YOLOv8n and YOLOv7-tiny. More importantly, this embodiment significantly reduces the computational complexity and storage requirements of the model while achieving high-precision detection. The number of parameters is only 0.67M, and the amount of calculation is 2.40G. Compared with YOLOv8n and YOLOv9-c, it has achieved a significant lightweight, suitable for embedded systems and resource-constrained environments. Therefore, this embodiment not only exceeds multiple mainstream algorithms in the prior art in terms of indicators such as accuracy and recall rate, but also has obvious advantages in computational efficiency and storage requirements, and has a wide range of practical application value. Specific embodiment 2:
[0105] The present disclosure also provides an embodiment:
[0106] An electronic device for lightweight PCB defect detection includes: a storage medium and a processing unit; wherein the storage medium is used to store a computer program; the processing unit exchanges data with the storage medium, and is used to execute the computer program through the processing unit when performing PCB defect detection, and perform the steps of the lightweight PCB defect detection method based on improved YOLOv8n as described in specific embodiment 1.
[0107] The CPU can perform various appropriate actions and processes according to the program stored in the storage medium. The electronic device also includes the following peripherals, including input parts such as keyboards and mice, and output parts such as cathode ray tubes (CRTs), liquid crystal displays (LCDs), and speakers.
[0108] The present disclosure also provides an embodiment:
[0109] A readable storage medium: a computer program is stored in the readable storage medium; when the computer program is run, the steps of the lightweight PCB defect detection method based on improved YOLOv8n as described in specific embodiment 1 are executed.
[0110] In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in combination with an instruction execution system, device or device. The program code contained on the computer-readable medium may be transmitted using any suitable medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0111] The above disclosures are only several specific implementation scenarios of the present disclosure, but the present disclosure is not limited thereto, and any changes that can be thought of by a person skilled in the art should fall within the protection scope of the present disclosure. The above disclosure serial numbers are only for description and do not represent the advantages and disadvantages of the implementation scenarios.
Claims
1. A lightweight PCB defect detection method based on improved YOLOv8n, characterized in that: include: Obtain a PCB surface defect dataset, preprocess the dataset, and convert the preprocessed dataset into YOLO format; Improve the YOLOv8n model to obtain an improved YOLOv8n model; The improved YOLOv8n model is trained using a YOLO format dataset to obtain a trained YOLOv8n model; Perform channel pruning on the trained YOLOv8n model to obtain a channel pruned model; Using the channel pruned model, defect detection and classification are performed on the image to be tested; The improved YOLOv8n model is improved to obtain an improved YOLOv8n model, including: Use the Ghost-HGNetV2 network to replace the backbone network in the YOLOv8n model; Replace the C2f module in the neck network of the YOLOv8n model with the C2f-Faster module; Integrate GroupConv into the head network of the YOLOv8n model through the GCDetect module; The CIoU loss function in the YOLOv8n model is replaced with the Inner-MPDIoU loss function.
2. According to claim 1, the lightweight PCB defect detection method based on improved YOLOv8n is characterized in that: The Ghost-HGNetV2 network is used to replace the backbone network in the YOLOv8n model, including: The Ghost-HGNetV2 network uses a multi-level feature extraction method to capture local details and global semantic context at different scales; and introduces the GhostConv structure to generate feature maps by decomposing standard convolutions, where part of the features are generated by standard convolutions and the other part is generated by linear transformation to generate Ghost feature maps, thereby reducing redundant features and reducing computational complexity.
3. The lightweight PCB defect detection method based on improved YOLOv8n according to claim 1 is characterized in that: The method of replacing the C2f module in the neck network of the YOLOv8n model with the C2f-Faster module includes: Use PConv for feature extraction and apply standard convolution operations to generate output feature maps; In PConv, the input feature map is represented as a three-dimensional tensor with height h, width w, and number of channels c. In the convolution operation, PConv only performs convolution on one quarter of the channels of the input feature, while the remaining feature channels are retained through residual connections, effectively reducing the computational burden while ensuring the smooth flow of information in the network.
4. The lightweight PCB defect detection method based on improved YOLOv8n according to claim 1 is characterized in that: The method of fusing GroupConv into the head network of the YOLOv8n model through the GCDetect module includes: The GCDetect uses two consecutive 3×3 GroupConvs, and the two GroupConvs are used together for classification and regression tasks; The GroupConv minimizes the number of parameters by dividing the input feature map into groups and performing convolution operations on each group separately.
5. The lightweight PCB defect detection method based on improved YOLOv8n according to claim 1 is characterized in that: The step of replacing the CIoU loss function in the YOLOv8n model with the Inner-MPDIoU loss function includes: The ratio scaling ratio and the width and height of the image are introduced into the Inner-MPDIoU loss function to more accurately measure the difference between the predicted box and the true box and adapt to images with different sizes and aspect ratios, thereby improving the performance of the model in detection and positioning.
6. The lightweight PCB defect detection method based on improved YOLOv8n according to claim 1 or 5, characterized in that: The Inner-MPDIoU loss function is defined as follows: ; Among them, InnerMPDIoU is the loss function, and InnerIoU is the intersection-over-union ratio between the real box and the predicted box; , They are the upper left corner distance and lower right corner distance between the real box and the predicted box respectively; , are the height and width of the image respectively; ; Among them, inter represents the intersection area of the real box and the predicted box; union represents the union area of the real box and the predicted box; ; in, , Represent the right boundary coordinates of the real box and the predicted box respectively; , Represent the left boundary coordinates of the real box and the predicted box respectively; , Represent the lower boundary coordinates of the real box and the predicted box respectively; , Represent the upper boundary coordinates of the real box and the predicted box respectively; ; in, Indicates the width of the real box; Indicates the height of the real frame; Indicates the width of the prediction box; Indicates the height of the prediction box; ratio indicates the scaling ratio.
7. The lightweight PCB defect detection method based on improved YOLOv8n according to claim 1 is characterized in that: The preprocessing of the data set includes: One or more of image scaling, random flipping, center cropping, color conversion, and adding random noise.
8. The lightweight PCB defect detection method based on improved YOLOv8n according to claim 1 is characterized in that: The channel pruning of the trained YOLOv8n model includes: The trained YOLOv8n model is processed using the LAMP channel pruning algorithm.
9. An electronic device for lightweight PCB defect detection, characterized in that: include: Storage medium for storing computer programs; A processing unit exchanges data with the storage medium, and is used to execute the computer program through the processing unit when performing PCB defect detection, and perform the steps of the lightweight PCB defect detection method based on improved YOLOv8n as described in any one of claims 1 to 8.
10. A readable storage medium, characterized in that: The readable storage medium stores a computer program; When the computer program is running, it executes the steps of the lightweight PCB defect detection method based on improved YOLOv8n as described in any one of claims 1 to 8.
Citation Information
Patent Citations
Method for identifying potential safety hazard of flue of gas water heater
CN117876800A
Wild animal target detection method based on improved yolov8 and knowledge distillation
CN118823736A
Lightweight printed circuit board detection method
CN118887161A
Improved YOLOv8n-based grape cluster young fruit lightweight detection method
CN119339367A
Cited By
Multi-model fusion PCB through hole defect detection method, device, equipment and medium
CN119810102A
Multi-model fusion PCB through-hole defect detection method, device, equipment and medium
CN119810102B
Lightweight small target detection method based on machine vision
CN120198772A
Concrete building peeling defect detection method, device and system and storage medium
CN120235885A