Aluminum material surface defect detection method integrating deformable convolution and no-parameter attention

By introducing deformable convolutional residual blocks, an improved feature fusion network, and the SimAM attention mechanism, the problems of variable shape and inaccurate detection of small targets in aluminum surface defect detection are solved, achieving higher accuracy and robustness in detection.

CN121481981APending Publication Date: 2026-02-06SUZHOU IND PARK SERVICE OUTSOURCING VOCATIONAL COLLEGE (SUZHOU SERVICE OUTSOURCING TALENT TRAINING & TRAINING CENT)
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202511654450.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-12
Publication Date
2026-02-06

AI Technical Summary

Technical Problem

Existing methods for detecting surface defects in aluminum materials are difficult to achieve high-precision detection in complex backgrounds, especially for defects with varied shapes and small targets, and are easily affected by background interference.

Method used

We employ deformable convolutional residual blocks to enhance feature extraction capabilities, and combine them with an improved lightweight bidirectional weighted feature fusion network and a parameterless SimAM attention mechanism. By adaptively adjusting the convolutional kernel offset and weights, we optimize the feature fusion and detection process.

Benefits of technology

It significantly improves the accuracy and robustness of aluminum surface defect detection, reduces the false negative rate of small targets, and enhances the anti-interference ability against complex backgrounds.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121481981A_ABST
    Figure CN121481981A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of defect detection, in particular to an aluminum material surface defect detection method fusing deformable convolution and no-parameter attention, and the method comprises the steps: obtaining a to-be-detected aluminum material surface image, and carrying out the preprocessing of the aluminum material surface image; the preprocessed aluminum material surface image is input into a preset aluminum material surface defect detection model, the aluminum material surface defect detection model comprises an input layer, a backbone network, a neck network and an output layer which are connected in sequence, and the input layer carries out standardization processing on the preprocessed aluminum material surface image; the backbone network carries out multi-scale feature extraction on the standardized input image to obtain a multi-layer feature map, the neck network carries out fusion on the multi-layer feature map to generate a fused multi-scale feature map, and the output layer carries out weighting on each neuron in the fused multi-scale feature map through a SimAM attention mechanism to output a detection result. According to the method, the complex background interference can be effectively inhibited, and the characterization capability of the key defect area is enhanced, so that the detection precision and robustness of the aluminum material surface defects are remarkably improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of defect detection, and particularly relates to an aluminum material surface defect detection method fusing deformable convolution and non-parametric attention. BACKGROUND

[0002] Aluminum material is an alloy material mainly composed of aluminum, which is formed into a structural material with different cross-sectional shapes through processes such as hot melting and extrusion, and is widely used in fields such as aerospace, transportation, and industrial construction. Aluminum material is widely used in industrial production due to its advantages such as light weight, easy processing, corrosion resistance, high strength, and non-magnetic properties. However, due to uncontrollable factors in the processing, storage, and transportation links, various defects such as non-conductivity, pits, and color spots inevitably occur on the surface of aluminum material. These defects not only affect the appearance quality of aluminum material, but also may reduce its mechanical properties and service life, and in severe cases may even cause safety accidents. Therefore, efficient and accurate detection of aluminum material surface defects is of great significance for improving product quality and ensuring safety in use.

[0003] Traditional defect detection methods mainly rely on manual visual inspection or algorithms based on traditional machine learning. Although these methods can play a certain role in specific application scenarios, they generally have low detection efficiency, poor adaptability, and high false detection rate. With the development of deep learning technology, convolutional neural networks (CNN) have shown significant advantages in automatic feature extraction of images, making detection models more accurate and robust. Defect detection methods based on deep learning can be divided into Two-Stage and One-Stage methods. Two-Stage methods generate candidate regions and then classify them, which have higher detection accuracy but relatively lower real-time performance. Representative algorithms include Faster R-CNN, Mask R-CNN, and Cascade R-CNN. One-Stage methods directly divide the image into grids and output the target class and position, which have higher real-time performance but slightly lower detection accuracy. Typical algorithms include YOLO series, SSD, and DETR series.

[0004] In recent years, the research on deep learning detection of aluminum surface defects has been continuously promoted. For example, in Faster R-CNN, feature pyramid and region of interest calibration are introduced to enhance the feature extraction ability of small defects, or in YOLO series network, channel attention mechanism, adaptive anchor frame, lightweight backbone network and Transformer decoding idea are added to improve the detection accuracy and recall rate. These methods have achieved remarkable results under experimental conditions. However, in the actual production environment, due to the complex and variable shape of aluminum defects, complex background and dense small targets, the existing detection methods mainly focus on enhancing the feature extraction ability, but pay insufficient attention to the features of defects with variable shapes, and are still difficult to achieve high-precision detection due to the influence of background interference and the loss of small target information caused by feature map downsampling. SUMMARY

[0005] The present application provides an aluminum surface defect detection method fusing deformable convolution and parameter-free attention, which effectively suppresses complex background interference and enhances the representation ability of key defect regions, thereby significantly improving the detection accuracy and robustness of aluminum surface defects. The present application provides the following technical solutions: In a first aspect, the present application provides an aluminum surface defect detection method fusing deformable convolution and parameter-free attention, which comprises: obtaining an aluminum surface image to be detected and preprocessing the aluminum surface image; inputting the preprocessed aluminum surface image into a pre-set aluminum surface defect detection model, wherein the aluminum surface defect detection model comprises an input layer, a backbone network, a neck network and an output layer connected in sequence, the input layer performs standardization processing on the preprocessed aluminum surface image, the backbone network performs multi-scale feature extraction on the standardized input image to obtain multi-layer feature maps, the neck network fuses the multi-layer feature maps to generate fused multi-scale feature maps, and the output layer outputs detection results by weighting each neuron in the fused multi-scale feature maps through a SimAM attention mechanism.

