Metal part defect detection method based on scale adaptive attention network

Through the method based on scale adaptive attention network, multi-scale features of metal parts images are extracted and fused, and the problems of small defects and low contrast in metal parts defect detection are solved, achieving more accurate defect detection.

CN119006397APending Publication Date: 2024-11-22QINGYUAN POLYTECHNIC

Patent Information

Application Number
CN202411067929.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-06
Publication Date
2024-11-22

AI Technical Summary

Technical Problem

The prior art has small defects and low contrast in metal parts defect detection, resulting in inaccurate detection. Traditional methods are limited by environmental complexity, and deep learning methods are difficult to effectively detect tiny defects on the surface of metal parts.

Method used

Using the metal parts defect detection method based on scale adaptive attention network, multi-scale feature maps are extracted through the encoder and interactive spatial position attention generate multi-scale feature location fusion feature maps, and combined with the decoder to reconstruct the spatial resolution of the feature maps , output defect detection results.

Benefits of technology

It significantly improves the detection performance of tiny defects on metal parts surfaces, can effectively identify small defects on metal parts, improves the accuracy and contrast of inspection, and is suitable for metal parts detection in complex environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119006397A_ABST
    Figure CN119006397A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of defect detection, and discloses a metal part defect detection method based on a scale adaptive attention network, which comprises the following steps: acquiring a metal part image; constructing a metal part defect detection model; the metal part defect detection model comprises an encoder and a decoder; extracting a multi-scale feature map from the metal part image by using an encoder, and generating a multi-scale feature position fusion feature map based on interactive spatial position attention; and reconstructing the spatial resolution of the multi-scale feature position fusion feature map by using a decoder, fusing feature information from different levels of the encoder through jump connection, and outputting a metal part defect detection result. The method obviously improves the detection performance of the tiny defects on the surface of the metal part.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of defect detection, and in particular to a metal parts defect detection method based on a scale-adaptive attention network. Background Art

[0002] In the manufacturing industry, metal parts are vital to the entire industrial chain, such as machinery and equipment, automobiles, and aerospace. However, during metal processing and loading, scratches, shape defects, missing or torn parts are usually inevitable, causing significant economic losses. Therefore, it is necessary to perform defect detection on the surface of metal parts during the manufacturing process.

[0003] Traditionally, metal parts inspection is usually performed by experienced workers, such as cracks and missing parts, but it is time-consuming and inaccurate for part production. To this end, many computer-aided methods have been proposed to detect defects from the surface of metal parts, which can be divided into traditional machine vision inspection methods and deep learning methods.

[0004] For traditional methods, they are always limited due to the complexity of the environment and background, such as extreme value analysis and support vector mechanism. To solve these problems, researchers have designed many deep learning-based methods to detect defects on the surface of metal parts. For example, Huang et al. proposed a small number of anomaly detection on a limited number of normal images in each category, but it was in categories with aggregated data. In the manufacturing industry, metal parts are crucial to the entire industrial chain, such as mechanical equipment, automobiles, and aerospace. Shin et al. proposed a new unsupervised anomaly detection method based on a score model, which does not require external knowledge but is affected by external random interference. Fang et al. proposed a small number of anomaly detection strategies for low data states, which introduced a new distribution regularization regression, achieved the optimal conversion from support features to query features, and guaranteed the visual similarity between the reconstruction results and the query samples. In summary, the above methods can detect anomalies through the core part of feature extraction.

[0005] However, due to these problems, defect repair of metal parts is still a challenging task. The main problems are that, first, the defects of the parts are small and appear randomly on the metal parts, which are easy to be ignored. Second, the contrast between the defect area and the normal surface of the metal parts is not obvious, resulting in failure of low-contrast defects. In short, the small defects and low contrast of metal parts will hinder their application. Summary of the invention

[0006] In view of the above-mentioned deficiencies in the prior art, the present invention provides a metal parts defect detection method based on a scale-adaptive attention network.

