A PCB defect detection method and system based on HPE-YOLO

CN122675869BActive Publication Date: 2026-10-16ZHEJIANG SCI-TECH UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202611185557.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2026-08-06
Publication Date
2026-10-16
Estimated Expiration
2046-08-06

AI Technical Summary

Technical Problem

然而,YOLOv11n在PCB缺陷检测任务中仍存在明显问题,即卷积神经网络在逐层特征提取过程中,缺陷的边缘轮廓和细节信息会逐渐衰减丢失,直接导致鼠咬、毛刺等微小缺陷的定位精度偏低

Benefits of technology

(1)本发明显著提升PCB缺陷的检测精度,尤其对微小缺陷的识别效果提升明显。全局边缘感知模块HEA可有效保留缺陷的边缘轮廓信息,局部多尺度融合模块PMF可增强模型的多尺度特征表达能力,二者共同作用强化了模型对缺陷特征的感知与判别能力。实验结果表明,HPE-YOLO在自建PCB缺陷测试集上的精确率达95.9%,召回率达91.94%,mAP@0.5达到95.47%,mAP@0.5:0.95达到62.85%;其中mAP@0.5较原YOLOv11n提升3.37个百分点,在鼠咬、露铜、开路、白斑、短路、余铜共6类缺陷上均实现精度提升,白斑缺陷的提升幅度最为显著。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122675869B_ABST
    Figure CN122675869B_ABST
Patent Text Reader

Abstract

The application provides a PCB defect detection method and system based on HPE-YOLO, and belongs to the technical field of industrial defect detection. The method comprises the following steps: collecting a printed circuit board surface image and preprocessing, constructing a PCB defect dataset and dividing it into a training set, a validation set and a test set; taking YOLOv11n as a basic network, embedding a global edge perception module, a local multi-scale fusion module, an efficient local attention high-level feature pyramid and a lightweight shared enhanced detection head in the backbone network to construct an HPE-YOLO detection model, then using the training set and the validation set to iteratively train and verify the model, and finally inputting a PCB image to be detected into the trained model to output the corresponding defect category, bounding box position and confidence information. The application solves the technical problems of easy loss of edge information, high micro target missing detection rate, and difficult balance between detection accuracy and real-time performance in PCB defect detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of industrial defect detection technology, and in particular to a PCB defect detection method and system based on HPE-YOLO. Background Technology

[0002] PCBs are the core carrier of electronic devices, and their manufacturing quality directly determines the performance and reliability of electronic products. As the electronics manufacturing industry develops towards higher precision and higher density, PCB defects are becoming smaller and more diverse, making traditional manual visual inspection and automated optical inspection insufficient to meet the quality requirements of modern production.

[0003] In recent years, deep learning-based target detection technology has been widely used in PCB defect detection. Among them, YOLOv11n (You Only Look Once version 11), as the latest lightweight single-stage detection algorithm, has become the mainstream choice for industrial inspection due to its high detection speed and accuracy. However, YOLOv11n still has significant problems in PCB defect detection tasks. During the layer-by-layer feature extraction process of the convolutional neural network, the edge contours and detailed information of defects gradually decay and are lost, directly leading to low positioning accuracy for small defects such as mouse bites and burrs. At the same time, the original C3K2 module adopts a unified convolution design across all channels, which not only easily generates a large number of redundant features, but also cannot effectively fuse defect features of different scales, making it difficult to adapt to the large size differences of PCB defects.

[0004] Furthermore, the traditional feature pyramid structure lacks an effective feature selection mechanism, is prone to introducing irrelevant background noise during cross-scale feature fusion, and suffers from high computational overhead, which restricts the inference efficiency of the model. Moreover, the design of independent convolutional layers for each scale detection head results in low parameter sharing, causing unnecessary parameter redundancy. In addition, traditional convolutional layers are not good at capturing the detailed features of small defects, which further limits the overall detection performance of the model.

[0005] Therefore, there is an urgent need to develop a PCB defect detection method and system that can enhance edge information perception, improve multi-scale feature fusion efficiency, and has the characteristics of being lightweight and highly accurate. Summary of the Invention

