Industrial product defect detection method and system based on state space and frequency domain attention

By introducing the C3k2-MSFB module and the multi-scale wavelet attention module, combined with the Inner-CIoU loss function, the problem of inaccurate localization of complex textures and small targets in existing industrial product surface defect detection methods is solved, achieving higher accuracy and wider applicability in defect detection.

CN121544529APending Publication Date: 2026-02-17GUANGDONG UNIV OF TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511544778.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-10-28
Publication Date
2026-02-17

AI Technical Summary

Technical Problem

Existing methods for detecting surface defects in industrial products suffer from insufficient feature extraction capabilities and inaccurate localization when dealing with defects involving complex textures, small targets, and blurred boundaries. In particular, traditional image processing methods and deep learning algorithms such as the YOLO series have limitations in these scenarios.

Method used

An industrial product defect detection method based on state space and frequency domain attention is adopted. By constructing a defect detection model, a C3k2-MSFB module, a multi-scale wavelet attention module, and an Inner-CIoU loss function are introduced to improve the global feature modeling capability and small target defect feature extraction, and enhance the accuracy of locating fuzzy boundaries and overlapping targets.

Benefits of technology

It significantly improves the accuracy and generalization ability of defect detection in industrial products, and can better handle complex textures and small targets, achieving more accurate defect detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121544529A_ABST
    Figure CN121544529A_ABST
Patent Text Reader

Abstract

The invention provides an industrial product defect detection method and system based on state space and frequency domain attention, and relates to the technical field of computer vision and artificial intelligence application, and the method comprises the steps: obtaining a data set which comprises a plurality of industrial product images and real defect positioning frames; preprocessing each industrial product image in the data set to obtain a preprocessed data set; inputting the preprocessed data set into a constructed defect detection model to obtain a prediction defect positioning frame of each industrial product image; constructing a total loss function according to a real defect positioning frame and a predicted defect positioning frame of the industrial product image, and training the defect detection model to obtain a trained defect detection model; and inputting a to-be-detected industrial product image into the trained defect detection model to obtain a defect detection result of the to-be-detected industrial product image. According to the method, the global feature modeling capability is improved, small target defect feature extraction is more sufficient, and more accurate industrial product defect detection is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the fields of computer vision and artificial intelligence application technology, and in particular to an industrial product defect detection method and system based on state space and frequency domain attention. Background Technology

[0002] With the rapid development of intelligent manufacturing and industrial automation, surface defect detection plays a crucial role in metal processing, printed circuit board production, and steel quality inspection. Surface defect detection in industrial products is a key link in intelligent manufacturing and quality control, aiming to promptly detect and locate various defects on product surfaces. This is of great significance for ensuring product quality, improving production efficiency, and reducing labor costs. Traditional methods for detecting surface defects in industrial products mainly rely on manual visual inspection or machine vision methods based on traditional image processing. Manual visual inspection is highly subjective, prone to fatigue, inefficient, and inconsistent, making it difficult to meet the demands of modern high-speed production lines. While methods based on traditional image processing have achieved a degree of automation, their feature extraction capabilities are limited, heavily reliant on carefully designed feature engineering and lighting conditions, and they have poor generalization ability in scenes with complex backgrounds, varied defect morphologies, and low contrast. Furthermore, their debugging and maintenance costs are high.

[0003] In recent years, with the rapid development of deep learning technology, deep learning-based defect detection algorithms have gradually become the mainstream choice for industrial applications. These algorithms can be divided into single-stage and two-stage detection methods. Single-stage methods complete target classification and localization simultaneously through a single forward propagation, featuring fast detection speed and simple structure, making them suitable for real-time detection tasks. Two-stage methods first generate region proposals, and then classify and regress bounding boxes on these regions. Although they have higher accuracy, they are slower and not suitable for real-time applications. Nevertheless, existing YOLO series algorithms still have some limitations when handling complex textures, small targets, and blurred boundary defects, such as insufficient feature extraction capabilities and unstable bounding box regression. Summary of the Invention

[0004] To overcome the shortcomings of poor global feature modeling, insufficient extraction of small target defect features, and inaccurate localization of fuzzy boundaries or overlapping targets, this invention provides an industrial product defect detection method and system based on state space and frequency domain attention.