[0007] In order to achieve the above-mentioned object of the invention, the technical solution adopted by the present invention is:

[0008] A metal parts defect detection method based on a scale-adaptive attention network comprises the following steps:

[0009] Acquire images of metal parts;

[0010] Constructing a metal parts defect detection model; the metal parts defect detection model includes an encoder and a decoder;

[0011] The encoder is used to extract multi-scale feature maps from metal part images, and a multi-scale feature position fusion feature map is generated based on interactive spatial position attention;

[0012] The decoder is used to reconstruct the spatial resolution of the multi-scale feature position fusion feature map, and the feature information from different levels of the encoder is fused through jump connections to output the metal parts defect detection results.

[0013] Preferably, the encoder comprises:

[0014] A multi-level feature extraction module is arranged sequentially from top to bottom, and each level of the feature extraction module includes a residual block and an interactive spatial position attention unit.

[0015] Preferably, the decoder comprises:

[0016] A multi-level feature reconstruction module is arranged in sequence from bottom to top. Each level of the feature reconstruction module is connected to the feature extraction module of the corresponding level through a jump connection, and the feature reconstruction modules of adjacent levels are connected through an upsampling layer; each level of the feature reconstruction module includes a residual block and an interactive spatial position attention unit.

[0017] Preferably, the top feature reconstruction module in the decoder also includes a convolution unit connected to the interactive spatial position attention unit.

[0018] Preferably, the interactive spatial position attention unit comprises:

[0019] The planarization layer, group normalization layer, first convolution layer, attention layer, second convolution layer and feature fusion layer are set in sequence.

[0020] Preferably, the generating of a multi-scale feature position fusion feature map based on interactive spatial position attention comprises the following steps:

[0021] The output feature map of the residual block is planarized by using a planarization layer to obtain a first feature map;

[0022] Performing group normalization processing on the first feature map using a group normalization layer to obtain a second feature map;

[0023] Using the first convolutional layer to perform a convolution operation on the second feature map to obtain a third feature map;

[0024] The third feature map is divided into a query feature map, a key feature map and a value feature map in the channel dimension by using the attention layer, and then the query feature map is multiplied by the key feature map and the attention weight is generated through the activation function, and finally the attention weight is multiplied by the value feature map to obtain the fourth feature map;

[0025] Using the second convolutional layer to perform convolution operations and reshape operations on the fourth feature map to obtain a fifth feature map;

[0026] The feature fusion layer is used to add the output feature map of the residual block to the fifth feature map to obtain a feature position fusion feature map.

[0027] Preferably, the feature extraction module at the bottom of the encoder is connected to the feature reconstruction module at the bottom of the decoder through a feature enhancement module.

[0028] Preferably, the feature enhancement module includes:

[0029] Residual blocks, dual local-global Transformer units, and interactive spatial position attention units.

[0030] Preferably, the dual local-global Transformer block comprises:

[0031] The local Transformer block and the global Transformer block are placed in parallel, and the feature fusion block is connected to the local Transformer block and the global Transformer block respectively.

[0032] Preferably, the local Transformer block comprises:

[0033] The first linear layer, the spatial flattening layer, the first multi-head attention layer, the first feedforward network layer and the first learnable layer are arranged in sequence;

[0034] The global Transformer block includes:

[0035] The second linear layer, the channel flattening layer, the second multi-head attention layer, the second feedforward network layer and the second learnable layer are set in sequence.

[0036] The present invention has the following beneficial effects:

[0037] The present invention constructs a metal parts defect detection model, uses an encoder to generate a multi-scale feature position fusion feature map based on interactive spatial position attention, and then uses a decoder to fuse feature information from different levels of the encoder to obtain metal parts defect detection results, which significantly improves the detection performance of tiny defects on the surface of metal parts. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] Figure 1 The figure is a flow chart of a metal parts defect detection method based on scale-adaptive attention network;

