A surface defect detection method based on frequency domain enhancement and multi-layer attention cooperation

By employing frequency domain enhancement and multi-layer attention collaboration, the shortcomings of the YOLOv11 model in detecting small-scale, weakly textured defects are addressed, improving detection accuracy and robustness, making it suitable for industrial metal surface defect detection.

CN122134639APending Publication Date: 2026-06-02UNIV OF SCI & TECH BEIJING

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
UNIV OF SCI & TECH BEIJING
Filing Date
2026-02-03
Publication Date
2026-06-02

AI Technical Summary

Technical Problem

The existing YOLOv11 model has insufficient early feature representation ability and inadequate multi-scale feature fusion when detecting small-scale and weak-texture defects on industrial metal surfaces. The input image has limited ability to express high-frequency detail information, resulting in insufficient detection accuracy and robustness.

Method used

Frequency domain enhancement is used to highlight high-frequency details caused by defects, and a multi-layer attention mechanism is introduced in the feature extraction and fusion stage, including channel attention, spatial attention and scale-aware attention modules, to enhance the expression of defect features.

Benefits of technology

It improves the accuracy and positioning of small-scale defect detection, enhances the robustness of detection in complex backgrounds, and achieves high-precision detection of small targets and weak texture defects.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122134639A_ABST
    Figure CN122134639A_ABST
Patent Text Reader

Abstract

This invention discloses a surface defect detection method based on frequency domain enhancement and multi-layer attention collaboration, belonging to the field of computer vision. The method involves performing Fast Fourier Transform (FFT) frequency domain enhancement processing on industrial metal surface images during the input stage; introducing differentiated attention mechanisms for different scale feature layers in the backbone feature extraction network; utilizing channel attention in shallow features to focus on enhancing semantic channels highly relevant to small-scale defect discrimination; employing spatial attention in mid-level features to highlight the spatial saliency of defect regions; and introducing a scale-aware attention module in the neck feature fusion stage to adaptively perceive and weight the overall response intensity of the feature maps participating in multi-scale fusion. This invention effectively avoids the problem of weakening key scale information during multi-scale feature fusion, improves the consistency and discrimination ability of multi-scale feature fusion results in representing defect targets, and achieves an overall improvement in the performance of industrial surface defect target detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to a surface defect detection method based on frequency domain enhancement and multi-layer attention collaboration, belonging to the field of computer vision. (Corresponding International Patent Classification IPC: G06T 7 / 00 Image Analysis G06N 3 / 08 (Neural Network Model)) Background Technology

[0002] With the continuous development of industrial automation and intelligent manufacturing technologies, the requirements for surface quality inspection of metal materials during processing and manufacturing are becoming increasingly stringent. Industrial metal surfaces are prone to various defects such as pinholes, scratches, abrasions, and cracks during production, transportation, and processing. These defects are typically characterized by small size, low contrast, indistinct texture features, and irregular shapes, and often overlap with complex background textures, posing a significant challenge to accurate defect identification and location. Traditional inspection methods relying on manual experience or fixed rules are ill-suited to the complex and ever-changing industrial environment, exhibiting poor stability and consistency, and are no longer sufficient to meet the demands for high-efficiency, high-precision automated inspection.

[0003] In recent years, with the development of deep learning technology, object detection methods based on convolutional neural networks have been widely used in the field of industrial surface defect detection. Among them, the YOLO (You Only Look Once) series of models, due to their end-to-end network structure and high detection efficiency, are widely used in industrial vision inspection scenarios with high real-time requirements. The newly proposed YOLOv11 model introduces the C3k2 structure and C2PSA module in its network structure design, which improves the model's feature representation ability and inference efficiency to a certain extent, and has good potential for engineering applications.

[0004] However, in practical applications targeting industrial metal surface defects, it has been found that the existing YOLOv11 model still has certain limitations, mainly in the following aspects: First, it lacks the ability to represent early features of small-scale, weakly textured defects. The attention mechanism of the existing YOLOv11 mainly operates in the mid-to-high-level feature representation stage of the network, while the shallow feature extraction process still mainly relies on conventional convolution operations, which makes it difficult to fully highlight the local high-frequency change features caused by subtle defects. This results in the problem of information weakening of small target defects in the early stage of feature extraction. Secondly, the spatial and scale information is not fully utilized in the multi-scale feature fusion process. Existing feature pyramid structures usually fuse features at different scales by direct splicing or summation, lacking an adaptive modeling mechanism for the importance of features at each scale. This can easily cause small-scale defect features to be masked by high-level semantic features during multi-scale fusion, thus affecting detection accuracy. Third, the input image has limited ability to represent subtle high-frequency defect information. Existing methods mostly focus on data augmentation or feature learning in the spatial domain, failing to fully explore the potential advantages of frequency domain information in representing high-frequency features such as abrupt edge changes and subtle texture variations, thus limiting the ability to discriminate weak texture defects.