[0005] To solve the above-mentioned technical problems, the technical solution of the present invention is as follows: This invention provides a method for detecting defects in industrial products based on state space and frequency domain attention, comprising: Obtain a dataset, which includes several images of industrial products and their actual defect location boxes; Each industrial product image in the dataset is preprocessed to obtain a preprocessed dataset; The preprocessed dataset is input into the constructed defect detection model to obtain the predicted defect localization box for each industrial product image. Based on the actual defect location boxes and predicted defect location boxes of the industrial product image, a total loss function is constructed, and the defect detection model is trained to obtain a trained defect detection model. The defect detection model is trained by inputting the image of the industrial product to be detected, and the defect detection result of the image of the industrial product is obtained.

[0006] Preferably, the defect detection model includes a backbone network; The backbone network includes a first convolutional unit, a second convolutional unit, a first C3k2 module, a third convolutional unit, a second C3k2 module, a fourth convolutional network, a third C3k2 module, a fifth convolutional unit, a first C3k2-MSFB module, an SPPF module, a C2PSA module, and a multi-scale wavelet attention module, all connected in sequence.

[0007] Preferably, the defect detection model further includes a neck network; The neck network includes a first downsampling unit, a second Concat unit, a second C3k2-MSFB module, a second downsampling unit, a third Concat unit, a third C3k2-MSFB module, an eighth convolution unit, a fourth Concat unit, a fourth C3k2-MSFB module, a ninth convolution unit, a fifth Concat unit, and a fifth C3k2-MSFB module connected in sequence. The output of the multi-scale wavelet attention module is connected to the input of the first downsampling unit and the input of the fifth Concat unit, respectively. The output of the third C3k2 module is connected to the input of the second Concat unit; The output of the second C3k2 module is connected to the input of the third Concat unit.

[0008] Preferably, the first C3k2-MSFB module, the second C3k2-MSFB module, the third C3k2-MSFB module, the fourth C3k2-MSFB module, and the fifth C3k2-MSFB module have the same structure, each including a sixth convolutional unit, a split layer, a preset number of MSFB components, a first concat unit, and a seventh convolutional unit connected in sequence. The output of the Split layer is also connected to the input of the first Concat unit.

[0009] Preferably, the MSFB component includes a first CBS module, a feedforward network unit, an MCB module, a first connection point, a second CBS module, and a second connection point connected in sequence. The output of the first CBS module is also connected to the input of the second connection point; The output of the feedforward network unit is also connected to the input of the first connection point.

[0010] Preferably, the MCB module includes a first normalized layer, a first linear layer, a first depthwise separable convolutional layer, a third CBS module, a second linear layer, a second depthwise separable convolutional layer, an SS2D module, and a third connection point; The first normalization layer, the first linear layer, the first depthwise separable convolutional layer, the third CBS module, the second linear layer, and the third connection point are connected in sequence. The second depth-separable convolutional layer and the SS2D module are connected sequentially; The output of the SS2D module is also connected to the input of the third connection point; The input of the first normalized layer is also connected to the input of the third connection point and the input of the second depth separable convolutional layer.

[0011] Preferably, the multi-scale wavelet attention module includes a first wavelet transform convolutional unit, a channel attention unit, a fourth connection point, a spatial attention unit, a fifth connection point, a channel connection point, a fourth CBS module, a sixth connection point, a second normalization layer, a fifth CBS module, a second wavelet transform convolutional unit, a third wavelet transform convolutional unit, and a seventh connection point. The first wavelet transform convolutional unit, channel attention unit, fourth connection point, spatial attention unit, fifth connection point, channel connection point, fourth CBS module, sixth connection point, and second normalization layer are connected sequentially. The output of the first wavelet transform convolution unit is also connected to the input of the fourth connection point, the input of the sixth connection point, and the input of the fifth CBS module, respectively. The output of the fourth connection point is also connected to the input of the fifth connection point; The output of the fifth CBS module is connected to the input of the second wavelet transform convolution unit and the third wavelet transform convolution unit, respectively. The outputs of the second wavelet transform convolutional unit and the third wavelet transform convolutional unit are connected to the input of the seventh connection point; The output of the seventh connection point is connected to the input of the channel connection point.

