Industrial PCB defect identification method based on sample generation model

By constructing a condition generator and a multi-scale discriminator to generate diverse defect samples, and combining the YOLO-ADF model of adaptive dual-stream fusion backbone network and dynamic decoupling detection head, the problems of high error detection and high miss detection rates in industrial PCB circuit board detection are solved, and high precision and real-time defect detection are achieved.

CN120278974AActive Publication Date: 2025-07-08CHONGQING UNIV OF POSTS & TELECOMM

Patent Information

Application Number
CN202510381041.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-28
Publication Date
2025-07-08
Estimated Expiration
2045-03-28

AI Technical Summary

Technical Problem

The prior art has problems such as high error detection rate, high missed detection rate and poor adaptability of models to complex backgrounds in the detection of defects of industrial PCB circuit boards. Especially when dealing with small defects and complex defects, the defect pattern generated by traditional data enhancement methods is single, resulting in insufficient generalization capabilities of the model.

Method used

Using a method based on sample generation model, a variety of defect samples are generated by building a condition generator and a multi-scale discriminator, combined with an adaptive dual-stream fusion backbone network and a dynamic decoupling detection head, the training and detection of the data set quality and model detection performance are improved.

Benefits of technology

It significantly improves the accuracy of small defect detection, reduces the missed detection rate, improves the accuracy of detection and the robustness of the model, and meets the needs of industrial-grade real-time detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120278974A_ABST
    Figure CN120278974A_ABST
Patent Text Reader

Abstract

The invention belongs to the field of defect detection, and particularly relates to an industrial PCB defect identification method based on a sample generation model. Comprising the following steps: constructing an original PCB defect image data set with labels, and preprocessing original PCB defect images to obtain preprocessed images; inputting the preprocessed image into a sample generation model for processing to generate a defect sample; combining the original PCB defect image data set and the defect sample, and performing adaptive size filling and high-frequency noise injection processing to obtain an enhanced defect data set; training the YOLO-ADF target detection model by adopting the enhanced defect data set to obtain a trained YOLO-ADF target detection model; sampling the trained target detection model to carry out industrial PCB defect identification; according to the invention, the accuracy of small target defect detection is improved, the omission ratio is reduced, and the detection accuracy and the model robustness are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of defect detection, and particularly relates to an industrial PCB defect recognition method based on a sample generation model. Background Art

[0002] In industrial production, the quality inspection of PCB circuit boards is crucial for the reliability of electronic products. Traditional inspection methods have problems such as low efficiency and high misdetection rate. In recent years, deep learning models, especially object detection technologies such as YOLO, have been widely used in surface defect detection, improving the efficiency and accuracy of detection.

[0003] Although the YOLO model has strong real-time detection capabilities in complex scenarios, when the background is complex or the defects are small and difficult to distinguish, the model may still have a high misdetection rate and missed detection rate. Since small defects are relatively rare in PCB images and often mixed with background noise, when existing YOLO variants detect defects with an area <0.05% of the image area, the missed detection rate >18% due to the loss of feature pyramid information.

[0004] In addition, traditional data augmentation methods (such as rotation, flipping, translation, etc.) can expand the dataset, but these augmentation methods mainly deal with geometric changes and are difficult to generate diverse and complex defect samples. Especially when dealing with uncommon defects (such as virtual soldering and burrs), the augmentation effect is limited, restricting the generalization ability of the model. The defect morphologies generated by traditional data augmentation methods are single, and the morphological coverage rate of complex defects such as virtual soldering is <45%.

[0005] In order to improve the automatic detection accuracy and efficiency of surface defects on industrial PCB circuit boards, a new industrial PCB defect recognition method is urgently needed to address the problems of missed detection of tiny defects, insufficient training samples, and poor adaptability of the detection model to complex backgrounds, thereby reducing the missed detection rate while improving the detection accuracy and model robustness. Summary of the Invention

[0006] Aiming at the deficiencies of the existing technology, the present invention proposes an industrial PCB defect recognition method based on a sample generation model, which includes: obtaining a PCB defect image to be recognized and inputting it into a trained YOLO-ADF object detection model for processing to obtain a PCB defect recognition result;

[0007] The training process of the YOLO-ADF object detection model includes:

[0008] S1: Constructing a dataset of original PCB defect images with labels and preprocessing 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: Combine the original PCB defective image dataset and the defective samples and perform adaptive size padding and high-frequency noise injection processing to obtain an enhanced defective dataset;

