A method for constructing a surface defect detection model and its application

By constructing a neural network model including coding, defect location and shape detection modules, combined with bar and pyramid pooling, the problems of defect detection accuracy and information loss in the existing technology are solved, and accurate segmentation and detection of workpiece surface defects are achieved. Shape adaptability.

CN114332047BActive Publication Date: 2024-09-06HUAZHONG UNIV OF SCI & TECH
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202111666451.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-31
Publication Date
2024-09-06
Estimated Expiration
2041-12-31

AI Technical Summary

Technical Problem

When existing defect detection methods deal with workpiece surfaces with irregular textures, it is difficult to accurately detect defect areas of different shapes, and there are problems such as information loss and reduced detection accuracy.

Method used

A surface defect detection model is constructed, including a coding module, a defect positioning module, a defect shape detection module and a decoding module. Features are extracted through cascaded coding blocks, and the defect location and shape features are obtained by combining bar pooling and pyramid pooling. And the neural network parameters are updated through the loss function to achieve accurate segmentation of defects.

Benefits of technology

It effectively avoids background noise interference, adapts to defects of different shapes, and achieves accurate segmentation of defect areas. It combines the advantages of end-to-end detection and two-stage detection to improve detection accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114332047B
    Figure CN114332047B
Patent Text Reader

Abstract

The present invention belongs to the field of image processing, and specifically relates to a method for constructing a surface defect detection model and its application, including: extracting the features of the training image step by step by the first m layers of coding blocks cascaded in the coding module to obtain shallow features; fusing all shallow features and inputting them into the defect positioning module, using strip pooling to obtain position features, adding the position features to the shallow features of the last level, and then extracting the features step by step by using the last n layers of coding blocks cascaded in the coding module to obtain deep features, fusing all deep features and inputting them into the defect shape detection module, using pyramid pooling and local strip pooling to obtain shape features, controlling the decoding module to upsample, fuse and reduce the dimensions of the shape features and some or all of the hierarchical features layer by layer to obtain the defect area; updating the neural network parameters under the constraints of the defect position label, shape label and area label, and iterative training. The present invention not only pays attention to the defect position but also strengthens the defect shape adaptation to achieve accurate segmentation of the defect.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of image processing, and more specifically, relates to a method for constructing a surface defect detection model and an application thereof. Background Art

[0002] Due to different processing methods, the workpiece surface leaves regular or irregular processing textures, which increases the difficulty of defect detection. At the same time, due to the influence of various random factors in the processing process, the shapes of defects on the workpiece surface vary greatly, which also brings great interference to defect detection. Therefore, how to accurately detect defect areas of different shapes on the surface of workpieces with irregular textures has become an urgent problem to be solved in industrial production lines.

[0003] Among the defect detection methods based on machine vision, they can be divided into traditional defect detection methods and neural network-based defect detection methods according to different feature extraction methods.

[0004] In traditional defect detection methods, different defect detection methods are designed according to different defect characteristics, such as the more classic threshold method and the coefficient reconstruction method. These methods have poor adaptability and require different defect detection models for different types of defects. For defects with large differences, the detection method may even need to be redesigned.

[0005] Among the defect detection methods based on neural networks, the enhanced availability of large-scale data and the emergence of high-performance computing hardware have made it feasible to use defect detection methods based on neural networks. Representative methods include PGANet using a single model for detection or HDCB-Net using a multi-model cascade.

[0006] The multi-model cascade method uses multiple models in cascade to detect defect areas, and is mostly used for detecting local target areas in large images. This method is relatively complex to deploy. At the same time, the multi-model cascade method is usually accompanied by cropping operations during the detection process, which can easily cause information loss and reduce detection accuracy.

[0007] The single model detection method uses a set of multiple sub-models to enhance the network's feature extraction capabilities, thereby enhancing defect detection accuracy. This method avoids the potential risk of information loss in the multi-model cascade method, but none of the existing methods focus on the network structure of the defect location and shape. Summary of the invention

[0008] In view of the defects and improvement needs of the prior art, the present invention provides a method for constructing a surface defect detection model and its application, the purpose of which is to focus on the defect position and enhance the defect shape adaptation during the defect detection process, thereby achieving accurate segmentation of the defects.