[0039] Figure 2 This is a schematic diagram of the structure of the metal parts defect detection model;

[0040] Figure 3 Schematic diagram of the interactive spatial position attention unit structure;

[0041] Figure 4 Schematic diagram of the dual local-global Transformer structure;

[0042] Figure 5 Schematic diagram of the detection results of the present invention on the MPDD dataset for metal parts detection; (a) is a black bracket, (b) is a brown bracket, (c) is a white bracket, (d) is a connector, (e) is a metal plate, and (f) is a tube;

[0043] Figure 6 These are example diagrams of the ablation research results of the present invention on the magnetic tile dataset; wherein (a) is the original image, (b) is the ground truth, (c) is the baseline, (d) is the baseline + ISPA, (e) is the baseline + DLGT, and (f) is the baseline + ISPA + DLGT. DETAILED DESCRIPTION

[0044] The specific implementation modes of the present invention are described below so that those skilled in the art can understand the present invention. However, it should be clear that the present invention is not limited to the scope of the specific implementation modes. For those of ordinary skill in the art, as long as various changes are within the spirit and scope of the present invention as defined and determined by the attached claims, these changes are obvious, and all inventions and creations utilizing the concept of the present invention are protected.

[0045] like Figure 1 As shown, a metal parts defect detection method based on a scale-adaptive attention network provided by an embodiment of the present invention includes the following steps S1 to S4:

[0046] S1, obtaining metal parts images;

[0047] S2. Constructing a metal parts defect detection model; the metal parts defect detection model includes an encoder and a decoder;

[0048] S3, using the encoder to extract multi-scale feature maps from the metal part image, and generating multi-scale feature position fusion feature maps based on interactive spatial position attention;

[0049] S4. Use the decoder to reconstruct the spatial resolution of the multi-scale feature position fusion feature map, and at the same time fuse the feature information from different levels of the encoder through jump connections to output the metal parts defect detection results.

[0050] In an optional embodiment of the present invention, the metal part defect detection model constructed in this embodiment includes an encoder and a decoder; the encoder includes a multi-level feature extraction module arranged in sequence from top to bottom, and each level of the feature extraction module includes a residual block and an interactive spatial position attention unit; the decoder includes a multi-level feature reconstruction module arranged in sequence from bottom to top, and each level of the feature reconstruction module is connected to the feature extraction module of the corresponding level through a jump connection, and the feature reconstruction modules of adjacent levels are connected through an upsampling layer; each level of the feature reconstruction module includes a residual block and an interactive spatial position attention unit.

[0051] In an optional embodiment of the present invention, the metal part defect detection model constructed in this embodiment further includes a feature enhancement module, and the feature extraction module at the bottom of the encoder is connected to the feature reconstruction module at the bottom of the decoder through the feature enhancement module.

[0052] In an optional embodiment of the present invention, the top feature reconstruction module in the decoder also includes a convolution unit connected to the interactive spatial position attention unit.

[0053] like Figure 2As shown, the metal part defect detection model in this embodiment includes an encoder and a decoder to form a U-shaped structure; the encoder includes a first feature extraction module, a second feature extraction module, and a third feature extraction module arranged in sequence from top to bottom; the decoder includes a first feature reconstruction module, a second feature reconstruction module, and a third feature reconstruction module arranged in sequence from bottom to top; the first feature extraction module is connected to the third feature reconstruction module through a jump connection, the second feature extraction module is connected to the second feature reconstruction module through a jump connection, and the third feature extraction module is connected to the first feature reconstruction module through a jump connection; the output feature map of the feature enhancement module is spliced ​​with the output feature map of the third feature extraction module transmitted by the jump connection after passing through the upsampling layer as the input feature map of the first feature reconstruction module, the output feature map of the first feature reconstruction module is spliced ​​with the output feature map of the second feature extraction module transmitted by the jump connection after passing through the upsampling layer as the input feature map of the second feature reconstruction module, the output feature map of the second feature reconstruction module is spliced ​​with the output feature map of the first feature extraction module transmitted by the jump connection after passing through the upsampling layer as the input feature map of the third feature reconstruction module, and the third feature reconstruction module outputs the metal part defect detection result through the convolution unit.

