CN-122023803-A - Manual-labeling-free metal surface defect semantic segmentation method based on priori features
Abstract
The invention belongs to the technical field of computer vision and intelligent detection, and discloses a semantic segmentation method for metal surface defects without manual labeling based on prior features. The method comprises the steps of S1 collecting an original image of a metal surface, dividing local image blocks, S2 selecting a traditional image processing method based on defect pixel characteristics or defect boundary characteristics according to visual performance characteristics of target defects to generate candidate defect areas, S3 screening the candidate defect areas, training a lightweight semantic segmentation network, S4 model reasoning and correcting segmentation results by combining prior characteristic rule constraint. By the method, training and reasoning of the defect segmentation model are realized under the condition that manual pixel level mask labeling is not needed, the labor cost and the deployment period of model application are reduced, and the stability and the feasibility of a segmentation result in a complex industrial scene are improved.
Inventors
- ZHANG CHUNJIANG
- QUAN ZHENGYU
- GAO YIPING
- LI XINYU
- GAO LIANG
Assignees
- 华中科技大学
Dates
- Publication Date
- 20260512
- Application Date
- 20260130
Claims (10)
- 1. A semantic segmentation method for manually labeling-free metal surface defects based on prior features is characterized by comprising the following steps: s1, acquiring an original image of a metal surface through an image acquisition device, preprocessing the original image, dividing the processed image into a plurality of local image blocks, wherein the local image blocks are used as basic processing units for subsequent defect detection and marking; S2, aiming at each local image block in the S1, selecting a traditional image processing method based on defect pixel characteristics or defect boundary characteristics according to visual performance characteristics of target defects, and performing image processing on the local image blocks to generate candidate defect areas; s3, screening the candidate defect areas in the S2, reserving the areas with high credibility as coarse labeling samples, and training a lightweight semantic segmentation network after data enhancement of the coarse labeling samples; s4, model reasoning, based on the trained lightweight semantic segmentation network of S3, predicting the metal surface image to be detected by adopting a sliding window matched with the size of the local image block, and carrying out constraint correction on the preliminary segmentation result output by the lightweight semantic segmentation network based on the prior feature of the defect, and outputting the final semantic segmentation result of the metal surface defect.
- 2. The method for segmenting the metal surface defects based on the prior characteristics and without manual labeling is characterized in that in the step S1, the preprocessing method of the original image comprises the steps of uniformly cutting a shot image, extracting a region where defects possibly occur as a region of interest, carrying out different graying and contrast change processing according to the types of the defects, dividing a local image block, adopting a mode of equally dividing the width and the height, and arranging a certain overlapping region between adjacent image blocks to avoid information loss of the defects at the edges of the image blocks, wherein the overlapping region is used for preserving the context information of the defects.
- 3. The method for semantic segmentation of a metal surface defect based on a priori features without artificial labeling of claim 1, wherein in step S2, the conventional image processing method based on the defective pixel features comprises the following steps: determining a candidate pixel set by utilizing the difference between the defects and the background on the color or brightness characteristics; performing region growth by taking the candidate pixel set as a seed to generate a continuous candidate region; And carrying out constraint and screening on the generated region based on the geometric feature of the candidate region to obtain the candidate defect region.
- 4. The method for semantic segmentation of a metal surface defect based on a priori features without artificial labeling of claim 1, wherein in step S2, the conventional image processing method based on the boundary features of the defect comprises the following steps: performing edge detection or gradient feature extraction on the local image blocks to obtain a boundary response diagram; thresholding and morphological processing are carried out on the boundary response graph, and continuous candidate boundary structures are generated; candidate defect regions are generated and screened based on the spatial distribution and geometric features of the candidate boundary structures.
- 5. The method for semantic segmentation of defects on a metal surface based on prior features without artificial labeling of claim 1, wherein in step S3, the method for enhancing data comprises one or more of copying and pasting defects to different backgrounds, random background filling of defect areas, random inversion of training images and contrast enhancement.
- 6. The method for segmenting the metal surface defects based on the prior features without manual labeling is characterized in that in the step S3, the lightweight semantic segmentation network adopts an encoder-decoder structure, wherein the encoder comprises a feature extraction module for extracting semantic features step by step and a multi-scale semantic representation module for carrying out multi-scale modeling on the semantic features, and the decoder is used for carrying out up-sampling and feature fusion on the multi-scale semantic features output by the encoder, recovering the spatial resolution and outputting a pixel level segmentation map; The multi-scale semantic representation module is arranged at the output end of the feature extraction module and is used for carrying out multi-scale modeling on the semantic features to form semantic representations with different space receptive fields so as to enhance the representation capability of defects with different sizes.
- 7. The method for segmenting metal surface defects based on priori features and free of manual labeling is characterized in that the feature extraction module is composed of a plurality of cascaded light convolution units, each light convolution unit comprises parallel partial convolution branches and depth separable convolution branches and is fused with input features through residual connection, the multi-scale semantic representation module comprises a plurality of parallel feature processing branches, each branch adopts convolution or pooling operation of different receptive fields, an attention mechanism is introduced at the output end of each branch and used for self-adaptive weighting to strengthen defect related features, and finally the weighted features of each branch are fused in channel dimensions.
- 8. The method for segmenting the metal surface defects based on the prior features without manual labeling is characterized in that the feature processing branches at least comprise feature extraction branches based on expansion convolution and parallel pooling feature extraction branches, the feature processing branches process features by adopting a depth separable convolution structure so as to reduce computational complexity while guaranteeing multi-scale semantic modeling capability, and the multi-scale semantic representation module fuses output results of the feature processing branches to generate semantic representations containing multi-scale context information and outputs the semantic representations to a subsequent decoder for defect segmentation.
- 9. The method for semantic segmentation of metal surface defects based on prior features without manual labeling of claim 1, wherein in step S4, a judgment rule is set according to the known area, thickness, length-width ratio or morphological continuity features of the target defects, and the regions which do not accord with the rule in the preliminary segmentation result output by the semantic segmentation network are suppressed or eliminated.
- 10. A computer readable storage medium, storing a program which when loaded by a processor implements the a priori feature based artificial annotation free metal surface defect semantic segmentation method according to any of claims 1 to 9.
Description
Manual-labeling-free metal surface defect semantic segmentation method based on priori features Technical Field The invention belongs to the technical field of computer vision and intelligent detection, and particularly relates to a priori feature-based semantic segmentation method for metal surface defects without artificial labeling. Background The scale characteristics of the metal surface defects are the core basis for product qualification determination. The traditional detection method mainly depends on manual visual inspection and test equipment, and the method has the problems of low efficiency, strong subjectivity and the like, and is difficult to meet the detection requirements of high quality and high efficiency. With the development of an automation technology, the detection method based on image processing and the detection method based on semantic segmentation are gradually applied to a metal surface defect detection task, and the automatic detection of target defects can be realized through the identification of defect characteristics by a computer. In industrial production, the surface of a metal workpiece has true defects such as oxidation corrosion, surface scratch, local pits and the like which affect the performance of the product, and also has false defects caused by factors such as dirt, processing trace, workpiece carrying and the like. The pseudo defects are highly similar to real defects in appearance form, color distribution and edge characteristics, and the subsequent processes can eliminate or not influence the performance of the workpiece, but can form serious interference on the accuracy of defect detection. Aiming at the problems, the existing detection technology has obvious limitations that firstly, the detection method based on image processing relies on a fixed threshold value, an edge detection operator and a manual setting rule to complete defect identification, and has poor parameter adaptability in a complex scene with mixed real defects and pseudo defects, so that a large number of false detection and omission problems are easily caused, and secondly, the detection method based on semantic segmentation has stronger feature expression capability, but the performance of the detection method based on semantic segmentation highly depends on accurate pixel-level mask labeling data, so that the manual labeling cost is high, the period is long, and the time and the labor cost for model landing application are greatly increased. Meanwhile, the real defects of the metal surface generally have the characteristics of small scale, blurred edges and low contrast with the background, the real-time performance and stability of the detection system of the industrial production line are severely required, the existing general semantic segmentation network is difficult to consider the requirements of segmentation precision and production beats, and the existing general semantic segmentation network cannot adapt to the actual industrial detection scene. In summary, it is highly desirable to propose a semantic segmentation method for metal surface defects based on prior features without manual labeling, which does not need manual pixel level mask labeling, can effectively resist pseudo defect interference, and combines defect segmentation accuracy and reasoning efficiency to meet the application requirements of complex industrial scenes. Disclosure of Invention Aiming at the above defects or improvement demands of the prior art, the invention provides a prior feature-based semantic segmentation method for manually marking metal surface defects, which aims to train a semantic segmentation model capable of effectively detecting the metal surface defects under the condition that the defects do not need to be manually marked, so as to realize high-precision and high-efficiency detection of the metal surface defects. In order to achieve the above object, according to one aspect of the present invention, there is provided a method for semantic segmentation of defects on a metal surface based on a priori features without manual labeling, comprising the steps of: s1, acquiring an original image of a metal surface through an image acquisition device, preprocessing the original image, dividing the processed image into a plurality of local image blocks, wherein the local image blocks are used as basic processing units for subsequent defect detection and marking; S2, aiming at each local image block in the S1, selecting a traditional image processing method based on defect pixel characteristics or defect boundary characteristics according to visual performance characteristics of target defects, and performing image processing on the local image blocks to generate candidate defect areas; s3, screening the candidate defect areas in the S2, reserving the areas with high credibility as coarse labeling samples, and training a lightweight semantic segmentation network after data enhancement of the coarse