[0009] To achieve the above object, according to one aspect of the present invention, a method for constructing a surface defect detection model is provided, comprising:

[0010] S1. Obtaining a neural network framework of a surface defect detection model, which includes: an encoding module, a defect location module, a defect shape detection module, and a decoding module;

[0011] S2, input the image in the training set into the encoding module, and extract features of the first m layers of cascaded encoding blocks in the encoding module step by step to obtain shallow features of different levels;

[0012] S3, downsampling all the shallow features to the same scale and connecting them as a whole to input into the defect location module, the defect location module extracts the relevant information of the defect location in the features by strip pooling to obtain the position feature representing the defect location;

[0013] S4, after adding the position feature to the shallow feature of the last level, the feature extraction is performed level by level using the cascaded n-layer coding blocks in the coding module to obtain deep features of different levels, and all deep features are downsampled to the same scale and input into the defect shape detection module after fusion;

[0014] S5, controlling the defect shape detection module to extract relevant information of the defect shape in the features by using simplified pyramid pooling and local strip pooling, obtaining shape features characterizing the defect shape and outputting them to the decoding module;

[0015] S6, controlling the decoding module to upsample, fuse and reduce the dimension layer by layer the features received by the decoding module and part or all of the hierarchical features obtained by the encoding module, and finally obtaining the defect area;

[0016] S7. Based on the position features and defect position labels, the shape features and defect shape labels, and the defect areas and defect area labels, calculate the loss function to update the neural network parameters, and repeat S2 until the termination condition is reached, thereby completing the training and construction of the surface defect detection model.

[0017] Furthermore, the S2 further includes:

[0018] Another encoding block in the encoding module is controlled to re-extract features of the first-level features obtained through encoding, update the first-level features, and use them as shallow features.

[0019] Further, in S3, the defect location module is specifically used for:

[0020] The received features are fused with features of each layer using a coding block, and then different convolutional units are used to reduce the dimension and group the fused features. The number of groups is given according to the number of defects in a single image. Then, row strip pooling and column strip pooling are used to pool the grouped features respectively, and the pooled features are upsampled and fused to obtain features reflecting the defect location.

[0021] Further, in S4, the position features are extracted step by step using the cascaded n-layer coding blocks in the coding module to obtain deep features at different levels, specifically:

[0022] After adding the position feature to the shallow feature of the last level, feature extraction is performed level by level using the cascaded last n-layer coding blocks in the coding module to obtain deep features of different levels.

[0023] Further, the defect shape detection module includes a simplified pyramid pooling submodule and a local strip pooling submodule; in S5, the defect shape detection module is specifically used for:

[0024] The simplified pyramid pooling submodule uses square pooling kernels of different sizes to perform a pooling operation on the feature V obtained by S4, upsamples the pooled feature to the same size as the feature V, and then uses the first convolution unit to fuse and reduce the dimension of the upsampled pooled feature to obtain the feature V1. This process is constrained by the defect shape label, wherein the feature used in calculating the constraint is: the one-dimensional feature V11 obtained by reducing the dimension of the feature V1 using the second convolution unit;

[0025] The local strip pooling submodule uses local row pooling kernels and local column pooling kernels of different shapes to perform pooling operations on the feature V obtained by S4, respectively, and upsamples the two pooled features to the same size as the feature V, and then adds the two upsampled pooled features and fuses the features using the third convolution unit to obtain the feature V2. This process is constrained by the defect shape label, wherein the feature used in calculating the constraint is: the one-dimensional feature V21 obtained by reducing the dimension of the feature V2 using the fourth convolution unit;

[0026] The fusion feature obtained in S4, the feature V1 and the feature V2 are connected as a whole and fused by the fifth convolution unit and feature dimension reduction is performed to obtain feature V';

[0027] The feature V' is used as the defect shape feature W and output to the decoding module, or the feature V11 and the feature V21 are added and softmax is taken and then multiplied with the feature V'. The multiplication result is connected with the feature V' as a whole and sent to the sixth convolution unit for dimensionality reduction fusion to obtain the defect shape feature W and output to the decoding module.