[0006] In a specific implementable embodiment, the standardization processing of the input layer on the preprocessed aluminum surface image comprises: The input layer performs adaptive scaling on the preprocessed aluminum surface image to adjust the image to the input size specified by the model while maintaining the aspect ratio, normalizes the pixel values of the image to map them to the [0, 1] interval, and outputs the standardized input image.

[0007] In a specific implementable embodiment, the multi-scale feature extraction of the backbone network on the standardized input image to obtain multi-layer feature maps comprises: In the backbone network, a deformable convolution residual block is introduced by adding a learnable offset to each sampling point of the convolution kernel The convolution kernel can adaptively change the shape and sampling position, and the calculation formula is: ; wherein, is the input feature map center sampling point, is the offset in the convolution kernel, is the convolution kernel weight, and represent the input and output feature maps respectively, is the set of all sampling points covered by the convolution kernel; by calculating the sampling position according to the geometric shape of the defect at each sampling point.

[0008] In one specific implementation, the backbone network performs multi-scale feature extraction on the standardized input image to obtain a plurality of layers of feature maps, and further comprises: An amplitude adjustment mechanism is designed for the deformable convolution residual block, and different weights are given to each sampling point , enhancing the attention ability of the network to important feature information, and the formula is expressed as: ; wherein, represents the importance weight of the nth sampling point, and the value range is [0, 1]; in the convolution calculation process, the feature contribution is adjusted according to the importance of each sampling point, the key region information related to the defect is strengthened, and the background noise is suppressed.

[0009] In one specific implementation, the neck network fuses the plurality of layers of feature maps to generate a fused multi-scale feature map, and the method comprises: A bidirectional weighted feature pyramid network is introduced, which deletes nodes that only have a single input path and have no feature interaction significance in the feature fusion process, and simultaneously adds additional edges between input nodes and output nodes at the same level, so that features of different scales can be fused through additional connection paths; The neck network receives the plurality of layers of feature maps output by the deformable convolution residual block in the backbone network, and performs bidirectional cross-scale fusion by using the bidirectional weighted feature pyramid network structure, in the top-down path, the high-level feature map is fused with the low-level feature map after being up-sampled, and in the bottom-up path, the shallow feature map is fused with the high-level feature map after being down-sampled.

[0010] In one specific implementation, the output layer outputs a detection result by weighting each neuron in the fused multi-scale feature map through a SimAM attention mechanism, and the method comprises: The output layer uses the SimAM attention mechanism to weight each neuron. The neuron is the feature value of each pixel in each channel of the fused multi-scale feature map. The energy value of each neuron in the feature map is calculated, and weights are assigned to each neuron according to the energy value. The weights are multiplied element-wise with the original feature map to obtain the weighted feature map. The weighted feature map is used by the detection head to predict the location, category and confidence of the defect target.

[0011] In one specific implementation, the output layer further includes weighting the output detection results for each neuron in the fused multi-scale feature map using the SimAM attention mechanism, and also includes: Let the input features be Each channel contains several neurons, and the energy value of each neuron can be calculated using the following formula. : ; ; ; In the formula, Represents neurons Differences between neurons and other neurons in the same pathway Indicates the current neuron, and Let represent the mean and variance of neurons in the same channel, respectively. Indicates the total number of neurons within the channel. This is the regularization coefficient.

[0012] Secondly, this application provides an aluminum surface defect detection system that integrates deformable convolution and parameterless attention, employing the following technical solution: A surface defect detection system for aluminum materials that integrates deformable convolution and parametric attention includes: The image acquisition module is used to acquire an image of the aluminum surface to be detected and to preprocess the image of the aluminum surface. The model detection module is used to input the preprocessed aluminum surface image into a preset aluminum surface defect detection model. The aluminum surface defect detection model includes an input layer, a backbone network, a neck network, and an output layer connected in sequence. The input layer standardizes the preprocessed aluminum surface image. The backbone network extracts multi-scale features from the standardized input image to obtain multi-layer feature maps. The neck network fuses the multi-layer feature maps to generate a fused multi-scale feature map. The output layer uses the SimAM attention mechanism to weight each neuron in the fused multi-scale feature map and outputs the detection result.

[0013] Thirdly, this application provides an electronic device, the device including a processor and a memory; the memory stores a program, the program being loaded and executed by the processor to implement a method for detecting surface defects in aluminum materials that integrates deformable convolution and parametric attention as described in the first aspect.

[0014] Fourthly, this application provides a computer-readable storage medium storing a program that, when executed by a processor, is used to implement a method for detecting surface defects in aluminum materials that integrates deformable convolution and parameterless attention as described in the first aspect.

[0015] In summary, the beneficial effects of this application include at least the following: (1) By replacing the Bottleneck structure in the C2f module of the YOLOv8n backbone network with deformable convolutional residual blocks, a learnable offset and amplitude adjustment mechanism is introduced for each sampling point of the convolutional kernel. This enables the convolutional kernel to adapt to defect regions of different shapes and sizes, thereby enhancing the ability to capture defect features with diverse shapes. This technique ensures that the input standardized aluminum surface image, after multi-scale feature extraction in the backbone network, yields a multi-layer feature map containing rich defect information, providing high-quality basic features for subsequent feature fusion and detection.