[0006] To overcome the shortcomings of existing technologies, the purpose of this invention is to provide a PCB defect detection method and system based on HPE-YOLO. The HPE-YOLO detection model is constructed based on YOLOv11n. Through the optimized combination of global edge perception, local multi-scale fusion, efficient local attention feature pyramid, and lightweight shared enhanced detection head, it solves the technical problems in PCB defect detection, such as easy loss of edge information, high missed detection rate of small targets, and difficulty in balancing detection accuracy and real-time performance. While maintaining the model's lightweight nature, it significantly improves detection accuracy and inference efficiency, providing technical support for automated online detection of PCB defects in industrial production lines.

[0007] To achieve the above objectives, the present invention provides the following solution: On the one hand, this invention provides a PCB defect detection method based on HPE-YOLO, comprising the following steps: S1. Collect images of the printed circuit board surface and preprocess them to construct a PCB defect dataset and divide it into training set, validation set and test set; S2. Based on YOLOv11n, a global edge awareness module HEA is embedded in the backbone network. The original C3K2 module in the backbone network is replaced by a local multi-scale fusion module PMF. The original neck network is replaced by an efficient local attention high-level feature pyramid E-HLFPN. The original detection head is replaced by a lightweight shared enhancement detection head LSEHead, thus constructing the HPE-YOLO detection model. S3. Use the training set and validation set to iteratively train and validate the HPE-YOLO detection model until the model converges and training is complete. S4. Input the PCB image to be detected into the trained HPE-YOLO detection model, and output the PCB defect category, bounding box location, and confidence information.

[0008] Preferably, the global edge awareness module HEA includes a multi-scale edge detail generator and an edge interaction fusion module; the multi-scale edge detail generator is used to extract image edge features and generate a multi-scale edge feature map; the edge interaction fusion module is used to perform cross-channel fusion of semantic features of the corresponding layer of the backbone network with edge features of the same scale, and output semantic features of fused edge information.

[0009] Preferably, the multi-scale edge detail generator is embedded in the P2 layer of the backbone network. It extracts the gradients in the x and y directions through Sobel convolution and adds them to obtain the basic edge features. Multiple edge feature maps of different scales are generated through multiple max pooling operations, and then the number of channels is adjusted through 1×1 convolution. The edge interaction fusion module concatenates the semantic features of the corresponding layer of the backbone network with the edge features of the same scale along the channel dimension, and then performs cross-channel feature fusion through 1×1 convolution, 3×3 convolution and 1×1 convolution in sequence.

[0010] Preferably, the local multi-scale fusion module PMF adopts a progressive channel splitting method to extract the input features through multi-branch, multi-receptive-field grouped deep separable convolution, and outputs the multi-scale features after splicing and fusing them through residual connection.

[0011] Preferably, the construction steps of the local multi-scale fusion module (PMF) are as follows: The input feature map is initially transformed by 3×3 convolution to obtain Q1. Q1 is then evenly split into two parts, Q1a and Q1b, according to the channel dimension. Apply a 5×5 depthwise separable convolution with C / 2 groups to Q1a to obtain Q2, and then split Q2 into two parts Q2a and Q2b. Q3 is obtained by applying a 7×7 depthwise separable convolution with C / 4 group numbers to Q2a; Q3, Q2b, and Q1b are concatenated along the channel dimension, multi-scale features are fused through 1×1 convolution, and the output features are obtained by adding them to the original input through residual connection.

[0012] Preferably, the High-Efficiency Local Attention High-Level Feature Pyramid (E-HLFPN) includes a high-efficiency local attention module and a cross-scale feature interaction mechanism; the high-efficiency local attention module is used to extract the orientation and position information of features and generate adaptive attention weights; the cross-scale feature interaction mechanism realizes weighted fusion and residual integration of high-level semantic features and low-level detail features based on the attention weights.

[0013] Preferably, the efficient local attention module performs horizontal and vertical strip pooling on each channel of the input feature, captures directional dependencies through one-dimensional convolution, generates adaptive attention weights through GroupNorm normalization and Sigmoid activation, and multiplies the input feature with the bidirectional attention weights to obtain the optimized feature; The processing flow of the cross-scale feature interaction mechanism is as follows: after upsampling, high-level features generate attention weights through an efficient local attention module; after convolution to adjust the channels of low-level features, they are multiplied element-wise with the attention weights; residual connections are introduced to retain the original low-level features; and finally, deep feature integration is completed through the C3k2 module.