[0028] Furthermore, the neural network framework also includes a fine extraction module;

[0029] The shape feature obtained in S5 is first input into the fine extraction module; the fine extraction module performs dilated convolution on the shape feature, connects the output result with the shape feature, and uses the seventh convolution unit to reduce the dimension and fuse to obtain feature Z and input it into the decoding module.

[0030] Furthermore, the loss function loss in S7 is:

[0031] loss = λloss loc +μ1loss shp +μ2loss shp +νloss seg ;

[0032] Among them, loss loc 、loss shp and loss seg They represent position loss, shape loss and segmentation loss respectively, and λ, μ1, μ2 and ν represent the weights of the three losses respectively.

[0033] Furthermore, the weights μ1 and μ2 corresponding to the two processes of pyramid pooling and local strip pooling in the shape loss may be set to be the same.

[0034] The present invention also provides a surface defect detection method, which uses the surface defect detection model constructed by the surface defect detection model construction method as described above to perform surface defect detection.

[0035] The present invention also provides a computer-readable storage medium, which includes a stored computer program, wherein when the computer program is executed by a processor, the device where the storage medium is located is controlled to execute a surface defect detection model construction method as described above and / or a surface defect detection method as described above.

[0036] In general, the above technical solutions conceived by the present invention can achieve the following beneficial effects:

[0037] (1) The present invention provides a convolutional neural network model composed of a defect location module, a defect shape detection module, and a fine extraction module, so as to achieve both focusing on the defect location and strengthening the defect shape adaptation during the defect detection process, thereby achieving the demand for accurate segmentation of defects.

[0038] (2) According to the neural network constructed by the present invention, since the defect localization module locates the defect area, it can effectively avoid the interference of background noise in the image. The combination of square pooling and local strip pooling effectively adapts to the detection of defects of different shapes, thereby accurately segmenting the defect area.

[0039] (3) Existing image detection schemes only use end-to-end detection or a two-stage detection method of first positioning and then segmenting. The present invention combines the advantages of end-to-end detection and two-stage detection. The key technology is to use strip pooling to determine the location of the defect, and local strip pooling and simplified pyramid pooling to determine the defect shape. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] Figure 1 A schematic diagram of a neural network framework focusing on defect location and shape features provided by an embodiment of the present invention;

[0041] Figure 2 A schematic diagram of a neural network focusing on defect location and shape features provided by an embodiment of the present invention;

[0042] Figure 3 A schematic diagram of a defect location module provided by an embodiment of the present invention;

[0043] Figure 4 A schematic diagram of a defect location module provided in an embodiment of the present invention;

[0044] Figure 5 Partial schematic diagram of a defect shape module provided in an embodiment of the present invention; wherein (a) is a simplified schematic diagram of a pyramid pooling module structure; (b) is a schematic diagram of a local strip pooling module structure;

[0045] Figure 6 A working principle diagram of a defect shape detection module provided in an embodiment of the present invention;

[0046] Figure 7 A schematic diagram of a defect shape detection module provided by an embodiment of the present invention;

[0047] Figure 8 A schematic diagram of a fine extraction module provided by an embodiment of the present invention;

[0048] Fig. 9 Some defect detection effects provided by the embodiments of the present invention; wherein, (a) is the original image; (b) is the DANet detection effect image; (c) is the SPNet detection effect image; (d) is the U-Net detection effect image; (e) is the RefineNet detection effect image; (f) is the detection effect image of the method of the present invention; (g) is the label image;

[0049] Fig.10Detection effect diagram of each sub-module provided in an embodiment of the present invention, wherein (a) is the original image, (b) is the shape label image, (c) is the position label image, (d) is the feature image after detection and processing by the position detection module, (e) is the feature image after processing by the shape detection module, and (f) is the final detection result. DETAILED DESCRIPTION

[0050] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention. In addition, the technical features involved in the various embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.

[0051] Embodiment 1

[0052] A method for constructing a surface defect detection model, such as Figure 1 As shown, including:

[0053] S1. Obtaining a neural network framework of a surface defect detection model, which includes: an encoding module, a defect location module, a defect shape detection module, and a decoding module;

