An industrial PCB defect identification method based on a sample generation model
By constructing a condition generator and a multi-scale discriminator to generate diverse defect samples, and combining an adaptive dual-stream fusion backbone network and a dynamically decoupled detection head YOLO-ADF model, the problems of high false negative rate and poor model adaptability in industrial PCB circuit board defect detection are solved, achieving high-precision and real-time defect detection.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-28
- Publication Date
- 2026-03-31
AI Technical Summary
Existing technologies for defect detection in industrial PCB circuit boards suffer from high false negative rates, high false positive rates, and poor model adaptability to complex backgrounds. In particular, when detecting defects with an area of less than 0.05%, traditional data augmentation methods generate defects with limited morphology, which are difficult to cover complex defects, resulting in insufficient model generalization ability.
A sample generation model-based approach is adopted, which generates diverse defect samples by constructing a condition generator and a multi-scale discriminator. The YOLO-ADF target detection model, which combines an adaptive dual-stream fusion backbone network and a dynamically decoupled detection head, is used for training and detection. The generated defect samples are processed by adaptive size padding and high-frequency noise injection to expand the dataset and improve the detection accuracy and robustness of the model.
It significantly reduces the false negative rate, improves detection accuracy and model robustness, and enhances the quality of the dataset by increasing the diversity and realism of the generated samples. The YOLO-ADF model outperforms existing models in small target detection and detection in complex backgrounds, meeting the needs of industrial-grade real-time detection.
Smart Images