[0054] In an optional embodiment of the present invention, since some defects of metal parts are very small and appear randomly on painted metal parts, these defects are always ignored by the network, resulting in poor performance; therefore, this embodiment constructs an interactive spatial position attention unit to model the interdependence between feature map pixels to detect tiny defects on the surface of metal parts.

[0055] like Figure 3 As shown, the interactive spatial position attention unit includes a planarization layer, a group normalization layer, a first convolutional layer, an attention layer, a second convolutional layer, and a feature fusion layer, which are arranged in sequence, and can be expressed as:

[0056] ISPA(X)=FPS{ATT[SLI(I)]+I}

[0057] Among them, FPS, ATT and SLI represent feature position fusion, attention mechanism and spatial position interaction respectively, and I represents the input feature map.

[0058] The method of generating a multi-scale feature position fusion feature map based on interactive spatial position attention comprises the following steps:

[0059] The output feature map of the residual block is planarized in the spatial dimension using a planarization layer to obtain a first feature map;

[0060] Performing group normalization processing on the first feature map using a group normalization layer to obtain a second feature map;

[0061] The second feature map is convolved by the first convolutional layer to obtain a third feature map of the three-layer channel feature map. By applying the above operation to the spatial pixels of the feature map, the interaction between pixels can be learned.

[0062] The third feature map is divided into a query feature map, a key feature map and a value feature map in the channel dimension by using the attention layer, and then the query feature map is multiplied by the key feature map and the attention weight is generated through the activation function, and finally the attention weight is multiplied by the value feature map to obtain the fourth feature map;

[0063] Using the second convolutional layer to perform convolution operations and reshape operations on the fourth feature map to obtain a fifth feature map;

[0064] The output feature map of the residual block is added to the fifth feature map by using the feature fusion layer to obtain a feature position fusion feature map. The above operation can fuse the feature details and the pixel position by summing, thereby realizing feature position fusion.

[0065] In an optional embodiment of the present invention, since the defective area in the metal part is highly similar to the non-defective area, where the color distribution is consistent and the edge feature details are similar, these low-contrast defects always fail. In order to distinguish the defective area from the surrounding normal area, this embodiment uses the visual Transformer to learn fine features from the original image, and designs a dual local-global Transformer block to distinguish similar defects in metal parts by fusing the overall attributes and local key features. The local Transformer module is designed to focus on the features of specific key areas in the image here, and the global Transformer is developed to learn the overall attributes of the image.

[0066] like Figure 4 As shown, the dual local-global Transformer block includes a local Transformer block and a global Transformer block in parallel, and a feature fusion block connected to the local Transformer block and the global Transformer block respectively, which can be expressed as:

[0067] DLGT(Q,K,V)=α*LTB(Q,K,V)+β*GTB(Q,K,V)

[0068] Among them, LTB and GTB represent the local Transformer block and the global Transformer block respectively, and α and β represent learnable parameters.

[0069] The local Transformer block includes:

[0070] The first linear layer, spatial planarization layer, first multi-head attention layer, first feedforward network layer and first learnable layer are set in sequence.

[0071] The global Transformer block includes:

[0072] The second linear layer, the channel flattening layer, the second multi-head attention layer, the second feedforward network layer and the second learnable layer are set in sequence.

[0073] The specific processing process of the dual local-global Transformer block is:

[0074] For the local Transformer block, the input feature map is first fed to the first linear layer, and then output to the spatial flattening layer for flattening in the spatial dimension to generate three feature maps Q, K, and V, which are then passed to the first multi-head attention layer to learn the features of specific key areas. Next, these feature maps are fed to the first feedforward network layer to generate efficient local feature maps through the learnable parameters α of the first learnable layer;