[0011] S4: Use the enhanced defective dataset to train the YOLO-ADF object detection model to obtain a trained YOLO-ADF object detection model.

[0012] Preferably, the process of preprocessing the original PCB defective image includes: performing adaptive normalization processing on the original PCB defective image; performing conditional vector encoding processing on the label of the original PCB defective image to obtain a conditional vector.

[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; where: the input layer of the conditional generator sends the conditional vector to the fully connected layer, and the input layer of the multi-scale discriminator concatenates the conditional vector and the input image in channels and then sends them to the downsampling module; each upsampling module consists of a transposed convolutional layer and an AdaIN layer, and each downsampling module consists of a convolutional layer and an instance normalization layer; the multi-scale discriminator head performs parallel processing on the output of the conditional feature projection layer through three convolutional layers with different kernel sizes and then performs channel concatenation.

[0014] Preferably, the loss function for training the sample generation model is the sum of the basic adversarial loss, the feature matching loss, and the conditional consistency loss.

[0015] Furthermore, the feature matching loss is expressed as:

[0016]

[0017] Where represents the feature matching loss, x represents the real PCB defective sample, F(x) represents the deep features extracted by the discriminator from the PCB defective sample, y represents the label vector of the defective category, z represents the random noise vector input to the conditional generator, G(z|y) represents the defective sample synthesized by concatenating y and z and inputting them into the conditional generator, and F(G(z|y)) represents the corresponding features extracted from the defective sample G(z|y) synthesized by the generator. represents the expectation, and ||·||1 represents the L1 norm.

[0018] Furthermore, the conditional consistency loss is expressed as:

[0019]

[0020] Among them, represents the conditional consistency loss, represents the expectation, y represents the label vector of the defect category, G(z|y) represents the defect sample synthesized by concatenating y and z and inputting them into the conditional generator, and C(·) represents the multi-scale discriminant head.

[0021] Preferably, the YOLO-ADF object detection model includes an adaptive dual-stream fusion backbone network, a four-way feature pyramid, and a dynamic decoupling detection head; among them, the adaptive dual-stream fusion backbone network consists of four cascaded dual-stream fusion modules, and each dual-stream fusion module processes the standard convolutional stream and the lightweight convolutional stream in parallel, and then fuses the features through a three-dimensional attention mechanism; the four-way feature pyramid processes the sub-pixel upsampling path and the SPDConv downsampling path in parallel, and then realizes multi-scale feature fusion through the channel attention gating; the dynamic decoupling detection head consists of a classification branch and a regression branch, and uses a dynamic anchor box assignment strategy to update the anchor box parameters every 50 iterations to optimize the detection accuracy.

[0022] Furthermore, the standard convolutional stream consists of a 3×3 convolutional module and an SPD convolutional module, and the lightweight convolutional stream consists of a depthwise separable convolutional module and a Ghost convolutional module.

[0023] Furthermore, the formula for realizing multi-scale feature fusion through channel attention gating is expressed as:

[0024]

[0025] Among them, represents the feature map output by the i-th layer of the feature pyramid, α i , β i , γ i respectively represent the first, second, and third dynamic weight coefficients of the i-th layer, CAG(·) represents the channel attention gating, represents the feature map of the (i + 1)-th layer, represents the input feature of the upsampling path, represents the feature map of the (i - 1)-th layer, P i represents the original feature of the current i-th layer.

[0026] Furthermore, the determination process of the first, second, and third dynamic weight coefficients includes:

[0027] The first, second, and third dynamic weight coefficients are generated by a 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; and 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 the present invention are:

[0030] 1. Dataset expansion and quality improvement:

[0031] Diversity and authenticity: The defect samples generated by conditional GAN ​​perform well in FID, SSIM and LPIPS indicators, ensuring the diversity and authenticity of the data. Compared with the traditional GAN ​​method, the morphological variation coefficient of the generated samples reaches 0.48±0.07, breaking through the morphological singleness limitation of the traditional GAN.

[0032] Addressing the small sample problem: Generating samples effectively expands the original data set, increasing the proportion of samples <32px from 18% to 37%, significantly improving the training effect of the detection model under small sample data.

[0033] 2. Improved detection performance

[0034] High-precision detection: The YOLO-ADF model designed by the present invention significantly outperforms existing models in terms of AP@0.5 (0.913) and mAP50:95 (0.687). The ADF backbone network achieves feature retention of tiny defects (<32px) at the 320×320 resolution level through parallel feature extraction and 3D attention fusion, which increases AP@0.5 to 0.91±0.03.

[0035] Complex background interference resistance: Quad-FPN adopts a bidirectional cross-scale attention fusion mechanism to effectively suppress high-similar background interference with ΔE<15, reducing the false detection rate to 7.8%. Dynamic anchor frame allocation and composite loss function are coordinated and optimized to ensure the detection accuracy of 45:1 aspect ratio defects while keeping the model parameter volume at 4.7M and the inference speed at 123FPS.

[0036] 3. Model Lightweighting and Efficient Reasoning

[0037] Parameter quantity and speed optimization: Through dynamic detection head and lightweight design, the model optimizes the parameter quantity and inference speed while maintaining high accuracy. Compared with the traditional YOLO model, this invention performs well in both parameter quantity (4.7M) and inference speed (123FPS), and is suitable for industrial-grade real-time detection needs.

[0038] Real-time guarantee: The system is deployed and verified on NVIDIA Jetson AGX Xavier, with an inference speed of 123 FPS, meeting the requirement of 4-way parallel processing for 4K cameras (30 FPS) in the production line. TensorRT optimization reduces the model latency from 8.1 ms to 6.5 ms, ensuring real-time requirements in industrial scenarios;

[0039] The present invention improves the accuracy of small target defect detection, reduces the missed detection rate, and improves the detection accuracy and model robustness at the same time. Brief Description of the Drawings

[0040] Figure 1 It is a flow chart of the industrial PCB defect recognition method based on the sample generation model in the present invention;

[0041] Figure 2 It is a network structure diagram of the sample generation model in the present invention;

[0042] Figure 3 It is a network structure diagram of the YOLO-ADF target detection model in the present invention;

[0043] Figure 4 It is a structure diagram of the dual-stream fusion module in the YOLO-ADF target detection model in the present invention;

[0044] Figure 5 It is a working flow chart of the SimAM three-dimensional attention mechanism in the YOLO-ADF target detection model in the present invention;

[0045] Figure 6 It is a working flow chart of the CAG channel attention gating in the YOLO-ADF target detection model in the present invention. Detailed Embodiments

[0046] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts fall within the protection scope of the present invention.

[0047] The present invention proposes an industrial PCB defect recognition method based on a sample generation model, as Figure 1 shown, the method includes the following contents:

[0048] Obtain the PCB defect image to be recognized, and input it into the trained YOLO-ADF target detection model for processing to obtain the PCB defect recognition result.

[0049] The training process of the YOLO-ADF object detection model includes:

[0050] S1: Construct an original PCB defect image dataset with labels and preprocess the original PCB defect images to obtain preprocessed images.

[0051] Construct an original PCB defect image dataset. In this embodiment, the PKU PCB Dataset is used, which contains labels for 6 types of defects, as shown in Table 1; preprocess the original PCB defect images. Specifically: perform adaptive normalization processing on the original PCB defect images; perform conditional vector encoding processing on the labels of the original PCB defect images to obtain category conditional vectors.

[0052] Table 1 Defect statistics of the dataset

[0053]

[0054] S2: Input the preprocessed images into a sample generation model for processing to generate defect samples.

[0055] Construct a dual-path conditional generative adversarial network, namely the sample generation model, as Figure 2 shown. This sample generation model includes a conditional generator and a multi-scale discriminator.

[0056] 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 input layer of the conditional generator sends the category conditional vector to the fully connected layer. Each upsampling module consists of a two-dimensional transposed convolutional layer and an AdaIN layer. The data flow process of the conditional generator is: input layer (128-dimensional conditional 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 to generate a 256×256 image).

[0057] The working process of the AdaIN (Adaptive Instance Normalization) layer is as follows:

[0058] ① Map the category conditional vector to affine transformation parameters (scaling factor translation factor ) through the fully connected layer;

[0059] ② Perform normalization on the convolutional output features: AdaIN(x) = γ·(x - μ(x)) / σ(x) + β;

[0060] ③ Inject category conditional 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 in channels and then sends them into the downsampling module. Each downsampling module consists of a two-dimensional convolutional layer and an instance normalization layer; the multi-scale discriminator head performs parallel processing on the output of the conditional feature projection layer through three convolutions with different kernel sizes and then concatenates the channels. The data flow process of the multi-scale discriminator is: input layer (3-channel image + conditional vector concatenation) → 4-level downsampling module (Conv + IN) → conditional feature projection layer → multi-scale discriminator head parallel processing → global pooling to output the discrimination probability.

[0062] The multi-scale discriminator head contains three parallel branches: a 1×1 convolutional kernel extracts local detailed features, a 3×3 convolutional kernel captures medium-scale features, and a 5×5 convolutional kernel perceives global structural features; the outputs of each branch are concatenated in channels and then input into the global pooling output layer.

[0063] The sample generation model designed in the present invention adopts a progressive training strategy and performs adversarial training on the generator and the discriminator based on an improved Wasserstein loss function; the total loss of the model, that is, the improved Wasserstein loss function, is the sum of the basic adversarial loss, the feature matching loss, and the conditional consistency loss; where:

[0064] Basic adversarial loss

[0065]

[0066] Among them, D(x|y) represents the score of the conditional discriminator for real samples, G(z|y) represents the defective samples synthesized by inputting the concatenation of y and z into the conditional generator, x represents the real PCB defective samples, y represents the label vector of the defective category, and λ gp represents the gradient penalty coefficient, represents the score of the discriminator for the interpolation samples, where the construction of the interpolation samples is ∈ follows a U(0,1) distribution, represents the gradient operator for the interpolation samples, and an adaptive gradient clipping is used to set the value in the model.

[0067] Feature matching loss

[0068]

[0069] F(x) represents the deep features extracted by the discriminator from the PCB defective samples, z represents the random noise vector input into the generator, and F(G(z|y)) represents the corresponding features extracted from the defective samples G(z|y) synthesized by the generator. denotes expectation, and ||·||1 denotes the L1 norm.

[0070] conditional consistency loss

[0071]

[0072] where denotes the conditional consistency loss, C(·) denotes the multi-scale discriminant head, which is a sub-module of the multi-scale discriminator. It receives the generated images G(z|y) of all classes and outputs the conditional probability distribution to verify whether the defect class of the generated samples is consistent with the input condition y.

[0073] According to the training results, the optimal sample generation model is screened through the feature matching index and the diversity evaluation index, and the preprocessed images output in step S1 are input into the optimal sample generation model for processing to generate defect samples.

[0074] S3: Combine the original PCB defect image dataset and the defect samples, and perform adaptive size padding and high-frequency noise injection processing to obtain an enhanced defect dataset.

[0075] Combine the original PCB defect image dataset and the defect samples, and perform adaptive size padding and high-frequency noise injection processing on the combined data to obtain an enhanced defect dataset.

[0076] S4: Use the enhanced defect dataset to train the YOLO-ADF object detection model to obtain a trained YOLO-ADF object detection model.

[0077] As Figure 3 shown, the YOLO-ADF object detection model includes an adaptive two-stream fusion backbone network, a four-way feature pyramid, and a dynamic decoupling detection head.

[0078] The adaptive two-stream fusion backbone network is composed of four cascaded two-stream fusion modules, and the structure of each two-stream fusion module of this network is as Figure 4As shown in the figure, each dual-stream fusion module processes the standard convolution stream and the lightweight convolution stream in parallel, and then fuses the features through a 3D attention mechanism. Among them, the standard convolution stream consists of a 3×3 convolution module and an SPD convolution module, which is used to retain high-frequency detailed features; the lightweight convolution stream consists of a depthwise separable convolution module and a Ghost convolution module, which is used to extract global context information and reduce the computational complexity. The outputs of the two streams are fused through the SimAM 3D attention mechanism to achieve joint weighting of channels and spaces, enhancing the feature expression ability. The meaning of the data stream passing through 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 DualStream2 is 128×160×160, representing 128 intermediate semantic channels, and the output feature map of DualStream3 is 256×80×80, representing 256 high-level feature channels. Finally, the fourth component DualStream4 outputs at multiple scales to different levels of the feature pyramid (P2 for small-sized defects, P3 for medium and small-sized defects, P4 for capturing aspect ratio defects, P5 for providing global features and suppressing complex background interference). Multiple cascaded dual-stream modules gradually abstract the features, and the captured features range from local to global context.

[0079] As Figure 5 shown, the SimAM 3D attention mechanism measures the importance of each feature map by calculating the energy function of the feature map, effectively improving the feature expression ability and detection accuracy of the model. The specific process includes:

[0080] Energy function calculation: Calculate the energy value of each pixel according to the mean and variance of the feature map.

[0081] Weight generation: Use the Sigmoid function to normalize the energy value to generate a weight matrix.

[0082] Feature enhancement: Perform weight weighting on the input feature map to enhance important features and suppress irrelevant information.

[0083] The four-way feature pyramid processes the sub-pixel upsampling path and the SPDConv downsampling path in parallel, and then realizes multi-scale feature fusion 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, since the 320×320 feature map output by DualStream1 is denoted as P1, which contains too much low-frequency noise and is not conducive to defect detection, so the level here directly starts from P2).

