Lead frame surface defect detection method and system
The lead frame image is processed through the feature hierarchical network and feature fusion module, and the hole convolution and point convolution are combined to generate a comprehensive defect feature map, and the defect perception model is used for reconstruction, which solves the time-consuming and labor-intensive problem of manual inspection of lead frame blanks. , improving detection accuracy and efficiency.
Patent Information
- Application Number
- CN202410448311.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-15
- Publication Date
- 2024-09-10
- Estimated Expiration
- 2044-04-15
AI Technical Summary
In the prior art, the particle size of the lead frame material is small, so manual inspection is time-consuming, laborious, and inefficient, and it is difficult to ensure inspection stability.
The feature hierarchical network and feature fusion module are used to process the lead frame image, and the details and semantic features are extracted through the parallel convolution module and the serial convolution module, combined with atrous convolution and point convolution, to generate a comprehensive defect feature map, and use The defect-aware model performs reconstruction and difference comparison, and trains the model through defect-free images to improve detection accuracy.
It improves the accuracy and efficiency of lead frame surface defect detection, reduces the workload of manual re-judgment, enhances the ability to identify different types of defects, and improves the multi-scale and generalization capabilities of the detection system.
Smart Images

Figure CN118052817B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of detection technology, and in particular to a lead frame surface defect detection method and system. Background Art
[0002] Lead frame is the chip carrier of integrated circuits. It is a key structural component that uses bonding materials (gold wire, aluminum wire, copper wire) to achieve electrical connection between the internal circuit lead-out end of the chip and the external lead to form an electrical circuit. It plays a bridge role in connecting with external wires. Lead frame is required in most semiconductor integrated blocks and is an important basic material in the electronic information industry. Lead frame is the chip carrier of many integrated circuits. Whether its quality is reliable and stable determines the function and performance of the subsequent final semiconductor products. Therefore, it is necessary to conduct quality inspection on lead frame materials in the actual production process.
[0003] CN202211288696.3, discloses a lead frame surface defect detection method, system, storage medium and terminal, belonging to the field of lead frame detection technology, through the defect judgment method of extracting array unit images and their pixel values, the ability to resist image tilt is strong, thereby improving the accuracy of defect detection; by adopting a neural network based on an improved Unet, the defect segmentation is realized, and the detection rate of small and weak targets that are difficult to identify with the naked eye is very high, and the defects are accurately located; finally, the level of defects is determined by a deep learning method, thereby eliminating the manual re-judgment work required after detection and improving the re-judgment efficiency;
[0004] To sum up, in the prior art, the lead frame material is composed of many particles with small size. Manual inspection requires visual judgment of each particle with the help of a microscope, which is time-consuming and labor-intensive and it is difficult to ensure the stability of the inspection. At the same time, the efficiency of manual inspection is low. The application of the present invention can at least solve some of the problems of the prior art. Summary of the invention
[0005] The embodiments of the present invention provide a lead frame surface defect detection method and system, which can at least solve some problems in the prior art.
[0006] According to a first aspect of the embodiments of the present invention,
[0007] A lead frame surface defect detection method is provided, comprising:
[0008] Collecting lead frame images, inputting the preprocessed lead frame images into a defect extraction network, downsampling the lead frame images using a feature hierarchical network in the defect extraction network, obtaining a shallow feature atlas and a deep feature atlas, the shallow feature atlas is passed through a parallel convolution module to obtain a defect detail enhancement atlas, and the deep feature atlas is passed through a serial convolution module to obtain a defect semantic enhancement atlas;
[0009] The defect detail enhancement atlas and the defect semantic enhancement atlas are input into a feature fusion module, superimposed along the channel dimension, and then a hole convolution operation is performed according to a preset expansion rate. After corresponding position pixel superposition and point convolution fusion, a comprehensive defect feature map is obtained;
[0010] The comprehensive defect feature map is input into a defect perception model, and the comprehensive defect feature map is reconstructed to obtain a reconstructed image. The surface defects of the lead frame are determined by comparing the difference between the defect perception model and the reconstructed image, wherein a defect-free lead frame image is used to train the defect perception model, and the defect-free lead frame image is encoded into a low-dimensional space, the low-dimensional space parameters are captured, combined with random noise, and decoded into a reconstructed image. The low-dimensional features of the defect-free lead frame are learned through a loss adjustment strategy to complete the training of the defect perception model.
[0011] In an optional embodiment,
[0012] Downsampling the lead frame image using a feature hierarchical network in the defect extraction network to obtain a shallow feature atlas and a deep feature atlas, wherein the shallow feature atlas is passed through a parallel convolution module to obtain a defect detail enhancement atlas, and the deep feature atlas is passed through a serial convolution module to obtain a defect semantic enhancement atlas, including:
[0013] The defect extraction network includes a feature hierarchical network, a parallel convolution module, a serial convolution module and a feature fusion module;
[0014] Downsampling the lead frame image using the feature hierarchical network, extracting basic features of the lead frame image by reducing the spatial size of the lead frame image, and obtaining a shallow feature atlas and a deep feature atlas;
[0015] The shallow feature atlas obtains detail defect features through a parallel convolution module, using hole convolution, combined with skip connection operation and pixel addition, to construct a defect detail enhancement atlas;
[0016] The deep feature atlas captures the defect context and identifies the overall meaning of the defect through a serial convolution module, using hole convolution and depth-wise separable convolution operations, combined with skip connections and pixel addition, to construct a defect semantic enhancement atlas.
[0017] In an optional embodiment,
[0018] The defect detail enhancement atlas and the defect semantic enhancement atlas are input into the feature fusion module, superimposed along the channel dimension, and then a hole convolution operation is performed according to a preset expansion rate. After corresponding position pixel superposition and point convolution fusion, a comprehensive defect feature map is obtained, including:
[0019] Superimposing the defect detail enhancement atlas and the defect semantic enhancement atlas in the channel dimension, increasing the number of channels, and obtaining a primary fusion feature atlas;
[0020] According to a preset expansion rate, an expansion convolution kernel is set to construct a dilated convolution operation, and the primary fused feature atlas is subjected to the dilated convolution operation to expand the receptive field;
[0021] In the primary fusion feature map set, pixel values at corresponding positions of feature maps with the same number of channels are added, a 1×1 point convolution kernel is constructed, and point convolution fusion is performed on the added feature maps to obtain a comprehensive defect feature map;
[0022] In an optional embodiment,
[0023] Also includes:
[0024] One of the parallel convolution modules and two of the serial convolution modules are provided, namely, a first serial convolution module and a second serial convolution module. Meanwhile, three detection heads are provided, namely, a first detection head, a second detection head and a third detection head. Defect detection is performed on the output results of the parallel convolution module and the output results of the serial convolution module, and then a comprehensive defect feature map is obtained through the feature fusion module.
[0025] The formula is as follows:
[0026] ;
[0027] in, Y 1 Indicates the detection result of the first detection head, Y 2 Indicates the detection result of the second detection head, Y 3 Indicates the detection result of the third detection head, f DH1 Indicates the first detection head, f DH2 Indicates the second detection head, f DH3 Indicates the third detection head, X 1 Represents the feature map corresponding to the parallel convolution module, X 2represents the feature map corresponding to the first serial convolution module, X 3 represents the feature map corresponding to the second serial convolution module, f FFM Represents the feature fusion function corresponding to the feature fusion module, f PCM Represents the parallel convolution function corresponding to the parallel convolution module, f up represents the upsampling operation, f SCM Represents the serial convolution function corresponding to the serial convolution module.
[0028] In an optional embodiment,
[0029] The defect perception model is trained using a defect-free lead frame image, by encoding the defect-free lead frame image into a low-dimensional space, capturing low-dimensional space parameters, combining random noise, decoding into a reconstructed image, and learning low-dimensional features of the defect-free lead frame through a loss adjustment strategy. The training of the defect perception model is completed, including:
[0030] Collect defect-free lead frame images as training atlases and start defect perception model training;
[0031] An encoder is constructed by multiple convolutional layers, a training image in the training image set is input into the encoder, features are extracted by gradually reducing the image dimension, low-dimensional space parameters are captured by a fully connected layer, random noise is extracted based on a standard normal distribution, and low-dimensional space variables are calculated in combination with the low-dimensional space parameters;
[0032] Based on the mirror image of the encoder, a decoder is constructed to reconstruct the low-dimensional space variables back to the original data space to generate a reconstructed image;
[0033] Based on the training image and the corresponding reconstructed image, a reconstruction loss function is set; based on the difference between the distribution of low-dimensional space variables and the standard normal distribution, a relative entropy formula is constructed;
[0034] The defect perception model training is iterated to minimize the reconstruction loss function and the relative entropy so that the reconstructed image is closest to the training image and the distribution of the low-dimensional space variables is closest to the standard normal distribution, thereby completing the training of the defect perception model.
[0035] In an optional embodiment,
[0036] Based on the training image and the corresponding reconstructed image, setting a reconstruction loss function comprises:
[0037] The reconstruction loss function has the following formula:
[0038] ;
[0039] in, L δ represents the reconstruction loss function, y represents the original true value corresponding to the training image, f ( x ) represents the model prediction value corresponding to the reconstructed image, k represents the scale factor, s represents the standard deviation, | yf ( x )| represents the absolute value of the error;
[0040] In an optional embodiment,
[0041] Based on the difference between the distribution of low-dimensional space variables and the standard normal distribution, the relative entropy formula is constructed as follows:
[0042] The relative entropy formula is as follows:
[0043] ;
[0044] in, K represents the relative entropy, l represents the global adjustment parameter, β ( t ) represents the dynamic weight parameter that changes with the number of iterations, t represents the number of iterations, J represents the total dimension of the low-dimensional space, j represents the ordinal number of the variable in the low-dimensional space, m j Indicates j The mean of the low-dimensional space variables, σ j Indicates j The standard deviation of a variable in a low-dimensional space.
[0045] According to a second aspect of the embodiments of the present invention,
[0046] A lead frame surface defect detection system is provided, comprising:
[0047] The first unit is used to collect lead frame images, input the preprocessed lead frame images into a defect extraction network, and downsample the lead frame images using a feature hierarchical network in the defect extraction network to obtain a shallow feature atlas and a deep feature atlas, wherein the shallow feature atlas is passed through a parallel convolution module to obtain a defect detail enhancement atlas, and the deep feature atlas is passed through a serial convolution module to obtain a defect semantic enhancement atlas;
[0048] The second unit is used to input the defect detail enhancement atlas and the defect semantic enhancement atlas into a feature fusion module, superimpose them along the channel dimension, and then perform a hole convolution operation according to a preset expansion rate, and obtain a comprehensive defect feature map through pixel superposition and point convolution fusion at corresponding positions;
[0049] The third unit is used to input the comprehensive defect feature map into the defect perception model, reconstruct the comprehensive defect feature map to obtain a reconstructed image, and determine the surface defects of the lead frame by comparing the difference between the defect perception model and the reconstructed image, wherein the defect perception model is trained using a defect-free lead frame image, and the defect-free lead frame image is encoded into a low-dimensional space, the low-dimensional space parameters are captured, combined with random noise, and decoded into a reconstructed image, and the low-dimensional features of the defect-free lead frame are learned through a loss adjustment strategy to complete the training of the defect perception model.
[0050] According to a third aspect of the embodiments of the present invention,
[0051] An electronic device is provided, comprising:
[0052] processor;
[0053] a memory for storing processor-executable instructions;
[0054] The processor is configured to call the instructions stored in the memory to execute the aforementioned method.
[0055] A fourth aspect of the embodiments of the present invention is:
[0056] A computer-readable storage medium is provided, on which computer program instructions are stored. When the computer program instructions are executed by a processor, the aforementioned method is implemented.
[0057] In an embodiment of the present invention, a shallow feature atlas and a deep feature atlas are obtained, and the shallow feature atlas and the deep feature atlas have information at different levels and different abstractions, so that the system can understand the lead frame image from multiple angles; the shallow feature atlas is processed by a parallel convolution module to extract the detail features of the defects, such as burrs and scratches; the deep feature atlas is processed by a serial convolution module to capture the overall semantic information of the defects, including the semantic information of the shape and size of the defects; the introduction of skip connections and pixel addition operations is helpful for gradient propagation and information fluency, and improves the expression ability of the network to prevent information loss; the defect detail enhancement atlas and the defect semantic enhancement atlas are processed in the channel dimension. Superposition increases the number of channels of the feature map, thereby enriching the diversity and complexity of feature representation, helping the system to more comprehensively capture the information in the image and improve the ability to identify different types of defects; the multi-module design and the combination of parallel and serial structures help the system to more comprehensively and deeply understand the image features and improve the perception and detection accuracy of defects; different detection heads focus on features at different levels to improve the system's multi-scale defect detection capabilities; the reconstruction loss function is used to measure the difference between the original image and the reconstructed image, and the image loss function is used to encourage the model to learn to accurately reconstruct the image; the relative entropy loss is introduced to encourage the learned distribution to tend to the normal distribution, which helps to improve the generalization ability of the model. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] Figure 1 It is a schematic diagram of the process of the lead frame surface defect detection method according to an embodiment of the present invention;
[0059] Figure 2 It is a schematic structural diagram of a lead frame surface defect detection system according to an embodiment of the present invention. DETAILED DESCRIPTION
[0060] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0061] The technical solution of the present invention is described in detail with specific embodiments below. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.
[0062] Figure 1 FIG. 1 is a flow chart of a lead frame surface defect detection method according to an embodiment of the present invention. Figure 1As shown, the method includes:
[0063] S101. Collecting lead frame images, inputting the preprocessed lead frame images into a defect extraction network, downsampling the lead frame images using a feature hierarchical network in the defect extraction network, obtaining a shallow feature atlas and a deep feature atlas, wherein the shallow feature atlas is passed through a parallel convolution module to obtain a defect detail enhancement atlas, and the deep feature atlas is passed through a serial convolution module to obtain a defect semantic enhancement atlas;
[0064] Acquire a data set of lead frame images, preprocess the lead frame images in the collected data set, including denoising, resizing and other operations, and input the preprocessed lead frame images into a defect extraction network;
[0065] In the defect extraction network, a feature hierarchical network is used to downsample the lead frame image, and the basic features of the lead frame image are extracted by reducing the image space size; a shallow feature atlas and a deep feature atlas are obtained according to the downsampled features, and the shallow feature atlas and the deep feature atlas contain feature information at different levels;
[0066] Apply parallel convolution modules to shallow feature atlases to obtain detailed features of defects, and apply serial convolution modules to deep feature atlases to obtain semantic information of defects;
[0067] In this embodiment, a shallow feature atlas and a deep feature atlas are obtained, and the shallow feature atlas and the deep feature atlas have information of different levels and different abstract degrees, so that the system can understand the lead frame image from multiple angles; the shallow feature atlas is processed by a parallel convolution module to extract the detailed features of the defects, such as burrs and scratches; the deep feature atlas is processed by a serial convolution module to capture the overall semantic information of the defects, including semantic information of the shape and size of the defects; through the collaborative work of multiple modules, the system is more robust in processing lead frame images, and can adapt to lead frames of different types and states, thereby improving the universality and adaptability of the system;
[0068] In an optional embodiment, downsampling the lead frame image using a feature hierarchical network in the defect extraction network to obtain a shallow feature atlas and a deep feature atlas, wherein the shallow feature atlas is passed through a parallel convolution module to obtain a defect detail enhancement atlas, and the deep feature atlas is passed through a serial convolution module to obtain a defect semantic enhancement atlas, including:
[0069] The defect extraction network includes a feature hierarchical network, a parallel convolution module, a serial convolution module and a feature fusion module;
[0070] Downsampling the lead frame image using the feature hierarchical network, extracting basic features of the lead frame image by reducing the spatial size of the lead frame image, and obtaining a shallow feature atlas and a deep feature atlas;
[0071] The shallow feature atlas obtains detail defect features through a parallel convolution module, using hole convolution, combined with skip connection operation and pixel addition, to construct a defect detail enhancement atlas;
[0072] The deep feature atlas captures the defect context and identifies the overall meaning of the defect through a serial convolution module, using hole convolution and depth-wise separable convolution operations, combined with skip connections and pixel addition, to construct a defect semantic enhancement atlas.
[0073] The dilated convolution specifically refers to a convolution operation in which one or more intervals, i.e. holes, are inserted between the elements in the convolution kernel. The holes can increase the receptive field of the convolution kernel, allowing the network to obtain a wider range of input information while keeping the number of parameters relatively small. It also includes the concept of dilation rate, which defines the size of the interval between the convolution kernels.
[0074] The skip connection specifically refers to establishing a direct connection between different layers of the neural network, directly passing the input or features of the lower layer to the higher layer of the network, which helps to better propagate the gradient, prevent the gradient from disappearing or exploding, and provides an effective way of information transmission;
[0075] The pixel addition specifically refers to adding two pixels at the same position. Each hole convolution involves a pixel addition operation, which means that the feature map obtained after the convolution operation is added element by element to the previous feature map, which helps to retain the information of the previous layer and introduce new features at the same time.
[0076] The depthwise separable convolution specifically refers to a convolution operation, which is divided into two steps: first, spatial convolution (convolution in the depth direction) is performed on each channel of the input, and then the channels are combined through point-by-point convolution (1x1 convolution), which can significantly reduce the number of parameters and reduce the computational cost while maintaining the expressiveness of the model;
[0077] Collect a dataset of lead frame images from a production line or other sources, ensuring that the dataset contains lead frames of different types and states; preprocess the collected lead frame images, including denoising, resizing, contrast enhancement, and other operations, and input them into the defect extraction network;
[0078] In the defect extraction network, a feature hierarchical network is used to downsample the lead frame image, and the basic features of the lead frame image are extracted by reducing the image space size; based on the downsampled basic features, a shallow feature atlas and a deep feature atlas are obtained, which contain information of different levels and abstraction degrees;
[0079] A parallel convolution module is applied to the shallow feature atlas. The parallel convolution module includes a dilated convolution, a skip connection operation, and a pixel addition operation. The parallel convolution operation uses a dilated convolution with dilation rates of 1, 2, and 3 to obtain a defect detail enhanced atlas.
[0080] Apply a serial convolution module to the deep feature atlas. The serial convolution module contains dilated convolution and depthwise separable convolution operations to capture the context and overall semantic information of the defect and obtain a semantically enhanced defect atlas.
[0081] In this embodiment, the introduction of skip connections and pixel addition operations is helpful for gradient propagation and information fluency, and improves the expression ability of the network to prevent information loss; through the feature hierarchical network, the parallel convolution module and the serial convolution module, the features of the lead frame image are extracted at multiple levels, including basic features, detail features and semantic features; the parallel convolution module focuses on extracting the detail features of the defects, while the serial convolution module captures the semantic information of the defects, which are fused through the feature fusion module to achieve comprehensive enhancement of details and semantics; the defect features of the lead frame image are comprehensively extracted to provide richer feature representation for subsequent defect detection, thereby improving the accuracy and robustness of detection.
[0082] S102. Input the defect detail enhancement atlas and the defect semantic enhancement atlas into a feature fusion module, superimpose them along the channel dimension, and then perform a dilation convolution operation according to a preset expansion rate, and obtain a comprehensive defect feature map through pixel superposition and point convolution fusion at corresponding positions;
[0083] The defect detail enhancement atlas and the defect semantic enhancement atlas are used as the input of the feature fusion module; the two input atlases are superimposed in the channel dimension through a simple channel splicing operation so that the features of each channel are retained, and the obtained superimposed feature atlas is subjected to a dilated convolution operation to reduce the number of parameters while maintaining the receptive field; the dilation rate determines the interval between the holes in the convolution kernel and affects the size of the receptive field. The parameters of the dilated convolution are set using the preset dilation rate, and the pixels at the corresponding positions are superimposed, including pixel addition or weighted addition operations, to obtain the fused feature map; the fused feature map is subjected to point convolution fusion using a 1x1 convolution operation to further integrate information and reduce the number of channels to obtain the final comprehensive defect feature map;
[0084] In this embodiment, by superimposing two input atlases along the channel dimension, the feature fusion module can combine defect details and semantic information to obtain a more comprehensive feature representation; the atrous convolution operation expands the receptive field through a preset expansion rate, so that the model can understand the characteristics of the defect in a wider context; the superposition of corresponding position pixels helps to retain the position information in the original image, ensuring that the fused feature map still matches the structure of the input image; point convolution fusion helps to reduce the number of channels and reduce computational costs through 1x1 convolution operations, while retaining important information and improving the computational efficiency of the model; after being processed by the feature fusion module, the obtained comprehensive defect feature map has a multi-level expression and contains rich information in details and semantics.
[0085] In an optional embodiment, the defect detail enhancement atlas and the defect semantic enhancement atlas are input into a feature fusion module, superimposed along the channel dimension, and then a hole convolution operation is performed according to a preset expansion rate. After corresponding position pixel superposition and point convolution fusion, a comprehensive defect feature map is obtained, including:
[0086] Superimposing the defect detail enhancement atlas and the defect semantic enhancement atlas in the channel dimension, increasing the number of channels, and obtaining a primary fusion feature atlas;
[0087] According to a preset expansion rate, an expansion convolution kernel is set to construct a dilated convolution operation, and the primary fused feature atlas is subjected to the dilated convolution operation to expand the receptive field;
[0088] In the primary fusion feature map set, pixel values at corresponding positions of feature maps with the same number of channels are added, a 1×1 point convolution kernel is constructed, and point convolution fusion is performed on the added feature maps to obtain a comprehensive defect feature map;
[0089] The defect detail enhancement atlas and the defect semantic enhancement atlas are superimposed in the channel dimension to increase the number of channels and obtain the primary fusion feature atlas; for example, assuming W Indicates the image width, H Indicates the image height, C represents the number of channels, then the defect detail enhancement atlas is W × H × C 1 , the defect semantic enhancement atlas is W × H × C 2 , after superposition of channel dimensions, the primary fusion feature atlas is W × H ×( C 1 + C 2); Assuming that the preset expansion rate is 3, the dilated convolution kernel is set to 3×3 according to the expansion rate, and the dilated convolution operation is performed on the primary fused feature atlas; the purpose of the dilated convolution operation is to expand the receptive field so that the model can capture a wider range of contextual information; the pixel values at the same position of each channel in the primary fused feature atlas that has undergone the dilated convolution operation are added to obtain a fused feature map; finally, a 1×1 point convolution kernel is used to perform point convolution fusion on the fused feature map to obtain a comprehensive defect feature map;
[0090] In this embodiment, by superimposing the defect detail enhancement atlas and the defect semantic enhancement atlas in the channel dimension, the number of channels of the feature map is increased, thereby enriching the diversity and complexity of the feature representation, which helps the system to more comprehensively capture the information in the image and improve the recognition ability of different types of defects; through the void convolution operation, the receptive field of the feature map is expanded, so that the system can better understand the relationship between the local and global aspects of the image, which helps to improve the defect detection system's understanding and recognition accuracy of the defect context, especially for larger defects or defects related to the surrounding environment; point convolution fusion, through the addition operation and the application of 1x1 convolution kernel, helps to integrate information at adjacent positions and reduce the number of channels, thereby refining the fusion features and reducing redundant information, which helps to improve the system's ability to express comprehensive defect features, so that the detector can more accurately locate and identify defects and reduce false detection and missed detection rates.
[0091] In an optional embodiment, it also includes:
[0092] One of the parallel convolution modules and two of the serial convolution modules are provided, namely, a first serial convolution module and a second serial convolution module. Meanwhile, three detection heads are provided, namely, a first detection head, a second detection head and a third detection head. Defect detection is performed on the output results of the parallel convolution module and the output results of the serial convolution module, and then a comprehensive defect feature map is obtained through the feature fusion module.
[0093] The formula is as follows:
[0094] ;
[0095] in, Y 1 Indicates the detection result of the first detection head, Y 2 Indicates the detection result of the second detection head, Y 3 Indicates the detection result of the third detection head, f DH1 Indicates the first detection head, f DH2 Indicates the second detection head, fDH3 Indicates the third detection head, X 1 Represents the feature map corresponding to the parallel convolution module, X 2 represents the feature map corresponding to the first serial convolution module, X 3 represents the feature map corresponding to the second serial convolution module, f FFM Represents the feature fusion function corresponding to the feature fusion module, f PCM Represents the parallel convolution function corresponding to the parallel convolution module, f up represents the upsampling operation, f SCM Represents the serial convolution function corresponding to the serial convolution module.
[0096] Using the parallel convolution module function f PCM For the last layer feature map of the backbone network X 1 Processing is performed to obtain the output feature map of the parallel convolution module; using the serial convolution module function f SCM The penultimate feature map of the backbone network X 2 And the third-to-last feature map X 3 Processing is performed to obtain an output feature map of the first serial convolution module and an output feature map of the second serial convolution module;
[0097] Using feature fusion module function f FFM Performing feature fusion on the output of the parallel convolution module, the output of the first serial convolution module after upsampling, and the output of the second serial convolution module after upsampling to obtain a comprehensive defect feature map;
[0098] Use the first detection header function f DH1 Feature fusion module f FFM The output of is processed to obtain the detection result of the first detection head Y 1 ; Use the second detection head function f DH2 Output of the first serial convolution module X 2 Processing is performed to obtain the detection result of the second detection head Y 2 ; Use the third detection head function f DH3Output of the second serial convolution module X 3 Processing is performed to obtain the detection result of the second detection head Y 3 ;
[0099] According to the formula, the design of multiple modules and the combination of parallel and serial structures help the system to understand the image features more comprehensively and deeply, and improve the perception and detection accuracy of defects; different detection heads focus on features at different levels, improving the system's multi-scale defect detection capabilities; the feature fusion module improves the system's understanding and expression of comprehensive defect information by fusing features from different sources.
[0100] S103. Input the comprehensive defect feature map into the defect perception model, reconstruct the comprehensive defect feature map to obtain a reconstructed image, and determine the surface defects of the lead frame by comparing the difference between the defect perception model and the reconstructed image, wherein the defect perception model is trained using a defect-free lead frame image, and the defect-free lead frame image is encoded into a low-dimensional space, the low-dimensional space parameters are captured, and the image is combined with random noise to be decoded into a reconstructed image, and the low-dimensional features of the defect-free lead frame are learned through a loss adjustment strategy to complete the training of the defect perception model;
[0101] The integrated defect feature map is input into the defect perception model for processing. In the defect perception model, the integrated defect feature map is reconstructed into an image through a decoding process to obtain a reconstructed image, which indicates that the model attempts to learn important features and structures of the input image;
[0102] Prepare a batch of defect-free lead frame images as training sets;
[0103] The defect perception model is trained using the training set. During the training process, the model understands the lead frame in a normal state by learning the features of the defect-free image. The defect perception model encodes the defect-free lead frame image into parameters in a low-dimensional space, adds random noise to the encoded parameters in the low-dimensional space, and decodes the noisy low-dimensional parameters into a reconstructed image through a decoding process. The loss function is used to measure the difference between the reconstructed image and the original image. The loss function in the training process is adjusted so that the low-dimensional features of the training set are effectively learned.
[0104] The defect perception model is trained using optimization algorithms such as back-propagation and gradient descent to minimize the difference between the reconstructed image and the original image. This process is repeated iteratively until the model learns low-dimensional features that represent defect-free lead frames.
[0105] Using the trained defect perception model, the comprehensive defect feature map is input into the model.
[0106] Compare the difference between the reconstructed image generated by the model and the original comprehensive defect feature map. A larger difference indicates that there are defects in the image.
[0107] In this embodiment, the defect perception model is trained by using a defect-free lead frame image, and the defect perception model learns the feature representation of the defect-free case; the defect perception model can capture anomalies and defects in the image by reconstructing the image, and using the loss adjustment strategy, the model can better learn the low-dimensional features of the defect-free lead frame, thereby improving the sensitivity to defects.
[0108] In an optional embodiment, the defect perception model is trained using a non-defective lead frame image, by encoding the non-defective lead frame image into a low-dimensional space, capturing low-dimensional space parameters, combining with random noise, decoding into a reconstructed image, and learning low-dimensional features of the non-defective lead frame through a loss adjustment strategy, completing the training of the defect perception model includes:
[0109] Collect defect-free lead frame images as training atlases and start defect perception model training;
[0110] An encoder is constructed by multiple convolutional layers, a training image in the training image set is input into the encoder, features are extracted by gradually reducing the image dimension, low-dimensional space parameters are captured by a fully connected layer, random noise is extracted based on a standard normal distribution, and low-dimensional space variables are calculated in combination with the low-dimensional space parameters;
[0111] Based on the mirror image of the encoder, a decoder is constructed to reconstruct the low-dimensional space variables back to the original data space to generate a reconstructed image;
[0112] Based on the training image and the corresponding reconstructed image, a reconstruction loss function is set; based on the difference between the distribution of low-dimensional space variables and the standard normal distribution, a relative entropy formula is constructed;
[0113] The defect perception model training is iterated to minimize the reconstruction loss function and the relative entropy so that the reconstructed image is closest to the training image and the distribution of the low-dimensional space variables is closest to the standard normal distribution, thereby completing the training of the defect perception model.
[0114] The encoder specifically refers to the structure in the defect perception model, which is responsible for gradually reducing the dimension of the input training atlas and extracting the features of the input image. The encoder is composed of multiple convolutional layers. Through step-by-step convolution and pooling operations, the image dimension is gradually reduced.
[0115] The decoder specifically refers to a structure in a defect perception model, which corresponds to the encoder and is a mirror image of the decoder. It receives the low-dimensional spatial variables obtained from the encoder and gradually restores the dimensions of the image through a fully connected layer to achieve image reconstruction of the low-dimensional representation.
[0116] The low-dimensional space variable specifically refers to the output of the fully connected layer in the encoder, which represents the low-dimensional representation of the input image compressed in the encoder and is usually used to describe important features of the image;
[0117] Collect a large number of defect-free lead frame images to ensure the diversity of the data set and cover different scenarios. Design an encoder composed of multiple convolutional layers to gradually reduce the spatial dimension of the image and extract features. Add a fully connected layer on top of the encoder to capture the parameters of the low-dimensional space. Generate random noise that matches the image size from a standard normal distribution. Build a decoder for the inverse operation by mirroring the encoder structure, and combine random noise with low-dimensional space parameters. Through the decoder, gradually restore the low-dimensional space variables to images to generate reconstructed images.
[0118] The image loss function is used, combined with the corresponding dynamic threshold adjustment method, to measure the difference between the original image and the reconstructed image by calculating the relative entropy between the distribution of the low-dimensional space parameters and the standard normal distribution;
[0119] Use the training atlas to perform multiple rounds of iterative training to make the reconstructed image close to the original image and make the distribution of low-dimensional space parameters tend to normal distribution;
[0120] When the defect perception model is applied, the lead frame image to be inspected is processed by the encoder and decoder. If the image has no defects, it is closer to the normal image during training, so the reconstructed image is less different from the original image; if the image has defects, it may deviate from the normal image, resulting in a large difference between the reconstructed image and the original image, thereby identifying the anomaly;
[0121] In this embodiment, the constructed encoder network can gradually reduce the spatial dimension of the image, extract effective features from the lead frame image, and help to better represent the image content; adding a fully connected layer to capture the parameters of the low-dimensional space enables the model to express important information of the image in the low-dimensional space, which helps to compactly encode the image; by generating random noise and combining it with the low-dimensional space parameters, the model has a certain robustness to noise, which helps to cope with the complexity and variability in real scenes; a reconstruction loss function is used to measure the difference between the original image and the reconstructed image, and through the image loss function, the model is prompted to learn to accurately reconstruct the image; introducing relative entropy loss encourages the learned distribution to tend to the normal distribution, which helps to improve the generalization ability of the model.
[0122] In an optional embodiment, setting a reconstruction loss function based on the training image and the corresponding reconstructed image includes:
[0123] The reconstruction loss function has the following formula:
[0124] ;
[0125] in, L δ represents the reconstruction loss function, y represents the original true value corresponding to the training image, f ( x ) represents the model prediction value corresponding to the reconstructed image, k represents the scale factor, s represents the standard deviation, | yf ( x )| represents the absolute value of the error;
[0126] Reconstruction loss function L δ Used to measure the training graph y The corresponding reconstructed image model prediction value f ( x ), the loss function has a combination of square loss and absolute loss, which makes it more robust when dealing with outliers;
[0127] The loss function includes two cases, when | yf ( x )|Less than or equal to ks When , the square loss is adopted, that is, half of the square of the error; when | yf ( x )|greater than ks When , the absolute loss is used, that is, the absolute error is ks The linear part of the difference minus a quadratic term;
[0128] According to the formula, a reconstruction loss function is used, which has a combination of square loss and absolute loss, so that square error is used for small errors and linear error is used for large errors, thereby improving the robustness of the model to outliers or noise; the proportional factor is introduced in the formula k and standard deviation s These two parameters can control the degree of penalty of the loss function for errors of different magnitudes, making the model more tolerant when dealing with larger errors and less susceptible to interference from extreme values.
[0129] In an optional embodiment, based on the difference between the distribution of low-dimensional space variables and the standard normal distribution, constructing the relative entropy formula includes:
[0130] The relative entropy formula is as follows:
[0131] ;
[0132] in, K represents the relative entropy, lrepresents the global adjustment parameter, β ( t ) represents the dynamic weight parameter that changes with the number of iterations, t represents the number of iterations, J represents the total dimension of the low-dimensional space, j represents the ordinal number of the variable in the low-dimensional space, m j Indicates j The mean of the low-dimensional space variables, σ j Indicates j The standard deviation of a variable in a low-dimensional space.
[0133] Relative entropy K The calculation of is based on the difference between the distribution of low-dimensional space variables and the standard normal distribution. It is used to measure the similarity between two probability distributions. By calculating the difference between the mean and standard deviation of low-dimensional space variables and the standard normal distribution, the degree of deviation of low-dimensional space distribution is quantified. l It is a global adjustment parameter used to control the overall influence of relative entropy; β ( t ) is a dynamic weight parameter that changes with the number of iterations. By introducing dynamic weights, the calculation of relative entropy can be gradually converged or adaptively adjusted during the training process;
[0134] According to the formula, the global adjustment parameter l , can adjust the relative entropy importance overall, by l The setting of can flexibly control the influence of relative entropy on the model; the dynamic weight parameter changes with the number of iterations β ( t ), allowing the weight of relative entropy to be adjusted as training progresses, which helps to better balance the role of relative entropy at different stages of training; the introduction of relative entropy helps to avoid overfitting and improves the generalization ability of the model by making the learned low-dimensional representation more consistent with the standard normal distribution.
[0135] Figure 2 FIG. 1 is a schematic diagram of the structure of a lead frame surface defect detection system according to an embodiment of the present invention. Figure 2 As shown, the system comprises:
[0136] The first unit is used to collect lead frame images, input the preprocessed lead frame images into a defect extraction network, and downsample the lead frame images using a feature hierarchical network in the defect extraction network to obtain a shallow feature atlas and a deep feature atlas, wherein the shallow feature atlas is passed through a parallel convolution module to obtain a defect detail enhancement atlas, and the deep feature atlas is passed through a serial convolution module to obtain a defect semantic enhancement atlas;
[0137] The second unit is used to input the defect detail enhancement atlas and the defect semantic enhancement atlas into a feature fusion module, superimpose them along the channel dimension, and then perform a hole convolution operation according to a preset expansion rate, and obtain a comprehensive defect feature map through pixel superposition and point convolution fusion at corresponding positions;
[0138] The third unit is used to input the comprehensive defect feature map into the defect perception model, reconstruct the comprehensive defect feature map to obtain a reconstructed image, and determine the surface defects of the lead frame by comparing the difference between the defect perception model and the reconstructed image, wherein the defect perception model is trained using a defect-free lead frame image, and the defect-free lead frame image is encoded into a low-dimensional space, the low-dimensional space parameters are captured, combined with random noise, and decoded into a reconstructed image, and the low-dimensional features of the defect-free lead frame are learned through a loss adjustment strategy to complete the training of the defect perception model.
[0139] According to a third aspect of the embodiments of the present invention,
[0140] An electronic device is provided, comprising:
[0141] processor;
[0142] a memory for storing processor-executable instructions;
[0143] The processor is configured to call the instructions stored in the memory to execute the aforementioned method.
[0144] A fourth aspect of the embodiments of the present invention is:
[0145] A computer-readable storage medium is provided, on which computer program instructions are stored. When the computer program instructions are executed by a processor, the aforementioned method is implemented.
[0146] The present invention may be a method, an apparatus, a system and / or a computer program product. The computer program product may include a computer-readable storage medium carrying computer-readable program instructions for executing various aspects of the present invention.
[0147] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A lead frame surface defect detection method, characterized in that: include: Collecting lead frame images, inputting the preprocessed lead frame images into a defect extraction network, downsampling the lead frame images using a feature hierarchical network in the defect extraction network, obtaining a shallow feature atlas and a deep feature atlas, the shallow feature atlas is passed through a parallel convolution module to obtain a defect detail enhancement atlas, and the deep feature atlas is passed through a serial convolution module to obtain a defect semantic enhancement atlas; The defect detail enhancement atlas and the defect semantic enhancement atlas are input into a feature fusion module, superimposed along the channel dimension, and then a hole convolution operation is performed according to a preset expansion rate. After corresponding position pixel superposition and point convolution fusion, a comprehensive defect feature map is obtained; The comprehensive defect feature map is input into a defect perception model, and the comprehensive defect feature map is reconstructed to obtain a reconstructed image. The surface defects of the lead frame are determined by comparing the difference between the defect perception model and the reconstructed image, wherein the defect perception model is trained using a defect-free lead frame image, and the defect-free lead frame image is encoded into a low-dimensional space, the low-dimensional space parameters are captured, and the image is combined with random noise and decoded into a reconstructed image. The low-dimensional features of the defect-free lead frame are learned through a loss adjustment strategy to complete the training of the defect perception model; The defect perception model is trained using a defect-free lead frame image, by encoding the defect-free lead frame image into a low-dimensional space, capturing low-dimensional space parameters, combining random noise, decoding into a reconstructed image, and learning low-dimensional features of the defect-free lead frame through a loss adjustment strategy. The training of the defect perception model is completed, including: Collect defect-free lead frame images as training atlases and start defect perception model training; An encoder is constructed by multiple convolutional layers, a training image in the training image set is input into the encoder, features are extracted by gradually reducing the image dimension, low-dimensional space parameters are captured by a fully connected layer, random noise is extracted based on a standard normal distribution, and low-dimensional space variables are calculated in combination with the low-dimensional space parameters; Based on the mirror image of the encoder, a decoder is constructed to reconstruct the low-dimensional space variables back to the original data space to generate a reconstructed image; Based on the training image and the corresponding reconstructed image, setting a reconstruction loss function; Based on the difference between the distribution of low-dimensional space variables and the standard normal distribution, a relative entropy formula is constructed; Iterate the defect perception model training, and make the reconstructed image closest to the training image by minimizing the reconstruction loss function and the relative entropy, and the distribution of the low-dimensional space variables closest to the standard normal distribution, so as to complete the defect perception model training; Based on the training image and the corresponding reconstructed image, setting a reconstruction loss function comprises: The reconstruction loss function has the following formula: ; in, L δ represents the reconstruction loss function, y represents the original true value corresponding to the training image, f ( x ) represents the model prediction value corresponding to the reconstructed image, k represents the scale factor, σ represents the standard deviation, | yf ( x )| represents the absolute value of the error; Based on the difference between the distribution of low-dimensional space variables and the standard normal distribution, the relative entropy formula is constructed as follows: The relative entropy formula is as follows: ; in, K represents the relative entropy, λ represents the global adjustment parameter, β ( t ) represents the dynamic weight parameter that changes with the number of iterations, t represents the number of iterations, J represents the total dimension of the low-dimensional space, j represents the ordinal number of the variable in the low-dimensional space, μ j Indicates j The mean of the low-dimensional space variables, σ j Indicates j The standard deviation of a variable in a low-dimensional space.
2. The method according to claim 1, characterized in that: Downsampling the lead frame image using a feature hierarchical network in the defect extraction network to obtain a shallow feature atlas and a deep feature atlas, wherein the shallow feature atlas is passed through a parallel convolution module to obtain a defect detail enhancement atlas, and the deep feature atlas is passed through a serial convolution module to obtain a defect semantic enhancement atlas, including: The defect extraction network includes a feature hierarchical network, a parallel convolution module, a serial convolution module and a feature fusion module; Downsampling the lead frame image using the feature hierarchical network, extracting basic features of the lead frame image by reducing the spatial size of the lead frame image, and obtaining a shallow feature atlas and a deep feature atlas; The shallow feature atlas obtains detail defect features through a parallel convolution module, using hole convolution, combined with skip connection operation and pixel addition, to construct a defect detail enhancement atlas; The deep feature atlas captures the defect context and identifies the overall meaning of the defect through a serial convolution module, using hole convolution and depth-wise separable convolution operations, combined with skip connections and pixel addition, to construct a defect semantic enhancement atlas.
3. The method according to claim 2, characterized in that The defect detail enhancement atlas and the defect semantic enhancement atlas are input into the feature fusion module, superimposed along the channel dimension, and then a hole convolution operation is performed according to a preset expansion rate. After corresponding position pixel superposition and point convolution fusion, a comprehensive defect feature map is obtained, including: Superimposing the defect detail enhancement atlas and the defect semantic enhancement atlas in the channel dimension, increasing the number of channels, and obtaining a primary fusion feature atlas; According to a preset expansion rate, an expansion convolution kernel is set to construct a dilated convolution operation, and the primary fused feature atlas is subjected to the dilated convolution operation to expand the receptive field; In the primary fusion feature map set, the pixel values of the corresponding positions of the feature maps with the same number of channels are added, a 1×1 point convolution kernel is constructed, and the added feature maps are subjected to point convolution fusion to obtain a comprehensive defect feature map.
4. The method according to claim 3, characterized in that Also includes: One of the parallel convolution modules and two of the serial convolution modules are provided, namely, a first serial convolution module and a second serial convolution module. Meanwhile, three detection heads are provided, namely, a first detection head, a second detection head and a third detection head. Defect detection is performed on the output results of the parallel convolution module and the output results of the serial convolution module, and then a comprehensive defect feature map is obtained through the feature fusion module. The formula is as follows: ; in, Y 1 indicates the detection result of the first detection head, Y 2 represents the detection result of the second detection head, Y 3 represents the detection result of the third detection head, f DH1 Indicates the first detection head, f DH2 Indicates the second detection head, f DH3 Indicates the third detection head, X 1 represents the feature map corresponding to the parallel convolution module, X 2 represents the feature map corresponding to the first serial convolution module, X 3 represents the feature map corresponding to the second serial convolution module, f FFM Represents the feature fusion function corresponding to the feature fusion module, f PCM Represents the parallel convolution function corresponding to the parallel convolution module, f up represents the upsampling operation, f SCM Represents the serial convolution function corresponding to the serial convolution module.
5. A lead frame surface defect detection system, used to implement the lead frame surface defect detection method according to any one of claims 1 to 4, characterized in that: include: The first unit is used to collect lead frame images, input the preprocessed lead frame images into a defect extraction network, and downsample the lead frame images using a feature hierarchical network in the defect extraction network to obtain a shallow feature atlas and a deep feature atlas, wherein the shallow feature atlas is passed through a parallel convolution module to obtain a defect detail enhancement atlas, and the deep feature atlas is passed through a serial convolution module to obtain a defect semantic enhancement atlas; The second unit is used to input the defect detail enhancement atlas and the defect semantic enhancement atlas into a feature fusion module, superimpose them along the channel dimension, and then perform a hole convolution operation according to a preset expansion rate, and obtain a comprehensive defect feature map through pixel superposition and point convolution fusion at corresponding positions; The third unit is used to input the comprehensive defect feature map into the defect perception model, reconstruct the comprehensive defect feature map to obtain a reconstructed image, and determine the surface defects of the lead frame by comparing the difference between the defect perception model and the reconstructed image, wherein the defect perception model is trained using a defect-free lead frame image, and the defect-free lead frame image is encoded into a low-dimensional space, the low-dimensional space parameters are captured, combined with random noise, and decoded into a reconstructed image, and the low-dimensional features of the defect-free lead frame are learned through a loss adjustment strategy to complete the training of the defect perception model.
6. An electronic device, characterized in that: include: processor; a memory for storing processor-executable instructions; The processor is configured to call the instructions stored in the memory to execute the method described in any one of claims 1 to 4.
7. A computer-readable storage medium having computer program instructions stored thereon, characterized in that: When the computer program instructions are executed by a processor, the method according to any one of claims 1 to 4 is implemented.
