A printed circuit board defect detection method and system based on latent variable multi-step diffusion optimization and electronic equipment
Patent Information
- Application Number
- CN202610597784.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-04-30
- Publication Date
- 2026-09-11
AI Technical Summary
然而,现有基于卷积神经网络的检测方法大多采用单次前向推理的检测模式,缺乏对特征信息进行多阶段建模和逐步优化的处理机制,在复杂背景干扰或弱瑕疵区域条件下,其特征表达的稳定性和判别能力仍然受限,因而难以实现对印刷电路板瑕疵类型的稳定、可靠识别
[0028](1)引入基于去噪扩散模型的迭代优化机制,通过逐步矫正的方式突破单次推理瓶颈,有利于抑制干扰并提升瑕疵检测结果的稳定性;
Smart Images

Figure CN122736953A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the technical field of general image data processing or generation, and in particular to a printed circuit board defect detection method, system, and electronic device based on latent variable multi-step diffusion optimization in the field of industrial visual defect detection technology. Background Technology
[0002] With the rapid development of the electronics industry, electronic products are constantly evolving towards high-density integration, high performance, and miniaturization, leading to a continuous increase in the integration and structural complexity of printed circuit boards (PCBs). As a core component in electronic products that carries and connects various electronic components, the manufacturing quality of PCBs directly affects the reliability and stability of the entire system. Therefore, the rapid and accurate detection and identification of PCB defects has become one of the important technical aspects of achieving automation and intelligence in the manufacturing process of electronic products.
[0003] However, due to the diverse types of components, dense distribution, and small size of components in printed circuit boards, and the significant differences in shape and location between different types of defects, the actual automated placement and online inspection process is often accompanied by complex backgrounds, noise interference, and changes in imaging conditions. This makes it impossible to obtain accurate inspection results for defects in printed circuit boards.
[0004] In existing technologies, visual inspection methods based on traditional image processing or manually designed features typically rely on fixed rules or shallow features for discrimination. These methods have limited ability to represent small-sized, low-contrast, and irregularly shaped defects, making it difficult to balance detection accuracy and robustness, and prone to false negatives or missed detections. With the continuous development of deep learning technology, detection methods based on Convolutional Neural Networks (CNNs) are increasingly being applied to industrial image defect detection. These methods can automatically extract multi-level feature information from images through end-to-end learning, improving defect detection and classification performance to some extent. However, most existing CNN-based detection methods employ a single forward inference detection mode, lacking a mechanism for multi-stage modeling and progressive optimization of feature information. Under conditions of complex background interference or weak defect areas, the stability and discriminative ability of their feature representation remain limited, making it difficult to achieve stable and reliable identification of printed circuit board defect types. Summary of the Invention
[0005] This invention solves the problems existing in the prior art and provides a printed circuit board defect detection method, system and electronic device based on latent variable multi-step diffusion optimization.
[0006] The technical solution adopted in this invention is a printed circuit board defect detection method based on latent variable multi-step diffusion optimization. The method acquires an image of the printed circuit board to be detected, inputs it into a pre-trained defect detection model, and obtains defect prediction results. The defect detection model is constructed based on the iterative optimization mechanism of the denoising diffusion model. It extracts image features through an encoder and uses an iterative output head to perform multi-step optimization inference under noise perturbation conditions to output target detection results.
[0007] The defect prediction results are analyzed to obtain the defect category and location information in the printed circuit board to be inspected.
[0008] Preferably, the defect detection model includes an encoder and a decoder connected in sequence, and the decoder includes an iterative output head;
[0009] The encoder includes multiple cascaded feature extraction layers for extracting multi-scale image features from the input image.
[0010] The iterative output head is a neural network based on an attention mechanism, used to iteratively denoise and optimize the label representation after noise perturbation based on the multi-scale image features.
[0011] Preferably, the training images are input into the encoder to extract multi-scale image features; the target annotation information in the training data is mapped into continuous label embedding vectors; during the training process, random noise is applied to the label embedding vectors to obtain the label representation after noise perturbation.
[0012] The multi-scale image features are fused with the label representation after noise perturbation and input into the iterative output head to predict the target detection result.
[0013] Minimize the loss function and optimize the model parameters.
[0014] Preferably, the loss function is associated with the category loss and the target location regression loss.
[0015] Preferably, a standard image of the template printed circuit board and an image of the printed circuit board to be inspected are acquired and registered and aligned.
[0016] The registered and aligned images are preprocessed to construct a dataset for training the defect detection model.
[0017] Preferably, the preprocessing includes scaling, random cropping, and normalization of the registered and aligned image, and setting click guide points at the suspected defect locations in the preprocessed image of the printed circuit board to be inspected to generate a defect mask corresponding to the defect category.
[0018] Preferably, after the image of the printed circuit board to be inspected is input into the pre-trained defect detection model, a target latent variable is initialized from the standard Gaussian distribution based on the image features extracted by the encoder. At each time step, the image features are fused with the target latent variable of the current time step. The clean target representation of the current step is predicted by the iterative output head, and the target latent variable of the next step is calculated according to the update rule of the conditional diffusion model.
[0019] After a preset number of iterations, an initial prediction result is generated based on the final target latent variable. The initial prediction result is then parsed into multiple candidate prediction bounding boxes containing spatial coordinates and category confidence. Based on the prediction confidence and spatial overlap, the multiple candidate prediction bounding boxes are filtered to remove redundant detection boxes, thus obtaining the final defect prediction result.
[0020] A printed circuit board defect detection system based on latent variable multi-step diffusion optimization includes:
[0021] The image acquisition module is used to acquire images of the printed circuit board to be inspected.
[0022] The defect detection module has a built-in defect detection model pre-trained using the aforementioned printed circuit board defect detection method based on latent variable multi-step diffusion optimization. It is used to receive images of the printed circuit board to be detected and output defect prediction results.
[0023] The results parsing module is used to analyze the defect prediction results and generate structured detection results that include defect category, location, and confidence level.
[0024] Preferably, the defect detection module is deployed on an edge computing device.
[0025] An electronic device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the printed circuit board defect detection method based on latent variable multi-step diffusion optimization.
[0026] This invention relates to a method, system, and electronic device for detecting defects in printed circuit boards (PCBs) based on latent variable multi-step diffusion optimization. The method involves acquiring an image of the PCB to be detected and inputting it into a pre-trained defect detection model improved based on a denoising diffusion model. The defect prediction result is obtained. The defect detection model is constructed based on the iterative optimization mechanism of the denoising diffusion model. Image features are extracted through an encoder, and multi-step optimization inference is performed under noise perturbation conditions using an iterative output head to output the target detection result. The defect prediction result is analyzed to obtain the defect category and location information in the PCB to be detected. The system includes an image acquisition module, a defect detection module with a built-in defect detection model, and a result analysis module. An electronic device is implemented based on this method.
[0027] The beneficial effects of this invention are as follows:
[0028] (1) An iterative optimization mechanism based on the denoising diffusion model is introduced to break through the bottleneck of single inference by step-by-step correction, which is conducive to suppressing interference and improving the stability of defect detection results;
[0029] (2) Introduce a segmentation model to assist in generating annotation information for defective regions, thereby reducing the cost of manual annotation and improving the consistency of training data;
[0030] (3) While ensuring high accuracy of iterative optimization detection, it supports efficient operation and online inference deployment of the model at the edge;
[0031] (4) It has significant advantages in feature modeling capabilities under complex background conditions, detection accuracy of small-sized and weak-contrast defects, and adaptability to production environment interference. Attached Figure Description
[0032] Figure 1 This is a flowchart of the method of the present invention;
[0033] Figure 2 This is a flowchart illustrating the practical application of the present invention;
[0034] Figure 3 This is a flowchart of the detection process based on the defect detection model of the present invention;
[0035] Figure 4 This is a schematic diagram of the system structure of the present invention;
[0036] Figure 5 This is a schematic diagram of the system in actual implementation of the present invention. Detailed Implementation
[0037] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, 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, 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.
[0038] This invention relates to a method for detecting defects in printed circuit boards based on latent variable multi-step diffusion optimization. The method acquires an image of the printed circuit board to be detected, inputs it into a pre-trained defect detection model, and obtains defect prediction results. The defect detection model is constructed based on the iterative optimization mechanism of the denoising diffusion model. It extracts image features through an encoder and uses an iterative output head to perform multi-step optimization inference under noise perturbation conditions to output target detection results.
[0039] The defect prediction results are analyzed to obtain the defect category and location information in the printed circuit board to be inspected.
[0040] In this invention, under standard lighting conditions, multiple sets of raw image data of printed circuit boards are acquired using a common visible light camera. The acquired images are preprocessed to improve image quality and consistency. Then, a Segment Anything Model (SAM) is introduced to assist in labeling the preprocessed images, constructing a dataset for training a defect detection model. Based on this, an iteratively optimized defect detection model based on a denoising diffusion model is trained. The feature representation is progressively optimized through a multi-stage reverse denoising process, thereby improving the ability to identify defect regions and their categories. After model training, the trained defect detection model is deployed on an edge computing device to perform online inference on printed circuit board images acquired in real-time on the production line, thereby achieving automatic detection and identification of the location and category of defects on the printed circuit boards.
[0041] The method will be described below with reference to specific implementation methods.
[0042] Acquire a standard image of the template printed circuit board and an image of the printed circuit board to be inspected, and perform registration and alignment.
[0043] The registered and aligned images are preprocessed to construct a dataset for training the defect detection model.
[0044] Preprocessing includes scaling, random cropping, and normalization of the registered and aligned image, and setting click guide points at the suspected defect locations in the preprocessed image of the printed circuit board to be inspected to generate defect masks corresponding to the defect categories.
[0045] Specifically, under standard imaging and actual testing conditions, a visible light sensor is used to photograph the template PCB and the PCB to be tested to obtain template images. Original PCB image dataset to be detected ;right Perform localization and alignment operations, and use the SIFT algorithm to detect the set of image feature points of the template. and the set of feature points of the PCB image to be detected The descriptor set is used to establish reliable matching point pairs based on the local texture structure around the feature points encoded by the descriptors. The similarity between feature points is calculated, and the best match is found, where the template image... The feature descriptor is given by equation (1).
[0046] (1)
[0047] The feature descriptor of the PCB image to be detected is Equation (2).
[0048] (2)
[0049] Through calculation and The Euclidean distance between each pair of feature points can be used to obtain the similarity between each pair of feature points, thereby finding the best matching pair of feature points. The matching function expression is Equation (3).
[0050] (3)
[0051] in To match a set of pairs, The similarity threshold;
[0052] After obtaining the matching point pairs, an affine transformation is performed on the PCB image to be inspected to align it with the template image. The coordinate expressions for extracting the matching point pairs are given by equations (4) and (5).
[0053] (4)
[0054] (5)
[0055] Use the set of matching point coordinates and The PCB image and template image to be detected are estimated using the least squares method. affine transformation matrix Its mathematical expression is equation (6).
[0056] (6)
[0057] in, , , , Indicates the parameters for rotation and scaling transformation. , Indicates the translation parameter;
[0058] Using affine transformation matrix PCB image to be inspected Perform geometric transformations to map it to the template image. In the coordinate space, the aligned image is obtained. As shown in equation (7),
[0059] (7)
[0060] in, This indicates an image resampling operation based on affine transformation, marking the end of the positioning and alignment operation.
[0061] After image alignment is completed, the aligned PCB image to be inspected is... Scaling and random cropping are performed to unify the image scale and enhance the model's ability to learn features from different spatial locations. The mathematical expression for this process is Equation (8).
[0062] (8)
[0063] in, This indicates a scaling operation. The scaled image. This indicates a random cropping operation. ;in, and These represent the offsets of the cropping window in the horizontal and vertical directions, respectively. and This is the scaled image size. and This refers to the size of the cutting area.
[0064] The scaled and randomly cropped images are normalized to eliminate pixel distribution differences between different samples and improve the numerical stability of model training, as shown in Equation (9).
[0065] (9)
[0066] in, and The mean and standard deviation of the image pixels in the dataset. The preprocessed input image; the preprocessed input image It is divided into training set and test set.
[0067] Furthermore, after image alignment and preprocessing, a large-scale Segment Anything Model (SAM) is introduced for auxiliary annotation. By setting click guide points at suspected defect locations in the PCB image to be detected, the general segmentation characteristics of the large-scale model are used to automatically generate defect masks. This process enables rapid pixel-level extraction of defect features, which is used to assist in constructing a training dataset containing five defect types: missing components, inversion, rotation, short circuits, and tombstoning (indicating components standing upright).
[0068] In this invention, the core is a defect detection model; the defect detection model adopts an end-to-end deep learning architecture, including a sequentially connected encoder and decoder, and the decoder includes an iterative output head;
[0069] The encoder includes multiple cascaded feature extraction layers for extracting multi-scale image features from the input image.
[0070] The iterative output head is a neural network based on an attention mechanism, used to iteratively denoise and optimize the label representation after noise perturbation based on the multi-scale image features.
[0071] The preprocessed input image The training images in the divided training set are input into the encoder to extract multi-scale image features in order to obtain feature representations that simultaneously contain texture detail information and high-level semantic information.
[0072] Specifically, the encoder models the input image step by step at different receptive field scales through a multi-layer feature mapping structure. Its overall encoding process can be expressed as Equation (10).
[0073] (10)
[0074] in, Indicates encoder, The encoded high-dimensional semantic features are used to characterize the structural information and potential defect features in the PCB image; to enhance the representation ability of defects of different sizes and shapes, the encoder output features... It is composed of features at multiple scale levels, and its expression is given by equation (11).
[0075] (11)
[0076] in, Indicates the first Feature representations extracted at each scale The total number of feature levels in the encoder is denoted by . Features at different scales correspond to different spatial resolutions and receptive field ranges, enabling the model to simultaneously focus on fine-grained local texture changes and global structural semantic information.
[0077] The target annotation information in the training data is mapped into continuous label embedding vectors. During the training process, random noise is applied to the label embedding vectors to obtain the label representation after noise perturbation.
[0078] The multi-scale image features are fused with the label representation after noise perturbation and input into the iterative output head to predict the target detection result.
[0079] Specifically, encoder features The input is fed into the decoder network. During the decoding stage, an iterative decoding structure based on the concept of fusion diffusion modeling is introduced. Unlike traditional direct regression detection results, this invention integrates target detection with label recognition. Mapping to a continuous vector space, the object detection labels are embedded using an embedding function. Represented as a continuous vector, as in equation (12),
[0080] (12)
[0081] in, This represents the embedding representation of the target label in the feature space.
[0082] During model training, only the positive noise addition process is performed, and the model operates at random time steps. Below, the label embedding vector Applying Gaussian noise, the resulting noise perturbation is expressed as shown in equation (13).
[0083] (13)
[0084] in, , For the first Noise attenuation coefficient at each time step From step 1 to step 2 The cumulative multiplication factor of the step is used to control the noise intensity of the current time step.
[0085] Then, the encoder output features Labels after noise disturbance The data is embedded in the channel dimension for fusion and fed as a conditional input into the iterative output head. This output head is based on a neural network structure with an attention mechanism, which is used to better model the global dependency between features and noise labels. Its goal is to predict the target detection and recognition results under noise perturbation. The output prediction result can be obtained from equation (14).
[0086] (14)
[0087] in, This represents an iterative output head network where the predicted detection results are then converted into prediction vectors using the same embedding mapping function. Alignment learning is performed on the original label embedding.
[0088] Finally, minimize the loss function and optimize the model parameters.
[0089] The loss function is associated with both the category loss and the target location regression loss.
[0090] Specifically, the model training objective is centered on the loss of object detection and recognition, and parameter optimization is achieved by minimizing the difference between the predicted result and the true label, as expressed in equation (15).
[0091] (15)
[0092] in, For category loss, For the target position regression loss, and These are the weighting coefficients;
[0093] The target category recognition loss adopts the form of cross-entropy, and its mathematical expression is Equation (16).
[0094] (16)
[0095] in, The model represents the first Each target is predicted to be the true category. The probability, The target total number;
[0096] Target location regression loss is used to constrain the prediction of target location. relative to the actual target location Geometric deviations between them are smoothed out. The loss is as shown in equation (17).
[0097] (17)
[0098] in, .
[0099] By minimizing the joint loss function, the model can simultaneously optimize the target category discrimination ability and the target position regression accuracy under diffuse noise conditions, achieving robust detection and accurate identification of complex flawed targets.
[0100] During the inference phase, by quantizing the trained weight file, this invention can effectively reduce the memory and computing power requirements of the iterative optimization network based on the diffusion model, and perform real-time inference on edge devices.
[0101] After the image of the printed circuit board to be inspected is input into the pre-trained defect detection model, a target latent variable is initialized from the standard Gaussian distribution based on the image features extracted by the encoder. At each time step, the image features are fused with the target latent variable of the current time step. The clean target representation of the current step is predicted through the iterative output head, and the target latent variable of the next step is calculated according to the update rule of the conditional diffusion model.
[0102] After a preset number of iterations, an initial prediction result is generated based on the final target latent variable. The initial prediction result is then parsed into multiple candidate prediction bounding boxes containing spatial coordinates and category confidence. Based on the prediction confidence and spatial overlap, the multiple candidate prediction bounding boxes are filtered to remove redundant detection boxes, thus obtaining the final defect prediction result.
[0103] Specifically, the PCB image to be detected is input into the feature extraction network. Obtain the corresponding encoded feature representation To improve inference speed, the DDIM (Denoising Diffusion Implicit Models) sampling paradigm is adopted. First, the target latent variables are initialized from a standard Gaussian distribution. , indicating at time step The target representation is shown below. This latent variable is gradually denoised and converges to the target detection and recognition result in subsequent processes; the target latent variable is transformed from the initial latent variable through... It was obtained through gradual updates, at the... Each time step corresponds to the current target latent variable. For the first One reverse diffusion time step, the model will With the current target latent variables The data is concatenated along the channel dimension, and the fused features are obtained through a feature transformation module. ,in Indicates by The mapping function constructed by convolution embeds the time steps into the vector. and Input them together into the prediction header to obtain the prediction result at the current time step. The prediction results By prediction head The output includes the category prediction results and the corresponding spatial location regression information. It also maps the discrete target category predictions into a continuous embedding vector form, as expressed in equation (18).
[0104] (18)
[0105] Based on the diffusion inversion relationship, the noise estimate is calculated using the target representation at the current time step and the predicted clean target vector by equation (19).
[0106] (19)
[0107] Based on this, the target representation is updated to the next time step using the DDIM backsampling formula:
[0108] (20)
[0109] Finally, iterate and update continuously according to the above steps. At each time step, the latent variables of the target gradually transition from a noise-dominated state to a deterministic representation dominated by the target's semantics and spatial structure. After the backdiffusion model ends, the prediction results obtained from multiple random samplings are averaged and fused to obtain the final prediction output. .
[0110] After inference, the model's output is further processed. Parsing into target bounding box spatial coordinates With category confidence The algorithm then uses Non-Maximum Suppression (NMS) to remove highly overlapping detection boxes. Specifically, it sorts all candidate boxes in descending order based on their confidence scores and selects the bounding box with the highest confidence score. As the current reserved box, it is then calculated. With other candidate boxes The intersection-over-union (IoU) ratio between them can be calculated by equation (21).
[0111] (twenty one)
[0112] When the IoU value between a candidate bounding box and the currently retained bounding box exceeds a preset threshold When this happens, the candidate box is considered redundant and is suppressed; its retention rule can be derived from equation (22).
[0113] (twenty two)
[0114] The above process is iteratively executed in the remaining candidate box set until all candidate boxes have been processed, and finally the target detection result set after removing redundancy is obtained.
[0115] This invention also relates to a printed circuit board defect detection system based on latent variable multi-step diffusion optimization, comprising:
[0116] An image acquisition module, including but not limited to a visible light camera and a matching lighting device, is used to acquire images of the printed circuit board to be inspected;
[0117] The defect detection module has a built-in defect detection model pre-trained using the aforementioned printed circuit board defect detection method based on latent variable multi-step diffusion optimization. It is used to receive images of the printed circuit board to be detected and output defect prediction results.
[0118] The results parsing module is used to analyze the defect prediction results and generate structured detection results that include defect category, location, and confidence level.
[0119] The defect detection module is deployed on an edge computing device.
[0120] The present invention also relates to an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the aforementioned printed circuit board defect detection method based on latent variable multi-step diffusion optimization.
[0121] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0122] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0123] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0124] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0125] Although preferred embodiments of the invention have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including both the preferred embodiments and all changes and modifications falling within the scope of the invention.
[0126] Obviously, those skilled in the art can make various modifications and variations to this invention without departing from its spirit and scope. Therefore, if these modifications and variations fall within the scope of the claims of this invention and their equivalents, this invention also intends to include these modifications and variations.
Claims
1. A method for detecting defects in printed circuit boards based on latent variable multi-step diffusion optimization, characterized in that: The method acquires an image of the printed circuit board to be inspected, inputs it into a pre-trained defect detection model, and obtains a defect prediction result. The defect detection model is constructed based on the iterative optimization mechanism of the denoising diffusion model. It extracts image features through an encoder and uses an iterative output head to perform multi-step optimization inference under noise perturbation conditions to output the target detection result. The defect prediction results are analyzed to obtain the defect category and location information in the printed circuit board to be inspected.
2. The printed circuit board defect detection method based on latent variable multi-step diffusion optimization according to claim 1, characterized in that: The defect detection model includes an encoder and a decoder connected in sequence, and the decoder includes an iterative output head; The encoder includes multiple cascaded feature extraction layers for extracting multi-scale image features from the input image. The iterative output head is a neural network based on an attention mechanism, used to iteratively denoise and optimize the label representation after noise perturbation based on the multi-scale image features.
3. The printed circuit board defect detection method based on latent variable multi-step diffusion optimization according to claim 2, characterized in that: The training images are input into the encoder to extract multi-scale image features; the target annotation information in the training data is mapped into continuous label embedding vectors; during the training process, random noise is applied to the label embedding vectors to obtain the label representation after noise perturbation. The multi-scale image features are fused with the label representation after noise perturbation and input into the iterative output head to predict the target detection result. Minimize the loss function and optimize the model parameters.
4. The printed circuit board defect detection method based on latent variable multi-step diffusion optimization according to claim 3, characterized in that: The loss function is associated with both the category loss and the target location regression loss.
5. The printed circuit board defect detection method based on latent variable multi-step diffusion optimization according to claim 4, characterized in that: Acquire a standard image of the template printed circuit board and an image of the printed circuit board to be inspected, and perform registration and alignment. The registered and aligned images are preprocessed to construct a dataset for training the defect detection model.
6. The printed circuit board defect detection method based on latent variable multi-step diffusion optimization according to claim 5, characterized in that: Preprocessing includes scaling, random cropping, and normalization of the registered and aligned image, and setting click guide points at the suspected defect locations in the preprocessed image of the printed circuit board to be inspected to generate defect masks corresponding to the defect categories.
7. The printed circuit board defect detection method based on latent variable multi-step diffusion optimization according to claim 2, characterized in that: After the image of the printed circuit board to be inspected is input into the pre-trained defect detection model, a target latent variable is initialized from the standard Gaussian distribution based on the image features extracted by the encoder. At each time step, the image features are fused with the target latent variable of the current time step. The clean target representation of the current step is predicted through the iterative output head, and the target latent variable of the next step is calculated according to the update rule of the conditional diffusion model. After a preset number of iterations, initial prediction results are generated based on the final target latent variables; The initial prediction results are parsed into multiple candidate predicted bounding boxes containing spatial coordinates and category confidence scores. Based on the prediction confidence scores and spatial overlap, the multiple candidate predicted bounding boxes are filtered to remove redundant detection boxes, and the final defect prediction results are obtained.
8. A printed circuit board defect detection system based on latent variable multi-step diffusion optimization, characterized in that: include: The image acquisition module is used to acquire images of the printed circuit board to be inspected. The defect detection module has a built-in defect detection model pre-trained using the printed circuit board defect detection method based on latent variable multi-step diffusion optimization as described in any one of claims 1 to 7, which is used to receive an image of the printed circuit board to be detected and output defect prediction results. The results parsing module is used to analyze the defect prediction results and generate structured detection results that include defect category, location, and confidence level.
9. A printed circuit board defect detection system based on latent variable multi-step diffusion optimization according to claim 8, characterized in that: The defect detection module is deployed on an edge computing device.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, it implements the printed circuit board defect detection method based on latent variable multi-step diffusion optimization as described in any one of claims 1 to 7.