Figure CN120278974B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of defect detection, specifically relating to a method for identifying defects in industrial PCBs based on a sample generation model. Background Technology
[0002] In industrial production, PCB circuit board quality inspection is crucial to the reliability of electronic products. Traditional inspection methods suffer from low efficiency and high false positive rates. In recent years, deep learning models, especially target detection technologies such as YOLO, have been widely used for surface defect detection, improving both efficiency and accuracy.
[0003] Although the YOLO model possesses strong real-time detection capabilities in complex scenarios, it can still exhibit high false positive and false negative rates when the background is complex or the defects are small and difficult to distinguish. Because small defects are relatively rare in PCB images and often mix with background noise, existing YOLO variants suffer from a false negative rate exceeding 18% when detecting defects covering an area <0.05% of the image area due to the loss of feature pyramid information.
[0004] In addition, while traditional data augmentation methods (such as rotation, flipping, and translation) can expand the dataset, these methods primarily deal with geometric changes and struggle to generate diverse and complex defect samples. This is especially true when dealing with uncommon defects (such as virtual welds and burrs), where the augmentation effect is limited, restricting the model's generalization ability. Traditional data augmentation methods generate defects with limited morphological coverage for complex defects such as virtual welds (<45%).
[0005] To improve the accuracy and efficiency of automatic detection of surface defects on industrial PCBs, a new method for industrial PCB defect identification is urgently needed to address issues such as missed detection of minute defects, insufficient training samples, and poor adaptability of detection models to complex backgrounds. This would reduce the false negative rate while improving detection accuracy and model robustness. Summary of the Invention
[0006] To address the shortcomings of existing technologies, this invention proposes an industrial PCB defect identification method based on a sample generation model. The method includes: acquiring an image of a PCB defect to be identified and inputting it into a trained YOLO-ADF target detection model for processing to obtain the PCB defect identification result.
[0007] The training process of the YOLO-ADF object detection model includes:
[0008] S1: Construct a labeled dataset of original PCB defect images and preprocess the original PCB defect images to obtain preprocessed images;
[0009] S2: Input the preprocessed image into the sample generation model for processing to generate defective samples;
[0010] S3: Merge the original PCB defect image dataset and defect samples, and perform adaptive size padding and high-frequency noise injection processing to obtain an enhanced defect dataset;
[0011] S4: The YOLO-ADF object detection model is trained using the enhanced defect dataset to obtain the trained YOLO-ADF object detection model.
[0012] Preferably, the preprocessing of the original PCB defect image includes: adaptive normalization processing of the original PCB defect image; and conditional vector encoding processing of the labels of the original PCB defect image to obtain conditional vectors.
[0013] Preferably, the sample generation model includes a conditional generator and a multi-scale discriminator. The conditional generator consists of an input layer, a fully connected layer, a 4-level upsampling module, a dual-path attention module, and an output layer. The multi-scale discriminator consists of an input layer, a 4-level downsampling module, a conditional feature projection layer, a multi-scale discriminator head, and a global pooling output layer. Specifically, the input layer of the conditional generator feeds the conditional vector into the fully connected layer, and the input layer of the multi-scale discriminator concatenates the conditional vector and the input image into the downsampling module. Each upsampling module consists of a 2D transposed convolutional layer and an AdaIN layer, and each downsampling module consists of a 2D convolutional layer and an instance normalization layer. The multi-scale discriminator head processes the output of the conditional feature projection layer in parallel through three convolutions with different kernel sizes before concatenating the channels.
[0014] Preferably, the loss function of the training sample generation model is the sum of adversarial loss, feature matching loss, and conditional consistency loss.
[0015] Furthermore, the feature matching loss is expressed as:
[0016]
[0017] in, Let F(x) represent the feature matching loss, x represent the real PCB defect sample, F(x) represent the deep features extracted by the discriminator from the PCB defect sample, y represent the label vector of the defect category, z represent the random noise vector input to the conditional generator, G(z|y) represent the defect sample synthesized by inputting y and z into the conditional generator, and F(G(z|y)) represent the corresponding features extracted from the defect sample G(z|y) synthesized by the generator. Let ||·||1 represent the expectation, and let L1 norm represent the L1 norm.
[0018] Furthermore, the conditional consistency loss is expressed as:
[0019]
[0020] in, This represents the loss due to conditional consistency. Let G(z|y) represent the expectation, y represent the label vector of the defect category, G(z|y) represent the defect sample synthesized by inputting y and z into the condition generator after concatenation, and C(·) represent the multi-scale discriminator.
[0021] Preferably, the YOLO-ADF object detection model includes an adaptive dual-stream fusion backbone network, a four-way feature pyramid, and a dynamically decoupled detection head. The adaptive dual-stream fusion backbone network consists of four cascaded dual-stream fusion modules, each processed in parallel by a standard convolutional stream and a lightweight convolutional stream, and then features are fused through a three-dimensional attention mechanism. The four-way feature pyramid is processed in parallel by a sub-pixel upsampling path and an SPDConv downsampling path, and then multi-scale feature fusion is achieved through channel attention gating. The dynamically decoupled detection head consists of a classification branch and a regression branch, and uses a dynamic anchor box allocation strategy, updating the anchor box parameters every 50 iterations to optimize detection accuracy.
[0022] Furthermore, the standard convolutional stream consists of 3×3 convolutional modules and SPD convolutional modules, while the lightweight convolutional stream consists of depthwise separable convolutional modules and Ghost convolutional modules.
[0023] Furthermore, the formula for achieving multi-scale feature fusion through channel attention gating is expressed as follows:
[0024]
[0025] in, α represents the feature map output by the i-th layer feature pyramid. i β i γ i These represent the first, second, and third dynamic weight coefficients of the i-th layer, respectively, and CAG(·) denotes channel attention gating. Let represent the feature map of the (i+1)th layer, and represent the input features of the upsampling path. P represents the feature map of the (i-1)th layer. i This represents the original features of the current i-th layer.
[0026] Furthermore, the process of determining the first, second, and third dynamic weighting coefficients includes:
[0027] The first, second, and third dynamic weight coefficients are generated by third-order channel attention gating, and the sum of the three dynamic weight coefficients is 1.
[0028] A temperature coefficient is introduced to update the first and second dynamic weight coefficients; the third dynamic weight coefficient is independently adjusted so that the sum of the three dynamic weight coefficients is 1.
[0029] The beneficial effects of this invention are as follows:
[0030] 1. Dataset expansion and quality improvement:
[0031] Diversity and Authenticity: The defective samples generated by conditional GANs perform excellently on FID, SSIM, and LPIPS metrics, ensuring data diversity and authenticity. Compared to traditional GAN methods, the morphological variation coefficient of the generated samples reaches 0.48±0.07, breaking through the morphological uniformity limitation of traditional GANs.
[0032] Addressing the small sample problem: Generating samples effectively expands the original dataset, increasing the proportion of samples <32px from 18% to 37%, significantly improving the training performance of the detection model on small sample data.
[0033] 2. Improved detection performance
[0034] High-precision detection: The YOLO-ADF model designed in this invention significantly outperforms existing models in terms of AP@0.5 (0.913) and mAP50:95 (0.687). The ADF backbone network achieves feature preservation of tiny defects (<32px) at a 320×320 resolution level through parallel feature extraction and 3D attention fusion, thereby improving AP@0.5 to 0.91±0.03.
[0035] Complex background robustness: Quad-FPN employs a bidirectional cross-scale attention fusion mechanism to effectively suppress interference from highly similar backgrounds with ΔE < 15, reducing the false detection rate to 7.8%. Dynamic anchor box allocation and composite loss function are optimized in tandem, ensuring the accuracy of defect detection with a 45:1 aspect ratio while keeping the number of model parameters to 4.7M and achieving an inference speed of 123 FPS.
[0036] 3. Lightweight Model and Efficient Inference
[0037] Parameter and speed optimization: Through a dynamic detection head and lightweight design, the model maintains high accuracy while optimizing parameter count and inference speed. Compared to the traditional YOLO model, this invention demonstrates superior performance in both parameter count (4.7M) and inference speed (123FPS), making it suitable for industrial-grade real-time detection requirements.
[0038] Real-time performance guarantee: The system was deployed and verified on NVIDIA Jetson AGX Xavier, achieving an inference speed of 123 FPS, meeting the 4-way parallel processing requirements of a 4K camera (30 FPS) on the production line. TensorRT optimization reduced model latency from 8.1ms to 6.5ms, ensuring real-time requirements in industrial scenarios;
[0039] This invention improves the accuracy of small target defect detection, reduces the false negative rate, and enhances both detection accuracy and model robustness. Attached Figure Description
[0040] Figure 1 This is a flowchart of the industrial PCB defect identification method based on a sample generation model in this invention;
[0041] Figure 2 This is a network structure diagram of the sample generation model in this invention;
[0042] Figure 3 This is a network structure diagram of the YOLO-ADF target detection model in this invention;
[0043] Figure 4 This is a structural diagram of the dual-stream fusion module in the YOLO-ADF target detection model of this invention;
[0044] Figure 5 This is a flowchart illustrating the workflow of the SimAM 3D attention mechanism in the YOLO-ADF object detection model of this invention.
[0045] Figure 6 This is a flowchart illustrating the CAG channel attention gating process in the YOLO-ADF target detection model of this invention. Detailed Implementation
[0046] 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.
[0047] This invention proposes a method for identifying defects in industrial PCBs based on a sample generation model, such as... Figure 1 As shown, the method includes the following:
[0048] The image of the PCB defect to be identified is acquired and input into the trained YOLO-ADF target detection model for processing to obtain the PCB defect identification result.
[0049] The training process of the YOLO-ADF object detection model includes:
[0050] S1: Construct a labeled dataset of original PCB defect images and preprocess the original PCB defect images to obtain preprocessed images.
[0051] A dataset of original PCB defect images was constructed. In this embodiment, the PKU PCB Dataset dataset was used, which contains labels for 6 types of defects, as shown in Table 1. The original PCB defect images were preprocessed, specifically: adaptive normalization was performed on the original PCB defect images; and conditional vector encoding was performed on the labels of the original PCB defect images to obtain category conditional vectors.
[0052] Table 1. Defect Statistics in the Dataset
[0053]
[0054] S2: Input the preprocessed image into the sample generation model for processing to generate defective samples.
[0055] Constructing a dual-path conditional generative adversarial network, i.e., a sample generation model, such as... Figure 2 As shown, the sample generation model includes a condition generator and a multi-scale discriminator.
[0056] The condition generator consists of an input layer, a fully connected layer, a 4-level upsampling module, a dual-path attention module, and an output layer. The input layer feeds the category condition vector into the fully connected layer. Each upsampling module consists of a 2D transposed convolutional layer and an AdaIN layer. The data flow of the condition generator is as follows: Input layer (128-dimensional condition vector) → Fully connected layer (output 512×8×8) → 4-level upsampling module (including TransConv + AdaIN) → Dual-path attention module (channel + spatial attention) → Output layer (Tanh activation generates a 256×256 image).
[0057] The workflow of the AdaIN (Adaptive Instance Normalization) layer is as follows:
[0058] ① Map the class condition vector to affine transformation parameters (scaling factor) through a fully connected layer. Translation factor );
[0059] ② Normalize the convolution output features: AdaIN(x)=γ·(x-μ(x)) / σ(x)+β;
[0060] ③ Inject category condition information after each level of upsampling module.
[0061] The multi-scale discriminator consists of an input layer, a 4-level downsampling module, a conditional feature projection layer, a multi-scale discriminator head, and a global pooling output layer. The input layer of the multi-scale discriminator concatenates the conditional vector and the input image into the downsampling module, each of which consists of a 2D convolutional layer and an instance normalization layer. The multi-scale discriminator head processes the output of the conditional feature projection layer through three convolutions of different kernel sizes in parallel before concatenating the channels. The data flow of the multi-scale discriminator is as follows: Input layer (3-channel image + conditional vector concatenation) → 4-level downsampling module (Conv+IN) → Conditional feature projection layer → Parallel processing by the multi-scale discriminator head → Global pooling output of the discrimination probability.
[0062] The multi-scale discriminator consists of three parallel branches: a 1×1 convolutional kernel to extract local detail features, a 3×3 convolutional kernel to capture medium-scale features, and a 5×5 convolutional kernel to perceive global structural features; the outputs of each branch are concatenated and then input into the global pooling output layer.
[0063] The sample generation model designed in this invention adopts a progressive training strategy, using an improved Wasserstein loss function to perform adversarial training on the generator and discriminator; its total model loss is the sum of the basic adversarial loss, feature matching loss, and conditional consistency loss, based on the improved Wasserstein loss function; wherein:
[0064] Basic combat losses
[0065]
[0066] Where D(x|y) represents the conditional discriminator's score for the real sample, G(z|y) represents the defect sample synthesized by concatenating y and z and inputting it into the conditional generator, x represents the real PCB defect sample, y represents the label vector of the defect category, and λ gp Represents the gradient penalty coefficient. This represents the discriminator's score for the interpolated sample, where the interpolated sample is constructed as follows: ∈ follows a U(0,1) distribution. This represents the gradient operator with respect to the interpolated samples. The model uses an adaptive gradient clipping setting.
[0067] Feature matching loss
[0068]
[0069] F(x) represents the deep features extracted by the discriminator from the PCB defect samples, z represents the random noise vector input to the generator, and F(G(z|y)) represents the corresponding features extracted from the defect samples G(z|y) synthesized by the generator. Let ||·||1 represent the expectation, and let L1 norm represent the L1 norm.
[0070] Conditional consistency loss
[0071]
[0072] in, C(·) represents the conditional consistency loss, and C(·) represents the multi-scale discriminator head, which is a submodule of the multi-scale discriminator. It receives the generated images G(z|y) of all categories and outputs the conditional probability distribution to verify whether the defect category of the generated sample is consistent with the input condition y.
[0073] Based on the training results, the optimal sample generation model is selected by using feature matching index and diversity evaluation index. The preprocessed image output from step S1 is then input into the optimal sample generation model for processing to generate defective samples.
[0074] S3: Merge the original PCB defect image dataset and defect samples, and perform adaptive size padding and high-frequency noise injection processing to obtain an enhanced defect dataset.
[0075] The original PCB defect image dataset and defect samples are merged, and the merged data is subjected to adaptive size padding and high-frequency noise injection to obtain an enhanced defect dataset.
[0076] S4: The YOLO-ADF object detection model is trained using the enhanced defect dataset to obtain the trained YOLO-ADF object detection model.
[0077] like Figure 3 As shown, the YOLO-ADF object detection model includes an adaptive dual-stream fusion backbone network, a four-way feature pyramid, and a dynamically decoupled detection head.
[0078] The adaptive dual-stream fusion backbone network consists of four cascaded dual-stream fusion modules. The structure of each dual-stream fusion module in this network is as follows: Figure 4As shown, each dual-stream fusion module consists of a standard convolutional stream and a lightweight convolutional stream processed in parallel, and then the features are fused through a 3D attention mechanism. The standard convolutional stream comprises a 3×3 convolutional module and an SPD convolutional module to preserve high-frequency detail features; the lightweight convolutional stream comprises a depthwise separable convolutional module and a Ghost convolutional module to extract global contextual information and reduce computational complexity. The two stream outputs are fused using the SimAM 3D attention mechanism to achieve joint channel and spatial weighting, enhancing feature representation capabilities. The meaning of the data flow of each module is as follows: the output feature map of DualStream (dual-stream fusion module) 1 is 64×320×320, representing 64 basic feature channels; the output feature map of DualStream 2 is 128×160×160, representing 128 intermediate semantic channels; the output feature map of DualStream 3 is 256×80×80, representing 256 high-level feature channels; finally, the fourth component, DualStream 4, outputs the feature at multiple scales to different levels of the feature pyramid (P2 for small-sized defects, P3 for medium-sized defects, P4 for capturing aspect ratio defects, and P5 for providing global features and suppressing interference from complex backgrounds). Multiple cascaded dual-stream modules progressively abstract the features, capturing features from local to global context.
[0079] like Figure 5 As shown, the SimAM 3D attention mechanism measures the importance of each feature map by calculating its energy function, effectively improving the model's feature representation ability and detection accuracy. The specific process includes:
[0080] Energy function calculation: Calculate the energy value of each pixel based on the mean and variance of the feature map.
[0081] Weight generation: The energy values are normalized using the Sigmoid function to generate a weight matrix.
[0082] Feature enhancement: Weight the input feature map to enhance important features and suppress irrelevant information.
[0083] The four-way feature pyramid is processed in parallel by sub-pixel upsampling paths and SPDConv downsampling paths, and then multi-scale feature fusion is achieved through channel attention gating. Specifically:
[0084] First, input feature maps of different levels: P5 (1024×10×10), P4 (1024×20×20), P3 (512×40×40), P2 (256×80×80) (Here, because the 320×320 feature map output by DualStream1, if recorded as P1, contains too much low-frequency noise, which is not conducive to defect detection, the level here starts directly from P2).
[0085] Feature maps at different levels are processed through upsampling and downsampling paths; Upsampling path: resolution is doubled using sub-pixel convolution (formula: Downsampling path: SPDConv spatial reconstruction is used to halve the resolution (formula: ).
[0086] A cross-layer attention fusion mechanism is adopted, where the outputs of the upsampling and downsampling paths are dynamically adjusted by channel attention gating to achieve multi-scale feature fusion. This mechanism can effectively suppress the interference contribution of low-quality feature layers. The feature fusion formula is as follows:
[0087]
[0088] in, α represents the feature map output by the i-th layer feature pyramid. i β i γ i These represent the first, second, and third dynamic weight coefficients generated by the third-order channel attention gating in the i-th layer, respectively, and CAG(·) denotes channel attention gating. Let represent the feature map of the (i+1)th layer, and represent the input features of the upsampling path. Let P represent the feature map of the (i-1)th layer, and let P represent the input features of the downsampling path. i This represents the original feature of the current i-th layer. (The value range for the above layer is 2, 3, 4, 5.)
[0089] Dynamic weights (α) i ,β i ,γ i Generated by third-order channel attention gating, satisfying α i +β i +γ i =1. For example... Figure 6 As shown, the channel attention-gated CAG workflow is as follows:
[0090] The input feature map is subjected to global average pooling to generate a global feature description for each channel. The global average pooling of the input features is represented as: g = GAP(X);
[0091] Channel weights are generated using a fully connected layer and a Sigmoid activation function: w = σ(FC(g, r = 16)), where the compression ratio r = 16;
[0092] Feature recalibration is achieved by multiplying the channel weights element-wise with the original feature map: This enhances important channels and suppresses irrelevant channels.
[0093] Attention distribution is controlled by introducing a temperature coefficient τ = 0.5, and the original dynamic weighting coefficient α is adjusted. i With βi Make corrections:
[0094]
[0095] β i The correction process is the same as the above α i The correction process is the same, α i With β i Corrected independent adjustment of γ i , so that α i +β i +γ i =1. The purpose of using temperature coefficient correction is to sharpen the upper and lower layer weights α through temperature coefficient. i With β i Meanwhile, the current layer weight γ is retained. i This allows α to be reduced by adjusting the temperature coefficient when the characteristic noise of a certain level is large. i With β i This weakens its impact on feature learning while retaining γ. i No correction is used to ensure direct reliance on features at this level in simple defect scenarios.
[0096] The dynamic decoupled detection head consists of a classification branch and a regression branch. During training, a dynamic anchor box assignment strategy is used, and the anchor box parameters are updated every 50 iterations to optimize detection accuracy.
[0097] The loss function for training the YOLO-ADF object detection model is a composite loss, which is a weighted sum of the improved classification loss, regression loss, and feature contrast auxiliary loss; specifically:
[0098] Preferably, the formula for the composite loss function is expressed as follows:
[0099] L total =0.307L cls +0.461L reg +0.231L aux
[0100] The weight allocation scheme for the loss function can be obtained through the following process:
[0101] Bayesian optimization search was used on the validation set to determine the initial weight range; the weight ratio was dynamically adjusted through gradient conflict analysis (GradNorm); the final weight configuration made the gradient magnitude ratio of the three losses reach 1:1.5:0.8.
[0102] The specific meanings of each loss item are as follows:
[0103] For improving classification loss L clsIt is itself a variant of the Focal Loss function, serving to distinguish easily confused defect categories:
[0104] L cls =-α(1-p t ) γ log(p t )
[0105] Based on the traditional Focal Loss, a category margin is introduced to address the morphological similarity of PCB defects. Where m = 0.7 represents increasing the inter-class angular margin, and s = 30 represents the scaling factor (optimized from the PKU PCB Dataset). α is used to balance the weights of positive and negative samples, and γ is an adjustment factor for focusing on difficult-to-detect samples. After introducing the above improvements, the inter-class confusion rate can be reduced.
[0106] For regression loss L reg It is a variant of the Wise-IoUv3 loss function, and is used to locate defects with extreme aspect ratios.
[0107] L reg =β·Wise-IoUv3(b pred ,b gt )
[0108] Where b pred b represents the coordinates of the predicted bounding box. gt This represents the coordinates of the true bounding box, and β = 1.3 represents the weighting factor for aspect ratio defects. The main improvements to the Wise-IoUv3 loss function are:
[0109] D(·) is an added dynamic penalty term based on the actual physical dimensions of the PCB board, which increases the regression gradient by 1.8 times for defects with an aspect ratio > 20:1.
[0110] For feature contrast auxiliary loss L aux This enhances the distinguishability of small defects, and its functional form is:
[0111]
[0112] Where f i f represents the anchor point feature of the i-th layer. i + f represents the features of positive samples of the same class in the i-th layer. i - Let m represent the features of negative samples of the same class in the i-th layer, and m represent the boundary margin.
[0113] The three loss functions mentioned above achieve multi-objective joint optimization through a gradient magnitude ratio of 1:1.5:0.8.
[0114] During training, dynamic anchor box assignment and backpropagation of the composite loss are performed. When the loss function converges or reaches the maximum number of iterations, the optimal model parameters are saved, resulting in a trained YOLO-ADF object detection model. Images of PCB defects to be identified are acquired and input into the trained YOLO-ADF object detection model for processing, yielding the PCB defect identification results.
[0115] This invention can be deployed and verified on NVIDIA Jetson AGX Xavier, achieving an inference speed of 123 FPS, meeting the four-way parallel processing requirements of a 4K camera (30 FPS) on a production line. TensorRT optimization reduces model latency from 8.1 ms to 6.5 ms, ensuring real-time requirements in industrial scenarios. The performance comparison results of this invention with the contrasting detection strategies are shown in Table 2.
[0116] Table 2. Performance Comparison of Detection Strategies between the Invention and Comparative Methods Table 2.
[0117]
[0118] As can be seen from Table 2, the present invention significantly outperforms existing models in terms of AP@0.5 (0.913) and mAP50:95 (0.687).
[0119] In summary, this invention addresses the shortcomings of existing technologies in small target detection, insufficient sample size, and model generalization ability. By constructing a defect generation model based on conditional GANs, this invention improves the quality and diversity of PCB defect data generation. Furthermore, by introducing multi-scale features and attention-guided mechanisms based on the YOLO multi-stage target detection model (YOLO-ADF target detection model), the false detection rate under high-similarity background interference is reduced, and the detection accuracy for small target defects is improved. This reduces the false negative rate while simultaneously enhancing detection accuracy and model robustness.
[0120] The above-described embodiments further illustrate the purpose, technical solution, and advantages of the present invention. It should be understood that the above-described embodiments are merely preferred embodiments of the present invention and are not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made to the present invention within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. An industrial PCB defect recognition method based on a sample generation model, characterized in that, The method comprises the following steps: The training process of the YOLO-ADF target detection model comprises: S1: constructing a labeled original PCB defect image dataset and preprocessing the original PCB defect image to obtain a preprocessed image; S2: inputting the preprocessed image into a sample generation model for processing to generate a defect sample; the sample generation model comprises a conditional generator and a multi-scale discriminator; the conditional generator comprises an input layer, a full connection layer, a 4-level upsampling module, a dual-path attention module and an output layer; the multi-scale discriminator comprises an input layer, a 4-level downsampling module, a conditional feature projection layer, a multi-scale discrimination head and a global pooling output layer; wherein: the input layer of the conditional generator inputs a condition vector into the full connection layer, and the input layer of the multi-scale discriminator inputs the condition vector and the input image after channel splicing into the downsampling module; each upsampling module comprises a two-dimensional transpose convolution layer and an AdaIN layer, and each downsampling module comprises a two-dimensional convolution layer and an instance normalization layer; the multi-scale discrimination head parallelly processes the outputs of the conditional feature projection layer through three convolution kernels with different sizes and then performs channel splicing; S3: merging the original PCB defect image dataset and the defect sample and performing adaptive size padding and high-frequency noise injection processing to obtain an enhanced defect dataset; S4: training the YOLO-ADF target detection model by using the enhanced defect dataset to obtain the trained YOLO-ADF target detection model; the YOLO-ADF target detection model comprises an adaptive dual-flow fusion backbone network, a four-way feature pyramid and a dynamic decoupling detection head; wherein, the adaptive dual-flow fusion backbone network comprises four cascaded dual-flow fusion modules, each dual-flow fusion module parallelly processes a standard convolution stream and a lightweight convolution stream, and then fuses features through a three-dimensional attention mechanism; the four-way feature pyramid parallelly processes a sub-pixel upsampling path and a SPDConv downsampling path, and then realizes multi-scale feature fusion through a channel attention gate; the dynamic decoupling detection head is composed of a classification branch and a regression branch, and uses a dynamic anchor box assignment strategy, and updates anchor box parameters every 50 iterations to optimize detection accuracy. The preprocessing process of the original PCB defect image comprises: adaptive normalization processing of the original PCB defect image; and condition vector encoding processing of the label of the original PCB defect image to obtain a condition vector.
2. The industrial PCB defect identification method based on a sample generative model according to claim 1, characterized in that, The loss function of the sample generation model is the sum of a basic adversarial loss, a feature matching loss and a condition consistency loss.
3. The method of claim 1, wherein the method is based on a sample generative model. The feature matching loss is represented as:
4. The industrial PCB defect identification method based on a sample generative model according to claim 3, characterized in that, The condition consistency loss is represented as: wherein, represents a feature matching loss, x represents a real PCB defect sample, F(x) represents a deep feature extracted from the PCB defect sample by the discriminator, y represents a label vector of a defect category, z represents a random noise vector input into the conditional generator, G(z|y) represents a defect sample synthesized by inputting y and z into the conditional generator, F(G(z|y)) represents corresponding features extracted from the defect sample G(z|y) synthesized by the generator, represents an expectation, and ||·||1 represents an L1 norm.
5. The method of claim 3, wherein the method further comprises: The standard convolution stream is composed of a 3x3 convolution module and a SPD convolution module, and the lightweight convolution stream is composed of a depth separable convolution module and a Ghost convolution module. wherein, represents a condition consistency loss, represents an expectation, y represents a label vector of a defect category, z represents a random noise vector input to the condition generator, G(z|y) represents a defect sample synthesized by inputting y and z to the condition generator, and C(·) represents a multi-scale discrimination head.
6. The method of claim 1, wherein the method is based on a sample generative model for industrial PCB defect recognition. The formula for realizing multi-scale feature fusion through the channel attention gate is:
7. The method of claim 1, wherein the method is based on a sample generative model for industrial PCB defect recognition. The determination process of the first, second and third dynamic weight coefficients comprises: wherein, denotes the feature map of the i-th layer feature pyramid output, and i , β i , γ i denote the first, second and third dynamic weight coefficients of the i-th layer, respectively, and CAG(·) denotes the channel attention gate, denotes the feature map of the i+1-th layer, and denotes the input feature of the up-sampling path, denotes the feature map of the i-1-th layer, and denotes the input feature of the down-sampling path, and i denotes the original feature of the current i-th layer.
8. The method of claim 7, wherein the method further comprises: The first, second and third dynamic weight coefficients are generated by a third-order channel attention gate, and a sum of the three dynamic weight coefficients is 1; The first and second dynamic weight coefficients are updated by introducing a temperature coefficient; and the third dynamic weight coefficient is independently adjusted so that the sum of the three dynamic weight coefficients is 1.
Citation Information
Patent Citations
Facial expression migration method based on self-supervised learning and generative adversarial mechanism
CN111243066A
Lightweight rice disease prediction method based on SCL-YOLOv8n
CN119625543A