PCB micro-defect target detection method based on improved RT-DETR

CN122347589BActive Publication Date: 2026-08-18HUNAN NORMAL UNIVERSITY
View PDF 3 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

然而,高分辨率特征的直接引入会增加特征融合路径长度,导致卷积运算量与模型参数量大幅增加,这与实际工业产线边缘设备对算力与内存的轻量化限制产生了技术矛盾

Benefits of technology

[0012] This invention discloses a PCB micro-defect target detection method based on improved RT-DETR. Compared with the prior art, its advantages are: by constructing a lightweight high-resolution feature path, the redundant computation in the high-resolution feature path is reduced while retaining the spatial edge features of micro-defects; and by optimizing the regression process of micro-defect bounding boxes through SG-GCD metric and SCA-Loss loss function, a better balance is achieved between model lightweighting and detection accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122347589B_ABST
    Figure CN122347589B_ABST
Patent Text Reader

Abstract

The application discloses a PCB micro-defect target detection method based on an improved RT-DETR, which comprises the following steps: acquiring and amplifying a PKU-Market-PCB dataset, and dividing the dataset into a training set, a test set and a verification set; constructing a micro-defect target detection network for training; and performing target detection by using the trained model. The application constructs a light-weight high-resolution feature path, introduces a P2 shallow high-resolution feature layer in a feature pyramid, and configures a partial convolution structure in a backbone network, so as to retain micro-defect spatial edge features and reduce redundant calculation amount. For micro-defect regression, an SG-GCD metric with a fixed scale lower limit constraint introduced in a calculation denominator is constructed, an SCA-Loss loss function is designed, and dynamic weighted calculation of boundary overlap accuracy and center distance measurement is realized by using a global learnable parameter. The application reduces the model parameter amount, improves the training stability, and improves the detection accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of industrial vision inspection and target detection technology, specifically relating to a method for detecting minute defects in PCBs based on an improved RT-DETR. Background Technology

[0002] Printed circuit boards (PCBs) play a crucial role in electronic product manufacturing. Even minute defects (such as burrs and fake copper) can directly impact circuit performance and reliability, necessitating high-precision automated visual inspection. Existing PCB defect detection methods largely employ deep learning-based object detection models, extracting image features to locate and classify defects. However, in scenarios involving the detection of minute objects, current technologies still face significant technical obstacles.

[0003] On the one hand, in order to enhance the model's ability to perceive minute defects, the conventional approach usually attempts to introduce shallow high-resolution features (such as the P2 feature layer) to retain more spatial feature information. However, the direct introduction of high-resolution features increases the feature fusion path length, resulting in a significant increase in the amount of convolutional computation and model parameters. This creates a technical contradiction with the lightweight limitations of computing power and memory in actual industrial production line edge devices.

[0004] On the other hand, the size of micro-defects is usually small, and the scale normalization term (denominator) of existing center distance loss metrics tends to approach zero during computation. In backpropagation, this leads to the over-amplification of small positional offsets, resulting in gradient instability. This limitation of the metric prevents the model from consistently optimizing within normal training cycles, thus restricting the final accuracy and detection limit for micro-defects. Summary of the Invention

[0005] Based on the original RT-DETR model, this invention provides a method for detecting minute defects in PCBs based on an improved RT-DETR model. The aim is to effectively reduce the number of model parameters while improving the model's ability to perceive minute defects, and to solve the gradient instability problem during the regression of minute defects from a computational perspective.