[0014] Preferably, the lightweight shared enhanced detection head LSEHead adopts a parameter-shared detail-enhanced convolutional architecture, which enhances edge detail feature extraction through multi-directional differential convolution. The bounding box prediction result and the category prediction result are output through parallel regression and classification branches, respectively, and the output feature amplitude is adaptively adjusted through a learnable scale module.

[0015] Preferably, the construction steps of the lightweight shared enhanced detection head (LSEHead) are as follows: The number of channels in the input feature maps at three different scales is adjusted by 1×1 convolution, and then normalized using GroupNorm; The adjusted feature map is input into two shared DEConv_GN detail enhancement convolutional modules, and each DEConv_GN module fuses multi-directional differential convolution DEConv with GroupNorm; After feature enhancement, bounding boxes and categories are predicted through parallel regression and classification branches, respectively. Finally, the output feature magnitude is adaptively adjusted through a learnable scale module.

[0016] On the other hand, the present invention also provides a system for implementing the above-mentioned HPE-YOLO-based PCB defect detection method, comprising: The dataset construction module is used to collect images of the printed circuit board surface and preprocess them to build a PCB defect dataset and divide it into training set, validation set and test set. The model building module is used to build the HPE-YOLO detection model based on YOLOv11n as the base network, embed the global edge awareness module HEA in the backbone network, replace the original C3K2 module in the backbone network with the local multi-scale fusion module PMF, replace the original neck network with the efficient local attention high-level feature pyramid E-HLFPN, and replace the original detection head with the lightweight shared enhancement detection head LSEHead. The model training module is used to iteratively train and validate the HPE-YOLO detection model using the training set and validation set until the model converges and training is complete. The defect detection module is used to input the PCB image to be detected into the trained HPE-YOLO detection model and output the PCB defect category, bounding box location, and confidence information.

[0017] Compared with the prior art, the present invention discloses at least the following technical effects: (1) This invention significantly improves the detection accuracy of PCB defects, especially the identification effect of small defects. The global edge perception module HEA can effectively preserve the edge contour information of defects, and the local multi-scale fusion module PMF can enhance the multi-scale feature expression capability of the model. The two work together to strengthen the model's ability to perceive and distinguish defect features. Experimental results show that HPE-YOLO achieves an accuracy of 95.9% and a recall of 91.94% on the self-built PCB defect test set, with mAP@0.5 reaching 95.47% and mAP@0.5:0.95 reaching 62.85%. Among them, mAP@0.5 is 3.37 percentage points higher than the original YOLOv11n, and the accuracy is improved in all 6 types of defects, including mouse bite, exposed copper, open circuit, white spot, short circuit, and excess copper. The improvement is most significant for white spot defects.

[0018] (2) This invention can achieve efficient multi-scale feature fusion. The E-HLFPN neck network adaptively selects key features through the efficient local attention mechanism of ELA, and completes the deep fusion of high-level semantic features and low-level detailed features with the cross-scale feature interaction mechanism. While improving the feature expression ability, the computational cost is controlled within a reasonable range, and the overall computational cost of the model is 8.2 GFLOPs.

[0019] (3) This invention achieves excellent real-time detection performance while maintaining a lightweight model. The LSEHead lightweight shared enhanced detection head reduces redundant parameters through a parameter sharing mechanism, and the DEConv detail-enhancing convolution maintains high computational efficiency while strengthening edge detail extraction capabilities. The HPE-YOLO has only 2.75 × 10 parameters. 6 The inference frame rate can reach 77.76 frames per second. -1 It is 31.2% better than the original YOLOv11n and can be adapted to online real-time detection scenarios in industrial production lines.

[0020] (4) The present invention has good generalization performance. The generalization experiment results on the existing public datasets show that HPE-YOLO’s mAP@0.5 reaches 86.31%, and its detection accuracy is better than mainstream lightweight detection models such as Faster-RCNN, RT-DETR-18 and YOLOv8n to YOLOv12n. This proves that the model has good cross-dataset adaptability and can be adapted to PCB defect detection tasks from different sources. Attached Figure Description

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

[0022] Figure 1 This is a flowchart of a PCB defect detection method based on HPE-YOLO according to the present invention.

[0023] Figure 2 This is a schematic diagram of the overall structure of the HPE-YOLO network provided by the present invention.

