A defect detection method and system for enhancing neural network feature diversity
By using feature extraction modules and feature difference loss functions of different dimensions in the neural network, the problem of feature difference measurement is solved, the accuracy and feature diversity of defect detection are improved, and a more accurate reflection of defect morphology is achieved.
Patent Information
- Application Number
- CN202210624077.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-02
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2042-06-02
AI Technical Summary
The existing technology cannot effectively measure the differences between different neural network feature extraction modules, resulting in feature redundancy and low detection accuracy, and cannot accurately reflect the original shape of the defect.
Design a method to enhance the diversity of neural network features by inputting the image to be detected into the neural network feature extraction module of different dimensions, and using the feature difference loss function to calculate the difference in feature extraction between the two modules, based on segmentation loss and difference The training function is constructed by weighting the loss, and the Adam optimization algorithm is used for model training to ensure feature differentiation and detection accuracy.
It achieves more diverse image feature extraction, reduces feature redundancy, improves defect detection accuracy, can more realistically reflect the original shape of defects, and improves the detection performance of the model.
Smart Images

Figure CN115100120B
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field related to defect detection, and more specifically, relates to a defect detection method and system for enhancing the diversity of neural network features. Background Art
[0002] In the feature processing methods based on neural networks, in order to ensure the diversity of features, a variety of feature processing schemes have been proposed, such as the pyramid pooling model in PSPNet, the strip pooling model in SPNet, the hole convolution in DeepLab, and the skip connection in FCN.
[0003] The above methods design feature extraction modules from different angles to obtain diversified features, thereby enhancing the model's ability to detect defects of different scales and shapes. However, none of the above methods provide how to ensure the differences between features obtained by different feature processing methods during the training process of the model. Chinese patent CN111932541A discloses a method to ensure feature diversity, which measures the difference between imaging genomics features and deep learning features by constructing a feature difference loss function, but this method measures the difference between neural network extracted features and manually designed features, so it cannot be used to measure the difference between features extracted by different methods in the neural network, and cannot measure the similarity between features, thereby causing some features to be filtered, subtle feature differences to be erased, and the original morphology of the features cannot be accurately reflected. Based on this, it is urgent to design a neural network module that can extract different features, and a loss function that measures the differences between features extracted by different modules, so as to obtain more diverse features. Summary of the invention
[0004] In response to the above defects or improvement needs of the prior art, the present invention provides a defect detection method and system for enhancing the diversity of neural network features. The present application designs a neural network module that can extract different features, and a loss function that measures the differences between features extracted by different modules, so as to obtain more diverse image features, reduce feature redundancy, and improve the detection accuracy of the model for defective images.
[0005] To achieve the above-mentioned purpose, according to one aspect of the present invention, a defect detection method for enhancing the diversity of neural network features is provided, the method comprising: S1: inputting an image to be detected into a first neural network feature extraction module and a second neural network feature extraction module to extract image defect features of different dimensions, wherein the first neural network feature extraction module is constructed based on one or more convolution kernels in a convolution kernel group, and the second neural network feature extraction module is constructed based on another one or more convolution kernels in a convolution kernel group, and the convolution kernel group includes a diagonal convolution kernel, a horizontal convolution kernel, a vertical convolution kernel and a common convolution kernel; S2: using a feature difference loss function to calculate Calculate the difference loss of the image defect features extracted by the first neural network feature extraction module and the second neural network feature extraction module, wherein the difference loss function is inversely proportional to the square or norm or divergence of the difference between the output results of the two neural network feature extraction modules; S3: construct a training function based on the weighting of the segmentation loss and the difference loss; S4: use the training function to train the fusion decoding process of the image defect features extracted by the first neural network feature extraction module, the second neural network feature extraction module, and the first neural network feature extraction module and the second neural network feature extraction module until convergence to obtain a defective image.
[0006] Preferably, the first neural network feature extraction module includes a plurality of edge perception submodules, wherein a maximum pooling layer is provided between two adjacent edge perception submodules to reduce the dimension of an output result of a previous edge perception submodule.
[0007] Preferably, when the edge-perceiving submodule includes a convolution kernel, the edge-perceiving submodule includes a plurality of connected first convolution units, each of which includes a convolution kernel, a batch normalization layer, and an activation layer in sequence; when the edge-perceiving submodule includes multiple convolution kernels, the edge-perceiving submodule includes multiple channels, each channel including a first convolution unit corresponding to a convolution kernel.
[0008] Preferably, the second neural network feature extraction module includes multiple combined convolution sub-modules, wherein a maximum pooling layer is provided between two adjacent combined convolution sub-modules to reduce the dimension of the output result of the previous combined convolution sub-module.
[0009] Preferably, when the combined convolution submodule includes a convolution kernel, the combined convolution submodule includes a plurality of connected second convolution units, each of which includes a convolution kernel, a batch normalization layer, and an activation layer in sequence; when the combined convolution submodule includes multiple convolution kernels, the combined convolution submodule includes multiple channels, each channel including a second convolution unit corresponding to a convolution kernel.
[0010] Preferably, the feature difference loss function loss diff The calculation formula is:
[0011]
[0012] Wherein, N is the number of images input to the network in a batch, b is the bth image input to the network, α is the adjustment parameter, F1 is the defect feature extraction result output by the first neural network feature extraction module, and F2 is the defect feature extraction result output by the second neural network feature extraction module;
[0013] Or:
[0014]
[0015] Among them, || || F is the F norm, β is the adjustment parameter, N is the number of images input to the network in a batch, b is the b-th image input to the network, F1 is the defect feature extraction result output by the first neural network feature extraction module, and F2 is the defect feature extraction result output by the second neural network feature extraction module;
[0016] Or:
[0017]
[0018] Among them, KLD is the KL divergence; γ is the adjustment parameter.
[0019] Preferably, the training function loss is:
[0020] loss = λloss diff +νloss seg (4)
[0021]
[0022] Among them, loss diff is the feature difference loss function, loss seg is the segmentation loss corresponding to the cross entropy loss function, λ and ν are weight coefficients, y i For image x i The real label image, 1 is predicted as a defect area, 0 is predicted as a non-defect area, Represents the model for sample x i The predicted result is in the range of (0,1).
[0023] Preferably, the Adam optimization algorithm is used to optimize the training function so as to make the model converge.
[0024] According to another aspect of the present invention, a defect detection system for enhancing the diversity of neural network features is provided, the system comprising: an image defect feature extraction module, used to input the image to be detected into a first neural network feature extraction module and a second neural network feature extraction module to extract image defect features of different dimensions, wherein the first neural network feature extraction module is constructed based on one or more convolution kernels in a convolution kernel group, and the second neural network feature extraction module is constructed based on another one or more convolution kernels in the convolution kernel group, and the convolution kernel group includes a diagonal convolution kernel, a horizontal convolution kernel, a vertical convolution kernel and a common convolution kernel; a difference loss calculation module, used to adopt a feature difference loss function The method comprises the following steps: calculating the difference between the image defect features extracted by the first and second neural network feature extraction modules, wherein the difference loss function is inversely proportional to the square or norm or divergence of the difference between the output results of the first and second neural network feature extraction modules; a training function construction module: used to construct a training function based on the weighting of the segmentation loss and the difference loss; a training generation module: used to use the training function to train the fusion decoding process of the image defect features extracted by the first neural network feature extraction module, the second neural network feature extraction module, and the first neural network feature extraction module and the second neural network feature extraction module until convergence to obtain a defective image.
[0025] In general, compared with the prior art, the above technical solutions conceived by the present invention provide a defect detection method and system for enhancing the diversity of neural network features, which has the following beneficial effects:
[0026] 1. This application obtains the multi-dimensional features of defects in the image through a variety of convolution kernels, and adopts a specific feature difference loss function to ensure the difference of multi-dimensional features, thereby obtaining more diverse features, allowing the deep learning features extracted by different modules to maintain differences, reducing feature redundancy, thereby improving the detection accuracy of the model, and then improving the detection accuracy of the defect image, which can more realistically reflect the original morphology of the defects.
[0027] 2. The feature difference loss function of the present application is inversely proportional to the difference between the features, which can maximize the difference between the features, making the defect features extracted by the model richer, so that the defect detection performed by the network can better conform to the actual defect morphology and have higher detection accuracy.
[0028] 3. The cross entropy loss function is added during the model training process to measure the prediction performance of the model, and the Adam optimization algorithm is used for optimization, so that a model with high detection accuracy can be obtained, thereby improving the detection accuracy of defect images. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] Figure 1 is a flow chart of a defect detection method for enhancing the diversity of neural network features according to an embodiment of the present application;
[0030] Figure 2 Schematic diagram of the types of convolution kernel groups in the embodiment of the present application, wherein (a) is a diagonal convolution kernel, (b) is a horizontal convolution kernel, (c) is a vertical convolution kernel, and (d) is a common convolution kernel;
[0031] Figure 3 It is a schematic diagram of the structure of the edge perception submodule and the combined convolution submodule of the embodiment of the present application;
[0032] Figure 4 It is a network architecture for defect detection that enhances the diversity of neural network features in an embodiment of the present application;
[0033] Figure 5 It is the difference between the two groups of features in the embodiment of the present application with or without the constraint of feature difference loss; wherein, with feature difference loss, the feature difference loss is calculated and the loss is taken as part of the total loss; without feature difference loss, the feature difference loss is calculated but the loss is not taken as part of the total loss. DETAILED DESCRIPTION
[0034] 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.
[0035] See also Figure 1 The present invention provides a defect detection method for enhancing the diversity of neural network features, the method comprising:
[0036] S1: Input the image to be detected into the first neural network feature extraction module and the second neural network feature extraction module to extract image defect features of different dimensions, wherein the first neural network feature extraction module is constructed based on one or more convolution kernels in the convolution kernel group, and the second neural network feature extraction module is constructed based on another one or more convolution kernels in the convolution kernel group, and the convolution kernel group includes a diagonal convolution kernel, a horizontal convolution kernel, a vertical convolution kernel and a common convolution kernel, such as Figure 2 shown.
[0037] An edge-aware feature extraction module is constructed. This module is similar to the sober operator for extracting edge features in image processing. The difference is that the weight values in this module can be learned.
[0038] In this embodiment, the first neural network feature extraction module is constructed based on horizontal convolution kernels and vertical convolution kernels, and then the defect image is processed to obtain a deep learning feature group F1 reflecting horizontal and vertical direction features.
[0039] The first neural network feature extraction module includes a plurality of edge perception submodules, wherein a maximum pooling layer is provided between two adjacent edge perception submodules to reduce the dimension of the output result of the previous edge perception submodule. For example, a maximum pooling layer of size 2×2 can be used for dimensionality reduction.
[0040] When the edge perception submodule includes one convolution kernel, the edge perception submodule includes a plurality of connected first convolution units, each of which includes a convolution kernel, a batch normalization layer, and an activation layer in sequence. When the edge perception submodule includes multiple convolution kernels, the edge perception submodule includes a plurality of channels, each of which includes a first convolution unit corresponding to a convolution kernel. In this embodiment, each edge perception submodule includes two channels, such as Figure 3 As shown in (a), one channel consists of horizontal convolution kernels, including stacked multiple 3×3 horizontal edge-aware convolution layers, batch normalization layers, and Relu activation layers; the other channel consists of vertical convolution kernels, also including stacked multiple 3×3 vertical edge-aware convolution layers, batch normalization layers, and Relu activation layers. The two sub-channel features are added or connected as a group and input to the next edge-aware submodule. The image defect feature output by the last edge-aware submodule is recorded as F1.
[0041] In other preferred embodiments, other neural network feature extraction methods can be used for reference, such as using a residual connection to add the input and output of the submodule, or using a method similar to a dense connection, a separate convolution method, etc.
[0042] In this embodiment, the second neural network feature extraction module is constructed based on the diagonal convolution kernel and the ordinary convolution kernel, and then the defect image is processed to obtain a deep learning feature group that reflects the overall information and diagonal information.
[0043] The second neural network feature extraction module includes multiple combined convolution sub-modules, wherein a maximum pooling layer is provided between two adjacent combined convolution sub-modules to reduce the dimension of the output result of the previous combined convolution sub-module, for example, using a maximum pooling layer of size 2×2 for dimensionality reduction.
[0044] When the combined convolution submodule includes one convolution kernel, the combined convolution submodule includes a plurality of connected second convolution units, each of which includes a convolution kernel, a batch normalization layer, and an activation layer in sequence. When the combined convolution submodule includes multiple convolution kernels, the combined convolution submodule includes a plurality of channels, each of which includes a second convolution unit corresponding to a convolution kernel. In this embodiment, each combined convolution submodule includes two channels, such as Figure 3 As shown in (b), one channel is composed of diagonal convolution kernels, including stacked multiple 3×3 diagonal convolution kernel perception convolution layers, batch normalization layers and Relu activation layers. The other channel is composed of ordinary 3×3 convolution kernels, also including stacked multiple 3×3 ordinary convolution layers, batch normalization layers and Relu activation layers. The features of the two sub-channels are added or connected as a group to the next combined convolution sub-module. The image defect feature of the output of the last combined convolution sub-module is recorded as F2.
[0045] In other preferred embodiments, other neural network feature extraction methods can be used for reference, such as using a residual connection to add the input and output of the submodule, or using a method similar to a dense connection, a separate convolution method, etc.
[0046] Any combination of the four convolution kernels in S1 can form a submodule, thereby obtaining a deep learning feature set with different information, such as a combination of a horizontal convolution kernel and a diagonal convolution kernel, or even a single horizontal convolution kernel and a single diagonal convolution kernel.
[0047] S2: Using a feature difference loss function to calculate the difference loss between the image defect features extracted by the first neural network feature extraction module and the second neural network feature extraction module, wherein the difference loss function is inversely proportional to the square or norm or divergence of the difference between the output results of the two neural network feature extraction modules.
[0048] After obtaining two sets of deep learning features through different feature extraction methods, in order to prevent the two sets of features from becoming similar in the continuous iterative learning process, a feature difference loss function applied to deep learning feature extraction is proposed. This feature difference loss function can ensure that the difference between the two sets of features is as large as possible to reduce feature redundancy, such as Figure 4 shown.
[0049] The feature difference loss function loss diff The calculation formula is:
[0050]
[0051] Wherein, N is the number of images input to the network in a batch, b is the bth image input to the network, α is the adjustment parameter, F1 is the defect feature extraction result output by the first neural network feature extraction module, and F2 is the defect feature extraction result output by the second neural network feature extraction module;
[0052] Or:
[0053]
[0054] Among them, || || F is the F norm, β is the adjustment parameter, N is the number of images input to the network in a batch, b is the b-th image input to the network, F1 is the defect feature extraction result output by the first neural network feature extraction module, and F2 is the defect feature extraction result output by the second neural network feature extraction module;
[0055] Or:
[0056]
[0057] Among them, KLD is the KL divergence; γ is the adjustment parameter.
[0058] S3: constructing a training function based on the weighting of the segmentation loss and the difference loss;
[0059] The training function loss is:
[0060] loss = λloss diff +νloss seg (4)
[0061]
[0062] Among them, loss diff is the feature difference loss function, loss seg is the segmentation loss corresponding to the cross entropy loss function, λ and ν are weight coefficients, y i For image x i The real label image, 1 is predicted as a defect area, 0 is predicted as a non-defect area, Represents the model for sample x i The predicted result is in the range of (0,1).
[0063] In a further preferred solution, the training function is optimized using the Adam optimization algorithm to achieve model convergence.
[0064] The feature difference loss function shown in formulas (1) to (3) is used to measure the difference between two different sets of deep learning features F1 to F2. When the two features are very different, the loss function produces a very small loss value. When the two features are similar, the loss function will produce a large loss value, which means that the extracted feature redundancy is too high and the model parameters need to be further optimized. Therefore, the above training function needs to be used to train it.
[0065] S4: Using the training function to train the first neural network feature extraction module, the second neural network feature extraction module, and the fusion decoding process of the image defect features extracted by the first neural network feature extraction module and the second neural network feature extraction module until convergence to obtain a defective image.
[0066] For the two different sets of deep learning defect features F1 and F2 obtained in step S1, the feature difference loss function proposed in step S3 is used to constrain the difference between the two defect features, and the above training function is used to train the above model and decoding fusion process, and the predicted defect image is obtained after convergence.
[0067] On the other hand, the present application proposes a defect detection system for enhancing the diversity of neural network features, the system comprising an image defect feature extraction module, a difference loss calculation module, a training function construction module and a training generation module, wherein:
[0068] An image defect feature extraction module, used for inputting the image to be detected into the first neural network feature extraction module and the second neural network feature extraction module to extract image defect features of different dimensions, wherein the first neural network feature extraction module is constructed based on one or more convolution kernels in the convolution kernel group, and the second neural network feature extraction module is constructed based on another one or more convolution kernels in the convolution kernel group, and the convolution kernel group includes a diagonal convolution kernel, a horizontal convolution kernel, a vertical convolution kernel and a common convolution kernel;
[0069] A difference loss calculation module, used to calculate the difference loss between the image defect features extracted by the first neural network feature extraction module and the second neural network feature extraction module using a feature difference loss function, wherein the difference loss function is inversely proportional to the square or norm or divergence of the difference between the output results of the two neural network feature extraction modules;
[0070] A training function construction module: used to construct a training function based on the weighting of the segmentation loss and the difference loss;
[0071] Training generation module: used to use the training function to train the first neural network feature extraction module, the second neural network feature extraction module, and the fusion decoding process of the image defect features extracted by the first neural network feature extraction module and the second neural network feature extraction module until convergence to obtain a defective image.
[0072] Example
[0073] This embodiment uses the above method and model to detect surface defects of workpieces.
[0074] Step 1: 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.
[0075] Step 2: 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. NG samples in both the training set and the test set need to be marked with defect shape labels.
[0076] Step 3: Construct the first neural network feature extraction module based on the edge perception submodule.
[0077] Edge features are crucial in the method of defect detection based on manually constructed features. In order to extract edge features in a neural network, the present application constructs the first neural network feature extraction module with edge perception. This module is similar to the sober operator for extracting edge features in image processing. The difference is that each weight value in this module can be learned. Through this module, a deep learning feature group F1 reflecting the horizontal and vertical directions is obtained;
[0078] More specifically, the first neural network feature extraction module is composed of multiple edge-aware submodules. A 2×2 maximum pooling layer is used between two edge-aware submodules for dimensionality reduction. Inside each edge-aware submodule, there are two channels. One channel is composed of horizontal convolution kernels, including stacked multiple 3×3 horizontal edge-aware convolution layers, batch normalization layers, and Relu activation layers. The other channel is composed of vertical convolution kernels, also including stacked multiple 3×3 vertical edge-aware convolution layers, batch normalization layers, and Relu activation layers. The two sub-channel features are added together as a group and input into the next edge-aware submodule. After 5 edge-aware submodules and maximum pooling processes, the output feature of the last edge-aware submodule is recorded as F1.
[0079] Step 4: Construct the second neural network feature extraction module based on the diagonal convolution kernel and the ordinary convolution kernel to obtain a deep learning feature group that reflects the overall information and diagonal information.
[0080] The feature information extracted by only using the edge perception submodule is missing, so the present invention further introduces a combined convolution submodule consisting of a diagonal information extraction kernel and a common convolution kernel.
[0081] The second neural network feature extraction module includes multiple combined convolution sub-modules, wherein a maximum pooling layer is provided between two adjacent combined convolution sub-modules to reduce the dimension of the output result of the previous combined convolution sub-module, for example, using a maximum pooling layer of size 2×2 for dimensionality reduction.
[0082] When the combined convolution submodule includes two convolution kernels, the combined convolution submodule includes two channels, each channel includes a second convolution unit corresponding to a convolution kernel, and specifically each combined convolution submodule contains two channels, one channel is composed of a diagonal convolution kernel, including a stacked plurality of 3×3 diagonal convolution kernel perception convolution layers, a batch normalization layer and a Relu activation layer, and the other channel is composed of an ordinary 3×3 convolution kernel, and also includes a stacked plurality of 3×3 ordinary convolution layers, a batch normalization layer and a Relu activation layer. The features of the two sub-channels are combined and fused into a group using a 1×1 convolution and then input into the next combined convolution submodule. After 5 combined convolution submodules and maximum pooling processing, the output feature of the last combined convolution submodule is recorded as F2.
[0083] Step 5: Differential feature learning between two sets of deep learning features.
[0084] After obtaining two sets of deep learning features through different feature extraction methods, in order to prevent the two sets of features from becoming similar in the continuous iterative learning process, a feature difference loss applied to deep learning feature extraction is proposed. This loss ensures that the difference between the two sets of features is as large as possible to reduce feature redundancy.
[0085] In this embodiment, the feature difference loss function loss diff The calculation formula is:
[0086]
[0087] The feature difference loss function shown in formula (1) is used to measure the difference between two different sets of deep learning features F1 and F2. When the two features are very different, the loss function produces a small loss value. When the two features are similar, the loss function will produce a large loss value. Figure 5 shown.
[0088] observe Figure 5It can be found that after the introduction of feature difference loss, the similarity between F1 and F2 gradually decreases with the training process, while without the introduction of feature difference loss, the similarity between F1 and F2 gradually increases.
[0089] Step 6: Surface defect detection of workpiece based on fusion features.
[0090] For the two different sets of deep learning features F1 and F2 obtained in step 3 and step 4, the feature difference loss function proposed in step 5 is used to constrain the difference between the two features. F1 and F2 are connected as a set of features and fused, and then upsampled and decoded to obtain the predicted defect image.
[0091] Among them, the decoder selects the VGG block and upsampling to decode and obtain the final predicted defect image.
[0092] When training the model, the cross entropy loss function is used for weighted summation as the final training function to train the model, as follows:
[0093] The training function loss is:
[0094] loss = λloss diff +νloss seg (4)
[0095]
[0096] Among them, loss diff is the feature difference loss function, loss seg is the segmentation loss corresponding to the cross entropy loss function, λ and ν are weight coefficients, y i For image x i The real label image, 1 is predicted as a defect area, 0 is predicted as a non-defect area, Represents the model for sample x i The predicted result is in the range of (0,1).
[0097] Finally, the Adam optimization algorithm is used to optimize the training function to make the model converge.
[0098] 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 defect detection method that enhances the diversity of neural network features, It is characterized in that The method comprises: S1: Inputting the image to be detected into a first neural network feature extraction module and a second neural network feature extraction module to extract image defect features of different dimensions, wherein the first neural network feature extraction module is constructed based on one or more convolution kernels in a convolution kernel group, and the second neural network feature extraction module is constructed based on another one or more convolution kernels in a convolution kernel group, and the convolution kernel group includes a diagonal convolution kernel, a horizontal convolution kernel, a vertical convolution kernel and a common convolution kernel; S2: using a feature difference loss function to calculate the difference loss between the image defect features extracted by the first neural network feature extraction module and the second neural network feature extraction module, wherein the difference loss function is inversely proportional to the square or norm or divergence of the difference between the output results of the two neural network feature extraction modules; S3: constructing a training function based on the weighting of the segmentation loss and the difference loss; S4: Using the training function to train the first neural network feature extraction module, the second neural network feature extraction module, and the fusion decoding process of the image defect features extracted by the first neural network feature extraction module and the second neural network feature extraction module until convergence to obtain a defective image.
2. The defect detection method according to claim 1, It is characterized in that The first neural network feature extraction module includes multiple edge perception sub-modules, wherein a maximum pooling layer is provided between two adjacent edge perception sub-modules to reduce the dimension of the output result of the previous edge perception sub-module.
3. The defect detection method according to claim 2, It is characterized in that When the edge-perceiving submodule includes a convolution kernel, the edge-perceiving submodule includes a plurality of connected first convolution units, each of which includes a convolution kernel, a batch normalization layer, and an activation layer in sequence; when the edge-perceiving submodule includes multiple convolution kernels, the edge-perceiving submodule includes multiple channels, each of which includes a first convolution unit corresponding to a convolution kernel.
4. The defect detection method according to claim 1, It is characterized in that The second neural network feature extraction module includes multiple combined convolution sub-modules, wherein a maximum pooling layer is provided between two adjacent combined convolution sub-modules to reduce the dimension of the output result of the previous combined convolution sub-module.
5. The defect detection method according to claim 4, It is characterized in that When the combined convolution submodule includes a convolution kernel, the combined convolution submodule includes a plurality of connected second convolution units, each of which includes a convolution kernel, a batch normalization layer, and an activation layer in sequence; when the combined convolution submodule includes multiple convolution kernels, the combined convolution submodule includes multiple channels, each channel including a second convolution unit corresponding to a convolution kernel.
6. The defect detection method according to claim 1, It is characterized in that The feature difference loss function loss diff The calculation formula is: Where N is the number of images in the input network in a batch, b is the bth image in the input network, α is the adjustment parameter, and F 1 is the defect feature extraction result output by the first neural network feature extraction module, F 2 It is the defect feature extraction result output by the second neural network feature extraction module; Or: Among them, || || F is the F norm, β is the adjustment parameter, N is the number of images input to the network in a batch, b is the bth image input to the network, and F 1 is the defect feature extraction result output by the first neural network feature extraction module, F 2 It is the defect feature extraction result output by the second neural network feature extraction module; Or: Among them, KLD is the KL divergence; γ is the adjustment parameter.
7. The defect detection method according to claim 1, It is characterized in that The training function loss is: loss=λloss diff +νloss seg (4) Among them, loss diff is the feature difference loss function, loss seg is the segmentation loss corresponding to the cross entropy loss function, λ and ν are weight coefficients, y i For image x i The real label image, 1 is predicted as a defect area, 0 is predicted as a non-defect area, Represents the model for sample x i The predicted result is in the range of (0,1).
8. The defect detection method according to claim 7, It is characterized in that The Adam optimization algorithm is used to optimize the training function to make the model converge.
9. A defect detection system that enhances the diversity of neural network features, It is characterized in that The system comprises: An image defect feature extraction module, used for inputting the image to be detected into the first neural network feature extraction module and the second neural network feature extraction module to extract image defect features of different dimensions, wherein the first neural network feature extraction module is constructed based on one or more convolution kernels in the convolution kernel group, and the second neural network feature extraction module is constructed based on another one or more convolution kernels in the convolution kernel group, and the convolution kernel group includes a diagonal convolution kernel, a horizontal convolution kernel, a vertical convolution kernel and a common convolution kernel; a difference loss calculation module, used to calculate the difference loss between the image defect features extracted by the first neural network feature extraction module and the second neural network feature extraction module using a feature difference loss function, wherein the difference loss function is inversely proportional to the square or norm or divergence of the difference between the output results of the two neural network feature extraction modules; A training function construction module: used to construct a training function based on the weighting of the segmentation loss and the difference loss; Training generation module: used to use the training function to train the first neural network feature extraction module, the second neural network feature extraction module, and the fusion decoding process of the image defect features extracted by the first neural network feature extraction module and the second neural network feature extraction module until convergence to obtain a defective image.