[0085] Feature maps at different levels are processed through upsampling and downsampling paths; Upsampling path: Sub-pixel convolution is used to double the resolution (formula: Downsampling path: SPDConv spatial reorganization is used to halve the resolution (formula: ).

[0086] A cross-layer attention fusion mechanism is adopted. The outputs of the upsampling and downsampling paths are further used to dynamically adjust the feature weights through 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:

[0087]

[0088] Among them, represents the feature map output by the i-th layer of the feature pyramid, α i , β i , γ i respectively represent the first, second, and third dynamic weight coefficients generated by the third-order channel attention gating for the i-th layer. CAG(·) represents the channel attention gating, represents the feature map of the (i + 1)-th layer, represents the input feature of the upsampling path, represents the feature map of the (i - 1)-th layer, represents the input feature of the downsampling path, P i represents the original feature of the current i-th layer. (The value range of the above levels is 2, 3, 4, 5)

[0089] The dynamic weights (α i , β i , γ i ) are generated by the third-order channel attention gating and satisfy α i + β i + γ i = 1. As Figure 6 shown, the working process of the channel attention gating CAG is:

[0090] The input feature map undergoes global average pooling to generate a global feature description for each channel. Performing global average pooling on the input feature is expressed as: g = GAP(X);

[0091] Channel weights are generated through a fully connected layer and a Sigmoid activation function: w = σ(FC(g, r = 16)), where the compression ratio r = 16;

[0092] The channel weights are multiplied element-wise with the original feature map, i.e., feature recalibration: Thereby enhancing important channels and suppressing irrelevant channels.

[0093] By introducing a temperature coefficient τ = 0.5 to control the attention distribution, and for the original dynamic weight coefficients α i and βi To make corrections:

[0094]

[0095] β i The correction process is the same as the above α i The correction process is the same as that of i With β i Corrected independent adjustment γ i , so that α i +β i +γ i = 1. The purpose of using temperature coefficient correction is to sharpen the upper and lower layer weights α through the temperature coefficient i With β i , while retaining the current layer weight γ i , so that when the characteristic noise of a certain level is large, α can be reduced by adjusting the temperature coefficient i With β i , weakening its influence on feature learning, while retaining γ i No correction is used to ensure that the current level features are directly relied upon in simple defect scenarios.

[0096] The dynamic decoupled detection head consists of a classification branch and a regression branch. A dynamic anchor box allocation strategy is used during training, and the anchor box parameters are updated every 50 iterations to optimize the detection accuracy.

[0097] The loss function for training the YOLO-ADF target detection model is a composite loss, which is a weighted sum of improved classification loss, regression loss, and feature comparison auxiliary loss; specifically:

[0098] Preferably, the formula for the composite loss function is expressed as:

[0099] L total =0.307L cls +0.461L reg +0.231L aux

[0100] The weight distribution scheme of the loss function can be obtained through the following process:

[0101] Bayesian optimization search is used on the validation set to determine the initial weight range; the weight ratio is dynamically adjusted through gradient conflict analysis (GradNorm); the final weight configuration makes 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 the classification loss L cls, which is itself a variant of the Focal Loss function and serves to distinguish between easily confused defect categories:

[0104] L cls = -α(1 - p t ) γ log(p t )

[0105] Based on the traditional Focal Loss, a class margin is introduced for the morphological similarity of PCB defects where m = 0.7 represents increasing the angular margin between classes, s = 30 represents the scaling factor (optimized from the PKU PCB Dataset). α is used as the weight to balance positive and negative samples, and γ is the adjustment factor for focusing on difficult-to-detect samples. After introducing the above improvements, the inter-class confusion rate can be reduced.

[0106] For the regression loss L reg , which is itself a variant of the Wise-IoUv3 loss function and serves to locate defects with extreme aspect ratios:

[0107] L reg = β·Wise-IoUv3(b pred , b gt )

[0108] where b pred represents the predicted box coordinates, b gt represents the ground truth box coordinates, and β = 1.3 represents the weighting factor for aspect ratio defects. The improvement of the Wise-IoUv3 loss function mainly lies in:

[0109] where D(·) is an added dynamic penalty term based on the actual physical size of the PCB board, which increases the regression gradient by 1.8 times for defects with an aspect ratio > 20:1.

[0110] For the feature contrast auxiliary loss L aux , which serves to enhance the feature distinctiveness of small defects, and its functional form is:

[0111]

[0112] where f i represents the anchor feature of the i-th layer, f i + represents the positive sample feature of the same class in the i-th layer, f i - represents the negative sample feature of the same class in the i-th layer, and m represents the boundary margin.

[0113] The above three loss functions achieve multi-objective joint optimization through a gradient magnitude ratio of 1:1.5:0.8.

[0114] During training, dynamic anchor box allocation and composite loss backpropagation are performed. When the loss function converges or reaches the maximum number of iterations, the optimal model parameters are saved to obtain the trained YOLO-ADF object detection model. The PCB defect image to be recognized is obtained and input into the trained YOLO-ADF object detection model for processing, and the PCB defect recognition result can be obtained.

[0115] The present invention can be deployed and verified on NVIDIA Jetson AGX Xavier, with an inference speed reaching 123 FPS, meeting the 4-way parallel processing requirements of a production line 4K camera (30 FPS). TensorRT optimization reduces the model latency from 8.1 ms to 6.5 ms, ensuring the real-time requirements in industrial scenarios. The performance comparison results of the detection strategies of the present invention and the comparative methods are shown in Table 2.

[0116] Table 2 Performance Comparison of Detection Strategies between the Present Invention and Comparative Methods

[0117]

[0118] As can be seen from Table 2, the present invention is significantly superior to the existing models in terms of indicators such as AP@0.5 (0.913) and mAP50:95 (0.687).

[0119] In summary, the present invention solves the deficiencies of the prior art in small object detection, insufficient samples, and model generalization ability. The present invention improves the quality and diversity of PCB defect data generation by constructing a defect generation model based on conditional GAN; through a multi-stage object detection model based on YOLO (YOLO-ADF object detection model), a multi-scale feature and attention guidance mechanism are introduced, reducing the false detection rate under high similarity background interference and improving the detection accuracy of small object defects, thereby reducing the missed detection rate while improving the detection accuracy and model robustness.

[0120] The above examples have further detailed the purpose, technical solutions, and advantages of the present invention. It should be understood that the above examples are only the preferred embodiments of the present invention and are not intended to limit the present invention. Any modifications, equivalent replacements, improvements, etc. made to the present invention within the spirit and principles of the present invention shall be included in the protection scope of the present invention.

Claims

1. An industrial PCB defect recognition method based on a sample generation model, characterized in that, Including: Obtain the PCB defect image to be recognized and input it into the trained YOLO-ADF object detection model for processing to obtain the PCB defect recognition result; The training process of the YOLO-ADF object detection model includes: S1: Construct an original PCB defect image dataset with labels and preprocess the original PCB defect images to obtain preprocessed images; S2: Input the preprocessed images into the sample generation model for processing to generate defect samples; S3: Merge the original PCB defect image dataset and the defect samples and perform adaptive size filling and high-frequency noise injection processing to obtain an enhanced defect dataset; S4: Use the enhanced defect dataset to train the YOLO-ADF object detection model to obtain the trained YOLO-ADF object detection model.

2. The industrial PCB defect recognition method based on a sample generation model according to claim 1, wherein The process of preprocessing the original PCB defect images includes: performing adaptive normalization processing on the original PCB defect images; performing conditional vector encoding processing on the labels of the original PCB defect images to obtain conditional vectors.

3. The industrial PCB defect recognition method based on a sample generation model according to claim 1, wherein, 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 discriminant head, and a global pooling output layer; where: the input layer of the conditional generator sends the conditional vector to the fully connected layer, and the input layer of the multi-scale discriminator concatenates the conditional vector and the input image in channels and then sends them to the downsampling module; each upsampling module consists of a two-dimensional transposed convolutional layer and an AdaIN layer, and each downsampling module consists of a two-dimensional convolutional layer and an instance normalization layer; the multi-scale discriminant head processes the output of the conditional feature projection layer in parallel through three convolutional layers with different kernel sizes and then performs channel concatenation.

4. The industrial PCB defect recognition method based on a sample generation model according to claim 1, wherein The loss function for training the sample generation model is the sum of the basic adversarial loss, the feature matching loss, and the conditional consistency loss.

5. The industrial PCB defect recognition method based on a sample generation model according to claim 4, characterized in that The feature matching loss is expressed as: Among them, denotes the feature matching loss, x represents the true PCB defect sample, F(x) represents the deep features extracted by the discriminator from the PCB defect sample, y represents the label vector of the defect category, z represents the random noise vector input to the conditional generator, G(z|y) represents the defect sample synthesized by concatenating y and z and inputting them into the conditional generator, and F(G(z|y)) represents the corresponding features extracted from the defect sample G(z|y) synthesized by the generator. denotes the expectation, and ||·||1 denotes the L1 norm.

6. The industrial PCB defect recognition method based on a sample generation model according to claim 4, wherein The conditional consistency loss is expressed as: Among them, represents the conditional consistency loss, represents the expectation, y represents the label vector of the defect category, G(z|y) represents the defect sample synthesized by inputting the concatenation of y and z into the conditional generator, and C(·) represents the multi-scale discriminant head.

7. A method for identifying industrial PCB defects based on a sample generation model according to claim 1, characterized in that, The YOLO-ADF object detection model includes an adaptive dual-stream fusion backbone network, a four-way feature pyramid, and a dynamic decoupling detection head; among them, the adaptive dual-stream fusion backbone network consists of four cascaded dual-stream fusion modules, and each dual-stream fusion module processes the standard convolutional stream and the lightweight convolutional stream in parallel and then fuses the features through a three-dimensional attention mechanism; the four-way feature pyramid consists of a sub-pixel upsampling path, The SPDConv downsampling path processes in parallel and then realizes multi-scale feature fusion through a channel attention gating; The dynamic decoupling detection head consists of a classification branch and a regression branch, and uses a dynamic anchor box assignment strategy to update the anchor box parameters every 50 iterations to optimize the detection accuracy.

8. The industrial PCB defect recognition method based on a sample generation model according to claim 7, characterized in that The standard convolutional stream consists of a 3×3 convolutional module and an SPD convolutional module, and the lightweight convolutional stream consists of a depthwise separable convolutional module and a Ghost convolutional module.

9. The industrial PCB defect recognition method based on a sample generation model according to claim 7, characterized in that The formula for realizing multi-scale feature fusion through a channel attention gating is expressed as: Among them, P i out represents the feature map output by the i-th layer of the feature pyramid, α i , β i , γ i respectively represent the first, second, and third dynamic weight coefficients of the i-th layer, CAG(·) represents the channel attention gate, represents the feature map of the (i + 1)-th layer, represents the input feature of the upsampling path, represents the feature map of the (i - 1)-th layer, P i represents the original feature of the current i-th layer.

10. The industrial PCB defect recognition method based on a sample generation model according to claim 9, characterized in that, The determination process of the first, second, and third dynamic weight coefficients includes: The first, second, and third dynamic weight coefficients are generated by a third-order channel attention gate, and the sum of the three dynamic weight coefficients is 1; 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.

Citation Information

Patent Citations

  • Multi-style traditional Chinese painting peanut forming method based on neural network

    CN111161137A

  • Facial expression migration method based on self-supervised learning and generative adversarial mechanism

    CN111243066A

  • PCB surface defect detection method and system

    CN116452540A

  • PCB defect detection method based on improved YOLO v5 algorithm

    CN117351288A

  • PCB defect detection system and method based on improved YOLO algorithm

    CN119540152A

Cited By

  • Industrial defect image generation method, terminal equipment and storage medium

    CN120931643A

  • Industrial defect image generation method, terminal device, and storage medium

    CN120931643B

  • Multi-mode super-resolution guided PCB defect detection method

    CN120931664A

  • A multi-modal super-resolution guided PCB defect detection method

    CN120931664B

  • Image-based plug defect detection method and system

    CN120953225A