[0012] Preferably, the defect detection model further includes a detection head network; the detection head network includes a first detection unit, a second detection unit, and a third detection unit arranged in parallel. The output terminals of the third, fourth, and fifth C3k2-MSFB modules are respectively connected to the input terminals of the first, second, and third detection units.

[0013] Preferably, the total loss function is expressed as follows:

[0014] in, , , These are the weighting coefficients for different loss terms. For classifying losses, For targeted losses; The The formula for calculating the loss is:

[0015] in, Indicates the center point of the prediction box Center point of the real frame The square of the Euclidean distance between them; Represents the diagonal length of the smallest enclosing rectangle that covers both the predicted and actual bounding boxes; This is a measure of the consistency of aspect ratio between the predicted bounding box and the ground truth bounding box, and the calculation formula is:

[0016] in, The actual height of the bounding box. The width of the actual bounding box. The height of the predicted bounding box, The width of the prediction box; It is a weighting factor used to balance aspect ratio consistency terms. The influence of is dynamically determined by the following formula:

[0017] The calculation formula is:

[0018] in, It is the area of ​​the intersection of the two inner boxes. It is the area of ​​the union of the two inner boxes.

[0019] This invention also provides an industrial product defect detection system based on state space and frequency domain attention, comprising: The data acquisition module is used to acquire a dataset, which includes several images of industrial products and their actual defect location boxes. The preprocessing module is used to preprocess each industrial product image in the dataset to obtain a preprocessed dataset. The data prediction module is used to input the preprocessed dataset into the constructed defect detection model to obtain the predicted defect location box for each industrial product image. The network training module is used to construct a total loss function based on the actual defect location boxes and predicted defect location boxes of the industrial product image, and to train the defect detection model to obtain a trained defect detection model. The detection module is used to input the image of the industrial product to be detected into the trained defect detection model and obtain the defect detection result of the image of the industrial product to be detected.

[0020] Compared with the prior art, the beneficial effects of the technical solution of the present invention are: This invention first acquires a dataset comprising several industrial product images and their true defect bounding boxes. Next, each industrial product image in the dataset is preprocessed to obtain a preprocessed dataset. Then, the preprocessed dataset is input into a constructed defect detection model to obtain predicted defect bounding boxes for each industrial product image. Following this, a total loss function is constructed based on the true and predicted defect bounding boxes of the industrial product images, and the defect detection model is trained to obtain a trained defect detection model. Finally, the industrial product image to be detected is input into the trained defect detection model to obtain the defect detection result. This invention improves global feature modeling capabilities by introducing a C3k2-MSFB module, a multi-scale wavelet attention module, and an Inner-CIoU loss function. This results in more thorough extraction of defect features for small targets and more accurate localization of blurred boundaries or overlapping targets, achieving more precise industrial product defect detection. Attached Figure Description

[0021] Figure 1 This is a flowchart illustrating an industrial product defect detection method based on state space and frequency domain attention in Example 1. Figure 2 This is a schematic diagram of the backbone network structure in Example 2; Figure 3 This is a schematic diagram of the neck network structure in Example 2; Figure 4 This is a schematic diagram of the structure of the first C3k2-MSFB module in Example 2; Figure 5 This is a schematic diagram of the MSFB component in Example 2; Figure 6This is a schematic diagram of the MCB module in Example 2; Figure 7 This is a schematic diagram of the structure of the multi-scale wavelet attention module in Example 2; Figure 8 This is a schematic diagram of the detection head network in Example 2; Figure 9 This is a schematic diagram of the structure of an industrial product defect detection system based on state space and frequency domain attention, as shown in Example 3. Detailed Implementation

[0022] The accompanying drawings are for illustrative purposes only and should not be construed as limiting the scope of this patent. To better illustrate this embodiment, some parts in the accompanying drawings may be omitted, enlarged, or reduced, and do not represent the actual product dimensions; It will be understood by those skilled in the art that certain well-known structures and their descriptions may be omitted in the accompanying drawings.

[0023] The technical solution of the present invention will be further described below with reference to the accompanying drawings and embodiments.