[0005] Therefore, there is an urgent need for an industrial surface defect detection method that can synergistically enhance feature representation capabilities from multiple levels, such as frequency domain enhancement, feature extraction, and multi-scale fusion, in order to effectively improve the detection accuracy, localization accuracy, and robustness of detection in complex industrial scenarios for small-scale, weakly textured defect targets. Summary of the Invention

[0006] Purpose of the invention

[0007] The purpose of this invention is to provide a surface defect detection method based on frequency domain enhancement and multi-layer attention collaboration, so as to solve the problem of insufficient detection accuracy for small-scale, weak-texture defects in industrial metal surface defect detection scenarios in the prior art.

[0008] Technical solution

[0009] This invention proposes a surface defect detection method based on frequency domain enhancement and multi-layer attention collaboration, which addresses the problem of the difficulty in effectively representing small targets and weak texture defects on industrial metal surfaces. By introducing differentiated attention mechanisms at different stages of feature extraction and feature fusion, the method achieves collaborative enhancement of defect detail features and multi-scale semantic information.

[0010] A surface defect detection method based on frequency domain enhancement and multi-layer attention synergy, characterized in that the detection method includes the following steps: S1: Acquire an image of the industrial metal surface to be inspected, perform Fast Fourier Transform (FFT) processing on the image, and enhance the high-frequency components in the frequency domain to highlight edge abrupt changes, subtle texture variations, and local structural anomalies caused by defects in the image; then, restore the enhanced frequency domain information to the spatial domain through inverse Fourier transform to obtain the frequency-enhanced input image; through the above frequency domain enhancement processing, the high-frequency detail information related to small-scale defects and weak texture defects is strengthened before network feature extraction, providing a more discriminative underlying representation for subsequent deep feature learning; S2: Input the frequency domain enhanced image processed in step S1 into the backbone feature extraction network of YOLOv11, and extract multi-scale feature maps through multi-layer convolution and continuous downsampling operations to obtain feature representations at different spatial resolutions; S3: To address the differences in spatial resolution and semantic information between feature layers of different scales, a differentiated attention enhancement strategy is introduced into the multi-scale feature layers output by the YOLOv11 backbone network to achieve targeted enhancement of defect-related features. S4: Input the multi-scale feature map after attention enhancement in step S3 into the neck feature fusion network of YOLOv11. In the multi-scale fusion process of top-down and bottom-up feature pyramids, design and introduce a scale-aware attention module (SAA) and set it at the feature fusion nodes of P3, P4 and P5 respectively. S5: Based on the multi-scale fusion features modulated by the scale-aware attention mechanism, the YOLOv11 detection head classifies and regresses the features, outputting the category information and corresponding location information of industrial metal surface defect targets, realizing high-precision detection of small targets and weak texture defects.

[0011] Further, in step S1, the frequency domain enhancement process includes: (1) Let the input image be... Perform a two-dimensional Fourier transform on it to obtain its frequency domain representation:

[0012] in, For frequency coordinates, The imaginary unit; (2) Weighted enhancement of high-frequency components in the frequency domain to highlight edge and fine texture information: First, define the normalized frequency radius: , ; Based on the high and low frequency boundary thresholds, construct a segmented frequency weighting function:

[0013] in, , which is the high-frequency gain coefficient, enhances the edge of the defect; , which is the low-frequency suppression coefficient, reduces background interference; The cutoff radius is used to control the "small target scale"; We obtain the following by weighting the frequency domain functions:

[0014] (3) The enhanced frequency domain features are restored to the spatial domain by inverse Fourier transform to generate a frequency domain enhanced image. :

[0015] Finally, residual fusion is used to avoid "over-enhancement":

[0016] in, This is the residual weight, used to control the enhancement intensity and prevent over-enhancement of texture.

[0017] Further, step S2 includes