[0024] Figure 3 This is a schematic diagram of the structure of the global edge awareness module (HEA) provided by the present invention.

[0025] Figure 4 This is a schematic diagram of the structure of the Local Multiscale Fusion (PMF) module provided by the present invention.

[0026] Figure 5 This is a schematic diagram of the structure of the High-Efficiency Local Attention High-Level Feature Pyramid (E-HLFPN) provided by the present invention.

[0027] Figure 6 This is a schematic diagram of the lightweight shared enhancement detection head (LSEHead) provided by the present invention.

[0028] Figure 7 A comparative bar chart of 7 types of defects mAP@0.5 provided by the present invention.

[0029] Figure 8 The overall precision-recall curve provided for this invention.

[0030] Figure 9 The image shows a comparison of the PCB defect detection results of the present invention and the original YOLOv11n, where (a) is the original image, (b) is the detection result of YOLOv11n, and (c) is the detection result of the present invention. Detailed Implementation

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

[0032] Existing YOLOv11n algorithms suffer from drawbacks in PCB defect detection tasks, including edge information loss, insufficient multi-scale feature fusion, and high false negative rates for small targets, failing to meet the high-precision, high-speed online inspection requirements of industrial production lines. To address this, this invention proposes a Hybrid Progressive Edge-Aware YOLO (HPE-YOLO) detection method based on the YOLOv11n architecture. Through the collaborative design of edge awareness enhancement, multi-scale feature fusion, an efficient attention mechanism, and a lightweight detection head, a better balance between detection accuracy and real-time performance is achieved.

[0033] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0034] like Figure 1 As shown, this invention provides a PCB defect detection method based on HPE-YOLO, comprising the following steps: S1. Collect images of the printed circuit board surface and preprocess them to construct a PCB defect dataset and divide it into training set, validation set and test set.

[0035] The PCB defect dataset consists of the publicly available HRIPCB dataset from Peking University and a self-built PCB defect dataset. The HRIPCB dataset contains 693 images of six typical defects: short circuits, open circuits, rodent bites, vias, burrs, and excess copper. The self-built dataset was acquired using a high-resolution GP-304K electron microscope, which features an ultra-high resolution of 3840×2160 and continuously adjustable optical magnification from 0.7X to 5.0X, with a measurement accuracy of 0.002-0.005mm. The acquisition environment was under stable indoor lighting conditions, with the lens maintained at a vertical distance of 20cm from the PCB board surface. A total of 2189 original images were obtained, covering seven types of defects: rodent bites, exposed copper, open circuits, white spots, short circuits, burrs, and excess copper. All images were annotated in YOLO format using the LabelImg 1.8.6 tool.

[0036] Both datasets were randomly divided into training, validation, and test sets in an 8:1:1 ratio, maintaining a consistent distribution ratio for each defect type during the partitioning process. To address overfitting caused by the limited size of the original data, six data augmentation operations were applied to the training set: Gaussian noise (σ=0.01), random rotation (±5°), horizontal / vertical mirroring, brightness adjustment (±20%), random occlusion cutout, and random cropping. After augmentation, the number of labels in the self-built dataset training set increased from 3363 to 13452, effectively improving the model's generalization ability.

[0037] S2. Based on YOLOv11n, a global edge awareness module HEA is embedded in the backbone network. The original C3K2 module in the backbone network is replaced by a local multi-scale fusion module PMF. The original neck network is replaced by an efficient local attention high-level feature pyramid E-HLFPN. The original detection head is replaced by a lightweight shared enhancement detection head LSEHead, thus constructing the HPE-YOLO detection model.

[0038] The overall network structure of the HPE-YOLO detection model is as follows: Figure 2 As shown, the construction process of each module is as follows: The structure of the global edge awareness module (HEA) is as follows: Figure 3 As shown, it includes a multi-scale edge detail generator and an edge interaction fusion module; the multi-scale edge detail generator is used to extract image edge features and generate multi-scale edge feature maps; the edge interaction fusion module is used to perform cross-channel fusion of semantic features of the corresponding layer of the backbone network with edge features of the same scale, and output semantic features of fused edge information.

[0039] Specifically, the multi-scale edge detail generator is embedded in the P2 layer of the backbone network, and the input feature map is... First, edge features are extracted using Sobel convolution, calculated as follows: ; in, and These are the Sobel convolution kernels in the horizontal and vertical directions, respectively.