[0024] Example 1 This embodiment provides an industrial product defect detection method based on state space and frequency domain attention, such as... Figure 1 As shown, it includes: Obtain a dataset, which includes several images of industrial products and their actual defect location boxes; Each industrial product image in the dataset is preprocessed to obtain a preprocessed dataset; The preprocessed dataset is input into the constructed defect detection model to obtain the predicted defect localization box for each industrial product image. Based on the actual defect location boxes and predicted defect location boxes of the industrial product image, a total loss function is constructed, and the defect detection model is trained to obtain a trained defect detection model. The defect detection model is trained by inputting the image of the industrial product to be detected, and the defect detection result of the image of the industrial product is obtained.

[0025] In the specific implementation process, firstly, a dataset is acquired, which includes several industrial product images and their true defect localization boxes. Then, each industrial product image in the dataset is preprocessed to obtain a preprocessed dataset. Next, the preprocessed dataset is input into a constructed defect detection model to obtain predicted defect localization boxes for each industrial product image. Then, based on the true and predicted defect localization boxes of the industrial product images, a total loss function is constructed, and the defect detection model is trained to obtain a trained defect detection model. Finally, the industrial product image to be detected is input into the trained defect detection model to obtain the defect detection result. This invention improves the global feature modeling capability by introducing a C3k2-MSFB module, a multi-scale wavelet attention module, and an Inner-CIoU loss function. This results in more thorough extraction of small target defect features and more accurate localization of blurred boundaries or overlapping targets, thereby significantly improving the overall accuracy and generalization ability of industrial product defect detection. Example 2 This embodiment provides an industrial product defect detection method based on state space and frequency domain attention, including: Obtain a dataset, which includes several images of industrial products and their actual defect location boxes; It should be noted that in this embodiment, the publicly available NEU-DET dataset and HRIPCB dataset are used as training datasets, while the glass panel dataset (GSD) is collected from industrial application scenarios; the dataset is divided into training set and test set in a ratio of 9:1. The NEU-DET dataset is used for defect detection on steel surfaces. There are six types of defects: entanglement defects (RS), pitted surfaces (Ps), inclusions (In), patches (Pa), cracks (Cr), and scratches (Sc). There are 300 images for each type of defect, for a total of 1800 images. The HRIPCB is a public printed circuit board defect dataset containing 6 defect types: vias, open circuits, burrs, short circuits, fake copper, and rodent bites, totaling 693 images with an average resolution of 2777 x 2188. The GSD contains 146 original images with a resolution of 5120 x 5120. Defect types are categorized into three types: bubbles, scratches, and tin ash.

[0026] Each industrial product image in the dataset is preprocessed to obtain a preprocessed dataset; It should be noted that in this embodiment, the preprocessing package includes cropping, rotation, and inversion data augmentation operations, and the processed dataset contains a total of 6000 images.

[0027] The preprocessed dataset is input into the constructed defect detection model to obtain the predicted defect localization box for each industrial product image. It should be noted that the defect detection model described in this embodiment includes a backbone network; like Figure 2 As shown, the backbone network includes a first convolutional unit, a second convolutional unit, a first C3k2 module, a third convolutional unit, a second C3k2 module, a fourth convolutional network, a third C3k2 module, a fifth convolutional unit, a first C3k2-MSFB module, an SPPF module, a C2PSA module, and a multi-scale wavelet attention module connected in sequence.

[0028] It should be noted that, in this embodiment, the defect detection model also includes a neck network; like Figure 3 As shown, the neck network includes a first downsampling unit, a second Concat unit, a second C3k2-MSFB module, a second downsampling unit, a third Concat unit, a third C3k2-MSFB module, an eighth convolution unit, a fourth Concat unit, a fourth C3k2-MSFB module, a ninth convolution unit, a fifth Concat unit, and a fifth C3k2-MSFB module connected in sequence. The output of the multi-scale wavelet attention module is connected to the input of the first downsampling unit and the input of the fifth Concat unit, respectively. The output of the third C3k2 module is connected to the input of the second Concat unit; The output of the second C3k2 module is connected to the input of the third Concat unit.

[0029] It should be noted that, in this embodiment, as Figure 4 As shown, the first, second, third, fourth, and fifth C3k2-MSFB modules have the same structure, each including a sixth convolutional unit, a split layer, a preset number of MSFB components, a first concat unit, and a seventh convolutional unit connected in sequence. The C3k2-MSFB module captures global context and long-range dependencies; The output of the Split layer is also connected to the input of the first Concat unit.