[0006] This invention is specifically achieved through the following technical solution: a PCB micro-defect target detection method based on improved RT-DETR proposed in this invention, the steps of which are as follows: 1. Obtain the publicly available PKU-Market-PCB industrial defect dataset, and perform appropriate sample augmentation on the original PKU-Market-PCB dataset to construct a PCB defect detection dataset containing 3505 defect images; 2. Divide the dataset into a training set, a test set, and a validation set in an 8:1:1 ratio; 3. Construct a PCB micro-defect target detection network based on improved RT-DETR. In the process of feature extraction and fusion, construct a lightweight high-resolution feature path. By introducing a P2 shallow high-resolution feature layer, the spatial edge features of micro-defects are preserved. The redundant computation introduced by the high-resolution feature path is reduced by using a partial convolutional structure in the backbone network. 4. To address the gradient stability requirement of minute defects in regression, a generalized center distance metric SG-GCD based on scale constraints is constructed. 5. Import the training and validation sets into the detection network and train the model using the adaptive regression loss SCA-Loss based on SG-GCD; 6. Use the trained detection model to perform target detection on the test set to obtain defect category and location information.

[0007] The present invention provides a preferred embodiment of the lightweight high-resolution feature path implementation mechanism, which includes: on the basis of the original feature pyramid, the feature extraction depth of the network is lowered, and a shallow high-resolution feature layer of P2 is introduced to preserve the spatial edge features of small defects; at the same time, a partial convolution (PConv) structure is adopted in the backbone network, and only some channels are convolutionally operated through the channel separation mechanism, while the remaining input channels remain unchanged, thereby reducing the redundant computation in the high-resolution feature path while preserving the high-resolution spatial features.

[0008] In a preferred embodiment provided by the present invention, the SG-GCD (Scale-Grounded Generalized CenterDistance) metric includes: To address the gradient instability caused by the normalized denominator approaching zero during regression due to minor PCB defects, this metric incorporates a fixed-scale lower bound constraint τ into the denominator. The calculation formula is as follows: ,

[0009] Where, (x p , y p (x) represents the center coordinates of the prediction box. g , y g (w) represents the center coordinates of the true bounding box. g , h g ) represents the width and height of the true bounding box, τ represents the fixed scale lower limit constraint, and ϵ represents the numerical tolerance to prevent division by zero.

[0010] In a preferred embodiment provided by this invention, the SCA-Loss (Scale-Constrained Adaptive Loss) adaptive loss function includes: The dynamic weighted calculation of the GIoU regression term and the SG-GCD regression term is achieved through a globally learnable fusion parameter λ. The calculation formula is as follows: ,

[0011] Wherein, GIoU represents the boundary overlap accuracy based on generalized intersection-union ratio (GUCR), σ is the Sigmoid activation function, and λ is the globally learnable fusion parameter. This adaptive loss function automatically optimizes the fusion coefficients during backpropagation, enabling the model to rely on SG-GCD to smooth gradient instability in the early stages of training and on GIoU for fine-tuning of edges in the later stages.

[0012] This invention discloses a PCB micro-defect target detection method based on improved RT-DETR. Compared with the prior art, its advantages are: by constructing a lightweight high-resolution feature path, the redundant computation in the high-resolution feature path is reduced while retaining the spatial edge features of micro-defects; and by optimizing the regression process of micro-defect bounding boxes through SG-GCD metric and SCA-Loss loss function, a better balance is achieved between model lightweighting and detection accuracy. Attached Figure Description

[0013] Figure 1 The flowchart illustrates a PCB micro-defect target detection method based on an improved RT-DETR, as provided in this invention.

[0014] Figure 2 This is a schematic diagram of the detection network structure in a PCB micro-defect target detection method based on an improved RT-DETR provided by the present invention.

[0015] Figure 3 This is a schematic diagram of the P2-PConv feature path in the feature extraction and fusion module of this invention.

[0016] Figure 4 This is a schematic diagram illustrating the SCA-Loss regression optimization principle of this invention.

[0017] Figure 5 The image shows the PCB micro-defect target detection effect of the RT-DETR-SCA model; among them, Figure 5 (a) is a diagram showing the detection results of leak defects. Figure 5 (b) shows the detection results of short-circuit defects. Figure 5 (c) is a diagram showing the inspection results, including leaks and burr defects. Figure 5 (d) shows the detection results of rat bite defects. Detailed Implementation