[0018] The P2 feature layer obtained after the second downsampling; The P3 feature layer was obtained after the third downsampling. The P4 feature layer was obtained after the fourth downsampling. The P5 feature layer obtained after the fifth downsampling; Among them, the P2 and P3 feature layers have high spatial resolution and are mainly used to characterize the local details of small-scale defects; the P4 and P5 feature layers have stronger semantic expressive power and are used to describe the overall structural features of defects.

[0019] Furthermore, in step S3: to address the differences in spatial resolution and semantic information between feature layers of different scales, a differentiated attention enhancement strategy is introduced into the multi-scale feature layers output by the YOLOv11 backbone network to achieve targeted enhancement of defect-related features.

[0020] Furthermore, the strengthening described in step S3 specifically includes: (1) Introduce a channel attention mechanism (CA) in the P2 feature layer. By modeling the global response intensity of the channel dimension, the weight distribution of each semantic channel is adaptively adjusted, thereby enhancing the channel features that are highly related to the discrimination of small target defects and suppressing redundant background responses. (2) Introduce spatial attention (SA) mechanism in the P3 feature layer. By learning the saliency distribution relationship of different spatial locations in the feature map, the spatial response of the mesoscale defect area and its surrounding structural anomalies is highlighted, thereby improving the network’s sensitivity to the localization of defect areas. (3) By introducing the above-mentioned differential attention mechanism in the backbone network stage, the defect details after frequency domain enhancement are effectively preserved and enhanced in the early feature representation.

[0021] Furthermore, in step S3: (1) The calculation steps of the CA attention mechanism module are as follows: Assuming the input feature map ,in The number of channels output by the C3k2 module in layer P2. and These represent the height and width of the intermediate feature map, respectively.

[0022] First, perform a global average pooling operation in the spatial dimension:

[0023] in, Indicates the spatial position of the c-th channel. The characteristic response; this operation compresses the two-dimensional feature map into a one-dimensional channel description vector. Let represent the global average response of the c-th channel, and .

[0024] Subsequently, the channel description vector The sequence is treated as a one-dimensional sequence along the channel dimension and input into a one-dimensional convolutional layer to model the local interaction between adjacent channels. The importance weight vector for each channel is generated by the sigmoid function. ,

[0025] in, This represents a one-dimensional convolution operation with a kernel size of k; the kernel size k is a preset odd constant used to limit the local receptive field range of channel interaction. This represents the Sigmoid function, which constrains the weights to (0,1).

[0026] Finally, the channel weights Applying to the original feature map, adaptive recalibration along the channel dimension is achieved: ,

[0027] in, This represents a one-dimensional channel attention feature vector, where each element is the channel weight corresponding to the c-th channel; " indicates element-wise multiplication; This represents the feature map enhanced by the channel attention mechanism, and its dimension is the same as that of the input feature map.

[0028] CA in S3 can enhance features such as small targets and weak texture defects, and suppress redundant features such as background.

[0029] Furthermore, in step S3: (2) The calculation steps of the SA attention mechanism module are as follows: Assuming the input feature map ,in This refers to the number of channels output by the C3k2 module in layer P3. and These represent the height and width of the intermediate feature map, respectively. First, statistical modeling is performed on the features along the channel dimension to highlight the spatial salience of the defect region. Specifically, average pooling and max pooling operations are performed on the input feature map along the channel dimension C.

[0030]

[0031] in, Indicates the spatial position of the c-th channel. The characteristic response; This is the channel average response feature map, used to characterize the overall response trend; This is the maximum response feature map of the channel, used to characterize the activation of local salient features; Subsequently, the two spatial feature maps are concatenated along the channel dimension to obtain: ,

[0032] in, This indicates that a splicing operation is performed along the channel dimension; The concatenated feature maps are convolved with a 7×7 2D convolutional layer, and a spatial attention weight map is generated using the sigmoid function. ,

[0033] Represents a 2D 7×7 convolution; This represents the Sigmoid function, with the weights constrained to (0,1). Finally, the spatial attention weight map is applied element-wise to the original input feature map to obtain the spatially augmented feature representation: ,

[0034] in, For spatial location Attention weights at each location; " indicates element-wise multiplication; This represents the feature map after spatial attention enhancement, whose dimension is the same as the input feature map.

[0035] Furthermore, the scale-aware attention module described in step S4 senses the global response intensity of feature maps at different scales and generates corresponding scale weight coefficients to adaptively weight the multi-scale features participating in the fusion, thereby dynamically adjusting the contribution ratio of features at different scales in the fusion stage and preventing small target defect features from being submerged by high-level semantic features during the multi-scale fusion process.