[0030] It should be noted that, in this embodiment, as Figure 5 As shown, the MSFB component includes a first CBS module, a feedforward network unit, an MCB module, a first connection point, a second CBS module, and a second connection point connected in sequence. The output of the first CBS module is also connected to the input of the second connection point; The output of the feedforward network unit is also connected to the input of the first connection point.

[0031] It should be noted that, in this embodiment, as Figure 6 As shown, the MCB module includes a first normalization layer, a first linear layer, a first depthwise separable convolutional layer, a third CBS module, a second linear layer, a second depthwise separable convolutional layer, an SS2D module, and a third connection point; The first normalization layer, the first linear layer, the first depthwise separable convolutional layer, the third CBS module, the second linear layer, and the third connection point are connected in sequence. The second depth-separable convolutional layer and the SS2D module are connected sequentially; The output of the SS2D module is also connected to the input of the third connection point; The input of the first normalized layer is also connected to the input of the third connection point and the input of the second depth separable convolutional layer.

[0032] It should be noted that, in this embodiment, the specific operation flow of the MSFB component is as follows: Input feature map The training process begins with the first CBS module, which consists of a 1×1 convolutional layer, a batch normalization layer, and a SiLU activation function, in sequence to introduce nonlinearity and stabilize the training process.

[0033] Next, the nonlinear representation capability of the features is enhanced through a feedforward network (FFN):

[0034] in, , For learnable weight matrix, , For bias terms, It is a non-linear activation function. Representative input After processing by the CBS module.

[0035] The core component introduces Mamba convolutional blocks (MCBs), which capture both local and global features simultaneously through a dual-branch structure: Local branching: Extracting local features using depthwise separable convolution (DWConv):

[0036] Global branching: Capturing long-range dependencies using state-space equations through selective scanning of 2D modules (SS2D):

[0037]

[0038] in, This represents the hidden state vector at time t. Indicates the position in the sequence Input features, A Here is the state transition matrix. B For the input matrix, C For the output matrix, D This is for direct matrix transmission.

[0039] Local features, global features, and FFN output are fused via residual concatenation:

[0040] Finally, the output characteristics are adjusted using a CBS module, and then added to the module input via a residual connection:

[0041] By replacing a specific number of layers of C3k2 modules at a specific depth in the network with C3k2-MSFB, the model significantly improves its ability to handle complex structural defects without excessively increasing the computational burden.

[0042] It should be noted that, in this embodiment, as Figure 7 As shown, the multi-scale wavelet attention module includes a first wavelet transform convolutional unit, a channel attention unit, a fourth connection point, a spatial attention unit, a fifth connection point, a channel connection point, a fourth CBS module, a sixth connection point, a second normalization layer, a fifth CBS module, a second wavelet transform convolutional unit, a third wavelet transform convolutional unit, and a seventh connection point. The first wavelet transform convolutional unit, channel attention unit, fourth connection point, spatial attention unit, fifth connection point, channel connection point, fourth CBS module, sixth connection point, and second normalization layer are connected sequentially. The output of the first wavelet transform convolution unit is also connected to the input of the fourth connection point, the input of the sixth connection point, and the input of the fifth CBS module, respectively. The output of the fourth connection point is also connected to the input of the fifth connection point; The output of the fifth CBS module is connected to the input of the second wavelet transform convolution unit and the third wavelet transform convolution unit, respectively. The outputs of the second wavelet transform convolutional unit and the third wavelet transform convolutional unit are connected to the input of the seventh connection point; The output of the seventh connection point is connected to the input of the channel connection point.

[0043] The multi-scale wavelet attention module enhances the ability to extract and focus on multi-scale features, especially small target defect features.

[0044] It should be noted that, in this embodiment, the module aims to improve the model's ability to extract multi-scale features, especially small target features. Unlike traditional convolutional layers that only operate in the spatial domain, the multi-scale wavelet attention module uses discrete wavelet transform to decompose the input features into complementary sub-bands and combines a dual attention mechanism to enhance the representation of key features.