[0016] (2) An improved lightweight bidirectional weighted feature fusion network, LBiFPN, is adopted to perform top-down and bottom-up cross-scale fusion of the multi-layer feature maps output by the backbone network, and the fusion effect of features at different scales is optimized through extra edges and weighting mechanisms. This structure can not only preserve the integrity of deep semantic information while retaining fine-grained information such as shallow texture, contour and edge, but also effectively enhance the expressive ability of small defect targets, significantly reduce the risk of missing small targets, and reduce the number of model parameters and computational complexity.

[0017] By introducing deformable convolutional residual blocks into the backbone network, the feature extraction capability for defects of different shapes and sizes is enhanced; an improved lightweight BiFPN structure is adopted in the neck network to achieve efficient fusion of shallow fine-grained features and deep semantic information, thereby improving the detection capability of small targets; a parameter-free SimAM attention mechanism is introduced into the detection head to effectively suppress interference from complex backgrounds and enhance the characterization capability of key defect regions, thereby significantly improving the detection accuracy and robustness of aluminum surface defects.

[0018] The above description is only an overview of the technical solution of this application. In order to better understand the technical means of this application and to implement it in accordance with the contents of the specification, the preferred embodiments of this application are described in detail below with reference to the accompanying drawings. Attached Figure Description

[0019] Figure 1This is a flowchart illustrating the aluminum surface defect detection method that integrates deformable convolution and parameterless attention in the embodiments of this application.

[0020] Figure 2 This is a schematic diagram of the structure of the aluminum surface defect detection model in the embodiments of this application.

[0021] Figure 3 This is a basic schematic diagram of deformable convolution in the embodiments of this application.

[0022] Figure 4 This is a schematic diagram of the structure of the c2f-DCNv2 module in the embodiments of this application.

[0023] Figure 5 This is a schematic diagram of use cases for different attention mechanisms in the embodiments of this application.

[0024] Figure 6 This is a schematic diagram of a surface defect sample in an embodiment of this application.

[0025] Figure 7 This is a comparison chart of the detection performance of the original model and the improved model in the embodiments of this application.

[0026] Figure 8 This is a structural block diagram of an aluminum surface defect detection system that integrates deformable convolution and parameterless attention in an embodiment of this application.

[0027] Figure 9 This is a block diagram of an electronic device for detecting aluminum surface defects by integrating deformable convolution and parameterless attention, as described in this application. Detailed Implementation

[0028] The specific embodiments of this application will be described in further detail below with reference to the accompanying drawings and examples. The following examples are used to illustrate this application, but are not intended to limit the scope of this application.

[0029] Optionally, this application uses the aluminum surface defect detection method that integrates deformable convolution and parameterless attention provided in various embodiments as an example for application in an electronic device. The electronic device is a terminal or server. The terminal can be a computer, tablet computer, etc. This embodiment does not limit the type of electronic device.

[0030] First, the model structure of the aluminum surface defect detection model in this application is YOLOv8n. YOLOv8n is a lightweight detection model that achieves a good balance between detection accuracy and speed. Based on this, this algorithm is selected as the experimental benchmark model. The model consists of four parts: input layer, backbone network, neck network, and output layer. In the input stage, multiple images are stitched together using Mosaic technology to enhance the model's generalization ability, and an adaptive scaling strategy is adopted to adapt to detection targets of different sizes. The backbone network is based on DarkNet53 to achieve effective feature extraction and includes three parts: CBS, C2F, and SPPF. Among them, CBS consists of standard convolution, batch normalization, and SiLu activation function, used for feature extraction. C2F is a bottleneck structure composed of multiple residuals to realize the representation and transmission of depth information. SPPF adopts spatial pyramid technology, which can aggregate features of different scales to better capture targets of different sizes. The neck network is responsible for upsampling features, combining feature pyramid network (FPN) and path aggregation network (FPN) to fuse feature information from different levels, obtaining rich multi-scale semantic and localization information, and improving the model's detection capability. The output layer is based on a decoupled structure. To improve the model's flexibility and scalability, the detection and regression tasks are separated, and three feature maps of different scales are output simultaneously to detect targets of different sizes.

[0031] Reference Figure 1 This is a flowchart illustrating a method for detecting surface defects in aluminum materials that integrates deformable convolution and parametric attention, according to an embodiment of this application. The method includes at least the following steps: Step S101: Obtain the surface image of the aluminum material to be inspected and preprocess the surface image of the aluminum material.

[0032] In step S101, images of the aluminum surface to be inspected under industrial production conditions are first acquired. These images may originate from industrial cameras or CCD imaging equipment and contain various defects that may exist on the aluminum surface, such as non-conductivity, pitting, and discoloration. The acquired images may have problems such as uneven lighting, noise interference, and color distortion. Therefore, preprocessing is required before inputting them into the detection model to improve the accuracy and robustness of subsequent defect detection.

[0033] Specifically, preprocessing of the acquired aluminum surface images includes, but is not limited to, the following operations: image size normalization to adapt the image to the input size of the defect detection model, ensuring consistency in spatial proportions during subsequent feature extraction; image noise suppression, such as using Gaussian filtering, median filtering, or adaptive filtering, to remove random noise that may be introduced during imaging; and enhancement of image brightness and contrast to improve the distinction between defect areas and the background, enabling the model to obtain sufficient feature information even when processing low-contrast defects. Furthermore, data augmentation processing, such as random rotation, horizontal flipping, and color perturbation, can be performed on the images to expand the training dataset and improve the model's generalization ability.