[0075] For the global Transformer block, the input feature map is first fed to the second linear layer, and then output to the channel flattening layer for flattening in the channel dimension to obtain three feature maps Q, K, and V, which are then fed to the second multi-head attention layer to focus on the overall properties of the feature map. Next, the feature map is transferred to the second feedforward network layer to generate attention-guided features through the learnable parameters β of the second learnable layer;

[0076] Finally, the local feature map output by the local Transformer block, the global feature map output by the global Transformer block and the input feature map are added to obtain the final output feature map, in which the key area details and overall attributes are fused into the original feature map.

[0077] The metal parts defect detection method based on scale-adaptive attention network provided by the present invention is analyzed and explained in combination with specific experiments.

[0078] In order to evaluate the performance of the present invention in metal parts monitoring, experiments are conducted using the MPDD dataset as a benchmark. Specifically, MPDD contains six categories, namely, 368 black brackets, 262 brown brackets, 170 white brackets, 172 connectors, 152 metal plates, and 223 tubes. In the experiment, this dataset is divided into a training set with 1076 images and a test set with 270 images.

[0079] In order to obtain the performance of the proposed model for surface defect detection of metal parts, the area under the receiver working feature and the precision-recall area are used as evaluation metrics, which are defined as:

[0080]

[0081] Among them, TPR is the true positive rate, FPR is the false positive rate, AUC is the area under the curve, P is the precision, R is the accuracy, AP is the average precision, TP is the predicted defective pixel, FP is the misclassified defective pixel, FN is the misestimated normal pixel, TN is the identified normal pixel, and d is the differential.

[0082] In addition, the saturation per-region overlap (sPRO) is used to obtain the anomaly detection capability of metal parts, which is defined as:

[0083]

[0084] Among them, m is the total number of true values, P is the predicted abnormal pixel, A is the real defect area, s is the saturation value, and i represents the i-th category.

[0085] The detection model proposed in this paper is built by Pytorch 1.9.0 on a workstation with NVIDIA GeForce GTX3060 GPU. Specifically, the Adam optimizer and CrossEntroy are used to train the proposed detection model in the experiment, where the learning rate, epoch and batch size are set to 3e-5, 200 and 8 respectively. In addition, the size of the original image is resized to 224×224, and then the mean of [0.485, 0.456, 0.406] is subtracted and divided by the standard of [0.229, 0.224, 0.225].

[0086] In order to demonstrate the superiority of the detection model proposed in this invention, nine state-of-the-art network models, namely CFA, DRAEM, FastFlow, FAVAE, PaDiM, PatchCore, RD4AD, SPADE and STPM, are used as comparison methods on the MPDD dataset, which are described as follows.

[0087] First, all models are tested on the MPDD dataset, and the results are shown in Table 1. As can be seen from Table 1, the detection model proposed in the present invention can achieve better performance on the MPDD dataset, with an AP of 90.7% and an sPRO of 96.1%, showing superior performance.

[0088] Table 1. Results of different methods on the MPDD dataset

[0089]

[0090] In addition, it can be found from Table 1 that compared with the second best PatchCore, the present invention improves by 47.5% and 2.2% on AP and sPRO, respectively, verifying that the attention mechanism performs better than the patch scoring strategy. In addition, the FastFlow, PaDiM, SPADE, CFA, RD4AD and STPM methods are used to perform feature embedding detection on metal parts. The results show that the SAA-Net method can achieve significant improvements compared with these methods. For example, compared with FastFlow, the present invention can obtain 16.7% and 46.23% progress on AP and sPRO, respectively. These excellent performances verify that the detection model proposed by the present invention is more suitable for the monitoring of metal parts.