[0036] Further, in step S4, the calculation steps of the SAA attention mechanism module are as follows: Suppose that at a certain scale level (P3, P4, or P5) in the feature pyramid, the fused feature map obtained by feature concatenation is as follows: ,in Indicates batch size, This represents the number of channels in the feature map. and These represent the spatial height and width of the feature map, respectively. First, the fused feature map Perform global average pooling to obtain the overall response of each channel in the spatial dimension:

[0037] in, Indicates the spatial position of the c-th channel. The characteristic response; Let represent the global average activation response of the c-th channel, and ; Subsequently, to characterize the overall semantic response strength of the feature map at the current scale, an averaging operation is performed on the channel dimensions to obtain the scale descriptor: ,

[0038] in, It is a scale descriptor in scalar form, used to represent the overall response strength of the current scale feature in the input sample; scale descriptor Input a lightweight linear mapping layer and generate scale attention weights using the Sigmoid function: ,

[0039] in, For learnable linear mapping parameters, For the Sigmoid function, The attention weight scalar; Finally, the scale attention weights Applying this to the original fused feature map to achieve scale-level feature modulation, we obtain: ,

[0040] in, This represents the feature map enhanced by the scale-aware attention mechanism, and its dimension is the same as that of the input feature map.

[0041] Beneficial effects

[0042] Compared with existing technologies, the surface defect detection method based on frequency domain enhancement and multi-layer attention synergy proposed in this invention has the following advantages: (1) By performing fast Fourier transform frequency domain enhancement processing on industrial metal surface images during the input stage, the high-frequency details and edge response features caused by defects are effectively enhanced, and the salience and distinguishability of small target defects and weak texture defects at the input data level are improved, providing more sufficient discrimination information for subsequent deep feature extraction. (2) By introducing a differentiated attention mechanism for feature layers of different scales in the backbone feature extraction network, channel attention is used in the shallow features to focus on enhancing the semantic channels that are highly related to the discrimination of small-scale defects, and spatial attention is used in the middle features to highlight the spatial saliency of the defect area, thereby effectively improving the network’s feature representation ability for small-scale defects and structurally abnormal areas. (3) By introducing a scale-aware attention module in the neck feature fusion stage, the overall response intensity of the feature map participating in multi-scale fusion is adaptively perceived and weighted, which effectively avoids the problem of key scale information being weakened in the multi-scale feature fusion process and improves the consistency and discrimination ability of the multi-scale feature fusion results for defect targets. (4) Under the synergistic effect of the above technical solutions, the overall performance of industrial surface defect target detection has been improved, especially in terms of defect target positioning accuracy, detection stability and robustness under complex background conditions. Attached Figure Description

[0043] Figure 1 This is a schematic diagram of the overall structure of an industrial surface defect detection system; Figure 2 This is a schematic diagram of the frequency domain enhancement module (FFT). Figure 3 This is a schematic diagram of the Channel Attention Module (CA) structure; Figure 4 This is a schematic diagram of the spatial attention module (SA). Figure 5 This is a schematic diagram of the scale-aware attention module (SAA). Detailed Implementation

[0044] Taking online detection of surface defects on aluminum sheets in industrial production lines as an application scenario, the specific implementation process of the method of the present invention includes the following steps: S1: On the industrial production line, a high-resolution industrial camera is used to continuously acquire images of the aluminum sheet surface. The industrial camera is fixedly installed at a key inspection station on the production line. By reasonably configuring the lens focal length, exposure time, and light source illumination conditions, clear and stable raw image data of the aluminum sheet surface are obtained to ensure the observability of minute defect areas.

[0045] The acquired aluminum sheet surface images, after being normalized to a uniform size and preprocessed, are used as input data for subsequent defect detection models.

[0046] S2: To address the issues of small surface defect size, low contrast, and indistinct edge information on aluminum sheets, the original image obtained in step S1 undergoes frequency domain enhancement processing. Specifically, the input image is processed using Fast Fourier Transform (FFT), and high-frequency components are enhanced in the frequency domain to highlight edge abrupt changes, subtle texture variations, and local structural anomalies caused by defects. Subsequently, the enhanced frequency domain information is restored to the spatial domain using Inverse Fourier Transform, resulting in the frequency-enhanced input image. Through this frequency domain enhancement processing, high-frequency detail information related to small-scale and weak-texture defects is strengthened before network feature extraction, providing a more discriminative underlying representation for subsequent deep feature learning.