[0034] After the above preprocessing, the resulting image retains the key details of the aluminum surface while reducing noise interference and the influence of environmental factors, thus providing a high-quality input feature map for the subsequent defect detection model.

[0035] Step S102: Input the preprocessed aluminum surface image into the preset aluminum surface defect detection model. The aluminum surface defect detection model includes an input layer, a backbone network, a neck network, and an output layer connected in sequence. The input layer standardizes the preprocessed aluminum surface image. The backbone network extracts multi-scale features from the standardized input image to obtain multi-layer feature maps. The neck network fuses the multi-layer feature maps to generate a fused multi-scale feature map. The output layer uses the SimAM attention mechanism to weight each neuron in the fused multi-scale feature map and outputs the detection result.

[0036] In implementation, the preprocessed aluminum surface image is first input to the input layer of the aluminum surface defect detection model. The input layer performs size normalization and numerical normalization on the preprocessed aluminum surface image to obtain a standardized input image suitable for feature extraction by the backbone network. Specifically, the input layer first adaptively scales the preprocessed single aluminum surface image to adjust the image to the input size specified by the model while maintaining the aspect ratio to avoid deformation of the defect target shape. Subsequently, the pixel values ​​of the image are normalized and mapped to the [0,1] interval to ensure the numerical stability of convolution calculation and improve the training convergence speed. After the above processing, the output standardized input image retains the detailed features of aluminum surface defects and unifies the size and numerical range, providing high-quality input for subsequent feature extraction by the backbone network.

[0037] A standardized image of the aluminum surface is then input into the backbone network of a pre-defined aluminum surface defect detection model. The backbone network performs a series of convolution operations on the image to extract its basic features. In the traditional YOLOv8n model architecture, feature extraction mainly relies on fixed-size standard convolution kernels. The convolution process involves sliding the convolution kernel row by row and column by column on the input feature map, multiplying the kernel weights by the pixel values ​​at corresponding positions in the feature map, and summing the results to obtain the output feature map. Its mathematical expression is: ; However, in aluminum surface defect detection, the same type of defect may have different shapes and sizes. The fixed receptive field of standard convolution can easily lead to the loss of key feature information, making it difficult for the anchor frame to accurately describe the location of the defect, thus affecting the target detection accuracy. To solve this problem, this application introduces deformable convolutional residual blocks (DCNv2) into the backbone network. The principle of deformable convolution is as follows: Figure 3 As shown, deformable convolution adds a learnable offset to each sampling point of the convolution kernel. This allows the convolution kernel to adaptively change its shape and sampling position, better covering defect regions of different shapes. The calculation formula is: ; in, The input feature map center sampling point, This is the offset within the convolution kernel. For convolution kernel weights, and These represent the input and output feature maps, respectively (the first layer is the input image, and each subsequent layer is the feature map output from the previous layer). This represents the set of all sampling points covered by the convolution kernel. Through calculation using a formula, the sampling position at each sampling point is adjusted according to the geometry of the defect, allowing the convolution kernel to cover a more flexible region, thereby generating a more accurate feature response. After this calculation, the output feature map contains feature information about defects of different shapes in the input image, providing a more comprehensive description of the defect region.

[0038] Furthermore, as a preferred embodiment, DCNv2 adds an amplitude adjustment mechanism, assigning different weights to each sampling point. This further enhances the network's ability to focus on important feature information, as expressed by the formula: ; in, The importance weight of the nth sampling point is represented, and its value ranges from [0,1]. During the convolution calculation, the feature contribution is adjusted according to the importance of each sampling point, which strengthens the key region information related to defects, suppresses background noise, and generates a more discriminative feature response.

[0039] By introducing offset and weight adjustment mechanisms, deformable convolution can more flexibly adapt to the irregular shape of defects in the input feature map, outputting features highly correlated with the target region, thereby accurately extracting feature information of aluminum surface defects. Based on this, the original Bottleneck structure in the C2f module of the YOLOv8n backbone network is replaced with DCNv2 to form a new c2f-DCNv2 module, which serves as the core feature extraction unit of the backbone network. Its structure is as follows: Figure 4 As shown, this significantly improves the model's ability to extract features from defects with varying shapes. The backbone network consists of multiple stacked c2f-DCNv2 modules, each extracting features at different depths: shallow feature maps preserve edge, texture, and contour information, resolving details of small defects; mid-level feature maps contain both local details and some semantic information; deep feature maps extract high-level semantic information, capturing the approximate location and category features of defects. The above formulas are calculated in each convolutional module, ultimately outputting multi-layer feature maps. The backbone network, by introducing deformable convolution and amplitude adjustment mechanisms, sequentially performs convolution calculations on the input image, generating feature maps of different depths and scales. Each feature map contains information about aluminum surface defects.

[0040] The neck network receives multi-layer feature maps from the backbone network as input. These feature maps contain information about aluminum surface defects at different scales and semantic levels. Shallow feature maps retain fine-grained information such as the edges, contours, colors, textures, and shapes of the defects, but also contain more noise. High-level feature maps contain richer semantic information, but have lower resolution and lack precise location information and detailed features of the target. The main goal of the neck network is to fuse shallow and high-level features to generate multi-scale feature maps suitable for detecting defects of different sizes, ensuring that small targets do not lose contour information while preserving high-level semantic information.