[0045] Multi-scale wavelet convolution feature extraction: The input feature map is decomposed using discrete wavelet transform to generate four sub-bands (LL, LH, HL, HH):

[0046]

[0047]

[0048]

[0049] in, and These represent the scaling function and the wavelet function, respectively. ↓2 indicates the downsampling operation here. This is a low-frequency approximate sub-band, which mainly preserves the macroscopic structural information of the image; , , These are high-frequency detail sub-bands, capturing horizontal, vertical, and diagonal details respectively.

[0050]

[0051] in, This is a general symbol referring to any DWT output sub-band, and its value range is... ; and In This indicates the size of the convolution kernel.

[0052] Enhanced dual attention mechanism: Channel attention: Global average pooling and max pooling are performed on features at each scale, and the outputs are processed by a multilayer perceptron with shared weights. The sum of the outputs is then passed through a sigmoid activation function to generate channel weights, which are used to emphasize information-rich feature channels.

[0053]

[0054] in, , For learnable weight matrix, For average pooling, For max pooling, This represents the Sigmoid activation function.

[0055] Spatial attention: The pooled features are concatenated along the channel dimension, and a spatial weight map is generated through a convolutional layer to highlight the spatial regions where defects may occur.

[0056]

[0057] in, For a convolution with a kernel of 7, For average pooling, For max pooling, This represents the Sigmoid activation function, and [;] represents the channel concatenation operation.

[0058] Overall workflow of multi-scale wavelet attention module: Based on the theoretical foundation of discrete wavelet transform and attention mechanism, the multi-scale wavelet attention module adopts a dual-path structure to process input features:

[0059]

[0060]

[0061] in, This represents a combined operation of convolution, batch normalization, and the SiLU activation function. Subsequently, the outputs of the two branches are merged by concatenation and residual connection:

[0062]

[0063] Where LN represents layer normalization operation; [ ; ] represents channel splicing operation.

[0064] By combining frequency domain decomposition with a dual attention mechanism, the multi-scale wavelet attention module effectively enhances the representation capability of small-sized and subtle defects, which is beneficial for industrial inspection scenarios in complex environments.

[0065] The neck network performs upsampling, downsampling, and feature concatenation on feature maps of different scales output by the backbone network to achieve effective fusion of deep and shallow features, thereby constructing a multi-scale feature pyramid with both high semantic information and fine spatial details, providing higher quality feature input for subsequent detection heads.

[0066] It should be noted that, in this embodiment, as Figure 8 As shown, the defect detection model also includes a detection head network; The detection head network includes a first detection unit, a second detection unit, and a third detection unit arranged in parallel. The output terminals of the third, fourth, and fifth C3k2-MSFB modules are respectively connected to the input terminals of the first, second, and third detection units.

[0067] The decoupled detection heads perform convolution operations on the feature maps output by the neck network to independently predict the target's category confidence, targetability score, and bounding box coordinates.

[0068] Based on the actual defect location boxes and predicted defect location boxes of the industrial product image, a total loss function is constructed, and the defect detection model is trained to obtain a trained defect detection model. It should be noted that, in this embodiment, the total loss function is expressed as follows:

[0069] in, , , These are the weighting coefficients for different loss terms. For classifying losses, For targeted losses; The The formula for calculating the loss is:

[0070] in, Indicates the center point of the prediction box Center point of the real frame The square of the Euclidean distance between them; Represents the diagonal length of the smallest enclosing rectangle that covers both the predicted and actual bounding boxes; This is a measure of the consistency of aspect ratio between the predicted bounding box and the ground truth bounding box, and the calculation formula is:

[0071] in, The actual height of the bounding box. The width of the actual bounding box. The height of the predicted bounding box, The width of the prediction box; It is a weighting factor used to balance aspect ratio consistency terms. The influence of is dynamically determined by the following formula:

[0072] The calculation formula is:

[0073] in, It is the area of ​​the intersection of the two inner boxes. It is the area of ​​the union of the two inner boxes.

[0074] By constructing an auxiliary inner bounding box and calculating its intersection-union ratio (IoU_inner), the alignment of the target's internal regions is focused on, thereby providing more accurate regression gradients in complex industrial scenarios and effectively improving positioning accuracy.