[0047] The frequency domain enhancement process includes: (1) Let the input image be... Perform a two-dimensional Fourier transform on it to obtain its frequency domain representation:

[0048] in, For frequency coordinates, The imaginary unit; (2) Weighted enhancement of high-frequency components in the frequency domain to highlight edge and fine texture information: First, define the normalized frequency radius: , ; Based on the high and low frequency boundary thresholds, construct a segmented frequency weighting function:

[0049] in, , which is the high-frequency gain coefficient, enhances the edge of the defect; , which is the low-frequency suppression coefficient, reduces background interference; The cutoff radius is used to control the "small target scale"; We obtain the following by weighting the frequency domain functions:

[0050] (3) The enhanced frequency domain features are restored to the spatial domain by inverse Fourier transform to generate a frequency domain enhanced image. :

[0051] Finally, residual fusion is used to avoid "over-enhancement":

[0052] in, This is the residual weight, used to control the enhancement intensity and prevent over-enhancement of texture.

[0053] S3: Input the frequency domain enhanced image processed in step S2 into the backbone feature extraction network of YOLOv11, and extract multi-scale feature maps through multi-layer convolution and continuous downsampling operations to obtain feature representations at different spatial resolutions.

[0054] The P2 feature layer obtained after the second downsampling; The P3 feature layer was obtained after the third downsampling. The P4 feature layer was obtained after the fourth downsampling. The P5 feature layer obtained after the fifth downsampling; Among them, the P2 and P3 feature layers have high spatial resolution and are mainly used to characterize the local details of small-scale defects; the P4 and P5 feature layers have stronger semantic expressive power and are used to describe the overall structural features of defects.

[0055] S4: To address the differences in spatial resolution and semantic information between feature layers of different scales, a differentiated attention enhancement strategy is introduced into the multi-scale feature layers output by the YOLOv11 backbone network to achieve targeted enhancement of defect-related features.

[0056] The enhancement specifically includes: (1) Introduce a channel attention mechanism (CA) in the P2 feature layer. By modeling the global response intensity of the channel dimension, the weight distribution of each semantic channel is adaptively adjusted, thereby enhancing the channel features that are highly related to the discrimination of small target defects and suppressing redundant background responses. (2) Introduce spatial attention (SA) mechanism in the P3 feature layer. By learning the saliency distribution relationship of different spatial locations in the feature map, the spatial response of the mesoscale defect area and its surrounding structural anomalies is highlighted, thereby improving the network’s sensitivity to the localization of defect areas. (3) By introducing the above-mentioned differential attention mechanism in the backbone network stage, the defect details after frequency domain enhancement are effectively preserved and enhanced in the early feature representation.

[0057] In step S4: (1) The calculation steps of the CA attention mechanism module are as follows: Assuming the input feature map ,in The number of channels output by the C3k2 module in layer P2. and These represent the height and width of the intermediate feature map, respectively.

[0058] First, perform a global average pooling operation in the spatial dimension:

[0059] in, Indicates the spatial position of the c-th channel. The characteristic response; this operation compresses the two-dimensional feature map into a one-dimensional channel description vector. Let represent the global average response of the c-th channel, and .

[0060] Subsequently, the channel description vector The sequence is treated as a one-dimensional sequence along the channel dimension and input into a one-dimensional convolutional layer to model the local interaction between adjacent channels. The importance weight vector for each channel is generated by the sigmoid function. ,

[0061] in, This represents a one-dimensional convolution operation with a kernel size of k; the kernel size k is a preset odd constant used to limit the local receptive field range of channel interaction. This represents the Sigmoid function, which constrains the weights to (0,1).

[0062] Finally, the channel weights Applying to the original feature map, adaptive recalibration along the channel dimension is achieved: ,

[0063] in, This represents a one-dimensional channel attention feature vector, where each element is the channel weight corresponding to the c-th channel; " indicates element-wise multiplication; This represents the feature map enhanced by the channel attention mechanism, and its dimension is the same as that of the input feature map.

[0064] CA in S4 can enhance features such as small targets and weak texture defects, and suppress redundant features such as background.