[0041] In traditional YOLOv8n, the neck network employs a combination of Feature Pyramid Network (FPN) and Path Aggregation Network (PAN): FPN upsamples high-level semantic information to low-level feature maps; PAN, from bottom to top, transfers shallow detail information to high-level feature maps, achieving fusion of shallow and deep features. This structure can improve detection performance in general scenarios, but in aluminum surface defect detection, due to the dense distribution of small targets and the increasing depth of the backbone network, the resolution of shallow feature maps gradually decreases, leading to the loss of contour and edge information of small targets, resulting in missed detections.

[0042] To address the aforementioned issues, this application introduces and improves the Bi-directional Feature Pyramid Network (BiFPN) in the neck network. This structure, first proposed by Tan et al. in EfficientDet, aims to eliminate the limitations of unidirectional information flow by establishing bidirectional cross-scale connections (top-down and bottom-up) to facilitate information interaction between multi-scale features. Specifically, during feature fusion, BiFPN first removes nodes with only a single input path and no feature interaction significance to simplify the structure and reduce computational complexity. Simultaneously, it adds extra edges between input and output nodes at the same level, allowing features of different scales to be fused through richer connection paths, thereby enhancing the information flow across layers. Furthermore, BiFPN assigns learnable weights to each input feature, adjusting the contribution ratio of features of different scales in the fusion process through weighting to achieve an adaptive balance between shallow details and deep semantics.

[0043] In the improved scheme of this application, the neck network receives multi-layer feature maps output from the first, second, and third DCNv2 modules and the SPPF module in the backbone network, and performs bidirectional cross-scale fusion using the improved BiFPN structure. Specifically, in the top-down path, the high-level feature maps are upsampled and then weighted and fused with the low-level feature maps, thereby transferring semantic information to the shallow layers, enabling the shallow features to gain semantic enhancement while preserving edge and texture details. In the bottom-up path, the shallow feature maps are downsampled and then fused with the high-level feature maps, supplementing the deep features with fine-grained defect information and compensating for the insufficient resolution of the high-level features. Through this bidirectional feature flow mechanism, the network preserves both spatial details and semantic information during the fusion process, and further enhances the efficiency of cross-scale information interaction by introducing additional edges. Finally, the improved BiFPN module outputs a set of fused multi-scale feature maps, which simultaneously possess high-resolution detailed features and deep semantic expression capabilities, providing more sufficient feature support for the accurate localization and defect classification of the subsequent detection head, effectively improving the detection accuracy of small target defects and reducing the false negative rate.

[0044] The output layer (detection head) receives the fused multi-scale feature maps from the neck network as input. These feature maps contain both high-resolution shallow fine-grained information and deep semantic information, comprehensively describing the shape, texture, edges, and semantic categories of aluminum surface defects. However, due to the complex background of aluminum surface defects, shallow features often contain a large amount of interfering information, which may prevent the model from fully focusing on the target defect region in subsequent detection, thus affecting detection accuracy. To address this issue, this application introduces the SimAM attention mechanism into the detection head. SimAM can assign three-dimensional attention weights to each neuron of the input features without adding additional learnable parameters, thereby reducing the interference of complex backgrounds on feature extraction and improving the representation ability of target defects.

[0045] Reference Figure 5 Attention mechanisms enable networks to automatically learn and focus on important feature regions, enhancing model performance and expressive power. Typical attention mechanisms include channel attention (1-D attention) and spatial attention (2-D attention). The former mainly includes SE (Squeeze-and-Excitation) and ECA (Efficient Channel Attention).

[23] l There are two main types of attention mechanisms, as shown in Figure 5(a). The former assigns larger weights to important channels through global average pooling and fully connected layers, while suppressing irrelevant or redundant channels, but assigns the same weight to all locations in the space. The latter mainly includes Convolutional Block Attention (CBAM) and Coordinate Attention (CA), as shown in Figure 5(b). The 2D attention mechanism enhances the importance of spatial locations, assigning different attention weights to different locations, but all channels are allocated the same weight. Due to the complex background of aluminum surface defects, the model's feature extraction is significantly interfered with, resulting in poor detection performance for aluminum surface defects in complex backgrounds. Compared to other attention mechanisms, SimAM can assign three-dimensional weights to features, reducing the interference of complex backgrounds on feature extraction, making it more suitable for aluminum surface defect detection. Figure 5 As shown in (c), the SimAM attention mechanism is a parameter-free 3D attention mechanism that combines channel and spatial information. It helps the network focus on important information in the input features without increasing the number of parameters. This attention mechanism mines the importance of each neuron by minimizing the energy function. It enhances the representational power of the feature map by calculating the differences between each neuron and its surrounding neurons and assigning attention weights to each neuron based on these differences.

[0046] Specifically, the SimAM attention mechanism evaluates the importance of each neuron based on minimizing an energy function. Let the input features be... Each channel contains several neurons, and the energy value of each neuron can be calculated using the following formula. : ; ; ; In the formula, Represents neurons Differences between neurons and other neurons in the same pathway Indicates the current neuron, and Let represent the mean and variance of neurons in the same channel, respectively. Indicates the total number of neurons within the channel. This is the regularization coefficient. As can be seen from the formula, when the neuron... When its energy value differs significantly from that of surrounding neurons, A lower value indicates that the neuron is of high importance and should be assigned a larger attention weight. To prevent excessive energy from causing some neurons to become ineffective, SimAM compresses the attention weights using the sigmoid function, as shown in the following equation: ; in, The energy values ​​of all neurons in each channel, symbol This represents the element-wise dot product operation. This is the attention-weighted output feature map. Through the above processing, each neuron receives a different weight based on its difference from surrounding neurons, enhancing the response to important defective regions while suppressing background interference.

