A deep learning method for filter surface defect detection
By introducing the attention mechanism SE module and the feature pyramid network BiFPN module into the YOLOv5 network, the filter surface defect detection is optimized, solving the problems of low efficiency and poor reliability of traditional manual detection, and achieving fast and accurate detection of filter surface defects. Improved detection accuracy and efficiency.
Patent Information
- Application Number
- CN202410318017.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-20
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2044-03-20
AI Technical Summary
Traditional filter surface defect detection relies on manual inspection, resulting in low efficiency and poor reliability. It is prone to missed detections and false detections, and it is difficult to achieve fast and accurate detection.
The attention mechanism SE module and the feature pyramid network BiFPN module are added to the YOLOv5 network algorithm to optimize the network structure and detect filter surface defects through deep learning methods.
It achieves fast and accurate detection of filter surface defects, improving detection efficiency and reliability. The optimized YOLOv5 network algorithm performs better than Faster R-CNN, YOLOv5 and YOLOv7 in terms of mAP@0.5 and mAP@0.5:0.95 indicators. Significantly improve detection accuracy and efficiency.
Smart Images

Figure CN117911840B
Abstract
Description
Technical Field
[0001] The present invention relates to a filter surface defect detection technology, and in particular to a deep learning method for filter surface defect detection. Background Art
[0002] Filter parts are key components in automobile airbag generators. They are used to reduce gas temperature and filter residues. Their quality is crucial in the production process and directly affects the evacuation safety of the airbag system. However, in the actual production process, due to the influence of manufacturing equipment, process flow, and on-site environment, various defects may occur on the surface of the filter. These defects will directly affect the impact and burning effect of the rapidly expanding gas in the generator on the airbag when the automobile airbag is deployed. How to accurately and efficiently identify surface defects of the filter and improve production efficiency is of great significance to improving the manufacturing industry. The traditional method of detecting surface defects of the filter is mainly achieved by manual inspection. Its shortcomings are obvious. It is not only time-consuming and labor-intensive, but also overly dependent on manual subjective judgment, resulting in low detection efficiency and poor reliability. It is also prone to missed detection and false detection. Summary of the invention
[0003] In view of the problems in the prior art, the present invention provides a deep learning method for filter surface defect detection, aiming to achieve fast, accurate and high-speed detection of filter surface defects.
[0004] A deep learning method for filter surface defect detection includes the following steps:
[0005] Step 1: Add the attention mechanism SE module to the last layer of the backbone network of the YOLOv5 network algorithm. The attention mechanism SE module is used to adaptively adjust and correct feature weights during feature extraction;
[0006] Step 2: Introduce the feature pyramid network BiFPN module into the neck network of the YOLOv5 network algorithm, and remove the original path aggregation network PANet structure of the YOLOv5 network algorithm to obtain the optimized YOLOv5 network algorithm;
[0007] Step 3: Train the optimized YOLOv5 network algorithm through the filter surface defect dataset, and obtain the YOLOv5 target detection network for filter surface defect detection.
[0008] Further: the filter surface defect dataset includes collecting different defect categories of the filter through a visual device and making a filter dataset, and then labeling the filter dataset through LabelImg, generating a .txt file at the same time, and randomly dividing the filter dataset and the corresponding .txt file into a training set and a verification set in a ratio of 8:2.
[0009] Further: the attention mechanism SE module includes a compression part and an excitation part. The compression part is used to compress the spatial information in the input feature map. H×W×C Compressed to 1×1×C , that is, using global average pooling in the spatial dimension to obtain 1×1×C Feature map; the excitation part is used to combine the learned attention information with the input features and obtain a feature map with channel attention U .
[0010] Further: the compression operation output of the compression part By shrinking the feature map U The spatial dimension H×W And generate, that is:
[0011]
[0012] in, is the compression function.
[0013] Further: The weight vector s of the incentive part is:
[0014]
[0015]
[0016] in, is the activation function, is the extrusion output and serves as the excitation input, is the channel mapping relationship, is the reduction rate of the channel;
[0017] The output of the attention mechanism SE module assigns weights to the feature map U through the weight vector s to obtain the feature map :
[0018] =
[0019] in, , For indicator and feature maps Multiply the channels between , c is a positive integer.
[0020] Further: The feature fusion of the third-layer feature pyramid network BiFPN module is:
[0021]
[0022]
[0023] in, represents the third layer input features, It is the intermediate feature of the third layer and is convolved by the input features of the fourth layer and the input features of the third layer. It is the output feature of the third layer and is convolved by the input feature of the third layer and the intermediate feature of the third layer. represents the fourth layer input features, is the output feature of the second layer, is the convolution operation, is an upsampling or downsampling operation, Indicates i The learnable weights of the input features, where ( i =1,2) and ( i =1,2,3) are weight parameters for distinguishing different feature levels. =0.0001.
[0024] The beneficial effect of the present invention is that by adding the attention mechanism SE and the pyramid network BiFPN module to the YOLOv5 network algorithm, defects on the filter surface can be accurately detected. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] Figure 1 A flowchart of the invention;
[0026] Figure 2 It is a structural diagram of the attention mechanism SE module in the present invention;
[0027] Figure 3 The backbone network structure for adding the attention mechanism SE module to the YOLOv5 network algorithm;
[0028] Figure 4 It is a schematic diagram of the structure of the feature pyramid network BiFPN module;
[0029] Figure 5 To add the network structure of the feature pyramid network BiFPN module to the YOLOv5 network algorithm;
[0030] Figure 6 This is a schematic diagram of the structure of the visual inspection automation equipment. DETAILED DESCRIPTION
[0031] The present invention is described in detail below in conjunction with the accompanying drawings. The embodiments of the present invention are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements with the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and cannot be interpreted as limiting the present invention. The directional terms such as left, middle, right, top, and bottom in the embodiments of the present invention are only relative concepts or are based on the normal use state of the product, and should not be considered as restrictive.
[0032] A deep learning method for filter surface defect detection, such as Figure 1 As shown, the following steps are included:
[0033] Step 1: Combine Figure 2 and Figure 3 As shown in the figure, the attention mechanism SE module is added to the last layer of the backbone network of the YOLOv5 network algorithm. The attention mechanism SE module is used to adaptively adjust and correct feature weights during feature extraction. Specifically, during feature extraction, the attention mechanism SE module can simulate the interdependence between channels and adaptively recalibrate the feature response of the channel. The attention mechanism SE module includes a compression part and an excitation part. The compression part is used to compress the spatial information in the input feature map. H×W×C Compressed to 1×1×C , that is, using global average pooling in the spatial dimension to obtain 1×1×C Feature map; the excitation part is used to combine the learned attention information with the input features and obtain a feature map with channel attention U ;
[0034] The attention mechanism SE module reduces the dimension of the input image through global average pooling. Secondly, the global information is learned through the feedforward network, and the corresponding weight of each feature map is obtained. Finally, the corresponding weight is multiplied by the original feature map to obtain the final feature information. At the same time, it is compared with the channelless attention mechanism SimAM to select the attention mechanism suitable for the present invention. The results are shown in Table 1.
[0035]
[0036] Compression operation output of the compression part By shrinking the feature map U The spatial dimension H×W And generate, that is:
[0037]
[0038] in, is the compression function;
[0039] The weight vector s of the excitation part is:
[0040]
[0041]
[0042] in, represents the ReLU nonlinear activation function, is the activation function, is the extrusion output and serves as the excitation input, is the channel mapping relationship, is the reduction rate of the channel;
[0043] The output of the attention mechanism SE module assigns weights to the feature map U through the weight vector s to obtain the feature map :
[0044] =
[0045] in, , For indicator and feature maps Multiply the channels between , c is a positive integer.
[0046] Step 2: Combine Figure 4 and Figure 5 As shown in the figure, the feature pyramid network BiFPN module is introduced into the neck network of the YOLOv5 network algorithm, and the original path aggregation network PANet structure of the YOLOv5 network algorithm is removed to obtain the optimized YOLOv5 network algorithm; specifically: after the backbone network extracts the input image, it must be processed by the neck network and then output to the detection part. In order to better fuse the feature information, the feature pyramid network BiFPN module combines the deep and shallow feature fusion from top to bottom and bottom to top, and repeats the same layer multiple times to achieve higher-level feature fusion; the feature fusion of the third-layer feature pyramid network BiFPN module is:
[0047]
[0048]
[0049] in, represents the third layer input features, It is the intermediate feature of the third layer and is convolved by the input features of the fourth layer and the input features of the third layer. It is the output feature of the third layer and is convolved by the input feature of the third layer and the intermediate feature of the third layer. represents the fourth layer input features, is the output feature of the second layer, is the convolution operation, is an upsampling or downsampling operation, Indicates i The learnable weights of the input features, where ( i =1,2) and ( i =1,2,3) are weight parameters for distinguishing different feature levels. = 0.0001 represents a small value to avoid numerical instability.
[0050] The optimized YOLOv5 algorithm in this paper is compared with three mainstream target detection algorithms, namely Faster R-CNN, YOLOv5 and YOLOv7, and the four parameters of Precision, Recall, mAP@0.5 and mAP@0.5:0.95 are used as evaluation indicators. The performance of different networks in detecting filter surface defects on the dataset is shown in Table 2.
[0051]
[0052] Step 3: Train the optimized YOLOv5 network algorithm through the filter surface defect dataset, and obtain the YOLOv5 target detection network for filter surface defect detection; wherein, the filter surface defect dataset includes collecting different defect categories of the filter through a visual device under different environments and making a filter dataset, and then labeling the filter dataset through LabelImg, generating a .txt file at the same time, and randomly dividing the filter dataset and the corresponding .txt file into a training set and a validation set in a ratio of 8:2.
[0053] The deep learning method for filter surface defect detection of the present invention is applied in visual inspection automation equipment, such as Figure 6As shown, the visual inspection automation equipment includes a filter feeding module 18, a filter inner and outer diameter detection module 10, a filter inner surface detection module 12, a filter outer surface detection module 13, and a filter weighing module 14. The filter feeding module 18 is used to transmit the filter to the filter picking station through a conveyor belt 181, and then the filter is grabbed by the mechanical claw 11 and rotated to the filter inner and outer diameter detection station. The filter inner and outer diameter detection module 10 is used to detect whether the inner and outer diameter errors of the filter are within the qualified range. The filter inner surface detection module 12 is used to detect the inner surface of the filter. The filter outer surface detection module 13 is used to detect the outer surface of the filter. The filter weighing module 14 is used to detect the outer surface of the filter. To detect whether the weight of the filter is within the qualified range, the industrial control screen 15 is used to display the operating status of the visual inspection automation equipment in real time, count the number of defective products of various types and the change of the qualified rate of the filter, and the printer 16 is used to print various data of the filter detection; a Gigabit Ethernet industrial linear array camera is selected, the model is MV-CL042-91GM, the light source 131 adopts a linear array scanning industrial visual light source, and the filter placement station is designed as a rotating station, which can collect a complete image of the filter surface with the linear array camera; wherein, the lifting mechanism 121 is used to control the lifting and lowering of the area array camera 122 to avoid collision with the mechanical claw when the camera does not need to scan; Figure 1 As shown, the feeding mechanism 133 is used to control the linear motion of the line scan camera 132 so as to adjust the distance between the line scan camera 132 and the filter.
[0054] According to the above technical solution, an example is given with a production line in a filter workshop as the application background. 1,000 products are randomly produced, and three mainstream algorithms, Faster R-CNN, YOLOv5 and YOLOv7, are used to compare with the improved algorithm of the present invention. The experiment was carried out on a Win10 operating system platform, an Intel i7 processor with a main frequency of 2.11GHz, 16GB of memory and a python3.8 development environment. The training category of the present invention is 5, the number of iterations is set to 300epochs, the batch size is set to 8, and the precision (P), recall (R), average precision (AP) and mean average precision (mAP) are used as performance evaluation indicators; Results Figure 3 As shown in the figure, P represents the correct ratio of all the results predicted as positive samples; R represents the ratio of all the positive samples that are correctly predicted; the PR curve is a curve with Recall as the horizontal axis and Precision as the vertical axis. The larger the area on the lower left of the PR graph, the better the model works on the data set. The area enclosed is the average precision AP, which represents the average precision of each category; mAP represents the average AP of each category. The larger the value, the better the performance of the model. The specific calculation formulas for each indicator are as follows:
[0055]
[0056]
[0057]
[0058]
[0059] In the formula, TP represents the number of true positive samples predicted as positive samples; FP represents the number of true negative samples predicted as positive samples; FN represents the number of true positive samples predicted as negative samples. Represents the total number of detection categories, represents the category index, Indicates Category Value, when hour, .
[0060] The optimized YOLOv5 network algorithm in this paper is compared with three mainstream target detection algorithms, namely Faster R-CNN, YOLOv5 and YOLOv7. The four parameters of Precision, Recall, mAP@0.5 and mAP@0.5:0.95 are used as evaluation indicators. The performance of different networks in detecting filter surface defects on the dataset is shown in Table 1.
[0061] For fair comparison, the training parameters of the YOLOv7 algorithm and the YOLOv5 network algorithm are kept consistent, such as training batches and number of iterations. The improved YOLOv5 network algorithm is 12.8%, 2%, and 5.1% higher than Faster R-CNN, YOLOv5, and YOLOv7 in mAP@0.5; in terms of mAP@0.5:0.95, the improved YOLOv5 algorithm is 4.8%, 0.5%, and 5.1% higher than Faster R-CNN, YOLOv5, and YOLOv7, respectively, which improves the algorithm detection accuracy and further improves the efficiency of filter surface detection.
[0062] The above shows and describes the basic principles, main features and advantages of the present invention. It should be understood by those skilled in the art that the present invention is not limited to the above embodiments. The above embodiments and descriptions are only for explaining the principles of the present invention. Without departing from the spirit and scope of the present invention, the present invention may have various changes and improvements, which fall within the scope of the present invention. The scope of protection of the present invention is defined by the attached claims and their equivalents.
Claims
1. A deep learning method for filter surface defect detection, characterized in that: The following steps are involved: Step 1: Add the attention mechanism SE module to the last layer of the backbone network of the YOLOv5 network algorithm. The attention mechanism SE module is used to adaptively adjust and correct feature weights during feature extraction; The attention mechanism SE module reduces the dimension of the input image through global average pooling. Secondly, it learns global information through the feedforward network and obtains the corresponding weights of each feature map. Finally, the corresponding weights are multiplied with the original feature map to obtain the final feature information. The attention mechanism SE module includes a compression part and an excitation part. The compression part is used to compress the spatial information in the input feature map and compress H×W×C into 1×1×C, that is, global average pooling is used in the spatial dimension to obtain a 1×1×C feature map; the excitation part is used to combine the learned attention information with the input features and obtain a feature map U with channel attention; the compression operation output Z of the compression part C It is generated by reducing the spatial dimension H×W of the feature map U, that is: Among them, F sq is the compression function; The weight vector s of the excitation part is: s=F ex (z,Q)=σ(g(z,Q))=σ(Q2δ(Q1,z)) (2) Q1∈R C / r×C ,Q2∈R C×r / C (3) Among them, δ represents the ReLU nonlinear activation function, F ex is the excitation function, z is the squeeze output and serves as the excitation input, Q is the channel mapping relationship, and r is the channel reduction rate; The output of the attention mechanism SE module assigns weights to the feature map U through the weight vector s to obtain the feature map in, F scale (u c ,s c ) is the indicator quantity s c and feature map u c Multiply the channels between c ∈R H×W , c is a positive integer; Step 2: Introduce the feature pyramid network BiFPN module into the neck network of the YOLOv5 network algorithm, and remove the original path aggregation network PANet structure of the YOLOv5 network algorithm to obtain the optimized YOLOv5 network algorithm; specifically: after the backbone network extracts the input image, it must be processed by the neck network and then output to the detection part. In order to better fuse the feature information, the feature pyramid network BiFPN module combines the deep and shallow feature fusion from top to bottom and bottom to top, and repeats the same layer multiple times to achieve higher-level feature fusion; The feature fusion of the third-layer feature pyramid network BiFPN module is: in, represents the third layer input features, It is the intermediate feature of the third layer and is convolved by the input features of the fourth layer and the input features of the third layer. It is the output feature of the third layer and is convolved by the input feature of the third layer and the intermediate feature of the third layer. represents the fourth layer input features, is the output feature of the second layer, Conv is a convolution operation, Resize is an upsampling or downsampling operation, ω i represents the learnable weight of the i-th input feature, where ω i where i is 1 or 2, ω i ' is 1, 2 or 3, ω i and ω i ′ are weight parameters for distinguishing different feature levels, θ = 0.0001; Step 3: Train the optimized YOLOv5 network algorithm through the filter surface defect dataset, and obtain the YOLOv5 target detection network for filter surface defect detection; The deep learning method for filter surface defect detection is applied in the visual inspection automation equipment. The visual inspection automation equipment includes a filter feeding module, a filter inner and outer diameter detection module, a filter inner surface detection module, a filter outer surface detection module, and a filter weighing module. The filter feeding module is used to transmit the filter to the filter picking station through a conveyor belt, and then the filter is grasped by a mechanical claw and rotated to the filter inner and outer diameter detection station. The filter inner and outer diameter detection module is used to detect whether the filter inner and outer diameter errors are within the qualified range. The filter inner surface detection module is used to detect the inner surface condition of the filter. The filter outer surface detection module Used to detect the outer surface condition of the filter, the filter weighing module is used to detect whether the filter weight is within the qualified range, the industrial control screen is used to display the operating status of the visual inspection automation equipment in real time, count the number of various types of defective products and the changes in the filter qualification rate, and the printer is used to print various data for filter inspection; a Gigabit Ethernet industrial line array camera is selected, and the light source adopts a line array scanning industrial visual light source. The filter placement station is designed as a rotating station, and the line array camera can be used to capture a complete image of the filter surface; among them, the lifting mechanism is used to control the lifting and lowering of the area array camera, and the feeding mechanism is used to control the linear motion of the line scan camera.
2. The deep learning method for filter surface defect detection according to claim 1, characterized in that: The filter surface defect dataset includes collecting different defect categories of the filter through a visual device and making a filter dataset, then labeling the filter dataset through LabelImg, generating a .txt file at the same time, and randomly dividing the filter dataset and the corresponding .txt file into a training set and a validation set in a ratio of 8:2.