[0054] S2, input the images in the training set into the encoding module, and the first m layers of cascaded encoding blocks in the encoding module perform feature extraction level by level to obtain shallow features at different levels;

[0055] S3, downsample all shallow features to the same scale and connect them as a whole to input into the defect location module, which uses strip pooling to extract relevant information about the defect location in the features to obtain position features that characterize the defect location;

[0056] S4, after adding the position features to the shallow features of the last level, the feature extraction is performed level by level using the cascaded n-layer coding blocks in the coding module to obtain deep features of different levels, and all deep features are downsampled to the same scale and input into the defect shape detection module after fusion;

[0057] S5, controlling the defect shape detection module to extract relevant information of the defect shape in the feature by using simplified pyramid pooling and local strip pooling, obtaining shape features characterizing the defect shape and outputting them to the decoding module;

[0058] S6, controlling the decoding module to upsample, fuse and reduce the dimension layer by layer the features received by it and part or all of the hierarchical features obtained by the encoding module, and finally obtaining the defect area;

[0059] S7. Based on the position features and defect position labels, shape features and defect shape labels, and defect areas and defect area labels, calculate the loss function to update the neural network parameters, repeat S2 until the termination condition is reached, and complete the construction of the surface defect detection model.

[0060] This embodiment is mainly divided into two stages: encoding and decoding. In the encoding stage, the defect location module is used in combination with the defect location label constraint for shallow features, so that the shallow features of the model pay more attention to the location of the defect; for the high-level features in the encoding stage, the shape perception module is used in combination with the defect shape label constraint, so that the model can obtain different receptive field features in the high-level features while paying attention to the defect detail information; at the same time, in the encoding stage, the dilated convolution is used to further extract features to enhance the generalization of the model. In the decoding stage, the outputs of each layer are fused using jump connections, and the final defect area is obtained by decoding.

[0061] It should be noted that Figure 1 The dashed boxes and dashed arrows in the figure are optional.

[0062] In one implementation mode, the method steps are as follows:

[0063] [S1] The collected qualified industrial images and unqualified industrial images are processed to generate an image data set, and the qualified industrial images are defined as OK samples and the unqualified industrial images are defined as NG samples. The OK samples and NG samples are mixed in a certain ratio, and the value range of the ratio is OK / NG = 2 / 3 to 4 / 5.

[0064] [S2] The mixed data is used as a data set for network training and testing, where the training set accounts for 0.7-0.8 and the test set accounts for 0.2-0.3. The NG samples in the training set and the test set are required to be marked with defect shape labels, and the minimum parallel axis circumscribed rectangle corresponding to the defect area is generated as the position label based on the marked defect shape labels.

[0065] [S2] Design the network structure, which mainly includes three modules: defect location module, defect shape detection module, fine extraction module and encoding and decoding structure.

[0066] [S3] Input the training set images in S1 into the encoder for encoding, obtain encoding features at different levels, and divide them into shallow features and high-level features.

[0067] [S4] Input the shallow features in S3 into the defect location module to extract the defect location and obtain features that reflect the defect location.

[0068] [S5] Input the high-level features in S3 into the defect shape detection module to extract the defect shape information and obtain the corresponding output features.

[0069] [S6] Input the features output in S5 into the fine extraction module to further obtain more accurate feature information and obtain corresponding output features.

[0070] [S7] The features output in S6 are fused and decoded with the shallow features and high-level features in S3 to obtain the final defect area.

[0071] [S8] The above process is realized in continuous training. The training process is constrained by the loss function, which includes position loss, shape loss and segmentation loss. The three losses together constitute the training loss, and the proportion of the three losses is adjusted according to different focuses.

[0072] Combination Figure 2 ,Detailedly, a method for constructing a surface defect online ,detection model includes the following steps:

[0073] Step 1: Input the images in the training set into the neural network for encoding to obtain features at different levels. Figure 1 The features output by each encoding block (such as VGG block) are all layer features, which are divided into shallow features and deep features.

[0074] Step 2: Use the defect location module to obtain the defect location information. In order to better integrate features at different levels, another VGG block is used to extract features again for the first layer features, and the shallow features of different scales are downsampled to the same scale, and then fused and input into the defect location module to extract the relevant information of the defect location.