[0065] (2) The calculation steps of the SA attention mechanism module are as follows: Assuming the input feature map ,in This refers to the number of channels output by the C3k2 module in layer P3. and These represent the height and width of the intermediate feature map, respectively. First, statistical modeling is performed on the features along the channel dimension to highlight the spatial salience of the defect region. Specifically, average pooling and max pooling operations are performed on the input feature map along the channel dimension C.

[0066]

[0067] in, Indicates the spatial position of the c-th channel. The characteristic response; This is the channel average response feature map, used to characterize the overall response trend; This is the maximum response feature map of the channel, used to characterize the activation of local salient features; Subsequently, the two spatial feature maps are concatenated along the channel dimension to obtain: ,

[0068] in, This indicates that a splicing operation is performed along the channel dimension; The concatenated feature maps are convolved with a 7×7 2D convolutional layer, and a spatial attention weight map is generated using the sigmoid function. ,

[0069] Represents a 2D 7×7 convolution; This represents the Sigmoid function, with the weights constrained to (0,1). Finally, the spatial attention weight map is applied element-wise to the original input feature map to obtain the spatially augmented feature representation: ,

[0070] in, For spatial location Attention weights at each location; " indicates element-wise multiplication; This represents the feature map after spatial attention enhancement, whose dimension is the same as the input feature map.

[0071] S5: Input the multi-scale feature map after attention enhancement in step S4 into the neck feature fusion network of YOLOv11. In the multi-scale fusion process of top-down and bottom-up feature pyramids, a scale-aware attention module (SAA) is designed and introduced, and set at the feature fusion nodes of P3, P4 and P5 respectively.

[0072] The scale-aware attention module described in step S5 senses the global response intensity of feature maps at different scales and generates corresponding scale weight coefficients. These coefficients are used to adaptively weight the multi-scale features participating in the fusion, thereby dynamically adjusting the contribution ratio of different scale features in the fusion stage and preventing small target defect features from being submerged by high-level semantic features during the multi-scale fusion process.

[0073] The calculation steps of the SAA attention mechanism module are as follows: Suppose that at a certain scale level (P3, P4, or P5) in the feature pyramid, the fused feature map obtained by feature concatenation is as follows: ,in Indicates batch size, This represents the number of channels in the feature map. and These represent the spatial height and width of the feature map, respectively. First, the fused feature map Perform global average pooling to obtain the overall response of each channel in the spatial dimension:

[0074] in, Indicates the spatial position of the c-th channel. The characteristic response; Let represent the global average activation response of the c-th channel, and ; Subsequently, to characterize the overall semantic response strength of the feature map at the current scale, an averaging operation is performed on the channel dimensions to obtain the scale descriptor: ,

[0075] in, It is a scale descriptor in scalar form, used to represent the overall response strength of the current scale feature in the input sample; scale descriptor Input a lightweight linear mapping layer and generate scale attention weights using the Sigmoid function: ,

[0076] in, For learnable linear mapping parameters, For the Sigmoid function, The attention weight scalar; Finally, the scale attention weights Applying this to the original fused feature map to achieve scale-level feature modulation, we obtain: ,

[0077] in, This represents the feature map enhanced by the scale-aware attention mechanism, and its dimension is the same as that of the input feature map.

[0078] By adaptively modeling the response intensity of multi-scale features, the SAA mechanism can highlight feature layer information that is more sensitive to the detection of small-scale defects, while suppressing the interference of irrelevant scale features, thereby improving the effectiveness of multi-scale feature fusion and enhancing the network's ability to detect defects of different sizes, especially small-scale defects.

[0079] S6: The features after multi-layer attention enhancement and scale fusion are input into the detection head of YOLOv11 to complete the category identification and location information regression of defects on the aluminum sheet surface. Finally, the category label of the defect and the corresponding bounding box coordinates are output to realize the automatic detection of defects on the aluminum sheet surface.

[0080] Experimental results show that, compared with the YOLOv11 model without frequency domain enhancement and multi-layer attention mechanism, the method of the present invention can significantly improve the detection accuracy and recall of small-scale defects on aluminum sheet surfaces in complex industrial backgrounds, and has stronger robustness and engineering application value, making it suitable for online quality inspection scenarios in industrial production lines.

Claims