[0018] To make the objectives, technical solutions, and advantages of the present invention clearer, the specific embodiments of the present invention will be further described below in conjunction with the accompanying drawings.

[0019] Figure 1 This is a flowchart illustrating the method of the present invention. The PCB micro-defect target detection method based on improved RT-DETR provided by the present invention specifically includes the following steps: Step 1: Obtain a publicly available authoritative dataset. For the needs of detecting minor defects in PCB industrial scenarios, preprocess and optimize the dataset by dividing it into training, testing and validation sets in an 8:1:1 ratio.

[0020] In this embodiment, the PKU-Market-PCB dataset is selected as the foundation. Through refined screening and label consistency checks, a PCB defect detection dataset containing 3505 defect images is constructed. This dataset covers six common industrial defects: leaks, rodent bites, open circuits, short circuits, burrs, and fake copper. A program is written to convert the dataset labels into a standardized format suitable for the improved model, and a summary file storing the relative paths and categories of each dataset is created.

[0021] Step 2: Construct the improved RT-DETR-SCA target detection network, the overall structure of which is as follows: Figure 2 As shown, it mainly consists of three parts: a backbone network, a feature extraction and fusion module, and a small defect target detection model.

[0022] First, after the PCB image to be tested is input into the backbone network, it undergoes preliminary feature extraction through Conv basic convolutions. Then, based on the deep features of the original feature pyramid (i.e., the BasicBlockPConv modules corresponding to layers P3, P4, and P5 in the diagram), this invention constructs the lightweight high-resolution feature path. Specifically, this path introduces a shallow high-resolution feature layer P2 (i.e., the BasicBlockPConv module corresponding to layer P2 in the diagram) to preserve the spatial edge features of minute defects. It should be noted that the BasicBlockPConv module in the backbone network is a lightweight processing module that specifically implements the "partial convolutional structure." It, together with the shallow high-resolution feature layer P2, constitutes the lightweight high-resolution feature path, and reduces redundant computation after introducing the P2 layer through a channel separation mechanism.

[0023] Next, the multi-scale features enter the feature extraction and fusion module. In the top-down FPN path, the features of the highest layer P5 are processed by the 1×1 feature projection and AIFI attention module, then sequentially upsampled and passed to the shallow layers, and concatenated with the shallow features corresponding to the backbone network. The concatenated features are then input to the RepC3 feature reconstruction module for deep fusion. This path extends until it is concatenated and reconstructed with the features output from the P2 layer. Subsequently, in the bottom-up PAN path, the fused features are sequentially downsampled and passed to the deeper layers starting from the P2 layer, and concatenated and reconstructed again with the features corresponding to the FPN path, achieving bidirectional deep fusion of multi-scale features.

[0024] Finally, the multi-scale fusion features output by the feature extraction and fusion module are uniformly fed into the micro-defect target detection model on the right for bounding box regression and category prediction, and finally output the detection results used to characterize the category and location information of micro-defects in the PCB image under test.

[0025] Step 3: For regression optimization of minor PCB defects, construct a scale-constrained generalized center distance metric SG-GCD, and design a scale-constrained adaptive loss function SCA-Loss based on this. The regression optimization principle is as follows: Figure 4 As shown.

[0026] Step 4: Import the divided dataset into the network for training, and use the SCA-Loss as the loss function for the detection head bounding box to guide backpropagation, thereby obtaining the trained small defect target detection model.

[0027] Step 5: Use the trained micro-defect target detection model to detect and verify micro-defects on the test set, and output the detection results containing defect category and location information, such as... Figure 5 As shown. Among them, Figure 5 (a) is a diagram showing the detection results of leak defects. Figure 5 (b) shows the detection results of short-circuit defects. Figure 5 (c) is a diagram showing the inspection results, which simultaneously include both leaks and burrs. Figure 5 (d) shows the detection results of rat bite defects.