[0075] Among them, the defect location module is implemented by strip pooling. One feasible implementation method is as follows: Figure 3 As shown in the figure, the first three layers of features are fused using a coding block, such as VGG, and then different convolution units (such as 1×1, the input and output sizes are the same) are used to reduce the dimension and group the features. The number of groups can be given according to the number of defects in a single image. Then, the features are pooled using row strip pooling and column strip pooling respectively, and the pooled features are upsampled and fused to obtain features that reflect the defect location. This process is constrained by the defect location loss function.

[0076] Step 3: For the features processed in step 2, add them to the third layer features and continue to use the encoding block to extract high-level features. Downsample the high-level features of different scales to the same scale and then fuse them into the defect shape detection module to extract the relevant information of the defect shape in the features.

[0077] Step 4: Use a simplified pyramid pooling submodule and a local strip pooling submodule to construct the shape features of the defect based on the features input into the defect shape detection module in step 3.

[0078] Specifically, for the feature V input to the pyramid pooling submodule, square pooling kernels of different sizes are used to perform pooling operations on the feature, and the pooled feature is upsampled to the same size as the feature V. Then, the upsampled feature is fused and reduced in dimension using the convolution unit to obtain the feature V1. This process is constrained by the shape label, where the feature used to calculate the constraint is: the one-dimensional feature V11 obtained by reducing the dimension of V1 using the convolution unit.

[0079] The feature V input to the local strip pooling submodule is pooled using local row pooling kernels and local column pooling kernels of different shapes, and the pooled features are upsampled to the same size as the feature V. Then, the two upsampled pooled features are added together and the features are fused using the convolution unit to obtain the feature V2. This process is constrained by the shape label, where the features used to calculate the constraint are: the one-dimensional feature V obtained by reducing the dimension of V2 using the convolution unit 21 .

[0080] The high-order fused features in step 3, the features V1 after simplified pyramid pooling, and the features V2 after local strip pooling are fused together using a certain convolution unit and feature dimension reduction is performed to obtain the feature V' (which can be directly output as the shape feature W).

[0081] Preferably, feature V11 and feature V21 are added and softmaxed before being multiplied with feature V'. The multiplication result and feature V' are sent to a certain convolution unit for dimensionality reduction and fusion to obtain feature W.

[0082] Step 5: The feature W processed in step 4 is sent to the fine extraction module for further extraction. The fine extraction module contains two 3×3 dilated convolutions with dilation rates of 2 and 4. The outputs of the two dilated convolutions and the feature W processed in step 4 are combined again using a convolution unit to reduce the dimension and obtain the feature Z.

[0083] Step 6: Upsample, fuse and reduce the dimension of the feature Z processed in step 5 and the optional layer features layer by layer, and finally obtain the defect area. This process is constrained by the defect label, and the optional layer is selected according to actual needs.

[0084] Furthermore, the loss function for label constraints in step 2, step 4, and step 6 is:

[0085] loss = λloss loc +μ1loss shp +μ2loss shp +νloss seg

[0086] Among them, loss loc ,loss shp , and lossseg They represent position loss, shape loss and segmentation loss respectively, and λ, μ1, μ2, ν represent the weights of the three losses. The weights μ1 and μ2 in the two submodules of the shape loss can be set to the same.

[0087] The present invention is further described in detail below with reference to examples.

[0088] The present invention is described in detail by taking the commutator cylindrical defect detection as an example, but the application object of the present invention is not limited to this. The commutator is an important part in the motor. During the production process, its outer surface leaves periodic and non-periodic texture features due to external cylindrical turning and grinding. At the same time, the surface defect features leave different defect features due to changes in processing tools and molds, showing different contrast characteristics. The present invention can effectively detect cylindrical defects in the commutator under the above conditions.

[0089] Step 1: Divide the acquired commutator images into training sets and test sets and label them to outline the defect areas. The training set accounts for 80% of the total data volume, and the test set accounts for 20% of the total data volume. Input the images in the training set into the neural network for encoding to obtain features at different levels. Figure 2 For example, the VGG block is used to encode the image. The features output by each VGG block in the figure are all hierarchical features, with a total of 5 layers, represented by serial numbers ①②③④⑤.