[0047] The output layer uses the SimAM attention mechanism to weight each neuron. Each neuron represents the feature value of each pixel in each channel of the fused multi-scale feature map. The energy value of each neuron in the feature map is calculated, and weights are assigned to each neuron based on their energy values. The weights are then multiplied element-wise with the original feature map to obtain the weighted feature map. After processing, the feature map obtained by the output layer enhances the response of key defect regions and suppresses background noise. This weighted feature map is then used by the detection head to predict the location, class, and confidence of the defect target. In other words, the final output is a feature representation containing the detection results, used to generate anchor boxes and class probabilities.

[0048] In summary, by introducing C2f-DCNv2 deformable convolutional residual blocks into the backbone network to enhance the feature extraction capability for defects of different shapes, employing an improved lightweight BiFPN feature fusion structure in the neck network to improve the detection capability for small targets, and introducing a parameter-free attention mechanism SimAM into the detection head to enhance the attention to key targets in complex backgrounds, the problems of difficulty in capturing defect features, inaccurate target location description, and missed detection of small defects are effectively solved.

[0049] Specifically, in the backbone network, the Bottleneck structure in the C2f module of the YOLOv8n backbone network is replaced by deformable convolutional residual blocks. Each sampling point of the convolutional kernel introduces a learnable offset and amplitude adjustment mechanism, enabling the kernel to adapt to defect regions of different shapes and sizes, thereby enhancing the ability to capture defect features with diverse shapes. This technique ensures that the input standardized aluminum surface image, after multi-scale feature extraction in the backbone network, yields a multi-layer feature map containing rich defect information, providing high-quality basic features for subsequent feature fusion and detection.

[0050] In the neck network, the model employs an improved lightweight bidirectional weighted feature fusion network, LBiFPN, to perform top-down and bottom-up cross-scale fusion of multi-layer feature maps output from the backbone network. Additional edges and a weighting mechanism are used to optimize the fusion effect of features at different scales. This structure not only preserves the integrity of deep semantic information while retaining fine-grained information such as shallow texture, contours, and edges, but also effectively enhances the expressive ability for small defect targets, significantly reducing the risk of missed detections of small targets, while simultaneously reducing the number of model parameters and computational complexity.

[0051] In the detection head, a parameter-free attention mechanism, SimAM, is introduced to perform three-dimensional attention weighting on the fused multi-scale feature map. Weights are assigned to each neuron based on the difference between it and its surrounding neurons, thereby enhancing the feature representation of key defect regions while suppressing background interference. This mechanism improves the model's ability to identify low-contrast defects in complex environments without requiring additional parameter learning. It makes the final weighted feature map more prominent in terms of target information, providing more reliable basic features for the detection head to predict defect category, location, and confidence, further improving the overall detection performance of the model.

[0052] In addition, to verify the performance of the model in this application, a technical effect verification experiment was conducted. The aluminum surface defect data in this experiment came from the Tianchi Big Data Platform. This dataset collected 2779 high-definition images in a real industrial environment, covering 10 different types of surface defects, including scratches, leakage, non-conductive, dents, orange peel, jets, paint bubbles, crates, dirt points, and parti colors. Samples of various types of surface defects are shown below. Figure 6 As shown. The original dataset has an uneven distribution of defects in each category and a small number of samples, which is prone to overfitting during training. In order to improve the generalization ability of the model, this paper enhances the original data. The main methods are: (1) Random adjustment of brightness and contrast to simulate uneven lighting in industrial production environment. (2) Random noise to simulate interference generated in complex industrial production environment. (3) Random flipping and rotation to simulate different shooting angles. The total number of samples was expanded to 9138, and the training set, test set and validation set were divided into a ratio of 8:1:1, that is, the training set included 7310 pictures, and the test set and validation set each contained 914 pictures.

[0053] In terms of software environment, this model is implemented based on Python 3.8 and PyTorch 2.0. Python is used for data augmentation and processing, PyTorch 2.0 is used to build the deep learning model, and CUDA 11.4 is used to enhance the program's parallel computing capabilities. All code runs on the Ubuntu 18.04 operating system platform. In terms of hardware environment, an Intel Xeon Gold 6234 @ 3.3GHz processor is used, along with Kingston Enterprise SSD 960GB DC500R series memory, and an NVIDIA GeForce RTX 4080 Ti (16GB) high-performance graphics card to accelerate the training process.

