CN-122023299-A - Lightweight metal surface defect detection method and system
Abstract
The invention relates to the technical field of metal defect detection, and provides a lightweight metal surface defect detection method and system, wherein a metal surface image to be detected is input into a trained defect detection model to detect the metal surface defect, the defect detection model is a lightweight RT-DETR model, a feature fusion module in the lightweight RT-DETR model is a spatial semantic information enhancement module, the spatial semantic information enhancement module is used for carrying out spatial attention processing on input low-level features, splicing and fusing the processed low-level features with the input high-level features, adding the obtained fused features with the low-level features, dividing the added features into three paths, processing the features by using a 1X 1 convolution kernel, cavity convolution and average pooling respectively, fusing processing results, carrying out depth separable convolution processing on the fused results, and carrying out residual connection on the processed features and the features before processing, wherein the result is output of the spatial semantic information enhancement module.
Inventors
- XU BINRUI
- LIU MIN
- Hao Zongchen
- LIU BO
- YANG ZHENHAO
- Ren Duoxin
- SONG FEIHONG
- GAO YAN
- CHANG LONG
- ZHANG JINCAN
Assignees
- 河南科技大学
Dates
- Publication Date
- 20260512
- Application Date
- 20260120
Claims (10)
- 1. A lightweight metal surface defect detection method is characterized by comprising the following steps: 1) Collecting an image of the surface of the metal to be detected; 2) The method comprises the steps of inputting a metal surface image to be detected into a trained defect detection model to detect the metal surface defect, wherein the defect detection model is a light RT-DETR model, a feature fusion module in the light RT-DETR model is a space semantic information enhancement module, the space semantic information enhancement module is used for carrying out space attention processing on input low-level features, splicing and fusing the processed low-level features with the input high-level features to obtain fused features and low-level features, adding the added features into three paths, dividing the first path into three paths, carrying out 1X 1 convolution kernel processing to obtain first features, carrying out cavity convolution processing to obtain second features, carrying out average pooling processing to obtain third features, carrying out depth separable convolution processing on the fused results, and carrying out residual connection between the depth separable convolution processing results and the results which are not subjected to the depth separable convolution processing, wherein the results are output by the space semantic information enhancement module.
- 2. The method for detecting the defects on the light-weight metal surface according to claim 1, wherein the cavity convolution comprises at least two convolution kernels with the same size, expansion rates of the convolution kernels are different, features in the second path are respectively processed by using the different convolution kernels, and a splicing result of the processing results of the convolution kernels is the second feature.
- 3. The method for detecting the defects on the lightweight metal surface according to claim 1, wherein the encoder in the lightweight RT-DETR model adopts an adaptive sparse self-attention-based encoder, the encoder sends the input features into two branches of attention, the first branch of attention is used for processing the product of a key vector and a query vector by using sparse self-attention, the second branch of attention is used for processing the product of the key vector and the query vector by using dense self-attention, the first branch of attention processing result and the second attention result are added and multiplied by a value vector and then subjected to feature space mapping, the result of feature space mapping and the input features of the encoder based on adaptive sparse self-attention are added, the added normalization processing is performed again on the added result and the input features of the encoder, the obtained processed result is input into a feedforward neural network for processing, and the feedforward network processing result and the result before being input into the feedforward neural network are added and normalized again to obtain the output of the adaptive sparse self-attention-based encoder.
- 4. A lightweight metal surface defect detection method as in claim 3 wherein the first attention branch uses a ReLU 2 activation function to process the product of the key vector K and the query vector Q.
- 5. A lightweight metal surface defect detection method as in claim 3 wherein the second attention branch uses a Softmax activation function to process the product of the key vector K and the query vector Q.
- 6. The method for detecting the light-weight metal surface defects according to claim 1, wherein a light-weight feature extraction module is adopted in a backbone network in the light-weight RT-DETR model, features input into the light-weight feature extraction module are divided into two paths, one path is subjected to convolution processing to obtain a convolution result, the other path is subjected to convolution processing to obtain a processing result of a double PCBlock module by using a double PCBlock module, the processing result of the double PCBlock module and the first path and the second path are spliced and then are divided into two paths, one path is subjected to convolution processing to obtain a convolution processing result, the other path is subjected to convolution processing to obtain a MCBlock processing result, the convolution processing result is spliced with the MCBlock processing result and then subjected to convolution processing, and the processing result is output of the backbone network.
- 7. The method for detecting a defect on a lightweight metal surface according to claim 6, wherein the double PCBlock modules comprise two PCBlock modules, the first PCBlock processed feature is obtained after the feature after convolution processing is input and processed by the first PCBlock module, the second PCBlock processed feature is obtained after the feature after processing by the second PCBlock module after processing the first PCBlock processed feature, and the splicing result of the first PCBlock processed feature and the second PCBlock processed feature is the double PCBlock module processing result.
- 8. The method for detecting the defects on the light-weight metal surface according to claim 6, wherein the MCBlock modules comprise N convolution kernels with the same size, the input features are respectively subjected to the N convolution kernels with the same size to obtain features with the corresponding size, the obtained features are spliced with the deconvoluted data, and the splicing result is the output of the MCBlock module.
- 9. The method for detecting defects on a lightweight metal surface according to claim 8, wherein N is 3.
- 10. A lightweight metal surface defect detection system, comprising a processor for running a computer program to implement a lightweight metal surface defect detection method as claimed in any one of claims 1 to 9.
Description
Lightweight metal surface defect detection method and system Technical Field The invention relates to the technical field of metal defect detection, in particular to a lightweight metal surface defect detection method and system. Background In the industrial field, in order to ensure the quality of products, defect detection is required for the produced metal surfaces. In the past, metal surface defect detection has been performed by manually identifying product defects, but this approach requires a significant amount of labor cost and has a high false detection rate. With the continuous development of machine learning, scientific researchers propose a metal surface defect detection method based on automatic learning, the method realizes high-precision detection of metal surface defects through an automatic model, and meanwhile, labor cost is greatly reduced, but the method has strong data dependence. In the academic field, morphological processing parameters are automatically learned by utilizing a genetic algorithm, so that defects on the metal surface are detected, and the subjectivity and low adjustability of manual parameter adjustment in the traditional method are avoided, but the detection capability on complex texture defects or micro defects is relatively weak. Thus, while machine learning has great potential in the field of metal surface defect detection in theory, there are still some drawbacks in the actual industry with existing machine learning methods. With the continuous development of deep learning, the application range of the neural network is wider and wider, and related algorithms such as convolutional neural networks and the like are widely applied in the field of metal surface defect detection. For example, researchers have proposed a bearing surface defect detection method based on a hierarchical attention mechanism, which significantly improves the detection performance of multi-scale defects by combining three levels of features of texture, semantics and examples. However, the method has higher computational complexity, and only aims at bearing surface defects, the performance on other metal surfaces is not verified, and the detection accuracy is lower. In addition, researchers also propose a PCB defect detection method through a multi-scale feature enhancement and attention mechanism, and the method suppresses redundant features through NAM modules to enhance the significance of a target area. However, the method does not consider actual industrial scenes such as noise and illumination robustness test, and has the problem of high computational complexity. Disclosure of Invention The invention aims to provide a lightweight metal surface defect detection method and system, which are used for solving the problems of low precision and large calculated amount of the existing metal surface defect detection method. The invention provides a lightweight metal surface defect detection method for solving the technical problems, which comprises the following steps: 1) Collecting an image of the surface of the metal to be detected; 2) The method comprises the steps of inputting a metal surface image to be detected into a trained defect detection model to detect the metal surface defect, wherein the defect detection model is a light RT-DETR model, a feature fusion module in the light RT-DETR model is a space semantic information enhancement module, the space semantic information enhancement module is used for carrying out space attention processing on input low-level features, splicing and fusing the processed low-level features with the input high-level features to obtain fused features and low-level features, adding the added features into three paths, dividing the first path into three paths, carrying out 1X 1 convolution kernel processing to obtain first features, carrying out cavity convolution processing to obtain second features, carrying out average pooling processing to obtain third features, carrying out depth separable convolution processing on the fused results, and carrying out residual connection between the depth separable convolution processing results and the results which are not subjected to the depth separable convolution processing, wherein the results are output by the space semantic information enhancement module. Further, the cavity convolution comprises at least two convolution kernels with the same size, expansion rates of the convolution kernels are different, features in the second path are respectively processed by using different convolution kernels, and a splicing result of processing results of the convolution kernels is the second feature. Further, the encoder in the lightweight RT-DETR model adopts an adaptive sparse self-attention-based encoder, the encoder sends input features into two branches of attention, the first branch of attention is used for processing the product of a key vector and a query vector by using sparse self-attention, the second branch of