[0090] Step 2: Use the defect location module to fuse the first three layers of features to obtain the defect location information. In order to better integrate features at different levels, the first layer features need to be re-extracted using the VGG block, and the first three layers of features at different scales are downsampled to the same scale, and then connected together and input into the defect location module to extract the relevant information of the defect location in the features.

[0091] The defect location module is implemented using strip pooling, such as Figure 3 shown. Figure 3 In the above method, the first three layers of features are connected together and a VGG encoding block is used to fuse the features of each layer. Then, multiple 1×1 convolutions are used to reduce the dimension and group the features. The number of groups can be given according to the number of defects in a single image. Then, the features are pooled using row strip pooling and column strip pooling respectively. The pooled features are upsampled and fused to obtain the features reflecting the defect location, which are recorded as Y. This process is constrained by the defect location loss function.

[0092] It should be noted that the defect location module is specifically used to extract features reflecting the defect location using row strip pooling and column strip pooling for the received features. The specific principle is as follows: Figure 4 As shown:

[0093] assumed Figure 4The gray area in (a) is a defect area. After row and column strip pooling, two vectors are obtained. Figure 4 As shown in (b), we multiply them by matrices to get the result Figure 4 (c) in the comparison Figure 4 (a) and (c) in Figure 4 The defect area shown in gray in (c) is Figure 4 The minimum outer parallel axis rectangle of the original defect area in (a) is basically the same (as shown in the rectangular box). This shows that after being processed by the defect location module, the defect location feature is obtained instead of the defect shape feature. This is simpler than the conventional method using FasterRCNN or YOLO.

[0094] Step 3, for the features processed in step 2, add them to the third layer features and continue to use the VGG block to extract high-level features. For the high-level features (fourth and fifth layer features), they are also connected as one and input into the defect shape detection module to extract the relevant information of the defect shape in the features.