[0040] Subsequently, three max-pooling operations with a kernel size of 2 and a stride of 2 are performed to generate three edge feature maps of different scales. Finally, a 1×1 convolution is used to adjust the number of channels to match the corresponding layer of the backbone network. The edge interaction fusion module integrates the semantic features of the backbone network. F Edge features of the same scale E By splicing along the channel dimension, we obtain Cross-channel feature fusion is achieved sequentially through 1×1 convolution, 3×3 convolution, and 1×1 convolution, ultimately outputting semantic features with fused edge information. .

[0041] The structure of the local multi-scale fusion module PMF is as follows: Figure 4 As shown, a progressive channel splitting method is used to extract the input features through multi-branch, multi-receptive-field grouped deep separable convolutions. The multi-scale features are then spliced ​​and fused and output through residual connections.

[0042] Specifically, the construction steps of the Local Multi-Scale Fusion (PMF) module are as follows: The input feature map P undergoes a preliminary feature transformation using a 3×3 convolution to obtain Q1. Q1 is then uniformly split into two parts, Q1a and Q1b, along the channel dimension. A 5×5 depthwise separable convolution with C / 2 groups is applied to Q1a to obtain Q2. Q2 is then further split into two parts, Q2a and Q2b. A 7×7 depthwise separable convolution with C / 4 groups is applied to Q2a to obtain Q3. Q3, Q2b, and Q1b are concatenated along the channel dimension, and multi-scale features are fused using a 1×1 convolution. The resulting output feature is obtained by adding it to the original input via residual connections. .

[0043] The structure of the High-Level Feature Pyramid (E-HLFPN) for efficient local attention is as follows: Figure 5 As shown, it includes an efficient local attention module and a cross-scale feature interaction mechanism; the efficient local attention module is used to extract the orientation and position information of features and generate adaptive attention weights; the cross-scale feature interaction mechanism realizes the weighted fusion and residual integration of high-level semantic features and low-level detail features based on the attention weights.

[0044] Specifically, the efficient local attention module applies attention to each channel of the input features. Perform strip pooling in both the horizontal and vertical directions to obtain... and The orientation dependency is captured by one-dimensional convolution, and adaptive attention weights are generated by GroupNorm normalization and Sigmoid activation. and The input features are multiplied by the bidirectional attention weights to obtain the optimized features, and the final output features are obtained. .

[0045] The processing flow of the cross-scale feature interaction mechanism is as follows: high-level features After upsampling, attention weights are generated through an efficient local attention module. Low-level features After adjusting the number of channels through 1×1 convolution, the weighted features are obtained by multiplying them element-wise with A. Introducing residual connections Finally, deep feature integration is completed through the C3k2 module.

[0046] The structure of the lightweight shared enhancement detection head (LSEHead) is as follows: Figure 6 As shown, a detail-enhancing convolutional architecture with parameter sharing is adopted. Edge detail feature extraction is enhanced through multi-directional differential convolution. The bounding box prediction result and the category prediction result are output by parallel regression branch and classification branch respectively. The output feature amplitude is adaptively adjusted by a learnable scale module.

[0047] Specifically, the construction steps of the Lightweight Shared Enhancement Detection Head (LSEHead) are as follows: Input feature maps at three different scales... 、 、 The number of channels is adjusted using 1×1 convolutions and normalized using GroupNorm. The adjusted feature maps are then input into two shared DEConv_GN detail enhancement convolutional modules. Each DEConv_GN module fuses multi-directional differential convolutions (DEConv) and GroupNorm. DEConv extracts gradient features comprehensively from four directions (center, horizontal, vertical, and angular) through center differential convolution, horizontal differential convolution, vertical differential convolution, and angular differential convolution, enhancing the ability to extract edge details. After feature enhancement, bounding boxes and categories are predicted through parallel regression and classification branches, respectively. Finally, the output feature magnitude is adaptively adjusted through a learnable Scale module.

[0048] S3. Use the training set and validation set to iteratively train and validate the HPE-YOLO detection model until the model converges and training is complete.

