A rapid detection method for multiple types of MLCC defects based on machine vision
By adopting a deep learning network based on the U-Net framework in the detection of surface defects of MLCC capacitors, combined with DFEM, DA and CPFFM modules, the problem of high difficulty and low robustness in the existing technology is solved, and high efficiency is achieved. Accurate defect detection and quick identification of effects.
Patent Information
- Application Number
- CN202410099413.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-24
- Publication Date
- 2025-02-14
- Estimated Expiration
- 2044-01-24
AI Technical Summary
In the detection of surface defects of MLCC capacitors, the problem of high difficulty in model design, single application scenarios and low robustness in the prior art.
Using a defect segmentation network based on the U-Net framework, combining the deep feature extraction module (DFEM), the dual attention module (DA) and the cascading pyramid feature fusion module (CPFFM), to build an efficient and lightweight deep learning network for defects Test.
It improves defect recognition capabilities, can describe defect edges more accurately, enhances the recognition capabilities of small defects, and realizes rapid detection to meet real-time processing requirements.
Smart Images

Figure CN118096659B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of deep learning semantic segmentation, and more specifically, to a method for rapid detection of multiple types of defects in MLCC based on machine vision. Background Art
[0002] Capacitors are components that can store electrical energy and are one of the electronic components used in large quantities in electronic devices. Multilayer ceramic capacitors (MLCC) have the advantages of small size, easy surface mounting, high reliability and excellent high-frequency characteristics. They are widely used in consumer electronics, communication information, automotive electronics, consumer appliances, lighting and other fields. The MLCC capacitor production process includes porcelain slurry preparation, casting, screen printing, lamination, cutting, degumming, high-temperature firing, chamfering, capping, burning, deposition, testing and taping. There are many reasons for the shape of MLCC surface defects. Improper operation at each stage will lead to unexpected defects. There are many reasons for the random generation of surface defects. The presence of these surface defects will cause the performance of the capacitor to deteriorate or even fail. Therefore, the detection of capacitor surface defects is an important part of the capacitor production process.
[0003] In the field of surface defect detection, the most commonly used method is machine vision. Traditional methods mainly use image processing methods based on defect geometric features for detection, but there are problems such as high difficulty in model design, single application scenario and low robustness. With the advancement and development of computer computing power, deep learning technology has gradually been applied in the field of capacitor surface defect detection. In recent years, deep learning methods have been widely used in defect detection, and their performance is better than traditional image processing methods. Deep learning has the ability of autonomous feature learning, can process complex and high-dimensional data, and improve analysis accuracy. At the same time, it has strong data fitting capabilities, can capture nonlinear relationships in data, and improve the accuracy of model prediction. In addition, deep learning can effectively use GPU for acceleration, improve computing efficiency, and realize rapid detection of algorithms. Therefore, the present invention integrates deep learning and proposes a rapid detection algorithm for multiple types of MLCC defects based on machine vision. Summary of the invention
[0004] In view of the deficiencies in the prior art, the object of the present invention is to provide a method for rapid detection of multiple types of MLCC defects based on machine vision, which has the advantage of improving defect recognition capability.
[0005] The above technical objectives of the present invention are achieved through the following technical solutions: A method for rapid detection of multiple types of defects in MLCC based on machine vision, comprising the following steps:
[0006] S1. Build a defect segmentation network based on the U-Net framework;
[0007] S2, evaluating the segmentation index of the defect segmentation network;
[0008] S3, constructing a data set of capacitor surface defect types;
[0009] S4. Importing the data set into the defect segmentation network to obtain a test result.
[0010] In one embodiment, the step S1 comprises the following steps:
[0011] S11, the encoder downsamples the input image to generate a first feature map, and the dual attention module performs attention aggregation on the first feature map;
[0012] S12, the decoder upsamples the input image to generate a second feature map;
[0013] S13, using the cascaded pyramid feature fusion module to connect, the encoder generates a third feature map;
[0014] S14. The third feature map is input into the decoder, and the dual attention module is used to enhance the spatial features of the third feature map.
[0015] In one embodiment, the step S11 further includes the following steps:
[0016] Input the input image into the deep feature extraction module, perform 3*3 convolution, batch normalization module and SiLU activation function, 1*1 convolution, batch normalization module and SiLU activation function on the input image in sequence, and connect through residual, and finally perform 1*1 convolution adjustment on the channel to complete the downsampling operation, so as to obtain the first feature map;
[0017] Among them, the SiLU activation function is for the input vector z k The kth activation a k It is calculated by multiplying the sigmoid function by its input, and the expression is as follows:
[0018] SiLU(z k )=z k σ(z k )#.
[0019] In one embodiment, the step S13 is further specifically:
[0020] Using the first Bottlenck module, three maximum pooling operations are performed continuously on the input feature map, and the pooling kernel is 5. The calculation expression is:
[0021] Maxpooling(x)=Max(x(C,i))
[0022] Among them, Maxpooling represents maximum pooling, C represents the number of input channels, and x(C, i) represents the input of the i-th channel;
[0023] The first Bottlenck module includes a residual structure of a CONV1 module and a CONV3 module;
[0024] The operations of the CONV1 module are 1*1 convolution, batch normalization module and SiLU activation function;
[0025] The operations of the CONV3 module are 3*3 convolution, batch normalization module and SiLU activation function;
[0026] After the three maximum pooling operation results are concat-operated, they are output through the second Bottlenck module.
[0027] In one embodiment, the step S14 is specifically as follows:
[0028] Performing average pooling and maximum pooling on the input third feature map, compressing the size of the third feature map to 1*1*C, performing dimension-up and dimension-down operations on the compressed third feature map through a multi-layer perceptron, performing an element-by-element summation operation on the output of the multi-layer perceptron, generating a channel attention feature weight through a Sigmoid function, and applying the weight to the third feature map to spatially enhance the third feature map to generate an enhanced third feature map;
[0029] The final mapping is expressed using ICA:
[0030] ICA(x)=σ(MLP(AvgPool(x))+MLP(Maxpool(x)))#
[0031] Among them, x represents the input feature from the upper layer, σ represents the Sigmod activation function, and MLP represents a multi-layer perceptron that first increases the dimension and then reduces the dimension;
[0032] Two one-dimensional average pooling operations are respectively used to divide the third feature map into two directions (h and w), and the features in the vertical and horizontal spatial directions are aggregated to obtain two independent direction-aware feature maps;
[0033] According to the height h and width w of the third feature map input, each channel is encoded along the vertical and horizontal coordinates with pooling kernels of scales (H, 1) and (1, W), respectively, to obtain a feature map that fuses specific direction information, as shown in the following formula:
[0034]
[0035]
[0036] Among them, s represents the input feature from the upper layer, S h (h) represents the longitudinal spatial output at height h, S w (w) represents the lateral spatial output at width w;
[0037] Aggregating features from the above two formulas and generating a pair of direction-aware feature maps can capture long-range dependency information along the horizontal space and retain accurate position information in the vertical space, thus assisting the model in accurately locating the defect area.
[0038] The two output feature maps obtained by encoding each channel along the vertical and horizontal coordinates using the above-mentioned pooling kernels with scales of (H, 1) and (1, W) are used to generate horizontal and vertical spatial weights for the third feature map S h (h) and S w (w) Perform the following operations:
[0039] g h =σ(c h (SiLU(s h (h))))#
[0040] g w =σ(C w (SiLU(S w (h))))#
[0041] Among them, for S h (h) and S w (w) Perform SiLU for nonlinear activation, C h , C w They correspond to the 1*1 convolution operations in the horizontal and vertical spaces respectively, and σ is the sigmoid activation function;
[0042] Finally, the output of the SiLU Coordinate Attention module is:
[0043] y(i, j) = x(i, j) g h (i) g w (j)#
[0044] Where x is the input feature map, g h and g w is the weight corresponding to the horizontal space and the vertical space;
[0045] Finally, the output of the dual attention module is:
[0046] DA(x)=x·ICA(x)·SCA(x).
[0047] In one embodiment, the step S2 is specifically:
[0048] Calculate the average pixel accuracy of each category, that is, the average value of the pixel accuracy of each category. The calculation formula is as follows:
[0049]
[0050] Among them, MPA represents the average pixel accuracy of the category, p ij represents the i-class pixel predicted to be the j-class, p ii represents pixels of class i predicted as class i, and k represents the total number of classes;
[0051] Calculate the average intersection-over-union ratio, that is, the average value of the ratio of the intersection and union of the two sets of real pixel categories and network predicted pixel categories on each category. The calculation formula is as follows:
[0052]
[0053] Among them, MIoU represents the mean intersection over union, p ij represents the i-class pixel predicted to be the j-class, p ii represents pixels of class i predicted as class i, and k represents the total number of classes.
[0054] In one embodiment, the step S3 comprises the following steps:
[0055] S31, obtaining a picture of the surface defects of the capacitor based on a microscopic defect image acquisition system;
[0056] S32, using labelme software to label the defects in the image to obtain a labeled image data set;
[0057] S33, dividing the data set into a training set and a test set.
[0058] In one of the embodiments, the ratio of the training set to the test set is 8:2.
[0059] In one embodiment, the step S4 comprises the following steps:
[0060] S41, importing the training set into the defect segmentation network, and the defect segmentation network obtains defect features through training;
[0061] S42, importing the test set into the defect segmentation network, and the defect segmentation network detects defect features in the test set.
[0062] The above-mentioned method for rapid detection of various types of defects of MLCC based on machine vision has the following beneficial effects:
[0063] The use of the deep feature extraction module (DFEM) can solve the problems of a significant increase in parameters, increased computational consumption, and slower reasoning speed caused by the addition of convolutional layers; the use of the dual attention module (DA) enables the network model to have a higher recognition ability for small defects, and the cascaded pyramid feature fusion module (CPFFM) improves the ability to fuse defect information of different scales, and can cope with the multi-scale problem of surface defects of MLCC capacitors. The algorithm is an efficient and lightweight deep learning network with good recognition ability for small defects, more accurate description of defect edges, and more complete recognition of defective parts. BRIEF DESCRIPTION OF THE DRAWINGS
[0064] Figure 1 is a flow chart of this embodiment;
[0065] Figure 2 is a schematic diagram of the sampling device in this embodiment;
[0066] Figure 3 is a basic structure diagram of the deep feature extraction module (DFEM) in this embodiment;
[0067] Figure 4 is a basic structural diagram of the dual attention module (DA) in this embodiment;
[0068] Figure 5 4 is a structural diagram of a Cascaded Pyramid Feature Fusion Module (CPFFM) in this embodiment;
[0069] Figure 6 It is a comparison chart of experimental results of LMS-net and other models in comparative experiments in the implementation method;
[0070] Figure 7 This is the main network structure diagram in this embodiment. DETAILED DESCRIPTION
[0071] The present invention is described in detail below in conjunction with the accompanying drawings and embodiments.
[0072] A method for rapid detection of various types of defects in MLCC based on machine vision, such as Figure 1 , Figure 7 As shown, the following steps are included:
[0073] S1. Build a defect segmentation network based on the U-Net framework;
[0074] Specifically, step S1 includes the following steps:
[0075] S11, the encoder downsamples the input image to generate a first feature map, and the dual attention module performs attention aggregation on the first feature map;
[0076] Specifically, Figure 3 As shown in Figure 1, the basic structure of the deep feature extraction module consists of multiple sub-convolution modules (i.e., CONV1 and CONV3), which use different kernel sizes. The structure of the sub-convolution module is a batch normalization module and a SiLU activation function after a 1*1 or 3*3 convolution operation.
[0077] Input the input image into the feature extraction module, perform 3*3 convolution, batch normalization module and SiLU activation function, 1*1 convolution, batch normalization module and SiLU activation function on the input image in sequence, and connect through residual, and finally perform 1*1 convolution adjustment on the channel to complete downsampling operation, so as to obtain the first feature map;
[0078] Among them, SiLU (Sigmoid-Weighted Linear Unit) activation function is used as a function approximation activation function for neural networks in reinforcement learning. Compared with ReLU, a feature of SiLU is its self-stabilizing property. The global minimum with a derivative of zero acts as a "softfloor" for the weights, and as an implicit regularizer, it inhibits the learning of a large number of weights.
[0079] The SiLU activation function takes an input vector z k The kth activation a k It is calculated by multiplying the sigmoid function by its input, and the expression is as follows:
[0080] SiLU(z k )=z k σ(z k )#.
[0081] S12, the decoder upsamples the input image to generate a second feature map;
[0082] Specifically, the decoder uses an upsampling algorithm to upsample the input image to obtain a second feature map.
[0083] S13, using the cascaded pyramid feature fusion module to connect, the encoder generates a third feature map;
[0084] The step S13 is also specifically as follows:
[0085] like Figure 5As shown in the figure, the cascaded pyramid feature fusion module consists of two Bootleneck modules and three Maxpooling layers with a kernel of 5. The bottleneck module uses CONV1 to adjust the channel through 1*1 convolution, and uses CONV3 to extract features through 3*3 convolution. Finally, the feature integration is strengthened through residual connection.
[0086] Using the first Bottlenck module, three maximum pooling operations are performed continuously on the input feature map, and the pooling kernel is 5. The calculation expression is:
[0087] Maxpooling(x)=Max(x(C,i))
[0088] Among them, Maxpooling represents maximum pooling, C represents the number of input channels, and x(C, i) represents the input of the i-th channel;
[0089] The first Bottlenck module includes a residual structure of a CONV1 module and a CONV3 module;
[0090] The operations of the CONV1 module are 1*1 convolution, batch normalization module and SiLU activation function;
[0091] The operations of the CONV3 module are 3*3 convolution, batch normalization module and SiLU activation function;
[0092] After the three maximum pooling operation results are concat-operated, they are output through the second Bottlenck module.
[0093] S14, the third feature map is input to the decoder, and the spatial features of the third feature map are enhanced using a dual attention module;
[0094] Specifically:
[0095] like Figure 4 As shown in the figure, the dual attention module (DA) consists of improved channel attention (ICA) and SiLU coordinate attention (SCA). Channel attention redistributes the weight of each pixel in the feature map through one-dimensional convolution to increase the weight of the defective pixels on the surface of the MLCC capacitor.
[0096] The input third feature map is average pooled and max pooled, and the size of the third feature map is compressed to 1*1*C. The compressed third feature map is first dimensioned and then dimensionally reduced by a multi-layer perceptron. Then, an element-by-element summation operation is performed using the output of the multi-layer perceptron. The channel attention feature weight is generated by the Sigmoid function. The weight acts on the third feature map to spatially enhance the third feature map to generate the enhanced third feature map. The final mapping is expressed by ICA: ICA(x)=σ(MLP(AvgPool(x))+MLP(Maxpool(x)))#
[0097] Where x represents the input feature from the upper layer, σ represents the Sigmod activation function, and MLP represents a multi-layer perceptron that first increases the dimension and then reduces the dimension.
[0098] Two one-dimensional average pooling operations are respectively used to divide the third feature map into two directions (h and w), and the features in the vertical and horizontal spatial directions are aggregated to obtain two independent direction-aware feature maps;
[0099] According to the height h and width w of the third feature map input, each channel is encoded along the vertical and horizontal coordinates with pooling kernels of scales (H, 1) and (1, W), respectively, to obtain a feature map that fuses specific direction information, as shown in the following formula:
[0100]
[0101]
[0102] Among them, s represents the input feature from the upper layer, S h (h) represents the longitudinal spatial output at height h, S w (w) represents the lateral spatial output at width w;
[0103] Aggregating features from the above two formulas and generating a pair of direction-aware feature maps can capture long-range dependency information along the horizontal space and retain accurate position information in the vertical space, thus assisting the model in accurately locating the defect area.
[0104] The two output feature maps obtained by encoding each channel along the vertical and horizontal coordinates using the above-mentioned pooling kernels with scales of (H, 1) and (1, W) are used to generate horizontal and vertical spatial weights for the third feature map S h (h) and S w (w) Perform the following operations:
[0105] g h =σ(c h (SiLU(sh(h))))#
[0106] g w =σ(C w (SiLU(Sw(h))))#
[0107] Among them, for S h (h) and Sw(w) perform SiLU nonlinear activation, C h , C w They correspond to the 1*1 convolution operations in the horizontal and vertical spaces respectively, and σ is the sigmoid activation function;
[0108] Finally, the output of the SiLU Coordinate Attention module is:
[0109] y(i, j) = x(i, j) g h (i) g w (j)#
[0110] Where x is the input feature map, g h and g w is the weight corresponding to the horizontal space and the vertical space;
[0111] Finally, the output of the dual attention module is:
[0112] DA(x)=x·ICA(x)·SCA(x).
[0113] S2, evaluating the segmentation index of the defect segmentation network;
[0114] Specifically, the step S2 is as follows:
[0115] Calculate the average pixel accuracy of each category, that is, the average value of the pixel accuracy of each category. The calculation formula is as follows:
[0116]
[0117] Among them, MPA represents the average pixel accuracy of the category, p ij represents the i-class pixel predicted to be the j-class, p ii represents pixels of class i predicted as class i, and k represents the total number of classes;
[0118] Calculate the average intersection-over-union ratio, that is, the average value of the ratio of the intersection and union of the two sets of real pixel categories and network predicted pixel categories on each category. The calculation formula is as follows:
[0119]
[0120] Among them, MIoU represents the mean intersection over union, p ij represents the i-class pixel predicted to be the j-class, pii represents pixels of class i predicted as class i, and k represents the total number of classes.
[0121] S3, constructing a data set of capacitor surface defect types;
[0122] Specifically, step S3 includes the following steps:
[0123] S31, obtaining a picture of the surface defects of the capacitor based on a microscopic defect image acquisition system;
[0124] Among them, a total of 304 sample images were obtained, each with a size of 1440*1080 pixels;
[0125] S32, using labelme software to label the defects in the image to obtain a labeled image data set;
[0126] First, outline the area where the defect features are located, save the coordinates representing the defect features into a JSON file, and use a Python script to extract this information from the JSON file to generate an accurate label image GroundTrue for the defect dataset.
[0127] S33, dividing the data set into a training set and a test set;
[0128] Among them, referring to Table 1, the data set is divided into a training set and a data set in a ratio of 8:2.
[0129]
[0130] Table 1
[0131] S4. Importing the data set into the defect segmentation network to obtain a test result.
[0132] Specifically, step S4 includes the following steps:
[0133] S41, importing the training set into the defect segmentation network, and the defect segmentation network obtains defect features through training;
[0134] S42, importing the test set into the defect segmentation network, and the defect segmentation network detects defect features in the test set;
[0135] In order to minimize the impact of randomness, we use the Xavier initialization technique to initialize the network weights. In order to solve the problem of limited number of samples of certain defect types, this experiment uses three image enhancement techniques: random cropping, random horizontal and vertical flipping. These data enhancement techniques increase the diversity of training data and improve the robustness of the network. Batch-size = 6, initial learning rate = 0.0003. We used the Adam optimizer, set to β1 = 0.5 and β2 = 0.999, and the network model was trained for a total of 100 epochs.
[0136] Comparative Example:
[0137] In this experiment, LMS-net is compared with other segmentation networks. In addition, improved variants of U-Net, including Mobile-Unet using MobilenetV3-small as the encoder, are evaluated to assess the impact of network lightweighting on performance. As shown in Table 2, LMS-net outperforms U-net by 3.12% in DSC, 3.55% in MIoU, and 4.09% in MPA. Compared with other lightweight networks such as Lraspp, the proposed method has significant improvements in all evaluation metrics. In addition, the performance of the LMS-net network is comparable to large networks such as FCN, DenseASPP, and DeeplabV3plus, while maintaining a low computational burden. LMS-net performs well on the test set, with an average processing time of 0.017 seconds, equivalent to 58FPS. This processing speed fully meets the requirements of real-time processing and achieves fast detection.
[0138]
[0139]
[0140] Table 2
[0141] In conclusion, LMS-net is an efficient and lightweight network that shows good performance in comprehensive evaluation metrics compared with other networks and can meet real-time requirements.
[0142] In addition, Figure 6As shown, the accuracy of LMS-net performs better than most other models, providing stronger defect segmentation capabilities and higher minor defect detection capabilities. Networks of similar size, such as DDRNet, are deficient in segmenting Exposure and Impurity defects. In addition, compared with large networks such as FCN, DenseASPP, and DeeplabV3p, LMS-net's performance in exposure and impurity defects is closer to the real situation. After statistical analysis of the test set segmentation results of all models, LMS-net achieved accurate classification in four categories: tilt, extension, fracture, and indentation. In contrast, the original Unet only achieved accurate classification in Skew. In summary, the segmentation results of LMS-net are that the boundaries of the segmented defect areas are smooth, the defect edges are accurately described, the details are finer, the recognition of smaller defects is improved, and the recognition of defect areas is improved.
[0143] 6. Ablation Experiment
[0144] Ablation experiments were carried out during the implementation process to verify the feasibility of introducing DA and CPFFM in LMS-net, and the impact of loss weights on the network performance was studied.
[0145] Effect of DA: As shown in Table 3 and Figure 6 As shown in Figure 2, adding DA to the baseline improves model performance and makes segmentation more accurate. This suggests that the use of DA enhances the model’s ability to capture defect regions.
[0146]
[0147] Table 3
[0148] Impact of CPFFM: After adding CPFFM to the baseline, DSC and MPA are significantly improved, and the segmented shape and area are closer to GroundTrue, which enhances the feature extraction ability of the model.
[0149] Effect of DA+CPFFM: As shown in Table 3, the combination of DA and CPFFM can significantly improve DSC, MIoU and MPA. The improvement is more obvious compared with no addition or single addition. This shows that the combination of DA and CPFFM can enhance each other in the extraction of different defect features in MLCC, thus achieving the best surface defect detection performance.
[0150] Although the size of the network parameters increases slightly, this change is still relatively small. It is worth noting that the DSC, MIoU, and MPA indicators are improved by 8.47%, 2.71%, and 5.79%, respectively. These results show the effectiveness of the introduced modifications, indicating that a balance has been achieved between network complexity and performance improvement.
[0151] LDCE Effect of: When α = 0.5, DSC and MIoU reach the highest values. We found that DSC improved by 0.15%, MIoU improved by 1.03%, and MPA improved by 0.63%, while the loss also decreased. These results confirm that L DCE Its effectiveness in addressing the class imbalance problem in small defect segmentation and its applicability to the MLCC surface defect dataset.
[0152] The above-mentioned embodiments only express several implementation methods of the present invention, and the description thereof is relatively specific and detailed, but it cannot be understood as limiting the scope of the patent of the present invention. It should be pointed out that, for ordinary technicians in this field, several variations and improvements can be made without departing from the concept of the present invention, which all belong to the protection scope of the present invention. Therefore, the protection scope of the patent of the present invention shall be subject to the attached claims.
Claims
1. A method for rapid detection of multiple types of defects in MLCC based on machine vision, characterized in that: The following steps are involved: S1. Build a defect segmentation network based on the U-Net framework; S2, evaluating the segmentation index of the defect segmentation network; S3, constructing a data set of capacitor surface defect types; S4, importing the data set into the defect segmentation network to obtain a test result; The step S1 comprises the following steps: S11, the encoder downsamples the input image to generate a first feature map, and the dual attention module performs attention aggregation on the first feature map; S12, the decoder upsamples the input image to generate a second feature map; S13, using the cascaded pyramid feature fusion module to connect, the encoder generates a third feature map; S14, the third feature map is input to the decoder, and the spatial features of the third feature map are enhanced using a dual attention module; The step S13 is specifically as follows: Using the first Bottlenck module, three maximum pooling operations are performed continuously on the input feature map, and the pooling kernel is 5. The calculation expression is: Maxpooling(x)=Max(x(C,i)) Among them, Maxpooling represents maximum pooling, C represents the number of input channels, and x(C, i) represents the input of the i-th channel; The first Bottlenck module includes a residual structure of a CONV1 module and a CONV3 module; The operations of the CONV1 module are 1*1 convolution, batch normalization module and SiLU activation function; The operations of the CONV3 module are 3*3 convolution, batch normalization module and SiLU activation function; After the three maximum pooling operation results are concat-operated, they are output through the second Bottlenck module; The step S14 is specifically as follows: Performing average pooling and maximum pooling on the input third feature map, compressing the size of the third feature map to 1*1*C, performing dimension-up and dimension-down operations on the compressed third feature map through a multi-layer perceptron, and then performing an element-by-element summation operation using the output of the multi-layer perceptron, generating a channel attention feature weight through a Sigmoid function, and applying the weight to the third feature map to spatially enhance the third feature map to generate an enhanced third feature map; The final mapping is expressed using ICA: ICA(x)=σ(MLP(AvgPool(x))+MLP(Maxpool(x))) Among them, x represents the input feature from the upper layer, σ represents the Sigmod activation function, and MLP represents a multi-layer perceptron that first increases the dimension and then reduces the dimension; Two one-dimensional average pooling operations are respectively used to divide the third feature map into two directions h and w, and the features in the vertical and horizontal spatial directions are aggregated to obtain two independent direction-aware feature maps; According to the height h and width w of the third feature map input, each channel is encoded along the vertical and horizontal coordinates with pooling kernels of scales (H, 1) and (1, W) respectively to obtain a feature map that integrates specific direction information. The expression is shown in the following formula: Among them, s represents the input feature from the upper layer, S h (h) represents the longitudinal spatial output at height h, S w (w) represents the lateral spatial output at width w; Aggregating features from the above two formulas and generating a pair of direction-aware feature maps can capture long-range dependency information along the horizontal space and retain accurate position information in the vertical space, thus assisting the model in accurately locating the defect area. The two output feature maps obtained by encoding each channel along the vertical and horizontal coordinates using the above-mentioned pooling kernels with scales of (H, 1) and (1, W) are used to generate horizontal and vertical spatial weights for the third feature map S h (h) and S w (w) Perform the following operations: g h =σ(C h (SiLU(S h (h)))) g w =σ(C w (SiLU(S w (In)))) Among them, for S h (h) and S w (w) Perform SiLU for nonlinear activation, C h , C w They correspond to the 1*1 convolution operations in the horizontal and vertical spaces respectively, and σ is the sigmoid activation function; Finally, the output of the SiLU Coordinate Attention module is: y(i,j)=x(i,j)·g h (i)·g w (j) Where x is the input feature map, g h and g w is the weight corresponding to the horizontal space and the vertical space; Finally, the output of the dual attention module is: DA(x)=x·ICA(x)·SCA(x).
2. According to claim 1, a method for rapid detection of multiple types of MLCC defects based on machine vision is characterized in that: The step S11 further comprises the following steps: Input the input image into the deep feature extraction module, perform 3*3 convolution, batch normalization module and SiLU activation function, 1*1 convolution, batch normalization module and SiLU activation function on the input image in sequence, and connect through residual, and finally perform 1*1 convolution adjustment on the channel to complete the downsampling operation, so as to obtain the first feature map; Among them, the SiLU activation function is for the input vector z k The kth activation a k It is calculated by multiplying the sigmoid function by its input, and the expression is as follows: SiLU(z k )=z k σ(z k )。 3. According to claim 1, a method for rapid detection of multiple types of MLCC defects based on machine vision is characterized in that: The step S2 is specifically as follows: Calculate the average pixel accuracy of each category, that is, the average value of the pixel accuracy of each category. The calculation formula is as follows: Among them, MPA represents the average pixel accuracy of the category, p ij represents the i-class pixel predicted to be the j-class, p ii represents pixels of class i predicted as class i, and k represents the total number of classes; Calculate the average intersection-over-union ratio, that is, the average value of the ratio of the intersection and union of the two sets of real pixel categories and network predicted pixel categories on each category. The calculation formula is as follows: Among them, MIoU represents the mean intersection over union, p ij represents the i-class pixel predicted to be the j-class, p ii represents pixels of class i predicted as class i, and k represents the total number of classes.
4. According to claim 1, a method for rapid detection of multiple types of MLCC defects based on machine vision is characterized in that: The step S3 comprises the following steps: S31, obtaining a picture of the surface defects of the capacitor based on a microscopic defect image acquisition system; S32, using labelme software to label the defects in the image to obtain a labeled image data set; S33, dividing the data set into a training set and a test set.
5. The method for rapid detection of multiple types of defects of MLCC based on machine vision according to claim 4 is characterized in that: The ratio of the number of the training set to the number of the test set is 8:
2.
6. The method for rapid detection of multiple types of defects of MLCC based on machine vision according to claim 4 is characterized in that: The step S4 comprises the following steps: S41, importing the training set into the defect segmentation network, and the defect segmentation network obtains defect features through training; S42, importing the test set into the defect segmentation network, and the defect segmentation network detects defect features in the test set.
Citation Information
Patent Citations
MLCC appearance defect detection method and device and storage medium
CN115439410A
Chicken carcass defect hyperspectral image detection method based on deep learning
CN116563237A