[0095] Step 4: A simplified pyramid pooling submodule ( Figure 5 (a)) and the local strip pooling submodule ( Figure 5 (b) in the figure constructs the shape features of the defect.

[0096] Specifically, for the feature V input to the pyramid pooling submodule, the pooling operation is performed using pooling kernels of size 2×2 and 4×4, and the pooled features are upsampled to the same size as the input feature V. Then, the upsampled features are reduced in dimension using 1×1 convolution and a VGG block and fused to obtain feature V1. This process is constrained by the shape label, where the feature used to calculate the constraint is: the one-dimensional feature V11 obtained by reducing the dimension of V1 using the convolution unit.

[0097] For the feature V input to the local strip pooling submodule, the local row pooling kernel (1×4) and local column pooling kernel (4×1) of different shapes are used to perform pooling operations on the features, and the pooled features are upsampled to the same size as the input feature V. Then, the two upsampled pooled features are added and fused using the VGG block to obtain the feature V2. This process is constrained by the shape label, where the features used to calculate the constraint are: the one-dimensional feature V obtained by reducing the dimension of V2 using a 1×1 convolution 21 .

[0098] The high-order fused features in step 3, the features processed by simplified pyramid pooling in step 5, and the features processed by local strip pooling in step 6 are fused together using VGG blocks and feature dimension reduction is performed.

[0099] The high-order fused features in step 3, the features V1 after simplified pyramid pooling, and the features V2 after local strip pooling are fused together using VGG blocks and feature dimension reduction is performed to obtain the feature V′.

[0100] It should be noted that the present invention proposes to use a pyramid pooling submodule to simplify the calculation. Compared with the original pyramid pooling model, the model modifies the original pyramid pooling model by performing a separate convolution after each pooling, then upsampling and connecting them together, and then convolution. This change effectively reduces the amount of calculation of the algorithm and simplifies the model complexity.

[0101] The local strip pooling proposed in the present invention has the following advantages: compared with strip pooling, the local strip pooling not only retains the advantage of detecting strip defects, but also reduces the influence of background noise when detecting defects. Figure 6 The first and second columns in show the differences between the three pooling kernels (light grey areas are defective areas in the pooling process, and dark grey areas are disturbed areas in the pooling kernel). Figure 6 The characteristics of strip pooling, local strip pooling, and square pooling are demonstrated. Strip pooling has advantages for long strip defects, while local strip pooling reduces the interference of small areas while maintaining the advantages of strip pooling, and square pooling works better for dense shapes. Taken together, it can adapt to the detection of defects of different shapes.

[0102] The defect detection shape of the present invention combines the square pooling core and the strip pooling core, giving full play to the advantages of the two pooling cores. Figure 6 This feature is demonstrated in detail: combining the strip pooling kernel and the square pooling kernel, combining the advantages of the two pooling kernels, making the network more adaptable to complex shapes and defects. Figure 6 As shown in Figure 2, local strip pooling can adapt to strip defects, while square pooling has some advantages for complex defects. Therefore, two pooling kernels can be used at the same time to adapt to defects of different shapes as much as possible.

[0103] Preferably, feature V11 and feature V21 are added and softmaxed, and then multiplied with feature V′. The multiplication result and feature V′ are sent to 1×1 convolution for dimensionality reduction fusion to obtain feature W. Figure 7 shown.

[0104] Step 5: Send the feature W processed in step 4 to the fine extraction module ( Figure 8 ) is further extracted, and the fine extraction module contains two 3×3 dilated convolutions with dilation rates of 2 and 4 respectively. The output results of the two dilated convolutions and the feature W processed in step 4 are combined again with 1×1 convolution to reduce the dimension and fuse the features to obtain feature Z.

[0105] Step 6: The features processed in step 5 are fused and upsampled layer by layer with the first 4 layers of features in step 1 to obtain the final defect area. Fig. 9 Shows some defect detection results. The process is constrained by defect labels.

[0106] Furthermore, the loss function for label constraints in step 2, step 4, and step 6 is:

[0107] loss = λloss loc +μ1loss shp +μ2loss shp +νloss seg

[0108] Among them, loss loc ,loss shp and loss seg They represent position loss, shape loss and segmentation loss respectively, and λ, μ1, μ2, ν represent the weights of the three losses. The weights μ1 and μ2 in the two submodules of the shape loss are usually set to the same. Fig.10 The effect diagram of each sub-module is displayed. It can be seen from the figure that the defect location module effectively extracts the location features of the defect, while the defect shape detection module accurately detects the defect shape features. These prove the effectiveness of the modules proposed in the present invention.

[0109] It will be easily understood by those skilled in the art that the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the present invention.

Claims

1. A method for constructing a surface defect detection model, It is characterized in that include: S1. Obtaining a neural network framework of a surface defect detection model, which includes: an encoding module, a defect location module, a defect shape detection module, and a decoding module; S2, input the image in the training set into the encoding module, and extract features of the first m layers of cascaded encoding blocks in the encoding module step by step to obtain shallow features of different levels; S3, downsampling all the shallow features to the same scale and connecting them as a whole to input into the defect location module, the defect location module extracts the relevant information of the defect location in the features by strip pooling to obtain the position feature representing the defect location; S4, after adding the position feature to the shallow feature of the last level, the feature extraction is performed level by level using the cascaded n-layer coding blocks in the coding module to obtain deep features of different levels, and all deep features are downsampled to the same scale and input into the defect shape detection module after fusion; S5, controlling the defect shape detection module to extract relevant information of the defect shape in the features by using simplified pyramid pooling and local strip pooling, obtaining shape features characterizing the defect shape and outputting them to the decoding module; S6, controlling the decoding module to upsample, fuse and reduce the dimension layer by layer the features received by the decoding module and part or all of the hierarchical features obtained by the encoding module, and finally obtaining the defect area; S7. Based on the position features and defect position labels, the shape features and defect shape labels, and the defect areas and defect area labels, calculate the loss function to update the neural network parameters, repeat S2 until the termination condition is reached, and complete the construction of the surface defect detection model.

2. A method for constructing a surface defect detection model according to claim 1, It is characterized in that The S2 further includes: Another encoding block in the encoding module is controlled to re-extract features of the first-level features obtained through encoding, update the first-level features, and use them as shallow features.

3. The method for constructing a surface defect detection model according to claim 1, It is characterized in that In S3, the defect location module is specifically used for: The received features are fused with features of each layer using a coding block, and then different convolutional units are used to reduce the dimension and group the fused features. The number of groups is given according to the number of defects in a single image. Then, row strip pooling and column strip pooling are used to pool the grouped features respectively, and the pooled features are upsampled and fused to obtain features reflecting the defect location.

4. The method for constructing a surface defect detection model according to claim 1, It is characterized in that In S4, the position features are extracted step by step using the cascaded n-layer coding blocks in the coding module to obtain deep features at different levels, specifically: After adding the position feature to the shallow feature of the last level, feature extraction is performed level by level using the cascaded last n-layer coding blocks in the coding module to obtain deep features of different levels.

5. The method for constructing a surface defect detection model according to claim 1, It is characterized in that The defect shape detection module includes a simplified pyramid pooling submodule and a local strip pooling submodule; in S5, the defect shape detection module is specifically used to: The simplified pyramid pooling submodule uses square pooling kernels of different sizes to perform a pooling operation on the feature V obtained by S4, upsamples the pooled feature to the same size as the feature V, and then uses the first convolution unit to fuse and reduce the dimension of the upsampled pooled feature to obtain the feature V1. This process is constrained by the defect shape label, wherein the feature used in calculating the constraint is: the one-dimensional feature V11 obtained by reducing the dimension of the feature V1 using the second convolution unit; The local strip pooling submodule uses local row pooling kernels and local column pooling kernels of different shapes to perform pooling operations on the feature V obtained by S4, upsamples the pooled features to the same size as the feature V, and then adds the two upsampled pooled features and fuses the features using the third convolution unit to obtain the feature V2. This process is constrained by the defect shape label, wherein the feature used in calculating the constraint is: the one-dimensional feature V21 obtained by reducing the dimension of the feature V2 using the fourth convolution unit; The fused feature V obtained in S4, the feature V1 and the feature V2 are connected as a whole and fused by the fifth convolution unit and feature dimension reduction is performed to obtain a feature V'; The feature V' is used as the defect shape feature W and output to the decoding module, or the feature V11 and the feature V21 are added and softmax is taken and then multiplied with the feature V'. The multiplication result is connected with the feature V' as a whole and sent to the sixth convolution unit for dimensionality reduction fusion to obtain the defect shape feature W and output to the decoding module.

6. A method for constructing a surface defect detection model according to claim 5, It is characterized in that The neural network framework also includes a fine extraction module; The shape feature obtained in S5 is first input into the fine extraction module; the fine extraction module performs dilated convolution on the shape feature, connects the output result with the shape feature, and uses the seventh convolution unit to reduce the dimension and fuse to obtain feature Z and input it into the decoding module.

7. The method for constructing a surface defect detection model according to claim 1, It is characterized in that The loss function loss in S7 is: loss=λloss loc +μ 1 loss shp +μ 2 loss shp +νloss seg ; Among them, loss loc 、loss shp and loss seg Represent position loss, shape loss and segmentation loss respectively, λ, μ 1 , μ 2 and ν represent the weights of the three losses respectively.

8. A method for constructing a surface defect detection model according to claim 7, It is characterized in that The weights μ corresponding to the two processes of pyramid pooling and local strip pooling in the shape loss 1 , μ 2 Can be set to the same.

9. A surface defect detection method, It is characterized in that Surface defect detection is performed using a surface defect detection model constructed using a surface defect detection model construction method as described in any one of claims 1 to 8.

10. A computer-readable storage medium, It is characterized in that The computer-readable storage medium includes a stored computer program, wherein, when the computer program is executed by a processor, the device where the storage medium is located is controlled to execute a method for constructing a surface defect detection model as described in any one of claims 1 to 8 and / or a surface defect detection method as described in claim 9.

Citation Information

Patent Citations

  • Deep neural network surface defect detection method based on feature fusion

    CN111627012A

  • Surface defect detection method based on multi-scale convolution and trilinear global attention

    CN112465790A

  • Casting surface defect identification method based on improved DeepLabv3 + network model

    CN112967271A

  • Computer vision based real-time pixel-level railroad track components detection system

    US20210370993A1