[0049] The specific implementation process of model training and validation is as follows: Experimental environment configuration: The hardware environment consists of an Intel Core i7-14650HX CPU (2.20GHz), an NVIDIA GeForce RTX4060 GPU (16GB VRAM), and a Windows 11 operating system; the software environment consists of CUDA 12.4, Python 3.9.13, PyTorch 2.5.1, and the Ultralytics 8.2.0 deep learning framework.

[0050] Training parameter settings: The input image size was uniformly adjusted to 640×640, the batch_size was set to 32, the total training epochs were 150, the initial learning rate was 0.01, the SGD optimizer (momentum 0.937, weight decay 0.0005) was used, and the cosine annealing learning rate scheduling strategy was used.

[0051] Model training and evaluation: During training, the model performance is evaluated on the validation set every 5 epochs. mAP@0.5, mAP@0.5:0.95, precision, recall and FPS are used as the main evaluation metrics. The model weight with the highest mAP@0.5 is saved.

[0052] The final trained HPE-YOLO detection model achieved the following performance metrics on the self-built PCB defect test set: precision 95.9%, recall 91.94%, mAP@0.5 = 95.47%, mAP@0.5:0.95 = 62.85%, and FPS = 77.76 frames per second. -1 Parameter quantity 2.75×10 6 , GFLOPs=8.2.

[0053] S4. Input the PCB image to be detected into the trained HPE-YOLO detection model, and output the PCB defect category, bounding box location, and confidence information.

[0054] The specific implementation process of real-time defect detection is as follows: The PCB image to be inspected is input into the preprocessing module for size adjustment (unified to 640×640), normalization (pixel value divided by 255) and noise reduction. The preprocessed image is input into the trained HPE-YOLO detection model for forward inference; The model outputs all detected defect information, including category labels and bounding box coordinates. , , , ) and confidence score; Filter out detection results with a confidence level below 0.5 and visualize the remaining results on the original image.

[0055] To visually verify the detection performance of the HPE-YOLO invention, the detection results of the present invention and the original YOLOv11n were compared for visualization. Figure 9 As shown. Figure 9 (a) in the image is the original PCB image, which includes short circuits and excess copper defects; Figure 9 (b) in the table shows the detection results of YOLOv11n, which have issues with missed detections and false detections. Figure 9 (c) in the figure represents the detection results of the present invention. All defects were accurately identified without any missed or false detections, further demonstrating that the method of the present invention can significantly improve the detection accuracy of PCB defects, especially the identification effect of small defects.

[0056] Based on the above, the present invention also provides a system for performing the above method, comprising: The dataset construction module is used to collect images of the printed circuit board surface and preprocess them to build a PCB defect dataset and divide it into training set, validation set and test set. The model building module is used to build the HPE-YOLO detection model based on YOLOv11n as the base network, embed the global edge awareness module HEA in the backbone network, replace the original C3K2 module in the backbone network with the local multi-scale fusion module PMF, replace the original neck network with the efficient local attention high-level feature pyramid E-HLFPN, and replace the original detection head with the lightweight shared enhancement detection head LSEHead. The model training module is used to iteratively train and validate the HPE-YOLO detection model using the training set and validation set until the model converges and training is complete. The defect detection module is used to input the PCB image to be detected into the trained HPE-YOLO detection model and output the PCB defect category, bounding box location, and confidence information.

[0057] To further illustrate the technical effects of the present invention, three types of comparative experiments are conducted below to further demonstrate the above content.

[0058] 1. Ablation test To verify the feasibility and effectiveness of each improved module in the HPE-YOLO model, ablation experiments were conducted on a self-built PCB dataset, using YOLOv11n as the baseline model and sequentially adding four modules: LSEHead, PMF, HEA, and E-HLFPN. mAP@0.5 was used as the main evaluation index, and the results are shown in Table 1.

[0059] Table 1 Ablation Experiment Results of Each Improved Module

[0060] As shown in Table 1, the model performance continuously improves with the gradual addition of each improved module. The HPE-YOLO model integrating all four modules achieves a mAP@0.5 of 95.47%, which is 3.37 percentage points higher than the baseline model, while keeping the computational cost within a reasonable range, thus verifying the effectiveness and synergistic effect of each improved module.