1. A surface defect detection method based on frequency domain enhancement and multi-layer attention synergy, characterized in that, The detection method includes the following steps: S1: Acquire an image of the industrial metal surface to be inspected, perform Fast Fourier Transform (FFT) processing on the image, and enhance the high-frequency components in the frequency domain to highlight the edge abrupt changes, subtle texture changes and local structural anomalies caused by defects in the image. Subsequently, the enhanced frequency domain information is restored to the spatial domain through inverse Fourier transform to obtain the frequency domain enhanced input image. Through the above frequency domain enhancement processing, the high-frequency detail information related to small-scale defects and weak texture defects is enhanced before network feature extraction, providing a more discriminative underlying representation for subsequent deep feature learning. S2: Input the frequency domain enhanced image processed in step S1 into the backbone feature extraction network of YOLOv11, and extract multi-scale feature maps through multi-layer convolution and continuous downsampling operations to obtain feature representations at different spatial resolutions; S3: To address the differences in spatial resolution and semantic information between feature layers of different scales, a differentiated attention enhancement strategy is introduced into the multi-scale feature layers output by the YOLOv11 backbone network to achieve targeted enhancement of defect-related features. S4: Input the multi-scale feature map after attention enhancement in step S3 into the neck feature fusion network of YOLOv11. In the multi-scale fusion process of top-down and bottom-up feature pyramids, design and introduce a scale-aware attention module (SAA) and set it at the feature fusion nodes of P3, P4 and P5 respectively. S5: Based on the multi-scale fusion features modulated by the scale-aware attention mechanism, the YOLOv11 detection head classifies and regresses the features, outputting the category information and corresponding location information of industrial metal surface defect targets, realizing high-precision detection of small targets and weak texture defects.

2. The surface defect detection method based on frequency domain enhancement and multi-layer attention synergy according to claim 1, characterized in that, In step S1, the frequency domain enhancement process includes: (1) Let the input image be... Perform a two-dimensional Fourier transform on it to obtain its frequency domain representation: in, For frequency coordinates, The imaginary unit; (2) Weighted enhancement of high-frequency components in the frequency domain to highlight edge and fine texture information: First, define the normalized frequency radius: , ; Based on the high and low frequency boundary thresholds, construct a segmented frequency weighting function: in, , which is the high-frequency gain coefficient, enhances the edge of the defect; , which is the low-frequency suppression coefficient, reduces background interference; The cutoff radius is used to control the "small target scale"; We obtain the following by weighting the frequency domain functions: (3) The enhanced frequency domain features are restored to the spatial domain by inverse Fourier transform to generate a frequency domain enhanced image. : Finally, residual fusion is used to avoid "over-enhancement": in, This is the residual weight, used to control the enhancement intensity and prevent over-enhancement of texture.

3. The surface defect detection method based on frequency domain enhancement and multi-layer attention synergy according to claim 1, characterized in that, Step S2 includes The P2 feature layer obtained after the second downsampling; The P3 feature layer was obtained after the third downsampling. The P4 feature layer was obtained after the fourth downsampling. The P5 feature layer obtained after the fifth downsampling; Among them, the P2 and P3 feature layers have high spatial resolution and are mainly used to characterize the local details of small-scale defects; the P4 and P5 feature layers have stronger semantic expressive power and are used to describe the overall structural features of defects.

4. The surface defect detection method based on frequency domain enhancement and multi-layer attention synergy according to claim 1, characterized in that, S3: To address the differences in spatial resolution and semantic information between feature layers of different scales, a differentiated attention enhancement strategy is introduced into the multi-scale feature layers output by the YOLOv11 backbone network to achieve targeted enhancement of defect-related features.

5. The surface defect detection method based on frequency domain enhancement and multi-layer attention synergy according to claim 3, characterized in that, The enhancement described in step S3 specifically includes: (1) Introduce a channel attention mechanism (CA) in the P2 feature layer. By modeling the global response intensity of the channel dimension, the weight distribution of each semantic channel is adaptively adjusted, thereby enhancing the channel features that are highly related to the discrimination of small target defects and suppressing redundant background responses. (2) Introduce spatial attention (SA) mechanism in the P3 feature layer. By learning the saliency distribution relationship of different spatial locations in the feature map, the spatial response of the mesoscale defect area and its surrounding structural anomalies is highlighted, thereby improving the network’s sensitivity to the localization of defect areas. (3) By introducing the above-mentioned differential attention mechanism in the backbone network stage, the defect details after frequency domain enhancement are effectively preserved and enhanced in the early feature representation.

