CN-122023364-A - PCBA surface defect detection method based on abnormal synthesis strategy
Abstract
The invention discloses a PCBA surface defect detection method based on an abnormal synthesis strategy. Firstly, constructing a PCBA target detection data set, training a target detection model by using the PCBA target detection data set, identifying electronic elements in a PCBA image by using the trained target detection model to obtain an electronic element image, classifying all the electronic element images according to categories to obtain defect detection data sets of various electronic elements to obtain a PCBA defect detection data set, then constructing a double-branch interconnection diffusion model, generating global abnormal images of various electronic elements by using the double-branch interconnection diffusion model to obtain an expanded PCBA defect detection data set, finally constructing a defect detection model, training the defect detection model by using the expanded PCBA defect detection data set, and using the trained defect detection model for PCBA surface defect detection. The structure and appearance information of the background are referred to when the abnormal image is generated, so that the rationality and the authenticity of the generated abnormal image are improved.
Inventors
- HE JINGFEI
- HE LIUMING
- Mi Chenghu
- LI ZHENGLONG
- YANG ZHUQING
Assignees
- 河北工业大学
Dates
- Publication Date
- 20260512
- Application Date
- 20260204
Claims (4)
- 1. The PCBA surface defect detection method based on the abnormal synthesis strategy is characterized by comprising the following steps of: Constructing a PCBA target detection data set, and training a target detection model by utilizing the PCBA target detection data set to obtain a trained target detection model; Collecting a small amount of PCBA images, preprocessing, and identifying electronic elements in the preprocessed PCBA images by using a trained target detection model to obtain electronic element images; classifying all the electronic element images according to the electronic element types to obtain defect detection data sets of various electronic elements, thereby obtaining PCBA defect detection data sets; Thirdly, constructing a double-branch interconnection diffusion model, and generating global abnormal images of various electronic elements by using the double-branch interconnection diffusion model to obtain an expanded PCBA defect detection data set; Acquiring a small amount of real global abnormal images and masks of each defect type of each type of electronic element, multiplying the real global abnormal images by the masks element by element to obtain real local abnormal images, and thus obtaining real global abnormal image-local abnormal image pairs; based on an SD model, constructing a double-branch interconnection diffusion model, wherein the double-branch interconnection diffusion model comprises a global branch and a local branch, and the two branches comprise a variable self-encoder and a DA-TransUNet network, wherein a background compensation block is embedded before each double-attention block of the DA-TransUNet network of the global branch, and the output characteristics of the double-attention blocks at the same position of the DA-TransUNet network of the two branches are interacted in a self-attention interaction block; The forward noise adding process of the double-branch interconnection diffusion model comprises the steps of respectively encoding a real global abnormal image-local abnormal image into a potential space through respective variational self-encoders to obtain a global abnormal image potential representation and a local abnormal image potential representation; the reverse denoising process of the double-branch interconnection diffusion model comprises the steps of gradually denoising the potential representation of the global abnormal image of the whole noise by the DA-TransUNet network of the global branch to generate the global abnormal image; In a background compensation block, extracting a foreground object mask of a real global abnormal image by using a pre-trained significance detection model, extracting a background image by using an inversion mask of the foreground object mask, encoding the background image into a potential space by a variational self-encoder to obtain a background image potential representation, adding random noise to the background image potential representation to a current diffusion time step to obtain a background image potential representation with the current diffusion time step being noisy, extracting background features of the background image potential representation with the current diffusion time step by a U-Net encoder, mapping the background features by a multi-layer perceptron to obtain modulated background features, and injecting the modulated background features serving as background information into a dual attention block of a DA-TransUNet network, so that query vectors of the dual attention block are obtained Key vector Sum vector The calculation formula is as follows: (4) (5) (6) Wherein, the As an input feature of the dual attention block, 、 And As a matrix of weights, the weight matrix, In order to be able to learn the adjustment coefficients, Is a modulated background feature; In the self-attention interactive block, the DA-TransUNet network for the global branch and the local branch according to the formula (7) Output features of individual dual attention blocks And Processing to obtain global-local joint characteristics ; (7) Wherein, the In order to operate for the purpose of discharging, The splicing operation is performed; DA-TransUNet network Using Global-local Joint feature as value vector, global Branch and local Branch The method comprises the steps of adding the global-local combined characteristic of information interaction and the global-local combined characteristic, and sequentially carrying out rearrangement operation and splitting operation on the added characteristics to obtain two characteristic sums, wherein the two characteristic sums are used as input characteristics of a DA-TransUNet network corresponding decoding layer of a global branch and a local branch; Fourth, constructing a defect detection model, training the defect detection model by using the expanded PCBA defect detection data set, and using the trained defect detection model for PCBA surface defect detection.
- 2. The method for detecting the surface defects of the PCBA based on the abnormal synthesis strategy according to claim 1 is characterized in that the defect detection model comprises a feature extractor and a conditional normalization stream, a test PCBA image is subjected to multi-scale feature extraction through the feature extractor, the multi-scale feature is subjected to conditional normalization stream mapping to a latent space to obtain Gaussian distribution of input features, log likelihood values are calculated according to the Gaussian distribution of the input features, the log likelihood values of the features at all positions are converted into intervals [0,1] to obtain abnormal scores of all the positions, the abnormal score of the test PCBA image is calculated according to the abnormal scores of all the positions by adopting a Top-K average aggregation algorithm, and if the abnormal score of the test PCBA image is larger than an abnormal threshold, the surface of the PCBA is defective, otherwise, the defect is not present.
- 3. The method for PCBA surface defect detection based on an anomaly synthesis strategy of claim 2, wherein the feature extractor employs a pre-trained EFFICIENTNET-B6 backbone network, and the multi-scale features are the output features of the third, fourth, and fifth feature extraction layers of the EFFICIENTNET-B6 backbone network, respectively.
- 4. The method for detecting surface defects of a PCBA based on an abnormal synthesis strategy according to any one of claims 1 to 3, wherein the noise adding process of the dual-branch interconnection diffusion model is represented as: (2) (3) Wherein, the 、 Respectively the first Global and local anomaly image potential representations that are each diffusion time step noisy, 、 Global and local anomaly image potential representations respectively, Is the diffusion coefficient of the light-emitting diode, 、 Is random noise.
Description
PCBA surface defect detection method based on abnormal synthesis strategy Technical Field The invention belongs to the technical field of PCBA defect detection, and particularly relates to a PCBA surface defect detection method based on an abnormal synthesis strategy. Background In modern electronics manufacturing, printed circuit board assembly (Printed Circuit Board Assemble, PCBA) has become an important component of most electronic devices, the quality of which directly affects the performance and lifetime of the electronic device, and surface defect detection is an essential element in PCBA quality control. As electronic components on printed circuit boards grow in size and layout become more complex, defect detection also becomes more challenging. At present, manual visual inspection and an AOI-based method are mainly adopted. The manual visual inspection has the advantages of low cost, high flexibility and the like, is limited by subjective judgment and fatigue of people, often cannot keep consistency and high efficiency of detection, and is difficult to deal with a large-batch detection task and complex defect types on a mass production line, so that the detection efficiency is low, and the false detection rate of products is high. The AOI-based detection method can realize high-precision surface defect detection by means of advanced industrial imaging and image processing methods, has the advantages of rapidness, high efficiency and the like, and can finish a large amount of detection tasks in a short time. However, many electronic components on a printed circuit board, because it is difficult to collect a sufficient number of abnormality samples with a complete variety, the model tends to focus on only the normal samples, learning from only the normal samples may limit the discernability of the model, and lack of discrimination guidance of abnormality data results in poor performance of the model in an abnormality detection task. Because of lack of available abnormal images and priori knowledge of abnormal categories, the existing method mainly relies on carefully designed data enhancement strategies or external data to generate abnormal images, so that the generated abnormal images are low in quality, abnormal areas are fused with the background unnaturally, and the diversity and complexity of real defects are difficult to accurately simulate. Disclosure of Invention Aiming at the defects of the prior art, the invention aims to solve the technical problem of providing a PCBA surface defect detection method based on an abnormal synthesis strategy. The invention solves the technical problems by adopting the following technical scheme: The PCBA surface defect detection method based on the abnormal synthesis strategy is characterized by comprising the following steps of: Constructing a PCBA target detection data set, and training a target detection model by utilizing the PCBA target detection data set to obtain a trained target detection model; Collecting a small amount of PCBA images, preprocessing, and identifying electronic elements in the preprocessed PCBA images by using a trained target detection model to obtain electronic element images; classifying all the electronic element images according to the electronic element types to obtain defect detection data sets of various electronic elements, thereby obtaining PCBA defect detection data sets; Thirdly, constructing a double-branch interconnection diffusion model, and generating global abnormal images of various electronic elements by using the double-branch interconnection diffusion model to obtain an expanded PCBA defect detection data set; Acquiring a small amount of real global abnormal images and masks of each defect type of each type of electronic element, multiplying the real global abnormal images by the masks element by element to obtain real local abnormal images, and thus obtaining real global abnormal image-local abnormal image pairs; based on an SD model, constructing a double-branch interconnection diffusion model, wherein the double-branch interconnection diffusion model comprises a global branch and a local branch, and the two branches comprise a variable self-encoder and a DA-TransUNet network, wherein a background compensation block is embedded before each double-attention block of the DA-TransUNet network of the global branch, and the output characteristics of the double-attention blocks at the same position of the DA-TransUNet network of the two branches are interacted in a self-attention interaction block; The forward noise adding process of the double-branch interconnection diffusion model comprises the steps of respectively encoding a real global abnormal image-local abnormal image into a potential space through respective variational self-encoders to obtain a global abnormal image potential representation and a local abnormal image potential representation; the reverse denoising process of the double-branch interconnection