[0075] It should be noted that, in this embodiment, the core idea of ​​the loss function is: By pre-setting a scaling factor ( According to the real frame and prediction boxes Generate auxiliary inner bounding boxes for width and height:

[0076] Calculate the IoU (Intersection over Union) of the original bounding box and the auxiliary interior bounding box. :

[0077]

[0078]

[0079]

[0080] in, It is the area of ​​the intersection of the two inner boxes. It is the area of ​​the union of the two inner boxes.

[0081] The defect detection model is trained by inputting the image of the industrial product to be detected, and the defect detection result of the image of the industrial product is obtained.

[0082] Example 3 This embodiment provides an industrial product defect detection system based on state space and frequency domain attention, used to implement the industrial product defect detection method based on state space and frequency domain attention described in Embodiment 1 or 2, such as... Figure 9 As shown, it includes: The data acquisition module is used to acquire a dataset, which includes several images of industrial products and their actual defect location boxes. The preprocessing module is used to preprocess each industrial product image in the dataset to obtain a preprocessed dataset. The data prediction module is used to input the preprocessed dataset into the constructed defect detection model to obtain the predicted defect location box for each industrial product image. The network training module is used to construct a total loss function based on the actual defect location boxes and predicted defect location boxes of the industrial product image, and to train the defect detection model to obtain a trained defect detection model. The detection module is used to input the image of the industrial product to be detected into the trained defect detection model and obtain the defect detection result of the image of the industrial product to be detected.

[0083] The same or similar labels correspond to the same or similar parts; The terms used to describe positional relationships in the accompanying drawings are for illustrative purposes only and should not be construed as limiting this patent. Obviously, the above embodiments of the present invention are merely examples for clearly illustrating the present invention, and are not intended to limit the implementation of the present invention. Those skilled in the art can make other variations or modifications based on the above description. It is neither necessary nor possible to exhaustively describe all embodiments here. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the scope of protection of the claims of the present invention.

Claims

1. A method for detecting defects in industrial products based on state space and frequency domain attention, characterized in that, include: Obtain a dataset, which includes several images of industrial products and their actual defect location boxes; Each industrial product image in the dataset is preprocessed to obtain a preprocessed dataset; The preprocessed dataset is input into the constructed defect detection model to obtain the predicted defect localization box for each industrial product image. Based on the actual defect location boxes and predicted defect location boxes of the industrial product image, a total loss function is constructed, and the defect detection model is trained to obtain a trained defect detection model. The defect detection model is trained by inputting the image of the industrial product to be detected, and the defect detection result of the image of the industrial product is obtained.

2. The industrial product defect detection method based on state space and frequency domain attention according to claim 1, characterized in that, The defect detection model includes a backbone network; The backbone network includes a first convolutional unit, a second convolutional unit, a first C3k2 module, a third convolutional unit, a second C3k2 module, a fourth convolutional network, a third C3k2 module, a fifth convolutional unit, a first C3k2-MSFB module, an SPPF module, a C2PSA module, and a multi-scale wavelet attention module, all connected in sequence.

3. The industrial product defect detection method based on state space and frequency domain attention according to claim 2, characterized in that, The defect detection model also includes a neck network; The neck network includes a first downsampling unit, a second Concat unit, a second C3k2-MSFB module, a second downsampling unit, a third Concat unit, a third C3k2-MSFB module, an eighth convolution unit, a fourth Concat unit, a fourth C3k2-MSFB module, a ninth convolution unit, a fifth Concat unit, and a fifth C3k2-MSFB module connected in sequence. The output of the multi-scale wavelet attention module is connected to the input of the first downsampling unit and the input of the fifth Concat unit, respectively. The output of the third C3k2 module is connected to the input of the second Concat unit; The output of the second C3k2 module is connected to the input of the third Concat unit.

4. The industrial product defect detection method based on state space and frequency domain attention according to claim 3, characterized in that, The first, second, third, fourth, and fifth C3k2-MSFB modules have the same structure, each including a sixth convolutional unit, a split layer, a preset number of MSFB components, a first concat unit, and a seventh convolutional unit connected in sequence. The output of the Split layer is also connected to the input of the first Concat unit.

5. The industrial product defect detection method based on state space and frequency domain attention according to claim 4, characterized in that, The MSFB component includes a first CBS module, a feedforward network unit, an MCB module, a first connection point, a second CBS module, and a second connection point connected in sequence. The output of the first CBS module is also connected to the input of the second connection point; The output of the feedforward network unit is also connected to the input of the first connection point.

6. The industrial product defect detection method based on state space and frequency domain attention according to claim 5, characterized in that, The MCB module includes a first normalization layer, a first linear layer, a first depthwise separable convolutional layer, a third CBS module, a second linear layer, a second depthwise separable convolutional layer, an SS2D module, and a third connection point; The first normalization layer, the first linear layer, the first depthwise separable convolutional layer, the third CBS module, the second linear layer, and the third connection point are connected in sequence. The second depth-separable convolutional layer and the SS2D module are connected sequentially; The output of the SS2D module is also connected to the input of the third connection point; The input of the first normalized layer is also connected to the input of the third connection point and the input of the second depth separable convolutional layer.

7. The industrial product defect detection method based on state space and frequency domain attention according to claim 6, characterized in that, The multi-scale wavelet attention module includes a first wavelet transform convolutional unit, a channel attention unit, a fourth connection point, a spatial attention unit, a fifth connection point, a channel connection point, a fourth CBS module, a sixth connection point, a second normalization layer, a fifth CBS module, a second wavelet transform convolutional unit, a third wavelet transform convolutional unit, and a seventh connection point. The first wavelet transform convolutional unit, channel attention unit, fourth connection point, spatial attention unit, fifth connection point, channel connection point, fourth CBS module, sixth connection point, and second normalization layer are connected sequentially. The output of the first wavelet transform convolution unit is also connected to the input of the fourth connection point, the input of the sixth connection point, and the input of the fifth CBS module, respectively. The output of the fourth connection point is also connected to the input of the fifth connection point; The output of the fifth CBS module is connected to the input of the second wavelet transform convolution unit and the third wavelet transform convolution unit, respectively. The outputs of the second wavelet transform convolutional unit and the third wavelet transform convolutional unit are connected to the input of the seventh connection point; The output of the seventh connection point is connected to the input of the channel connection point.

8. The industrial product defect detection method based on state space and frequency domain attention according to claim 7, characterized in that, The defect detection model also includes a detection head network; The detection head network includes a first detection unit, a second detection unit, and a third detection unit arranged in parallel. The output terminals of the third, fourth, and fifth C3k2-MSFB modules are respectively connected to the input terminals of the first, second, and third detection units.

9. The industrial product defect detection method based on state space and frequency domain attention according to claim 1, characterized in that, The total loss function is expressed as follows: in, , , These are the weighting coefficients for different loss terms. For classifying losses, For targeted losses; The The formula for calculating the loss is: in, Indicates the center point of the prediction box Center point of the real frame The square of the Euclidean distance between them; Represents the diagonal length of the smallest enclosing rectangle that covers both the predicted and actual bounding boxes; This is a measure of the consistency of aspect ratio between the predicted bounding box and the ground truth bounding box, and the calculation formula is: in, The actual height of the bounding box. The width of the actual bounding box. The height of the predicted bounding box, The width of the prediction box; It is a weighting factor used to balance aspect ratio consistency terms. The influence of is dynamically determined by the following formula: The calculation formula is: in, It is the area of ​​the intersection of the two inner boxes. It is the area of ​​the union of the two inner boxes.

10. An industrial product defect detection system based on state space and frequency domain attention, used to implement the industrial product defect detection method based on state space and frequency domain attention as described in claims 1-9, characterized in that, include: The data acquisition module is used to acquire a dataset, which includes several images of industrial products and their actual defect location boxes. The preprocessing module is used to preprocess each industrial product image in the dataset to obtain a preprocessed dataset. The data prediction module is used to input the preprocessed dataset into the constructed defect detection model to obtain the predicted defect location box for each industrial product image. The network training module is used to construct a total loss function based on the actual defect location boxes and predicted defect location boxes of the industrial product image, and to train the defect detection model to obtain a trained defect detection model. The detection module is used to input the image of the industrial product to be detected into the trained defect detection model and obtain the defect detection result of the image of the industrial product to be detected.