[0054] The model performance was comprehensively evaluated using metrics such as precision, recall, and mean accuracy (mAP). The mean accuracy value with IOU >= 0.5 was selected. The formulas for each evaluation metric are shown below: ; ; ; To evaluate the improvement effect of various enhancements on the detection of surface defects in aluminum materials, YOLOv8n was used as the baseline model, and c2f-DCNv2, the improved BiFPN, and the SimAM attention module were added sequentially. A series of ablation experiments were conducted, and the experimental results are shown in Table 1. As shown in Table 1, Experiment ① improved mAP by 1.5%, indicating that deformable convolutional residual blocks can enhance the feature extraction capability of aluminum defects of varying sizes and shapes, thus improving the model's detection accuracy. Since deformable convolution requires additional convolution to generate the offset at each sampling position, the number of parameters increases compared to the original model. In Experiment ②, the improved BiFPN retains more shallow features such as texture and shape, while ensuring that deep semantic information is not lost during the transformation process, reducing the missed detection of small targets. It improved mAP by 1.7% while reducing the number of parameters and computational complexity. Experiment ③ shows that SimAM can enhance the defect localization capability in complex environments. Experiments ④, ⑤, and ⑥ respectively fused the DCN-BottleNeck module, the improved BiFPN module, and the SimAM module in pairs, and the overall detection performance exceeded the sum of the performance of each module existing independently. Experimental results show that the detection accuracy of the algorithm in this paper is improved by 5.6% compared with the benchmark model, and the computational complexity and number of parameters are reduced by 0.9G and 0.96M respectively. This proves that the algorithm in this paper can enhance the feature characterization ability of aluminum material defects of different sizes and shapes, and achieve better detection results.

[0055] Table 2 shows the number of each type of defect detected in the test set before and after the model improvement. It can be seen that pitting and denting are caused by human factors, resulting in different defect shapes. Deformable residual blocks expand the sampling range by introducing offsets, which enhances the network's adaptability to features. Paint bubbles and dirt spots are small-sized defects, and LBiFPN can enhance the detection capability of small defects and reduce the model's missed detection. Non-conductive and orange peel defects are easily covered by the aluminum background. SimAM can effectively suppress the interference of the background image and accurately focus on the location information of various defects. Therefore, the improved model can significantly improve the detection accuracy of targets with varied shapes, complex backgrounds and small targets.

[0056] Figure 7 The results show the detection performance of the original model and the improved model. Analysis reveals that the original model exhibited missed detections due to variations in shape, dense clusters of small targets, and background interference. The improved model, however, can detect more defects with higher confidence levels, thus demonstrating its effectiveness in improving the detection accuracy of surface defects on aluminum materials.

[0057] Figure 8This is a structural block diagram of an aluminum surface defect detection system that integrates deformable convolution and parametric attention according to an embodiment of this application. The system includes at least the following modules: The image acquisition module is used to acquire images of the aluminum surface to be inspected and to preprocess the aluminum surface images. The model detection module is used to input the preprocessed aluminum surface image into a preset aluminum surface defect detection model. The aluminum surface defect detection model includes an input layer, a backbone network, a neck network, and an output layer connected in sequence. The input layer standardizes the preprocessed aluminum surface image. The backbone network extracts multi-scale features from the standardized input image to obtain multi-layer feature maps. The neck network fuses the multi-layer feature maps to generate a fused multi-scale feature map. The output layer uses the SimAM attention mechanism to weight each neuron in the fused multi-scale feature map and outputs the detection result.

[0058] For relevant details, please refer to the above method implementation examples.

[0059] Figure 9 This is a block diagram of an electronic device provided in one embodiment of this application. The device includes at least a processor 401 and a memory 402.

[0060] Processor 401 may include one or more processing cores, such as a quad-core processor or an octa-core processor. Processor 401 may be implemented using at least one hardware form selected from DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). Processor 401 may also include a main processor and a coprocessor. The main processor, also known as a CPU (Central Processing Unit), is used to process data in the wake-up state; the coprocessor is a low-power processor used to process data in the standby state. In some embodiments, processor 401 may integrate a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the screen. In some embodiments, processor 401 may also include an AI (Artificial Intelligence) processor, which is used to handle computational operations related to machine learning.

[0061] Memory 402 may include one or more computer-readable storage media, which may be non-transitory. Memory 402 may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices or flash memory devices. In some embodiments, the non-transitory computer-readable storage media in memory 402 is used to store at least one instruction, which is executed by processor 401 to implement the aluminum surface defect detection method fusing deformable convolution and parameterless attention provided in the method embodiments of this application.

[0062] In some embodiments, the electronic device may also optionally include: a peripheral device interface and at least one peripheral device. The processor 401, memory 402, and peripheral device interface can be connected via a bus or signal line. Each peripheral device can be connected to the peripheral device interface via a bus, signal line, or circuit board. Indicatively, peripheral devices include, but are not limited to: radio frequency circuits, touch displays, audio circuits, and power supplies.

[0063] Of course, electronic devices may also include fewer or more components, and this embodiment does not limit this.

[0064] Optionally, this application also provides a computer-readable storage medium storing a program that is loaded and executed by a processor to implement the aluminum surface defect detection method that fuses deformable convolution and parameterless attention as described in the above method embodiments.

[0065] Optionally, this application also provides a computer product including a computer-readable storage medium storing a program, which is loaded and executed by a processor to implement the aluminum surface defect detection method that fuses deformable convolution and parameterless attention as described in the above method embodiments.

[0066] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0067] The above embodiments merely illustrate several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the invention patent. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.

Claims

1. A method for detecting surface defects in aluminum materials that integrates deformable convolution and parameterless attention, characterized in that, The method includes: Acquire an image of the aluminum surface to be inspected and preprocess the image; The preprocessed aluminum surface image is input into a preset aluminum surface defect detection model. The aluminum surface defect detection model includes an input layer, a backbone network, a neck network, and an output layer connected in sequence. The input layer standardizes the preprocessed aluminum surface image. The backbone network extracts multi-scale features from the standardized input image to obtain multi-layer feature maps. The neck network fuses the multi-layer feature maps to generate a fused multi-scale feature map. The output layer uses the SimAM attention mechanism to weight each neuron in the fused multi-scale feature map and outputs the detection result.