[0091] at last, Figure 5 Some visualization examples are given to show the effectiveness of the detection model proposed in this invention, where the original image and groundtruth are listed in the first and second rows, while the prediction results and class attention maps are shown in the last two rows respectively. It can be seen that the detection model proposed in this invention pays great attention to defective areas such as black holes in the bracket (a), brown mismatched bends and parts of the bracket (b), white defects in the bracket (c), mismatched parts of the connector (d), scratches on the metal plate (e), and abnormal tubes (f). These visualization results show that the detection model proposed in this invention is an effective tool for metal parts monitoring.

[0092] We conduct some ablation experiments on the MPDD dataset to study the impact of the Interactive Spatial Position Attention (ISPA) unit and the Dual Local-Global Transformer (DLGT) unit, as described below.

[0093] The present invention designs an interactive spatial position attention (ISPA) unit to detect small defects on the surface of metal parts by modeling the interdependence between pixels. In order to explore the impact of the ISPA module proposed in this invention, many ablation studies were conducted on the MPDD dataset, and the results are shown in Table 2. Among them, N.1r represents the r result of the baseline U-net model composed of residual blocks, and its performance on AUC, AP and sPRO is 94.5%, 84.9% and 83.5%, respectively. After adding the ISPA module to the baseline model, these indicators can be increased to 96.6%, 89.3% and 88.6%, as shown in Table 2. Figure 2 As shown, it is verified that the ISPA unit is beneficial for metal component monitoring.

[0094] Table 2. Ablation research data table of the metal parts defect detection module based on the present invention

[0095]

[0096] also, Figure 6 Some visualization results are given to explore the effect of the proposed ISPA module, where the original images and ground truth are listed in the first and second columns respectively. Specifically, from the first two rows, comparing Figure 6 (c) and (d) (marked with yellow boxes), we can see that after adding the ISPA module to the baseline model, some small defects are segmented from the background, while many small defects are ignored by the baseline network. Figure 6 Similar results can be seen in (e) and (f). These results show that the proposed ISPA unit can help the network locate small defects from the background by learning the dependencies of feature maps.

[0097] The present invention designs a dual local-global transformer (DLGT) unit, which distinguishes the defective area from the surrounding normal area by fusing the overall attributes and key features. In order to further demonstrate the effectiveness of the DLGT module proposed in the present invention, a large number of ablation studies were also conducted on the MPDD dataset, and the results are recorded in Table 2. It can be seen from No. 1 and No. 3 in Table 2 that the performance of the network can be further improved, and the AUC, AP and sPRO have been improved by 1.1%, 3.6% and 12.0% respectively. It is verified that the DLGT unit proposed in the present invention can further enhance the network's ability to monitor metal parts.

[0098] also, Figure 6 Several ablation examples are shown in (c) and (e) of Fig. 3. It can be seen that after inserting the DLGT module (baseline+ISPA+DLGT), the network can distinguish similar defects from the surrounding normal areas, such as Figure 6 (d) and (f). These excellent results show that the DLGT module can distinguish similar defects from normal defects by fusing overall attributes and key features.

[0099] The present invention proposes a scale-adaptive attention network for metal part defect detection, in which an interactive spatial position attention (ISPA) unit is designed to detect small defects on the surface of metal parts, and a dual local-global Transformer (DLGT) unit is designed to distinguish defective areas from surrounding normal areas. A large number of experiments have proved the effectiveness of the present invention, which further helps the monitoring of metal parts in the manufacturing process.

[0100] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0101] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0102] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0103] The present invention uses specific embodiments to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of ​​the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.

[0104] Those skilled in the art will appreciate that the embodiments described herein are intended to help readers understand the principles of the present invention, and should be understood that the protection scope of the present invention is not limited to such specific statements and embodiments. Those skilled in the art can make various other specific variations and combinations that do not deviate from the essence of the present invention based on the technical revelations disclosed by the present invention, and these variations and combinations are still within the protection scope of the present invention.

Claims