[0028] Step 6: The detection results of the improved RT-DETR-SCA network of this invention are evaluated and analyzed. The model's recognition accuracy and various core performance indicators for each type of minor defect are statistically analyzed and compared.

[0029] Furthermore, the lightweight high-resolution feature path introduces a P2 shallow high-resolution feature layer and a PConv structure, such as... Figure 3As shown, directly introducing the P2 layer to explore the feature extraction depth would lead to a significant increase in convolutional computation and model parameters. Therefore, this invention introduces the PConv structure. PConv utilizes a channel separation mechanism to apply spatial convolution only to a portion of the input channels, while the remaining channels remain unchanged and undergo direct identity mapping. This reduces redundant computation in the high-resolution feature path while preserving high-resolution spatial features.

[0030] Furthermore, the SG-GCD (Scale-Grounded Generalized Center Distance) metric aims to address the problem that existing center distance metrics tend to have a normalized denominator close to zero in scenarios with small defects, leading to the excessive amplification of small positional deviations and causing gradient instability. SG-GCD provides the network with a smooth and stable mathematical optimization space by introducing a fixed scale lower bound constraint τ into the calculation denominator.

[0031] The mathematical expression for its stable center distance metric is as follows: ,

[0032] Among them, (x p , y p (x) represents the center coordinates of the prediction box. g , y g (w) represents the center coordinates of the true bounding box. g , h g ) represent the width and height of the true bounding box, respectively; τ is a fixed lower limit constraint of the scale, which is set to 0.01 in a preferred embodiment of the present invention; ϵ is the numerical tolerance to prevent division by zero.

[0033] Furthermore, the SCA-Loss (Scale-Constrained Adaptive Loss) adaptive loss function uses a globally learnable fusion parameter λ to dynamically weight the boundary overlap accuracy based on generalized intersection-union ratio (GUCR) ​​and the SG-GCD metric.

[0034] The mathematical expression for its total regression loss is as follows: ,

[0035] Wherein, GIoU is the boundary overlap accuracy based on generalized intersection-union ratio; σ is the sigmoid activation function; and λ is the globally learnable fusion parameter. This adaptive loss function automatically optimizes the best fusion coefficients through backpropagation, achieving an automated trade-off between relying on SG-GCD to effectively smooth gradient instability in the early stages of the model and relying on GIoU for fine-tuning of edges in the later stages.

[0036] Furthermore, experimental verification was conducted on the improved RT-DETR-SCA network of this invention. In a preferred embodiment of this invention, the batch size was uniformly set to 64, and the training period was set to 100 epochs. To objectively verify the beneficial effects of this invention, the parameters, model size, inference frame rate (FPS), mean precision (mAP@0.5), and recall on the test set of the improved model and the baseline model were statistically compared. The results are shown in Table 1 below.

[0037] Table 1 .

[0038] As shown in Table 1, compared to the original RT-DETR model, the proposed combined optimization scheme achieves a better balance between detection accuracy and model lightweighting. Regarding detection accuracy, thanks to the synergistic effect of the lightweight high-resolution feature path and SCA-Loss, the model's ability to perceive minute defects is improved. In one preferred embodiment, mAP@0.5 is improved by 2.74%. In particular, the core indicator reflecting the missed detection of small targets, recall, is improved by 3.69%, validating the effectiveness of the SG-GCD metric in mitigating gradient instability from an algorithmic perspective. In terms of lightweighting, by controlling the convolution calculation in the high-resolution feature path using the PConv module, the number of parameters in the improved model is reduced by 23.18%, and the model storage volume is compressed by 22.47%. Meanwhile, the inference speed (FPS) of the improved model remains at 204.54 frames per second, indicating its potential industrial application value in high-precision detection scenarios.

Claims