6. The surface defect detection method based on frequency domain enhancement and multi-layer attention synergy according to claim 5, characterized in that, In step S3: The calculation steps of the CA attention mechanism module are as follows: Assuming the input feature map ,in The number of channels output by the C3k2 module in layer P2. and These represent the height and width of the intermediate feature map, respectively. First, perform a global average pooling operation in the spatial dimension: in, Indicates the spatial position of the c-th channel. The characteristic response; this operation compresses the two-dimensional feature map into a one-dimensional channel description vector. Let represent the global average response of the c-th channel, and . Subsequently, the channel description vector The sequence is treated as a one-dimensional sequence along the channel dimension and input into a one-dimensional convolutional layer to model the local interaction between adjacent channels. The importance weight vector for each channel is generated by the sigmoid function. , in, This represents a one-dimensional convolution operation with a kernel size of k; the kernel size k is a preset odd constant used to limit the local receptive field range of channel interaction. This represents the Sigmoid function, which constrains the weights to (0,1). Finally, the channel weights Applying to the original feature map, adaptive recalibration along the channel dimension is achieved: , in, This represents a one-dimensional channel attention feature vector, where each element is the channel weight corresponding to the c-th channel. " indicates element-wise multiplication; This represents the feature map enhanced by the channel attention mechanism, and its dimension is the same as that of the input feature map. CA in S3 can enhance features such as small targets and weak texture defects, and suppress redundant features such as background.

7. The surface defect detection method based on frequency domain enhancement and multi-layer attention synergy according to claim 5, characterized in that, In step S3: The calculation steps of the SA attention mechanism module are as follows: Assuming the input feature map ,in This refers to the number of channels output by the C3k2 module in layer P3. and These represent the height and width of the intermediate feature map, respectively. First, statistical modeling is performed on the features along the channel dimension to highlight the spatial salience of the defect region. Specifically, average pooling and max pooling operations are performed on the input feature map along the channel dimension C. in, Indicates the spatial position of the c-th channel. The characteristic response; This is the channel average response feature map, used to characterize the overall response trend; This is the maximum response feature map of the channel, used to characterize the activation of local salient features; Subsequently, the two spatial feature maps are concatenated along the channel dimension to obtain: , in, This indicates that a splicing operation is performed along the channel dimension; The concatenated feature maps are convolved with a 7×7 2D convolutional layer, and a spatial attention weight map is generated using the sigmoid function. , Represents a 2D 7×7 convolution; This represents the Sigmoid function, with the weights constrained to (0,1). Finally, the spatial attention weight map is applied element-wise to the original input feature map to obtain the spatially augmented feature representation: , in, For spatial location Attention weights at each location; " indicates element-wise multiplication; This represents the feature map after spatial attention enhancement, whose dimension is the same as the input feature map.

8. The surface defect detection method based on frequency domain enhancement and multi-layer attention synergy according to claim 1, characterized in that, The scale-aware attention module described in step S4 senses the global response intensity of feature maps at different scales and generates corresponding scale weight coefficients. These coefficients are used to adaptively weight the multi-scale features participating in the fusion, thereby dynamically adjusting the contribution ratio of different scale features in the fusion stage and preventing small target defect features from being submerged by high-level semantic features during the multi-scale fusion process.

9. The surface defect detection method based on frequency domain enhancement and multi-layer attention synergy according to claim 1, characterized in that, In step S4, the calculation steps of the SAA attention mechanism module are as follows: Suppose that at a certain scale level (P3, P4, or P5) in the feature pyramid, the fused feature map obtained by feature concatenation is as follows: ,in Indicates batch size, This represents the number of channels in the feature map. and These represent the spatial height and width of the feature map, respectively. First, the fused feature map Perform global average pooling to obtain the overall response of each channel in the spatial dimension: in, Indicates the spatial position of the c-th channel. The characteristic response; Let represent the global average activation response of the c-th channel, and ; Subsequently, to characterize the overall semantic response strength of the feature map at the current scale, an averaging operation is performed on the channel dimensions to obtain the scale descriptor: , in, It is a scale descriptor in scalar form, used to represent the overall response strength of the current scale feature in the input sample; scale descriptor Input a lightweight linear mapping layer and generate scale attention weights using the Sigmoid function: , in, For learnable linear mapping parameters, For the Sigmoid function, The attention weight scalar; Finally, the scale attention weights Applying this to the original fused feature map to achieve scale-level feature modulation, we obtain: , in, This represents the feature map enhanced by the scale-aware attention mechanism, and its dimension is the same as that of the input feature map.