CN-122023982-A - Method, device, equipment and storage medium for detecting metal surface defects
Abstract
The application discloses a method, a device, equipment and a storage medium for detecting metal surface defects. The method comprises the steps of constructing a data set containing normal metal surface images, constructing a feature extraction network based on a multi-scale feature cyclic fusion depth residual error network, inputting the data set into the feature extraction network to obtain a multi-scale feature library of a normal sample, inputting the metal surface images to be detected into the feature extraction network to obtain multi-scale features of the images to be detected, calculating multi-scale fusion scores of the multi-scale features of the images to be detected and the multi-scale feature library, and determining that defects exist on the metal surface to be detected when the multi-scale fusion scores are larger than or equal to a preset threshold value. The application provides an unsupervised metal surface defect detection method, which does not need manual labeling, uses a depth residual error network based on multi-scale feature cyclic fusion to extract image features, outputs the image features from different scales, constructs a multi-scale fusion scoring mechanism and improves the detection accuracy and robustness.
Inventors
- CHEN WENMIAO
- WANG HAINING
- QI WEI
- LI SHUANG
- FANG YUNTAO
- MA CHANGHAI
- DOU QUANLI
- ZHAI QIANG
- KONG GANG
- GUO ZHIMING
- BAO YIPENG
Assignees
- 潍柴动力股份有限公司
Dates
- Publication Date
- 20260512
- Application Date
- 20260106
Claims (10)
- 1. A method for detecting a metal surface defect, comprising: Constructing a dataset comprising images of normal metal surfaces; Constructing a feature extraction network based on a depth residual error network of multi-scale feature cyclic fusion, and inputting the data set into the feature extraction network to obtain a multi-scale feature library of a normal sample; inputting the metal surface image to be detected into the feature extraction network to obtain the multi-scale features of the image to be detected; and calculating the multi-scale fusion score of the multi-scale features of the image to be detected and the multi-scale feature library, and determining that the metal surface to be detected has defects when the multi-scale fusion score is greater than or equal to a preset threshold value.
- 2. The method of claim 1, wherein inputting the dataset into the feature extraction network results in a multi-scale feature library of normal samples, comprising: Inputting the images in the dataset into a plurality of depth residual modules of the feature extraction network to obtain extracted feature layers with a plurality of scales; performing multi-scale feature cyclic fusion on the feature layers with multiple scales to obtain fusion features and full-scale fusion features; And carrying out feature enhancement on the feature layers with multiple scales based on the fusion features and the full-scale fusion features to obtain the multi-scale features of the image, and obtaining the multi-scale feature library based on the multi-scale features of the images.
- 3. The method of claim 2, wherein inputting the image in the dataset into a plurality of depth residual modules of the feature extraction network results in an extracted feature layer of a plurality of scales, comprising: Inputting the images in the dataset into a first depth residual error module of the feature extraction network to obtain a first feature layer, wherein the first feature layer is used for representing the edge and texture information of the images; Inputting the first feature layer into a second depth residual error module of the feature extraction network to obtain a second feature layer, wherein the second feature layer is used for representing structural information of an image; And inputting the second feature layer into a third depth residual error module of the feature extraction network to obtain a third feature layer, wherein the third feature layer is used for representing semantic information of the image.
- 4. A method according to claim 3, wherein performing multi-scale feature cyclic fusion on the feature layers of the plurality of scales to obtain fusion features and full-scale fusion features comprises: Upsampling the second and third feature layers; the first feature layer and the up-sampled second feature layer are subjected to weighted fusion to obtain a first fusion feature; Carrying out weighted fusion on the first fusion feature and the up-sampled third feature layer to obtain a second fusion feature; and carrying out weighted fusion on the second fusion feature and the first feature layer to obtain the full-scale fusion feature.
- 5. The method of claim 4, wherein feature enhancement is performed on the feature layer of the multiple scales based on the fused features and the full-scale fused features to obtain the multi-scale features of the image, comprising: Weighting and fusing the full-scale fusion features and the first feature layer to obtain fused first-scale features; After downsampling the first fusion feature, carrying out weighted fusion with the second feature layer to obtain a fused second scale feature; After downsampling the second fusion feature, carrying out weighted fusion with the third feature layer to obtain a fused third scale feature; and obtaining the multi-scale feature of the image based on the fused first-scale feature, the fused second-scale feature and the fused third-scale feature.
- 6. The method of claim 1, wherein calculating a multi-scale fusion score of the multi-scale feature of the image to be detected with a multi-scale feature library comprises: Calculating a first abnormal score of the image to be detected and the multi-scale feature library in a first scale feature layer based on the weighted Euclidean distance; Calculating a second abnormal score of the image to be detected and the multi-scale feature library in a second scale feature layer based on the weighted Manhattan distance; Calculating a third abnormal score of the image to be detected and the multi-scale feature library in a third scale feature layer based on the weighted cosine distance; And carrying out weighted summation based on the first abnormal score, the second abnormal score and the third abnormal score to obtain the multi-scale fusion score.
- 7. The method of claim 6, wherein calculating the first anomaly score for the first level of features for the image to be detected and the multi-level feature library based on the weighted euclidean distance further comprises: Dividing the feature images of each scale extracted from the image to be detected and the feature images of the corresponding scale in the multi-scale feature library into a plurality of local blocks with fixed sizes; For each local block of the image to be detected, calculating cosine similarity between the local block and all corresponding scale local blocks in the multi-scale feature library, and determining matched local blocks according to the cosine similarity; Calculating a structural similarity index between each pair of matched local blocks; Based on the structural similarity indexes of all matching block pairs under each scale, generating the weight corresponding to each scale through statistical aggregation.
- 8. A device for detecting defects on a metal surface, comprising: a data set construction module for constructing a data set containing images of normal metal surfaces; The feature extraction network construction module is used for constructing a feature extraction network based on a depth residual error network of multi-scale feature cyclic fusion, and inputting the data set into the feature extraction network to obtain a multi-scale feature library of a normal sample; The image feature extraction module is used for inputting the metal surface image to be detected into the feature extraction network to obtain the multi-scale features of the image to be detected; the defect detection module is used for calculating the multi-scale fusion score of the multi-scale features of the image to be detected and the multi-scale feature library, and determining that the defect exists on the metal surface to be detected when the multi-scale fusion score is greater than or equal to a preset threshold value.
- 9. An electronic device comprising a processor and a memory storing program instructions, the processor being configured to perform the method of detecting a metal surface defect according to any one of claims 1 to 7 when the program instructions are executed.
- 10. A computer storage medium having stored thereon computer readable instructions executable by a processor to implement the method of detecting a metal surface defect according to any one of claims 1 to 7.
Description
Method, device, equipment and storage medium for detecting metal surface defects Technical Field The present application relates to the field of image processing technologies, and in particular, to a method, an apparatus, a device, and a storage medium for detecting a metal surface defect. Background In the field of industrial detection, the determination of the existence of defects of a metal processing surface is a key link for ensuring the quality of products and improving the production efficiency. Traditional metal surface defect detection mainly relies on manual visual inspection, has the problems of low detection efficiency, strong subjectivity, easy fatigue and omission, and the like, and is difficult to meet the requirements of modern manufacturing industry on high-precision and high-efficiency detection. With the development of computer vision technology, a defect detection method based on deep learning is becoming the mainstream. At present, a supervised defect detection method is mainly adopted, and a training data set containing defect samples is constructed by manually marking defect positions and category information, so that the visual characteristics of defects are learned by a deep learning network. However, the supervised method requires a large number of manually marked defect samples, and has high marking cost and long period. For the scenes that the defect samples are rare, the defect forms are changeable and new defect types continuously appear in industrial production, the supervised method is difficult to obtain enough training data, so that the model generalization capability is insufficient. Disclosure of Invention The embodiment of the application provides a method, a device, equipment and a storage medium for detecting metal surface defects, which at least solve the technical problems of high labeling cost and insufficient model generalization capability of a defect detection method in the related technology. According to an aspect of an embodiment of the present application, there is provided a method for detecting a metal surface defect, including: Constructing a dataset comprising images of normal metal surfaces; constructing a feature extraction network based on a depth residual error network of multi-scale feature cyclic fusion, and inputting a data set into the feature extraction network to obtain a multi-scale feature library of a normal sample; inputting the image of the metal surface to be detected into a feature extraction network to obtain the multi-scale features of the image to be detected; calculating multi-scale fusion scores of the multi-scale features of the image to be detected and a multi-scale feature library, and determining that defects exist on the surface of the metal to be detected when the multi-scale fusion scores are larger than or equal to a preset threshold value. In one embodiment, inputting the data set into a feature extraction network to obtain a multi-scale feature library of normal samples, comprising: Inputting the images in the data set into a plurality of depth residual modules of a feature extraction network to obtain extracted feature layers with a plurality of scales; performing multi-scale feature cyclic fusion on the feature layers with multiple scales to obtain fusion features and full-scale fusion features; And carrying out feature enhancement on the feature layers with multiple scales based on the fusion features and the full-scale fusion features to obtain the multi-scale features of the image, and obtaining a multi-scale feature library based on the multi-scale features of the images. In one embodiment, inputting an image in a dataset into a plurality of depth residual modules of a feature extraction network, resulting in an extracted feature layer of a plurality of scales, comprising: inputting the image in the data set into a first depth residual error module of a feature extraction network to obtain a first feature layer, wherein the first feature layer is used for representing the edge and texture information of the image; Inputting the first feature layer into a second depth residual error module of a feature extraction network to obtain a second feature layer, wherein the second feature layer is used for representing structural information of an image; And inputting the second feature layer into a third depth residual error module of the feature extraction network to obtain a third feature layer, wherein the third feature layer is used for representing semantic information of the image. In one embodiment, performing multi-scale feature cyclic fusion on a plurality of scale feature layers to obtain fusion features and full-scale fusion features, including: Upsampling the second feature layer and the third feature layer; Carrying out weighted fusion on the first feature layer and the up-sampled second feature layer to obtain a first fusion feature; carrying out weighted fusion on the first fusion feature and the up-sampled thi