1. A method for detecting minute defects in PCBs based on an improved RT-DETR, characterized in that, The following processing steps are included: The publicly available PKU-Market-PCB industrial defect dataset was obtained, and the original PKU-Market-PCB industrial defect dataset was sample augmented to construct a PCB defect detection dataset containing 3505 defect images. The PCB defect detection dataset was then divided into a training set, a test set, and a validation set in a ratio of 8:1:

1. A small defect target detection network based on an improved RT-DETR architecture is constructed, wherein the small defect target detection network includes a backbone network, a feature extraction and fusion module, and a detection head; A lightweight high-resolution feature path is constructed jointly by the backbone network and the feature extraction and fusion module. The lightweight high-resolution feature path is configured as follows: on the basis of the P3, P4 and P5 levels of the original RT-DETR feature pyramid, a shallow high-resolution feature layer P2 is introduced to preserve the spatial edge features of small defects; and for the high-resolution feature path formed after introducing the shallow high-resolution feature layer P2, a partial convolutional structure is configured in the backbone network. The partial convolutional structure uses a channel separation mechanism to apply spatial convolution only to a portion of the input channels, while keeping the remaining input channels unchanged and directly performing identity mapping, so as to reduce the redundant computation introduced by the high-resolution feature path. In the feature extraction and fusion module, the features output from the P5 feature layer are processed by a 1×1 feature projection and an AIFI attention module. Then, in the top-down FPN path, the features are sequentially upsampled and passed to shallower layers. They are then concatenated with the corresponding layer features in the backbone network processed by the partial convolutional structure. The concatenated features are input to the RepC3 feature recombination module for fusion, until they are concatenated and recombined with the features output from the P2 shallow high-resolution feature layer. Subsequently, in the bottom-up PAN path, the fused features are sequentially downsampled and passed to deeper layers starting from the P2 layer. They are then concatenated and recombined again with the features of the corresponding layer in the FPN path, forming a bidirectional multi-scale feature fusion path with the P2 layer as the shallow starting point. For regression optimization targeting minor defects, a scale-constrained generalized center distance metric, SG-GCD, is constructed. SG-GCD uses the sum of the squared center coordinate distances between the predicted and ground truth bounding boxes as the numerator of the exponent, and the sum of the squared width of the ground truth bounding box, the squared height of the ground truth bounding box, the squared lower scale constraint τ, and the numerical tolerance ϵ as the denominator. Its calculation formula is as follows: , wherein (x p , y p ) is the center coordinate of the prediction box, (x g , y g ) is the center coordinate of the real box, (w g , h g ) are the width and height of the real box respectively, τ is the fixed scale lower bound constraint, and ε is a numerical tolerance to prevent division by zero, and the value of the fixed scale lower bound constraint τ is set to 0.

01. Based on the SG-GCD, a scale-constrained adaptive loss function SCA-Loss is constructed. SCA-Loss is configured to dynamically weight the (1-GIoU) ​​loss term and the (1-SG-GCD) loss term using a globally learnable fusion parameter λ. The formula for calculating the total regression loss is as follows: , Wherein, GIoU is the boundary overlap accuracy based on generalized intersection-union ratio, σ is the sigmoid activation function, and λ is the globally learnable fusion parameter; the globally learnable fusion parameter λ is used as a parameter to be trained in model training and is updated through backpropagation to automatically optimize the fusion weight between the (1-GIoU) ​​loss term and the (1-SG-GCD) loss term. The training set and the validation set are input into the small defect target detection network, and the SCA-Loss is used as the bounding box loss function of the detection head for regression optimization to obtain the trained small defect target detection model. The trained micro-defect target detection model is used to perform target detection on the test set, and the detection results are output to characterize the category and location information of micro-defects in the PCB image under test.

Citation Information

Patent Citations

  • PCB defect detection method, device and equipment based on improved YoloV11n

    CN121073958A

  • Printed circuit board defect detection method based on improved RT-DETR model

    CN121860935A

  • Electronic cigarette middle frame surface defect detection method based on improved RT-DETR

    CN122049459A