Automobile gear defect identification method based on machine vision
By integrating the self-, spatial, channel attention mechanism and Mixup data enhancement, combined with the Retinanet network, the problem of low efficiency and insufficient accuracy of automotive gear defect recognition in the existing technology is solved, achieving a more efficient and accurate recognition effect, and improving Quality control and safety production levels in the automotive manufacturing industry.
Patent Information
- Application Number
- CN202410689881.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-30
- Publication Date
- 2024-09-03
- Estimated Expiration
- 2044-05-30
AI Technical Summary
The existing technology is inefficient in identifying automotive gear defects and is easily affected by subjective factors. It is difficult for a simple CNN model to fully extract the subtle features of defects, especially in complex environments, with insufficient recognition accuracy.
Fusion of self-attention mechanism, spatial attention mechanism and channel attention mechanism, through convolution and element-wise addition operations, improves the fusion effect of feature map weights, builds a machine vision detection module, combines Mixup data enhancement and Retinanet network to improve automobile Accuracy and robustness of gear defect identification.
It significantly improves the accuracy and robustness of automotive gear defect identification, improves automation and efficiency, and enhances quality control and safety production levels.
Smart Images

Figure CN118587487A
Abstract
Description
Technical Field
[0001] 0001. The present invention belongs to the field of computer vision, and in particular relates to a method for identifying automobile gear defects based on machine vision. Background Art
[0002] 0002. With the rapid development of industrial automation, the application of machine vision technology in the field of quality inspection is becoming more and more extensive. Especially in the automotive manufacturing industry, gears are key transmission components, and their quality is directly related to the performance and safety of the car. Therefore, the accurate identification of automotive gear defects is particularly important. Traditional gear defect identification methods mostly rely on manual visual inspection, which is not only inefficient, but also easily affected by subjective factors, resulting in missed detection or false detection. Therefore, the use of machine vision technology to achieve automated and high-precision identification of automotive gear defects has become a research hotspot.
[0003] 0003. In the field of machine vision, deep learning models such as convolutional neural networks (CNN) have been proven to have excellent performance in tasks such as image classification and target detection. However, for complex gear defect recognition tasks, simple CNN models often have difficulty in fully extracting the subtle features of defects. This is mainly due to the wide variety of gear defects, and the different sizes and shapes of defects, and they may also be affected by environmental factors such as light and noise. Therefore, how to improve the model's ability to extract defect features has become the key to improving the accuracy of gear defect recognition.
[0004] 0004. In recent years, the attention mechanism has received widespread attention in the field of deep learning. It simulates the selective attention mechanism of the human visual system, allowing the model to automatically focus on the key areas in the image, thereby improving the pertinence and efficiency of feature extraction. Multi-Attention Fusion combines different types of attention mechanisms to make full use of their respective advantages and further improve the performance of the model. For example, the spatial attention mechanism can focus on information at different locations in the image, while the channel attention mechanism can emphasize the dependencies between different channels. By fusing these two attention mechanisms, the local and global features of gear defects can be better captured, thereby improving the accuracy of recognition.
[0005] 0005. In summary, the integration of machine vision technology and multi-attention mechanism for automotive gear defect recognition can not only improve the degree of automation and efficiency of recognition, but also effectively improve the accuracy and robustness of recognition, which is of great significance to improving the quality control and safety production level of the automotive manufacturing industry. Summary of the invention
[0006] 0006. The present invention provides a method for identifying automobile gear defects based on machine vision, aiming to integrate multiple attention mechanisms to improve the recognition effect of machine vision in automobile gear defect recognition scenarios.
[0007] 0007. The present invention aims to integrate multiple attention mechanisms based on machine vision recognition and provide a method for identifying automobile gear defects based on machine vision, comprising the following steps: S1. Build a machine vision detection module, input feature maps to branches 1, 2, 3, and 4, perform self-attention operation on the input feature map in branch 1 to obtain a self-attention feature map, perform convolution and spatial attention operation on the input feature map in branch 2 to obtain a spatial attention feature map, perform convolution and channel attention operation on the input feature map in branch 3 to obtain a channel attention feature map, add the self-attention feature map, the spatial attention feature map, and the channel attention feature map element by element to obtain an intermediate feature map, perform convolution operation on the intermediate feature map to obtain a convolution intermediate feature map, add the convolution intermediate feature map and the input feature map of branch 4 element by element to obtain an output feature map, input the output feature map to the detection head, and obtain the detection result; S2. Prepare a dataset of automobile gear defects, and classify the identification types into defective and non-defective types. For defective types, collect defective automobile gears, place the defective side of the gear horizontally and rotate it by a certain angle in sequence, take pictures of automobile gear defects from above multiple times, and mark the automobile gears in these pictures as defective as a whole. Collect normal automobile gears, place one side of the gear horizontally and rotate it by a certain angle in sequence, take pictures of automobile gear defects from above multiple times, and mark the automobile gears in these pictures as non-defective as a whole. After obtaining the automobile gear defect dataset, perform Mixup data enhancement on the pictures in the dataset. S3. Use machine vision algorithm to train the automotive gear defect data set. The machine vision algorithm includes input end, backbone network, machine vision detection module and output end. The input end inputs the picture and annotation file, and passes the picture through the backbone network. The backbone network includes convolution layer, residual block, batch normalization layer, activation function layer, pooling layer and linear layer. After the picture passes through the backbone network, the feature map corresponding to the picture is output. The feature map is input into the machine vision detection module to obtain the detection result. After the training is completed, the detection model is obtained; S4. Use the detection model to detect automobile gear defects. The detection model input is a single picture or a camera video frame. After the image is input into the detection model, it passes through the backbone network and the machine vision detection module in sequence and is input into the detection head to obtain the detection target position and classification. The classification includes defective or non-defective. If it is classified as defective, it is judged that the current vehicle gear has defects.
[0008] 0008. Preferably, in step S1, given the input feature map , H and W represent width and height respectively. The input image is sent to branches 1, 2, 3 and 4 in the module. Branch 1 is operated by the self-attention mechanism to obtain the self-attention feature map. , branch 2 obtains the spatial attention feature map through convolution and spatial attention mechanism operation , branch 3 obtains the channel attention feature map through convolution and channel attention mechanism operation , add the self-attention feature map, spatial attention feature map and channel attention feature map element by element to get the intermediate feature map , perform convolution operation on the intermediate feature map to obtain the convolution intermediate feature map , add the convolution intermediate feature map and the branch 4 input feature map element by element to get the output feature map .
[0009] 0009. Preferably, in step S2, one side of the gear defect is placed horizontally and rotated at a certain angle in turn, and the angle is set to 30 degrees, so that multiple pictures of gear defects in different positions can be obtained. For Mixup data enhancement, new sample data is obtained by linear interpolation, including flipping, rotation, scaling and shifting. New annotation data is generated while generating new pictures, and the new samples and new annotation data are integrated into the automotive gear defect dataset.
[0010] 0010. Preferably, in step S3, the convolution layer is used to extract image features, the residual block is used to build a deep network, the batch normalization layer is used to accelerate network training and improve performance, the activation function layer uses functions such as ReLU to increase the nonlinear expression ability of the network, the pooling layer is used to reduce the dimension of the feature map and reduce the amount of calculation, and the linear layer is used to map the previously extracted features to the label space of the sample. At the same time, the convolution layer in the backbone network is part of the residual block, and the output of the convolution layer is added to the input to form a residual connection. The residual block is calculated as follows: , where y is the output of the residual block and x is the input of the residual block. It is part of the residual block, which contains multiple convolutional layers, batch normalization layers, and activation function layers. The residual connection is connected by adding the input x directly to , allowing the algorithm to learn the residual mapping between input and output.
[0011] 0011. Compared with the prior art, the present invention has the following technical effects: The technical solution provided by the present invention proposes a machine vision detection module that integrates the self-attention mechanism, the spatial attention mechanism, and the channel attention mechanism. By performing operations such as convolution and element-by-element addition on these attention mechanisms, the feature map weights are appropriately integrated, thereby improving the recognition effect of machine vision in the automotive gear defect recognition scenario. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] 0012. Figure 1 The present invention provides a flow chart for identifying automobile gear defects.
[0013] 0013. Figure 2 It is a structural diagram of the machine vision detection module provided by the present invention. DETAILED DESCRIPTION
[0014] 0014. The present invention aims to propose a method for identifying automobile gear defects based on machine vision, and proposes a machine vision detection module that integrates the self-attention mechanism, the spatial attention mechanism, and the channel attention mechanism. By performing operations such as convolution and element-by-element addition on these attention mechanisms, the feature map weights are appropriately integrated, thereby improving the recognition effect of machine vision in the automobile gear defect recognition scenario.
[0015] 0015.Please see Figure 1 As shown, a method for identifying automobile gear defects based on machine vision in an embodiment of the present application: S1, build machine vision detection module, such as Figure 2 As shown, the feature map is input to branch 1, branch 2, branch 3 and branch 4. In branch 1, the input feature map is operated by a self-attention mechanism to obtain a self-attention feature map. In branch 2, the input feature map is sequentially convolved and operated by a spatial attention mechanism to obtain a spatial attention feature map. In branch 3, the input feature map is sequentially convolved and operated by a channel attention mechanism to obtain a channel attention feature map. The self-attention feature map, the spatial attention feature map and the channel attention feature map are added element by element to obtain an intermediate feature map. The intermediate feature map is convolved to obtain a convolution intermediate feature map. The convolution intermediate feature map and the input feature map of branch 4 are added element by element to obtain an output feature map. The output feature map is input to the detection head to obtain a detection result. S2. Prepare a dataset of automobile gear defects, and classify the identification types into defective and non-defective types. For defective types, collect defective automobile gears, place the defective side of the gear horizontally and rotate it by a certain angle in sequence, take pictures of automobile gear defects from above multiple times, and mark the automobile gears in these pictures as defective as a whole. Collect normal automobile gears, place one side of the gear horizontally and rotate it by a certain angle in sequence, take pictures of automobile gear defects from above multiple times, and mark the automobile gears in these pictures as non-defective as a whole. After obtaining the automobile gear defect dataset, perform Mixup data enhancement on the pictures in the dataset. S3. Use machine vision algorithm to train the automotive gear defect data set. The machine vision algorithm includes input end, backbone network, machine vision detection module and output end. The input end inputs the picture and annotation file, and passes the picture through the backbone network. The backbone network includes convolution layer, residual block, batch normalization layer, activation function layer, pooling layer and linear layer. After the picture passes through the backbone network, the feature map corresponding to the picture is output. The feature map is input into the machine vision detection module to obtain the detection result. After the training is completed, the detection model is obtained; S4. Use the detection model to detect automobile gear defects. The detection model input is a single picture or a camera video frame. After the image is input into the detection model, it passes through the backbone network and the machine vision detection module in sequence and is input into the detection head to obtain the detection target position and classification. The classification includes defective or non-defective. If it is classified as defective, it is judged that the current vehicle gear has defects.
[0016] 0016. Further, in step S1, given the input feature map , H and W represent width and height respectively. The input image is sent to branches 1, 2, 3 and 4 in the module. Branch 1 is operated by the self-attention mechanism to obtain the self-attention feature map , branch 2 obtains the spatial attention feature map through convolution and spatial attention mechanism operation , branch 3 obtains the channel attention feature map through convolution and channel attention mechanism operation , add the self-attention feature map, spatial attention feature map and channel attention feature map element by element to get the intermediate feature map , perform convolution operation on the intermediate feature map to obtain the convolution intermediate feature map , add the convolution intermediate feature map and the branch 4 input feature map element by element to get the output feature map .
[0017] 0017. Further, in S2, one side of the gear defect is placed horizontally and rotated at a certain angle in turn. The angle is set to 30 degrees. In this way, multiple pictures of gear defects in different positions can be obtained. For Mixup data enhancement, new sample data is obtained through linear interpolation, including flipping, rotation, scaling and shifting. New annotation data is generated while generating new pictures, and the new samples and new annotation data are integrated into the automotive gear defect dataset.
[0018] 0018. Further, in S3, the convolution layer is used to extract image features, the residual block is used to build a deep network, the batch normalization layer is used to accelerate network training and improve performance, the activation function layer uses functions such as ReLU to increase the nonlinear expression ability of the network, the pooling layer is used to reduce the dimension of the feature map and reduce the amount of calculation, and the linear layer is used to map the previously extracted features to the sample label space. At the same time, the convolution layer in the backbone network is part of the residual block. The output of the convolution layer will be added to the input to form a residual connection. The calculation method of the residual block is, , where y is the output of the residual block and x is the input of the residual block. It is part of the residual block, which contains multiple convolutional layers, batch normalization layers, and activation function layers. The residual connection is connected by adding the input x directly to , allowing the algorithm to learn the residual mapping between input and output.
[0019] 0019. Further, in S3, the backbone network uses the Retinanet network, and the detection head uses the Retinanet detection head. For the detection results, if the detection head does not output a defect recognition box, it is considered to be without a target. If a defect recognition box is output, it is judged whether there is a defect or not based on the recognition box classification.
[0020] 0020. The above are only preferred embodiments of the present invention. It should be pointed out that, for ordinary technicians in this field, several modifications and improvements can be made without departing from the creative concept of the present invention, which all belong to the protection scope of the present invention.
Claims
1. A method for identifying automobile gear defects based on machine vision, characterized in that: The following steps are involved: S1. Build a machine vision detection module, input feature maps to branches 1, 2, 3, and 4, perform self-attention operation on the input feature map in branch 1 to obtain a self-attention feature map, perform convolution and spatial attention operation on the input feature map in branch 2 to obtain a spatial attention feature map, perform convolution and channel attention operation on the input feature map in branch 3 to obtain a channel attention feature map, add the self-attention feature map, the spatial attention feature map, and the channel attention feature map element by element to obtain an intermediate feature map, perform convolution operation on the intermediate feature map to obtain a convolution intermediate feature map, add the convolution intermediate feature map and the input feature map of branch 4 element by element to obtain an output feature map, input the output feature map to the detection head, and obtain the detection result; S2. Prepare a dataset of automobile gear defects, and classify the identification types into defective and non-defective types. For defective types, collect defective automobile gears, place the defective side of the gear horizontally and rotate it by a certain angle in sequence, take pictures of automobile gear defects from above multiple times, and mark the automobile gears in these pictures as defective as a whole. Collect normal automobile gears, place one side of the gear horizontally and rotate it by a certain angle in sequence, take pictures of automobile gear defects from above multiple times, and mark the automobile gears in these pictures as non-defective as a whole. After obtaining the automobile gear defect dataset, perform Mixup data enhancement on the pictures in the dataset. S3. Use machine vision algorithm to train the automotive gear defect data set. The machine vision algorithm includes input end, backbone network, machine vision detection module and output end. The input end inputs the picture and annotation file, and passes the picture through the backbone network. The backbone network includes convolution layer, residual block, batch normalization layer, activation function layer, pooling layer and linear layer. After the picture passes through the backbone network, the feature map corresponding to the picture is output. The feature map is input into the machine vision detection module to obtain the detection result. After the training is completed, the detection model is obtained; S4. Use the detection model to detect automobile gear defects. The detection model input is a single picture or a camera video frame. After the image is input into the detection model, it passes through the backbone network and the machine vision detection module in sequence and is input into the detection head to obtain the detection target position and classification. The classification includes defective or non-defective. If it is classified as defective, it is judged that the current vehicle gear has defects.
2. The method for identifying automobile gear defects based on machine vision according to claim 1, characterized in that: In step S1, given the input feature map , H and W represent width and height respectively. The input image is sent to branches 1, 2, 3 and 4 in the module. Branch 1 is operated by the self-attention mechanism to obtain the self-attention feature map , branch 2 obtains the spatial attention feature map through convolution and spatial attention mechanism operation , branch 3 obtains the channel attention feature map through convolution and channel attention mechanism operation , add the self-attention feature map, spatial attention feature map and channel attention feature map element by element to get the intermediate feature map , perform convolution operation on the intermediate feature map to obtain the convolution intermediate feature map , add the convolution intermediate feature map and the branch 4 input feature map element by element to get the output feature map .
3. The method for identifying automobile gear defects based on machine vision according to claim 1, characterized in that: In step S2, the defective side of the gear is placed horizontally and rotated at a certain angle in turn. The angle is set to 30 degrees. In this way, multiple pictures of gear defects in different positions can be obtained. For Mixup data enhancement, new sample data is obtained through linear interpolation, including flipping, rotation, scaling and shifting. New annotation data is generated while generating new pictures, and the new samples and new annotation data are integrated into the automotive gear defect dataset.
4. The method for identifying automobile gear defects based on machine vision according to claim 1, characterized in that: In step S3, the convolution layer is used to extract image features, the residual block is used to build a deep network, the batch normalization layer is used to accelerate network training and improve performance, the activation function layer uses functions such as ReLU to increase the nonlinear expression ability of the network, the pooling layer is used to reduce the dimension of the feature map and reduce the amount of calculation, and the linear layer is used to map the previously extracted features to the sample label space. At the same time, the convolution layer in the backbone network is part of the residual block. The output of the convolution layer will be added to the input to form a residual connection. The calculation method of the residual block is: , where y is the output of the residual block and x is the input of the residual block. It is part of the residual block, which contains multiple convolutional layers, batch normalization layers, and activation function layers. The residual connection is connected by adding the input x directly to , allowing the algorithm to learn the residual mapping between input and output.
Citation Information
Patent Citations
Aero-engine blade defect detection method based on convolutional neural network
CN112465759A
Wafer surface defect mode detection method based on deep attention network
CN113362320A
Workpiece defect detection method and device fusing multi-attention mechanism
CN113822885A
Light-weight gear surface defect detection method based on MSTA-YOLOv5
CN115953386A
Deep learning-based face feature point detection method
WO2022151535A1
Cited By
Vehicle surface defect identification method and system based on artificial intelligence
CN120411910A