2. The method for detecting surface defects in aluminum materials by fusing deformable convolution and parametric attention according to claim 1, characterized in that, The input layer performs standardization processing on the preprocessed aluminum surface image, including: The input layer adaptively scales the preprocessed aluminum surface image to adjust it to the input size specified by the model while maintaining the aspect ratio. It also normalizes the pixel values ​​of the image, mapping them to the [0,1] interval, and outputs a standardized input image.

3. The method for detecting surface defects in aluminum materials by fusing deformable convolution and parametric attention according to claim 1, characterized in that, The backbone network performs multi-scale feature extraction on the standardized input image to obtain multi-layer feature maps, including: Deformable convolutional residual blocks are introduced into the backbone network, by adding a learnable offset to each sampling point of the convolutional kernel. This allows the convolution kernel to adaptively change its shape and sampling position; its calculation formula is as follows: ; in, The input feature map center sampling point, This is the offset within the convolution kernel. For convolution kernel weights, and These represent the input and output feature maps, respectively. The set of all sampling points covered by the convolution kernel; the sampling position is adjusted according to the geometry of the defect at each sampling point by computation.

4. The method for detecting surface defects in aluminum materials by fusing deformable convolution and parametric attention according to claim 3, characterized in that, The backbone network performs multi-scale feature extraction on the standardized input image to obtain multi-layer feature maps, which also includes: An amplitude adjustment mechanism is designed for deformable convolutional residual blocks, assigning different weights to each sampling point. This enhances the network's ability to focus on important feature information, as expressed by the formula: ; in, The value represents the importance weight of the nth sampling point, and its range is [0,1]. During the convolution calculation, the feature contribution is adjusted according to the importance of each sampling point to enhance the key area information related to the defect and suppress background noise.

5. The method for detecting surface defects in aluminum materials by fusing deformable convolution and parametric attention according to claim 1, characterized in that, The neck network fuses multi-layer feature maps to generate a fused multi-scale feature map, including: A bidirectional weighted feature pyramid network is introduced to remove nodes with only a single input path and no feature interaction meaning during the feature fusion process. At the same time, additional edges are added between input nodes and output nodes at the same level, so that features of different scales can be fused through additional connection paths. The neck network receives multi-layer feature maps output by deformable convolutional residual blocks in the backbone network and performs bidirectional cross-scale fusion using a bidirectional weighted feature pyramid network structure. In the top-down path, high-level feature maps are upsampled and then fused with low-level feature maps using weighted fusion. In the bottom-up path, shallow feature maps are downsampled and then fused with high-level feature maps.

6. The method for detecting surface defects in aluminum materials by fusing deformable convolution and parametric attention according to claim 1, characterized in that, The output layer uses the SimAM attention mechanism to weight the output detection results of each neuron in the fused multi-scale feature map, including: The output layer uses the SimAM attention mechanism to weight each neuron. The neuron is the feature value of each pixel in each channel of the fused multi-scale feature map. The energy value of each neuron in the feature map is calculated, and weights are assigned to each neuron according to the energy value. The weights are multiplied element-wise with the original feature map to obtain the weighted feature map. The weighted feature map is used by the detection head to predict the location, category and confidence of the defect target.

7. The method for detecting surface defects in aluminum materials by fusing deformable convolution and parametric attention according to claim 6, characterized in that, The output layer uses the SimAM attention mechanism to weight the output detection results of each neuron in the fused multi-scale feature map. The detection results also include: Let the input features be Each channel contains several neurons, and the energy value of each neuron can be calculated using the following formula. : ; ; ; In the formula, Represents neurons Differences between neurons and other neurons in the same pathway Indicates the current neuron, and Let represent the mean and variance of neurons in the same channel, respectively. Indicates the total number of neurons within the channel. is the regularization coefficient.

8. A surface defect detection system for aluminum materials that integrates deformable convolution and parameterless attention, characterized in that, include: The image acquisition module is used to acquire an image of the aluminum surface to be detected and to preprocess the image of the aluminum surface. The model detection module is used to input the preprocessed aluminum surface image into a preset aluminum surface defect detection model. The aluminum surface defect detection model includes an input layer, a backbone network, a neck network, and an output layer connected in sequence. The input layer standardizes the preprocessed aluminum surface image. The backbone network extracts multi-scale features from the standardized input image to obtain multi-layer feature maps. The neck network fuses the multi-layer feature maps to generate a fused multi-scale feature map. The output layer uses the SimAM attention mechanism to weight each neuron in the fused multi-scale feature map and outputs the detection result.

9. An electronic device, characterized in that, The device includes a processor and a memory; the memory stores a program that is loaded and executed by the processor to implement a method for detecting aluminum surface defects by fusing deformable convolution and parametric attention as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The storage medium stores a program that, when executed by a processor, is used to implement a method for detecting surface defects in aluminum materials that integrates deformable convolution and parameterless attention as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • A multi-scale photovoltaic cell defect detection method based on complex background

    CN119784716A

  • Photovoltaic panel defect detection method and device

    CN120031858A

  • Oxtail area detection method in complex environment

    CN120544228A

  • Aluminum profile surface defect detection method based on YOLOv8

    CN120598933A