1. A metal parts defect detection method based on scale-adaptive attention network, characterized in that: The following steps are involved: Acquire images of metal parts; Constructing a metal parts defect detection model; the metal parts defect detection model includes an encoder and a decoder; The encoder is used to extract multi-scale feature maps from metal part images, and a multi-scale feature position fusion feature map is generated based on interactive spatial position attention; The decoder is used to reconstruct the spatial resolution of the multi-scale feature position fusion feature map, and the feature information from different levels of the encoder is fused through jump connections to output the metal parts defect detection results.

2. The metal parts defect detection method based on scale-adaptive attention network according to claim 1 is characterized in that: The encoder comprises: A multi-level feature extraction module is arranged sequentially from top to bottom, and each level of the feature extraction module includes a residual block and an interactive spatial position attention unit.

3. The metal parts defect detection method based on scale-adaptive attention network according to claim 2 is characterized in that: The decoder comprises: A multi-level feature reconstruction module is arranged from bottom to top, each level of the feature reconstruction module is connected to the feature extraction module of the corresponding level through a jump connection, and the feature reconstruction modules of adjacent levels are connected through an upsampling layer; each level of the feature reconstruction module includes a residual block and an interactive spatial position attention unit.

4. The metal parts defect detection method based on scale-adaptive attention network according to claim 3 is characterized in that: The top feature reconstruction module in the decoder also includes a convolution unit connected to an interactive spatial position attention unit.

5. The metal parts defect detection method based on scale-adaptive attention network according to claim 4 is characterized in that: The interactive spatial position attention unit comprises: The planarization layer, group normalization layer, first convolution layer, attention layer, second convolution layer and feature fusion layer are set in sequence.

6. The metal parts defect detection method based on scale-adaptive attention network according to claim 5 is characterized in that: The method of generating a multi-scale feature position fusion feature map based on interactive spatial position attention comprises the following steps: The output feature map of the residual block is planarized by using a planarization layer to obtain a first feature map; Performing group normalization processing on the first feature map using a group normalization layer to obtain a second feature map; Using the first convolutional layer to perform a convolution operation on the second feature map to obtain a third feature map; The third feature map is divided into a query feature map, a key feature map and a value feature map in the channel dimension by using the attention layer, and then the query feature map is multiplied by the key feature map and the attention weight is generated through the activation function, and finally the attention weight is multiplied by the value feature map to obtain the fourth feature map; Using the second convolutional layer to perform convolution operations and reshape operations on the fourth feature map to obtain a fifth feature map; The feature fusion layer is used to add the output feature map of the residual block to the fifth feature map to obtain a feature position fusion feature map.

7. The metal parts defect detection method based on scale-adaptive attention network according to claim 6 is characterized in that: The bottom feature extraction module in the encoder is connected to the bottom feature reconstruction module in the decoder through the feature enhancement module.

8. The metal parts defect detection method based on scale-adaptive attention network according to claim 7 is characterized in that: The feature enhancement module comprises: Residual blocks, dual local-global Transformer units, and interactive spatial position attention units.

9. The metal parts defect detection method based on scale-adaptive attention network according to claim 8 is characterized in that: The dual local-global Transformer unit includes: The local Transformer block and the global Transformer block are placed in parallel, and the feature fusion block is connected to the local Transformer block and the global Transformer block respectively.

10. The metal parts defect detection method based on scale-adaptive attention network according to claim 9 is characterized in that: The local Transformer block includes: The first linear layer, the spatial flattening layer, the first multi-head attention layer, the first feedforward network layer and the first learnable layer are arranged in sequence; The global Transformer block includes: The second linear layer, channel flattening layer, second multi-head attention layer, second feedforward network layer and second learnable layer are set in sequence.

Citation Information

Patent Citations

  • Metal corrosion image segmentation method and device

    CN115170579A

  • Industrial product surface defect detection and positioning method and system based on generality and difference

    CN115439442A

Cited By

  • Copper-clad plate layering defect diagnosis method based on pattern recognition

    CN120876972A