[0061] To visually verify the improvement effect of the proposed solution on the detection performance of different PCB defects, a comparative analysis was conducted on the mAP@0.5 index of the original YOLOv11n model and the improved model across seven defect types. The results are as follows: Figure 7 As shown, this invention improves accuracy for all defect types except burrs, with the largest improvement observed in white spot defects. The results demonstrate that the improved scheme effectively enhances the model's ability to perceive and distinguish different types of defect features. The overall precision-recall curves are shown below. Figure 8 As shown, the curve is close to the upper right corner, indicating that the model achieves a good balance between high precision and high recall.

[0062] 2. Comparison Experiment of Mainstream Algorithms On the self-built PCB dataset, HPE-YOLO was compared with mainstream models such as Faster-RCNN, RT-DETR-18, and YOLOv8n to YOLOv12n. The results are shown in Table 2.

[0063] Table 2 Performance Comparison of Different Detection Algorithms

[0064] As shown in Table 2, HPE-YOLO achieved the highest mAP@0.5 and FPS among all the comparison models, while maintaining a lightweight parameter set, thus achieving a simultaneous improvement in detection accuracy and real-time performance.

[0065] 3. Generalization experiments on public datasets To verify the generalization ability of the method of this invention, a generalization experiment was conducted on the Peking University HRIPCB public dataset. This dataset contains 693 PCB images, covering six typical industrial defects: short circuit, open circuit, rodent bite, via, burr, and excess copper. The experiment used the same training parameters and evaluation metrics as the self-built dataset, and the results are shown in Table 3.

[0066] Table 3 Performance Comparison of Public Datasets

[0067] As shown in Table 3, HPE-YOLO achieves an mAP@0.5 of 86.31% on the public dataset, which is significantly better than other comparative models, demonstrating its good generalization ability and its ability to adapt to PCB defect detection tasks from different sources.

[0068] Therefore, the above-mentioned PCB defect detection method and system based on HPE-YOLO is adopted. The HPE-YOLO detection model is constructed based on YOLOv11n. Through the combination optimization of global edge perception, local multi-scale fusion, efficient local attention feature pyramid and lightweight shared enhanced detection head, the technical problems of easy loss of edge information, high missed detection rate of small targets and difficulty in balancing detection accuracy and real-time performance in PCB defect detection are solved. While maintaining the lightweight model, the detection accuracy and inference efficiency are significantly improved, which can provide technical support for automated online detection of PCB defects in industrial production lines.

[0069] This document uses specific examples to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. Furthermore, those skilled in the art will recognize that, based on the ideas of the present invention, there will be changes in the specific implementation methods and application scope. Therefore, the content of this specification should not be construed as a limitation of the present invention.

Claims

1. A PCB defect detection method based on HPE-YOLO, characterized in that, Includes the following steps: S1. Collect images of the printed circuit board surface and preprocess them to construct a PCB defect dataset and divide it into training set, validation set and test set; S2. Based on YOLOv11n, a global edge awareness module HEA is embedded in the backbone network. The original C3K2 module in the backbone network is replaced by a local multi-scale fusion module PMF. The original neck network is replaced by an efficient local attention high-level feature pyramid E-HLFPN. The original detection head is replaced by a lightweight shared enhancement detection head LSEHead, thus constructing the HPE-YOLO detection model. The High-Efficiency Local Attention High-Level Feature Pyramid (E-HLFPN) includes a high-efficiency local attention module and a cross-scale feature interaction mechanism. The high-efficiency local attention module is used to extract the orientation and position information of features and generate adaptive attention weights. The cross-scale feature interaction mechanism realizes the weighted fusion and residual integration of high-level semantic features and low-level detail features based on the attention weights. The lightweight shared enhanced detection head LSEHead adopts a parameter-shared detail-enhanced convolutional architecture, which enhances edge detail feature extraction through multi-directional differential convolution. The parallel regression and classification branches output bounding box prediction results and category prediction results, respectively, and the output feature amplitude is adaptively adjusted through a learnable scale module. S3. Use the training set and validation set to iteratively train and validate the HPE-YOLO detection model until the model converges and training is complete. S4. Input the PCB image to be detected into the trained HPE-YOLO detection model, and output the PCB defect category, bounding box location, and confidence information.

2. The PCB defect detection method based on HPE-YOLO according to claim 1, characterized in that, The global edge awareness module (HEA) includes a multi-scale edge detail generator and an edge interaction fusion module. The multi-scale edge detail generator is used to extract image edge features and generate multi-scale edge feature maps. The edge interaction fusion module is used to perform cross-channel fusion of semantic features of the corresponding layer of the backbone network with edge features of the same scale, and output semantic features of fused edge information.

3. The PCB defect detection method based on HPE-YOLO according to claim 2, characterized in that, The multi-scale edge detail generator is embedded in the P2 layer of the backbone network. It extracts the gradients in the x and y directions through Sobel convolution and adds them to obtain the basic edge features. Multiple max pooling operations are used to generate edge feature maps of different scales, and then the number of channels is adjusted through 1×1 convolution. The edge interaction fusion module concatenates the semantic features of the corresponding layer of the backbone network with the edge features of the same scale along the channel dimension, and then performs cross-channel feature fusion through 1×1 convolution, 3×3 convolution and 1×1 convolution in sequence.

4. The PCB defect detection method based on HPE-YOLO according to claim 1, characterized in that, The local multi-scale fusion module PMF adopts a progressive channel splitting method to extract the input features through multi-branch, multi-receptive-field grouped deep separable convolutions, and outputs the multi-scale features after splicing and fusing them through residual connections.

5. The PCB defect detection method based on HPE-YOLO according to claim 4, characterized in that, The construction steps of the local multi-scale fusion module (PMF) are as follows: The input feature map is initially transformed by 3×3 convolution to obtain Q1. Q1 is then evenly split into two parts, Q1a and Q1b, according to the channel dimension. Apply a 5×5 depthwise separable convolution with C / 2 groups to Q1a to obtain Q2, and then split Q2 into two parts Q2a and Q2b. Q3 is obtained by applying a 7×7 depthwise separable convolution with C / 4 group numbers to Q2a; Q3, Q2b, and Q1b are concatenated along the channel dimension, multi-scale features are fused through 1×1 convolution, and the output features are obtained by adding them to the original input through residual connection.

6. The PCB defect detection method based on HPE-YOLO according to claim 1, characterized in that, The efficient local attention module performs horizontal and vertical strip pooling on each channel of the input feature, captures directional dependencies through one-dimensional convolution, generates adaptive attention weights through GroupNorm normalization and Sigmoid activation, and multiplies the input feature with the bidirectional attention weights to obtain the optimized feature. The processing flow of the cross-scale feature interaction mechanism is as follows: after upsampling, high-level features generate attention weights through an efficient local attention module; after convolution to adjust the channels of low-level features, they are multiplied element-wise with the attention weights; residual connections are introduced to retain the original low-level features; and finally, deep feature integration is completed through the C3k2 module.

7. The PCB defect detection method based on HPE-YOLO according to claim 1, characterized in that, The construction steps of the Lightweight Shared Enhanced Detection Head (LSEHead) are as follows: The number of channels in the input feature maps at three different scales is adjusted by 1×1 convolution, and then normalized using GroupNorm; The adjusted feature map is input into two shared DEConv_GN detail enhancement convolutional modules, and each DEConv_GN module fuses multi-directional differential convolution DEConv with GroupNorm; After feature enhancement, bounding boxes and categories are predicted through parallel regression and classification branches, respectively. Finally, the output feature magnitude is adaptively adjusted through a learnable scale module.

8. A system for implementing the PCB defect detection method based on HPE-YOLO as described in any one of claims 1 to 7, characterized in that, include: The dataset construction module is used to collect images of the printed circuit board surface and preprocess them to build a PCB defect dataset and divide it into training set, validation set and test set. The model building module is used to build the HPE-YOLO detection model based on YOLOv11n as the base network, embed the global edge awareness module HEA in the backbone network, replace the original C3K2 module in the backbone network with the local multi-scale fusion module PMF, replace the original neck network with the efficient local attention high-level feature pyramid E-HLFPN, and replace the original detection head with the lightweight shared enhancement detection head LSEHead. The model training module is used to iteratively train and validate the HPE-YOLO detection model using the training set and validation set until the model converges and training is complete. The defect detection module is used to input the PCB image to be detected into the trained HPE-YOLO detection model and output the PCB defect category, bounding box location, and confidence information.

Citation Information

Patent Citations

  • 3D printing defect detection method based on improved YOLOv10n

    CN121169830A

  • Printed circuit board defect detection method and system

    CN121190470A