Lightweight network construction method with high-precision metal surface defect detection function

By introducing an adaptive hybrid attention module, a simplified deep convolution module and a multi-path lightweight structure into the metal surface defect detection network, the problems of low detection accuracy, high calculation complexity and poor real-time performance in the prior art are solved, and metal surface defect detection with high accuracy, low parameter quantity and low calculation complexity are achieved, which is suitable for complex industrial scenarios.

CN119600413AActive Publication Date: 2025-03-11YANCHENG INST OF TECH +1
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202411689195.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-25
Publication Date
2025-03-11
Estimated Expiration
2044-11-25

AI Technical Summary

Technical Problem

The existing metal surface defect detection technology has low detection accuracy, high calculation complexity and poor real-time performance in complex environments, making it difficult to meet the needs of industrial scenarios.

Method used

A lightweight and high-precision metal surface defect detection network (ASV-Net) is proposed. By introducing an adaptive hybrid attention module (AHA), a simplified deep convolution module (SDA-Conv) and a multi-path lightweight structure (VoV-GSCSP-GS3), the defect detection accuracy is significantly improved and the parameter amount and calculation amount of the model are reduced.

Benefits of technology

On the GC10-DET dataset, ASV-Net has improved the average accuracy of the benchmark model by 4.0%, and the parameter quantity and GFLOPs have been reduced by 33.98% and 41.98%, respectively. It has shown strong generalization capabilities on public datasets such as NEU-DET and APSPC, which verified its application potential in complex industrial scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119600413A_ABST
    Figure CN119600413A_ABST
Patent Text Reader

Abstract

The invention provides a lightweight network construction method with a high-precision metal surface defect detection function, and the method comprises the steps: obtaining three known data sets from big data, training each data set to obtain a defect recognition feature corresponding to each data set, then constructing a defect recognition model, carrying out the precision training, obtaining an upgrade recognition model, and carrying out the recognition of the upgrade recognition model. Secondly, performing ablation analysis on the upgrade recognition model, performing K-fold cross validation on the overall effectiveness of the upgrade recognition model according to the function effectiveness corresponding to each recognition function, and performing generalization processing on the upgrade recognition model according to the target recognition function with insufficient function effectiveness and the corresponding third defect recognition feature; according to the method, an effective recognition model is generated, the effective recognition model is mapped to an image recognition neural network, neural network parameters of the image recognition neural network are adjusted according to a mapping result, a lightweight network is generated, and the problems that in the prior art, detection precision is low, calculation is complex, and real-time performance is poor are solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of steel surface defect detection, and in particular to a lightweight network construction method with a high-precision metal surface defect detection function. Background Art

[0002] As an indispensable basic material in industrial manufacturing, steel is widely used in many key industries, such as automobiles, construction, and ships. During its production and use, the surface of steel is often affected by complex environmental conditions, resulting in scratches, cracks, corrosion and other defects. Although these defects seem small, they not only affect the appearance of the product, but may also damage its structural integrity, leading to more serious structural problems such as stress concentration and fatigue cracks, which in turn lead to consequences such as fracture or failure. Therefore, the role of steel surface defect detection in quality control is crucial, and it can detect and repair defects in a timely manner, thereby effectively extending the mechanical properties and service life of the product and improving overall production efficiency.

[0003] Early detection methods for steel surface defects mainly include manual inspection, laser scanning and eddy current testing. Manual inspection relies on the operator's experience and is affected by factors such as light and fatigue, resulting in high false detection and missed detection rates. Although laser scanning has high accuracy, it is easily limited by surface reflection conditions and complex working conditions. Eddy current testing is based on the principle of electromagnetic induction and is suitable for detecting cracks, but it has low sensitivity to tiny or deeply buried defects and has obvious limitations in complex scenarios. These traditional methods have limited performance in high-precision detection tasks and urgently need more advanced technologies to improve performance.

[0004] With the vigorous development of machine vision technology, traditional manual visual inspection has been gradually replaced by automated surface defect detection methods. These technologies not only effectively reduce the detection cost, but also greatly reduce the dependence on manual operation, thereby greatly improving the detection efficiency. At present, surface defect detection methods based on machine vision can be roughly divided into two categories: one is the manual feature extraction method based on image processing and machine learning. This type of method has achieved remarkable results in early applications, but due to excessive reliance on artificially designed features, it has certain limitations when the illumination, scale and direction change in complex environments, which limits its application in actual industrial scenarios. Since AlexNet achieved a breakthrough in the ImageNet Challenge in 2012, deep learning technology has achieved leapfrog development, leading to the rise of a new generation of surface defect detection methods. The second type of method is the surface defect detection method based on deep learning, which has been widely used in the industrial field. This type of method can not only automatically extract complex features in images, has excellent generalization ability and strong adaptability, but also effectively overcome the bottleneck of traditional methods in the detection of small defects, greatly improving the accuracy and robustness of detection.

[0005] At present, deep learning-based object detection algorithms are usually divided into two-stage object detection and single-stage object detection. The two-stage detection algorithm first generates candidate boxes and then regresses the target according to the content of the candidate area, so it has higher detection accuracy. Typical two-stage algorithms include RCNN, Fast R-CNN, Faster R-CNN and Mask R-CNN. For example, Xuanhan Wang et al. proposed a new model KE-RCNN by introducing implicit and explicit knowledge encoding methods, which enhanced the understanding and parsing capabilities of complex fashion images. Mengqi Chen et al. proposed a new "FasterGG R-CNN" model, which embedded Gabor filters into the first layer of Faster R-CNN and optimized Gabor filter parameters through genetic algorithms to improve detection accuracy. Lin Du et al. constructed a training set through preprocessing methods such as image restoration and data enhancement, and then used the Mask R-CNN model to identify and segment cracks.

[0006] The single-stage target detection algorithm is different from the two-stage method. It does not rely on the candidate box generation step and directly solves the target detection as a regression problem. The main advantage of this type of method is that the detection speed is fast and it is suitable for application scenarios with high real-time requirements. Common single-stage detection algorithms include SSD and YOLO series. For example, Qu Zhijian et al. proposed a positioning wire clamp defect detection method that combines DenseNet and Inception modules to improve the SSD model for the complex background of the contact network application environment. By sharing information between feature layers, the feature extraction capability is improved, and the loss function is optimized by combining FPN and GIoU to improve the recognition effect. Xijun Ye et al. enhanced underwater images by improving CycleGAN and multi-scale Retinex (MSR) models, and then used the improved YOLOv5 model to detect structural damage on the enhanced images. Yin Zhang et al. proposed a new small target detection algorithm called FFCA-YOLO, which was improved for the problem of small target detection in remote sensing images. Yukang Cao et al. proposed a lightweight YOLOv8-GD model based on the improvement of YOLOv8, which is dedicated to electroluminescence image defect detection of solar photovoltaic modules.

[0007] Although existing deep learning target detection algorithms have achieved remarkable results in certain tasks, they still face many challenges in metal surface defect detection. First, the texture of metal surface defects is complex and the lighting conditions are changeable. When faced with low contrast and complex backgrounds, the detection accuracy of traditional detection methods is easily significantly affected. In addition, the multi-scale and aspect ratio diversity of metal surface defects increases the difficulty of feature extraction networks in fully capturing all defect details, resulting in missed detection problems. In order to address these challenges, many researchers have proposed corresponding solutions in recent years. However, the training and testing of these deep learning models usually require a lot of computing resources, especially when processing high-resolution images and large-scale data sets, the computing cost is extremely high. At the same time, the limited computing power of terminal devices makes these methods face challenges that cannot be ignored in practical applications. Therefore, how to achieve efficient and lightweight surface defect detection technology while ensuring detection accuracy has become a core issue that needs to be solved urgently.

[0008] Therefore, the present invention provides a lightweight network construction method with high-precision metal surface defect detection function. Summary of the invention

[0009] The present invention provides a lightweight network construction method with high-precision metal surface defect detection function. The present invention aims to solve the problems of low detection accuracy, high computational complexity and poor real-time performance in existing metal surface defect detection technologies. Current metal surface detection methods often perform poorly when dealing with complex multi-scale defects, low-contrast backgrounds and complex textures, and usually require a large amount of computing resources, which is difficult to meet the requirements of real-time detection in actual industrial scenarios. In order to solve these problems, the present invention proposes a lightweight and high-precision metal surface defect detection network (ASV-Net). By introducing an adaptive hybrid attention module (AHA), a simplified deep convolution module (SDA-Conv) and a multi-path lightweight structure (VoV-GSCSP-GS3), the present invention significantly improves the accuracy of defect detection, reduces the number of parameters and the amount of calculation of the model, so that the technology can be efficiently applied in resource-constrained industrial environments, meet real-time requirements, and improve the automation level and production efficiency of steel surface defect detection. This invention is particularly suitable for surface quality detection of industrial metals such as steel and aluminum, which helps to improve the mechanical properties of products, extend service life, and reduce the risk of structural failure caused by defects.

[0010] The present invention provides a lightweight network construction method with high-precision metal surface defect detection function, comprising:

[0011] Step 1: Obtain the GC10-DET dataset, NEU-DET dataset, and APSPC dataset from the big data, and train each dataset to obtain the defect recognition features corresponding to each dataset;

[0012] Step 2: construct a defect recognition model, and use the first defect recognition feature corresponding to the NEU-DET data set to perform accuracy training on the defect recognition model to obtain an upgraded recognition model;

[0013] Step 3: Performing ablation analysis on the upgraded recognition model, the functional effectiveness of each recognition function, using K-fold cross-validation to validate the overall effectiveness of the upgraded recognition model, and screening target recognition functions with insufficient functional effectiveness;

[0014] Step 4: generalize the upgraded recognition model using the second defect recognition feature corresponding to the GC10-DET data set and the third defect recognition feature corresponding to the APSPC data set to generate an effective recognition model;

[0015] Step 5: Map the effective recognition model to the image recognition neural network, adjust the neural network parameters of the image recognition neural network according to the mapping result, and generate a lightweight network.

[0016] In one practicable manner,

[0017] The step 1 comprises:

[0018] Step 11: Obtain the GC10-DET dataset, the NEU-DET dataset and the APSPC dataset from the big data, and use a preset python script program to perform hierarchical training on the GC10-DET dataset, the NEU-DET dataset and the APSPC dataset, respectively, to obtain a training set and a test set corresponding to each of the datasets;

[0019] Step 12: using the training set to train the GC10-DET dataset to obtain several metal surface defect categories corresponding to the GC10-DET dataset, using the training set to train the NEU-DET dataset to obtain several typical surface defect categories corresponding to the NEU-DET dataset, and using the training set to train the APSPC dataset to obtain several defect surface defect categories corresponding to the APSPC dataset;

[0020] Step 13: using the corresponding test set to test the first defect accuracy corresponding to each of the metal surface defect categories, using the corresponding test set to test the second defect accuracy corresponding to each of the typical surface defect categories, and using the corresponding test set to test the third defect accuracy corresponding to each of the defective surface defect categories;

[0021] Step 14: According to the first defect accuracy, each of the metal surface defect categories is corrected to obtain the first defect identification feature corresponding to the GC10-DET data set; according to the second defect accuracy, each of the typical surface defect categories is corrected to obtain the second defect identification feature corresponding to the NEU-DET data set; according to the third defect accuracy, each of the defect surface defect categories is corrected to obtain the third defect identification feature corresponding to the APSPC data set.

[0022] In one practicable manner,

[0023] The step 2 comprises:

[0024] Step 21: Build a YOLOv8n model in a deep learning environment to obtain a model structure of the YOLOv8n model, determine a backbone network of the YOLOv8n model according to the model structure, connect the backbone network to a preset AHA module for attention training, and determine the channel attention and spatial attention of the YOLOv8n model;

[0025] Step 22: determining the input network of the YOLOv8n model according to the model structure, building a plurality of training images according to the metal information, inputting each of the training images into the YOLOv8n model, and adjusting the parameters of the input network of the YOLOv8n model according to the image specifications corresponding to each of the training images;

[0026] Step 23: Determine the neck network of the YOLOv8n model according to the model structure, connect the neck network to the preset SDA-Conv module for convolution training, generate several convolution channels of the YOLOv8n model, compress each of the convolution channels respectively, obtain the channel weight corresponding to each of the convolution channels, and adjust the feature capture accuracy of the corresponding convolution channel according to the channel weight;

[0027] Step 24: Construct a defect recognition model according to the model structure and the training results corresponding to each network, input each of the first defect recognition features into the defect recognition model for accuracy verification, determine the accuracy error of the defect recognition model according to the verification results, and train the accuracy error to generate an upgraded recognition model.

[0028] In one practicable manner,

[0029] The step 24 comprises:

[0030] Step 241: mapping the training results corresponding to each network into the model structure to generate a defect recognition model, constructing a defect verification image corresponding to each of the first defect recognition features, inputting the defect verification image into the defect recognition model for image verification, and obtaining a corresponding verification output result;

[0031] Step 242: Draw corresponding verification defect features according to the verification output results, analyze the feature difference between each of the verification defect features and the corresponding first defect recognition feature, and determine the recognition accuracy of the defect recognition model for each of the first defect recognition features according to the feature difference;

[0032] Step 243: Determine the accuracy error of the defect recognition model according to the recognition accuracy corresponding to each of the first defect recognition features, construct an accuracy adjustment parameter based on each of the recognition accuracy, and iteratively train the defect recognition model using the accuracy adjustment parameter until the accuracy error is within a preset range, thereby obtaining an upgraded recognition model.

[0033] In one practicable manner,

[0034] The step 3 comprises:

[0035] Step 31: obtaining several model functions included in the upgraded recognition model, performing ablation experiments on each of the model functions to obtain the functional validity corresponding to each of the model functions, obtaining functional attributes corresponding to each of the model functions, and screening several recognition functions included in the upgraded recognition model according to the functional attributes;

[0036] Step 32: Establishing screening conditions according to the standard effectiveness, comparing the functional effectiveness according to the screening conditions, and obtaining the target recognition function with insufficient functional effectiveness;

[0037] Step 33: Divide each of the target function models into K function details respectively, perform folded cross validation on the function details, obtain the detail stability corresponding to each of the function details, count several detail stabilities corresponding to each of the recognition functions, and construct the overall effectiveness of the upgraded recognition model.

[0038] In one practicable manner,

[0039] The step 4 comprises:

[0040] Step 41: establishing a plurality of generalized images according to the second defect recognition feature and the third defect recognition feature, respectively acquiring image data corresponding to each of the generalized images, generating training data, verification data and test data corresponding to each of the generalized images according to the image data, and obtaining corresponding training sets, verification sets and test sets;

[0041] Step 42: using the training set to perform hyperparameter optimization training on the upgrade recognition model to obtain the optimal hyperparameters of the upgrade recognition model, inputting the optimal hyperparameters into the upgrade recognition model to generate an optimized recognition model, and inputting the test data contained in the test set into the optimized recognition model for generalization testing to obtain test data;

[0042] Step 43: using the test data included in the test set to perform error analysis on the corresponding test data to obtain a test error value of the corresponding generalized image; when the test error value is outside a specified error range, correcting the corresponding training data according to the test error to obtain updated training data; using the updated training data to perform targeted optimization on the optimized recognition model to generate an effective recognition model;

[0043] Step 44: When the error test values ​​are all within the specified error range, the optimized recognition model is regarded as a valid recognition model.

[0044] In one practicable manner,

[0045] The step 5 comprises:

[0046] Step 51: Mapping the effective recognition model to the image recognition neural network, recording the mapped record of the image recognition neural network, and generating network change information of the image recognition neural network and model decomposition information of the effective recognition model;

[0047] Step 52: Establish a mapping result according to the network change information and the model decomposition information, determine the adjustment direction and adjustment amount corresponding to each neural network parameter according to the mapping result, synchronously adjust the neural network parameters with the same adjustment direction, and generate a lightweight network.

[0048] In one practicable manner,

[0049] The setting process of the preset AHA module includes:

[0050] A training feature map is constructed based on the GC10-DET dataset, and the training feature map is globally averaged pooled using formula (1) to generate the first channel-level descriptor F avg :

[0051]

[0052] Wherein, H and w represent the height and width of the training feature map, and F avg (c) represents the global average pooling value of channel c, F(c,i,j) represents the pixel value of channel c at position (i,j) in feature map F, and F represents the training feature map;

[0053] Inputting the first channel-level descriptor into a multi-layer perceptron for convolution processing, and calculating the nonlinear activation range of the first channel-level descriptor in the multi-layer perceptron according to formula (2);

[0054] M c =σ(W2ReLU(W1F avg )) (2)

[0055] Wherein, W1 represents the first weight matrix of the first convolutional layer in the multilayer perceptron, W2 represents the second weight matrix of the second convolutional layer in the multilayer perceptron, σ represents the Sigmoid function, M c represents the nonlinear activation range of the channel descriptor;

[0056] According to formula (3), weighted processing of the training feature map is performed using the nonlinear activation range:

[0057]

[0058] Among them, F c ′ represents the training feature map after weighting by the nonlinear activation range, Represents an element-wise product operation;

[0059] According to formulas (4) and (5), the 3*3 convolution kernel is used to perform weighted processing on the training feature map after weighting by the nonlinear activation range:

[0060]

[0061] in, represents the intermediate transition image produced in the weighted process, f 3×3 represents a 3*3 convolution kernel, BN represents normalization, ReLU is the activation function, M s represents the channel attention feature image obtained after completing the nonlinear activation range and the 3*3 convolution kernel weighting respectively, and σ represents the Sigmoid function; according to formula (6), the channel attention feature image and the spatial attention image are input into the blank AHA module for attention training to generate a preset AHA module;

[0062]

[0063] Among them, F cs Represents the attention training output.

[0064] In one practicable manner,

[0065] The setting process of the preset SDA-Conv module includes:

[0066] Using formula (7), the number of channels of the blank SDA-Conv module is adjusted to 2;

[0067] F bottleneck =Conv 1×1 (F,W bottleneck )(7)

[0068] Among them, F bottleneck Indicates the result of channel number adjustment, the value is 2, Conv 1×1 represents a 1*1 convolution kernel, F represents the standard feature map set for the blank SDA-Conv module, and W bottleneck Represents the original number of channels of the blank SDA-Conv module;

[0069] Using formula (8), the independent features corresponding to each channel are extracted according to the 3*3 convolution kernel;

[0070] F depthwise =DepthwiseConv(F bottleneck ,W depthwise ) (8)

[0071] Among them, F depthwise represents independent features, W depthwise Represents the depth convolution weight parameter;

[0072] Using formula (9), the channel of the blank SDA-Conv module is restored according to the 1*1 convolution kernel to obtain a preliminary SDA-Conv module;

[0073] F pointwise =Conv 1×1 (F depthwise ,W pointwise )(9)

[0074] Among them, F pointwise Indicates that the channel has been restored, F depthwise represents the depth convolution channel in the blank SDA-Conv module, W pointwise Represents the convolution weight of the 1*1 convolution kernel, Conv 1×1 Represents a 1*1 convolution kernel;

[0075] Obtaining a training feature map, inputting the training feature map into the preliminary SDA-Conv module for image compression, and determining a model channel included in the preliminary SDA-Conv module;

[0076] Calculate the second channel-level descriptor corresponding to each existing model channel in the preliminary SDA-Conv module according to formula (10);

[0077]

[0078] Among them, z c represents the average value corresponding to the cth existing model channel, S and K represent the height and width of the training feature map respectively, and F pointwise (c,i,j) represents the pixel value corresponding to the cth existing model channel at position (a,b);

[0079] According to formulas (11) and (12), the preliminary SDA-Conv module is normalized and trained;

[0080] s=σ(W2δ(W1z c )) (11)

[0081]

[0082] Among them, W1 and W2 represent the first weight matrix corresponding to the ReLU activation function and the second weight matrix corresponding to the Sigmoid activation function, δ represents the ReLU activation function, σ represents the Sigmoid activation function, μ represents the batch mean, σ 2 represents batch variance, γ and β represent learning parameters respectively;

[0083] Using formula (13), the expressive power of the preliminary SDA-Conv module is modified;

[0084] S′=ReLU(S)=max(0,S) (13) Convolution processing is performed on the model channel to obtain the weight coefficient of the model channel, and the model channel output features of the preliminary SDA-Conv module are calculated according to formula (14) in combination with the input features of the training feature map;

[0085]

[0086] Where S′ represents the model channel output features of the preliminary SDA-Conv module, F pointwise represents the input feature, F′ is the output feature, s represents the initial input data of the preliminary SDA-Conv module, ⊙ represents the element-by-element product operation, and ε represents a small constant to prevent the denominator from being zero;

[0087] The output features of the model channel are used to perform deep training on the model channel of the preliminary SDA-Conv module to obtain a preset SDA-Conv module.

[0088] The achievable beneficial effects of the above technical solution are as follows: in order to solve the problems of low detection accuracy, complex calculation and poor real-time performance in the prior art, defect recognition features are constructed by utilizing the existing GC10-DET data set, NEU-DET data set and APSPC data set, and then the constructed defect recognition model is trained multiple times using the defect recognition features to generate an effective recognition model. In order to expand the scope of application of defect recognition, the effective recognition model is mapped in an image recognition neural network for processing, and finally a lightweight network is obtained. The network can be used to simultaneously identify surface defects of multiple metals, determine their defect locations and make corresponding reminders. The present invention introduces an adaptive hybrid attention module (AHA), a lightweight convolution module (SDA-Conv) and a multi-path structure (VoV-GSCSP), and the model achieves a significant improvement in detection accuracy while reducing the amount of parameters and computational complexity. On the GC10-DET dataset, ASV-Net improved the average accuracy of the baseline model by 4.0%, and reduced the number of parameters and GFLOPs by 33.98% and 41.98%, respectively. In addition, experiments show that the model exhibits strong generalization ability on public datasets such as NEU-DET and APSPC, further verifying its application potential in complex industrial scenarios.

[0089] Other features and advantages of the present invention will be described in the following description, and partly become apparent from the description, or understood by practicing the present invention. The purpose and other advantages of the present invention can be realized and obtained by the structures particularly pointed out in the written description and the accompanying drawings.

[0090] The technical solution of the present invention is further described in detail below through the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS

[0091] The accompanying drawings are used to provide a further understanding of the present invention and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the present invention and do not constitute a limitation of the present invention. In the accompanying drawings:

[0092] Figure 1 A schematic diagram of the workflow of a lightweight network construction method with a high-precision metal surface defect detection function in an embodiment of the present invention;

[0093] Figure 2 A schematic diagram of the salary flow of step 3 of the method for building a lightweight network with a high-precision metal surface defect detection function in an embodiment of the present invention;

[0094] Figure 3 is a flow chart of the steel surface defect detection method of the present invention;

[0095] Figure 4 It is a schematic diagram of the YOLOv8n network architecture of the present invention;

[0096] Figure 5 is a schematic diagram of the ASV-Net network architecture of the present invention;

[0097] Figure 6 It is a structural diagram of the AHA (Adaptive Hybrid Attention) module of the present invention;

[0098] Figure 7 It is a structural diagram of the C2f_AHA module of the present invention;

[0099] Figure 8 It is the structural diagram of the SDAConv (Slim Depth Attention Convolution) module of the present invention;

[0100] Fig. 9 It is a structural diagram of the SDAFlow-Detect module of the present invention;

[0101] Fig.10 It is the structure diagram of the VoV-GSCSP-GS3 module of the present invention;

[0102] Fig.11 is an example diagram of a data set of the present invention;

[0103] Fig.12 It is a comparison diagram of the algorithms of the present invention;

[0104] Figure 13-14 It is the test result diagram of the present invention;

[0105] Fig.15 It is the average accuracy curve diagram of the present invention;

[0106] Fig.16 is a precision-recall curve diagram of the present invention;

[0107] Fig.17 It is a K-fold cross validation graph of the present invention;

[0108] Fig.18 It is a generalization experiment diagram of the present invention;

[0109] Fig.19 It is a generalization experiment diagram of the present invention. DETAILED DESCRIPTION

[0110] The preferred embodiments of the present invention are described below in conjunction with the accompanying drawings. It should be understood that the preferred embodiments described herein are only used to illustrate and explain the present invention, and are not used to limit the present invention.

[0111] Example 1

[0112] This embodiment provides a lightweight network construction method with high-precision metal surface defect detection function, such as Figure 1 As shown, including:

[0113] Step 1: Obtain the GC10-DET dataset, NEU-DET dataset, and APSPC dataset from the big data, and train each dataset to obtain the defect recognition features corresponding to each dataset;

[0114] Step 2: construct a defect recognition model, and use the first defect recognition feature corresponding to the NEU-DET data set to perform accuracy training on the defect recognition model to obtain an upgraded recognition model;

[0115] Step 3: Performing ablation analysis on the upgraded recognition model, the functional effectiveness of each recognition function, using K-fold cross-validation to validate the overall effectiveness of the upgraded recognition model, and screening target recognition functions with insufficient functional effectiveness;

[0116] Step 4: generalize the upgraded recognition model using the second defect recognition feature corresponding to the GC10-DET data set and the third defect recognition feature corresponding to the APSPC data set to generate an effective recognition model;

[0117] Step 5: Map the effective recognition model to the image recognition neural network, adjust the neural network parameters of the image recognition neural network according to the mapping result, and generate a lightweight network.

[0118] In this example, the GC10-DET dataset comes from the paper "Deep metallic surface defect detection: The new benchmark and detection network". The dataset contains ten common metal surface defect categories: punching_hole (Ph), welding_line (Wl), crescent_gap (Cg), water_spot (Ws), oil_spot (Os), silk_spot (Ss), inclusion (In), rolled_pit (Rp), crease (Cr), waist_folding (Wf), a total of 2294 images, each of which contains one or more defect categories; the NEU-DET dataset comes from Northeast The dataset contains 6 typical defects on the surface of hot-rolled strip: cracks (Cr), inclusions (In), patches (Pa), pits (Pd), surface creases (Ps) and scratches (Rs). Each defect has 300 samples, totaling 1,800 images; the APSPC dataset comes from the 2018 Guangzhou Industrial Intelligence Big Data Innovation Competition, and contains 1,885 images of aluminum profile surface defects, covering 10 defects including dents (Ao), linting (Bu), overall defects (Ca), peeling (Ju), bottom leakage (Lo), power failure (Ni), pitting (Qi), hole filling (Tf), through-hole cracking (Tu), leakage (Us), and blistering (Za);

[0119] In this example, the first defect identification feature represents a feature used to identify ten common metal surface defect categories;

[0120] In this example, the upgraded recognition model represents a model that can recognize ten common metal surface defects;

[0121] In this example, the recognition function refers to the function of recognizing common metal surface defects;

[0122] In this instance, the functional effectiveness indicates the recognition accuracy of the recognition function;

[0123] In this instance, the overall effectiveness indicates the effectiveness of the upgraded recognition model for defect identification;

[0124] In this example, the second defect recognition feature represents a feature used to recognize six typical defects on the surface of hot-rolled steel strips;

[0125] In this example, the third defect identification feature represents a feature used to identify ten types of surface defects of aluminum profiles;

[0126] In this example, the image recognition neural network refers to a neural network that is set in advance and is used to perform image recognition.

[0127] The working principle and beneficial effects of the above technical solution: In order to solve the problems of low detection accuracy, complex calculation and poor real-time performance in the prior art, defect recognition features are constructed by utilizing the existing GC10-DET data set, NEU-DET data set and APSPC data set, and then the constructed defect recognition model is trained multiple times using the defect recognition features to generate an effective recognition model. In order to expand the scope of application of defect recognition, the effective recognition model is mapped in an image recognition neural network for processing, and finally a lightweight network is obtained. The network can be used to simultaneously identify surface defects of multiple metals, determine their defect locations and make corresponding reminders. The present invention introduces an adaptive hybrid attention module (AHA), a lightweight convolution module (SDA-Conv) and a multi-path structure (VoV-GSCSP), and the model achieves a significant improvement in detection accuracy while reducing the amount of parameters and computational complexity. On the GC10-DET dataset, ASV-Net improved the average accuracy of the baseline model by 4.0%, and reduced the number of parameters and GFLOPs by 33.98% and 41.98%, respectively. In addition, experiments show that the model exhibits strong generalization ability on public datasets such as NEU-DET and APSPC, further verifying its application potential in complex industrial scenarios.

[0128] Example 2

[0129] On the basis of Example 1, the lightweight network construction method with high-precision metal surface defect detection function, the step 1 includes:

[0130] Step 11: Obtain the GC10-DET dataset, the NEU-DET dataset and the APSPC dataset from the big data, and use a preset python script program to perform hierarchical training on the GC10-DET dataset, the NEU-DET dataset and the APSPC dataset, respectively, to obtain a training set and a test set corresponding to each of the datasets;

[0131] Step 12: using the training set to train the GC10-DET dataset to obtain several metal surface defect categories corresponding to the GC10-DET dataset, using the training set to train the NEU-DET dataset to obtain several typical surface defect categories corresponding to the NEU-DET dataset, and using the training set to train the APSPC dataset to obtain several defect surface defect categories corresponding to the APSPC dataset;

[0132] Step 13: using the corresponding test set to test the first defect accuracy corresponding to each of the metal surface defect categories, using the corresponding test set to test the second defect accuracy corresponding to each of the typical surface defect categories, and using the corresponding test set to test the third defect accuracy corresponding to each of the defective surface defect categories;

[0133] Step 14: According to the first defect accuracy, each of the metal surface defect categories is corrected to obtain the first defect identification feature corresponding to the GC10-DET data set; according to the second defect accuracy, each of the typical surface defect categories is corrected to obtain the second defect identification feature corresponding to the NEU-DET data set; according to the third defect accuracy, each of the defect surface defect categories is corrected to obtain the third defect identification feature corresponding to the APSPC data set.

[0134] In this example, in order to maintain the consistency of data distribution, a Python script is used to randomly divide the grayscale images of ten typical surface defects in the GC10-DET dataset into a training set and a test set, respectively, with a ratio of 8:2. The training set contains 1835 samples and the test set contains 459 samples. The NEU-DET dataset and the APSPC dataset are also divided into samples at a ratio of 8:2.

[0135] In this example, the metal surface defect category corresponds to the first defect identification feature, which is the result of classifying ten common metal surface defects;

[0136] In this example, the typical surface defect category corresponds to the second defect identification feature, which is the result of classifying six typical defects on the surface of hot-rolled strip steel;

[0137] In this example, the defect surface defect category corresponds to the third defect identification feature, which is the result of classifying the defects on the surfaces of ten aluminum profiles;

[0138] In this example, the first defect accuracy represents the accuracy of classifying metal surface defect types, the second defect accuracy represents the accuracy of classifying classic surface defect types, and the third defect accuracy represents the accuracy of classifying flaw surface defect types.

[0139] The working principle and beneficial effects of the above technical solution: In order to ensure the effectiveness of defect recognition, it is necessary to refine the defect recognition features, and use the script program to perform layered training on the GC10-DET data set, NEU-DET data set and APSPC data set to obtain their corresponding training sets and test sets, and then use the training set to train the corresponding data sets to determine the metal surface defect categories, typical surface defect categories and flawed surface defect categories, and then use the test set to analyze the accuracy corresponding to each category, so that the corresponding defect category is corrected according to the accuracy, and the defect recognition features corresponding to each data set are obtained. In this way, different types of defect categories can be uniformly planned and processed, and several standard and effective defect recognition features are determined to improve the effectiveness of defect recognition.

[0140] Example 3

[0141] On the basis of Example 1, the lightweight network construction method with high-precision metal surface defect detection function, the step 2 includes:

[0142] Step 21: Build a YOLOv8n model in a deep learning environment to obtain a model structure of the YOLOv8n model, determine a backbone network of the YOLOv8n model according to the model structure, connect the backbone network to a preset AHA module for attention training, and determine the channel attention and spatial attention of the YOLOv8n model;

[0143] Step 22: determining the input network of the YOLOv8n model according to the model structure, building a plurality of training images according to the metal information, inputting each of the training images into the YOLOv8n model, and adjusting the parameters of the input network of the YOLOv8n model according to the image specifications corresponding to each of the training images;

[0144] Step 23: Determine the neck network of the YOLOv8n model according to the model structure, connect the neck network to the preset SDA-Conv module for convolution training, generate several convolution channels of the YOLOv8n model, compress each of the convolution channels respectively, obtain the channel weight corresponding to each of the convolution channels, and adjust the feature capture accuracy of the corresponding convolution channel according to the channel weight;

[0145] Step 24: Construct a defect recognition model according to the model structure and the training results corresponding to each network, input each of the first defect recognition features into the defect recognition model for accuracy verification, determine the accuracy error of the defect recognition model according to the verification results, and train the accuracy error to generate an upgraded recognition model.

[0146] In this example, the model structure represents the network structure of the YOLOv8n model, including: Input, Backbone, Neck, and Head;

[0147] In this example, the preset AHA module draws on the channel and spatial attention mechanism of CBAM and introduces an adaptive mechanism to further improve the feature capture capability and adaptability to multi-task scenarios. Then, referring to the design concept of the linear bottleneck structure, a lightweight SDA-Conv convolution module is designed and applied to SDA-Flow-Detect, which significantly reduces the number of model parameters while maintaining a high detection accuracy. Finally, the VoV-GSCSP module is introduced in Neck and its internal structure is reconstructed. By applying the GSConv convolution operation multiple times, redundant calculations are effectively reduced, further realizing the lightweight design of the network.

[0148] In this example, the metal information represents the surface information presented by flawless metals of different materials;

[0149] In this example, feature capture accuracy refers to the accuracy with which the convolution channel captures the defect recognition features of the image;

[0150] In this example, the purpose of training the accuracy error is to eliminate the error of the defect recognition model.

[0151] The working principle and beneficial effects of the above technical solution are as follows: by building a YOLOv8n model in a deep learning environment, and then performing attention analysis on each model network in the YOLOv8n model, channel attention and spatial attention are established for the YOLOv8n model, and the convolution channel of the YOLOv8n model is further adjusted for accuracy through convolution training. Finally, a defect recognition model is established, and the defect recognition model is processed by eliminating errors, and finally an upgraded recognition model is obtained. In this way, a lightweight model can be obtained, and at the same time, the model can recognize a variety of different defects with high recognition accuracy.

[0152] Example 4

[0153] On the basis of Example 3, the lightweight network construction method with high-precision metal surface defect detection function, the step 24 includes:

[0154] Step 241: mapping the training results corresponding to each network into the model structure to generate a defect recognition model, constructing a defect verification image corresponding to each of the first defect recognition features, inputting the defect verification image into the defect recognition model for image verification, and obtaining a corresponding verification output result;

[0155] Step 242: Draw corresponding verification defect features according to the verification output results, analyze the feature difference between each of the verification defect features and the corresponding first defect recognition feature, and determine the recognition accuracy of the defect recognition model for each of the first defect recognition features according to the feature difference;

[0156] Step 243: Determine the accuracy error of the defect recognition model according to the recognition accuracy corresponding to each of the first defect recognition features, construct an accuracy adjustment parameter based on each of the recognition accuracy, and iteratively train the defect recognition model using the accuracy adjustment parameter until the accuracy error is within a preset range, thereby obtaining an upgraded recognition model.

[0157] In this example, the preset range indicates that the accuracy is in the range of 0.982-1.00.

[0158] The working principle and beneficial effects of the above technical solution are as follows: a defect verification image is generated according to the training results of the network, and then the corresponding verification defect adjustment is determined, the recognition accuracy of the defect recognition model is determined by analyzing the difference between the verification defect feature and the first defect recognition feature, and then the recognition accuracy is adjusted to within a preset range, thereby obtaining an upgraded recognition model that can be used for image recognition.

[0159] Example 5

[0160] Based on Example 1, the lightweight network construction method with high-precision metal surface defect detection function is as follows: Figure 2 As shown, the step 3 includes:

[0161] Step 31: obtaining several model functions included in the upgraded recognition model, performing ablation experiments on each of the model functions to obtain the functional validity corresponding to each of the model functions, obtaining functional attributes corresponding to each of the model functions, and screening several recognition functions included in the upgraded recognition model according to the functional attributes;

[0162] Step 32: Establishing screening conditions according to the standard effectiveness, comparing the functional effectiveness according to the screening conditions, and obtaining the target recognition function with insufficient functional effectiveness;

[0163] Step 33: Divide each of the target function models into K function details respectively, perform folded cross validation on the function details, obtain the detail stability corresponding to each of the function details, count several detail stabilities corresponding to each of the recognition functions, and construct the overall effectiveness of the upgraded recognition model.

[0164] In this example, the core of the ablation experiment is to conduct an ablation experiment on the upgraded recognition model by gradually adding a single module. The process is as follows:

[0165] Method A: Use the original model of YOLOv8n; Method B: Use C2f_AHA module to replace the four C2f modules in the Backbone part; Method C: Based on Method B, use SDAFlow-Detect; Method D: Based on Method C, replace the four C2f modules in the Neck part with VOV-GSCSP; Method E: Based on Method D, further optimize the four C2f modules in the Neck part to VOV-GSCSP-GS3;

[0166] The specific data of the ablation experiment are shown in Table 4:

[0167]

[0168] Table 4

[0169] After adding the AHA module, the overall detection performance of the model is significantly improved, and the detection accuracy is increased by 2.6% compared with the basic model. Among them, the detection ability of Waist_folding defects is improved most significantly, which is 15.1% higher than the basic model. After combining SDAFlow-Detect, while maintaining high detection accuracy, the model reduces the number of parameters and GFLOPs by 18.27% and 28.40% respectively compared with the basic model, and further improves the Waist_folding detection accuracy to 77.5%. By introducing the VOV-GSCSP module, the model has been further optimized in terms of detection accuracy, parameter amount and GFLOPs, and the detection performance of various defects has been relatively balanced. In the final E method, the model achieved the highest detection accuracy, which was 4.0% higher than the basic model, and the number of parameters and GFLOPs were reduced by 33.98% and 41.98% respectively. It is worth noting that among the ten defect categories, except for the welding_line defect, the detection ability of the model for the other nine defects has been improved, and the detection performance of six defects has reached the optimal effect of this ablation experiment;

[0170] In this example, the amount of feature detail is related to the number of folds in cross-validation.

[0171] The working principle and beneficial effects of the above technical solution are as follows: by conducting ablation experiments on the upgraded recognition model to determine the several model functions it contains, and analyzing the effectiveness of each model function, several screening conditions are established for the upgraded recognition model, and the target recognition function is proposed through screening. Then, the target recognition function is subjected to folded cross-validation, and the overall effectiveness of the upgraded recognition model is determined by processing the stability of each functional detail, thereby achieving the purpose of targeted processing and targeted analysis.

[0172] Example 6

[0173] On the basis of Example 1, the lightweight network construction method with high-precision metal surface defect detection function, the step 4 includes:

[0174] Step 41: establishing a plurality of generalized images according to the second defect recognition feature and the third defect recognition feature, respectively acquiring image data corresponding to each of the generalized images, generating training data, verification data and test data corresponding to each of the generalized images according to the image data, and obtaining corresponding training sets, verification sets and test sets;

[0175] Step 42: using the training set to perform hyperparameter optimization training on the upgrade recognition model to obtain the optimal hyperparameters of the upgrade recognition model, inputting the optimal hyperparameters into the upgrade recognition model to generate an optimized recognition model, and inputting the test data contained in the test set into the optimized recognition model for generalization testing to obtain test data;

[0176] Step 43: using the test data included in the test set to perform error analysis on the corresponding test data to obtain a test error value of the corresponding generalized image; when the test error value is outside a specified error range, correcting the corresponding training data according to the test error to obtain updated training data; using the updated training data to perform targeted optimization on the optimized recognition model to generate an effective recognition model;

[0177] Step 44: When the error test values ​​are all within the specified error range, the optimized recognition model is regarded as a valid recognition model.

[0178] In this example, hyperparameters refer to the parameters manually set in advance in the upgrade recognition model;

[0179] In this example, the specified error range is ±0.99%;

[0180] In this example, the process of generating an effective recognition model also includes: configuring the network weight, learning rate, batch size, and number of iterations of the model. The specific parameters are shown in Table 1. The mean average precision (mAP) is mainly used as the core indicator for evaluating the performance of the model. mAP is used to measure the detection accuracy of the model on different defect types. The specific calculation formula is as follows:

[0181]

[0182] Among them, AP(i) represents the detection accuracy of the i-th category, P(R) is the precision, and R is the recall rate.

[0183]

[0184] mAP is the average of the detection accuracy of all categories, and n represents the total number of categories;

[0185]

[0186] Table 1

[0187] Tables 2 and 3 are used to compare the differences between YOLOv5n, YOLOv6n, YOLOv7-tiny, YOLOv8n, YOLOv9c, YOLOv10n, YOLOv10b, YOLOX-s, SSD, Faster-RCNN, DETR, RT-DETR, CenterNet, EfficientDet, RetinaNet, FCOS, DCC-CenterNet, STFE-Net, WSS-YOLO and the present invention;

[0188]

[0189] Table 2

[0190]

[0191] Table 3

[0192] It can be seen from Tables 5 and 6 that the present invention performs well on the NEU-DET and APSPC datasets, with the overall accuracy improved by 2.5% and 2.4% respectively;

[0193]

[0194] Table 5

[0195]

[0196] Table 6

[0197] The working principle and beneficial effects of the above technical solution are as follows: by generating generalized images to establish corresponding training sets, validation sets and test sets, then using the training set to perform hyperparameter optimization training on the upgraded recognition model to determine the optimal hyperparameters of the upgraded recognition model, and further using the test set to perform generalization testing on the obtained optimized recognition model to obtain test data, and by performing error analysis on the test data to correct the training data, an effective recognition model is obtained, which can be used to process the network to obtain a high-precision and high-efficiency defect analysis method.

[0198] Example 7

[0199] On the basis of Example 1, the lightweight network construction method with high-precision metal surface defect detection function, the step 5 includes:

[0200] Step 51: Mapping the effective recognition model to the image recognition neural network, recording the mapped record of the image recognition neural network, and generating network change information of the image recognition neural network and model decomposition information of the effective recognition model;

[0201] Step 52: Establish a mapping result according to the network change information and the model decomposition information, determine the adjustment direction and adjustment amount corresponding to each neural network parameter according to the mapping result, synchronously adjust the neural network parameters with the same adjustment direction, and generate a lightweight network.

[0202] In this example, the adjustment direction indicates the direction when adjusting the neural network parameters;

[0203] In this example, the adjustment amount represents the value that needs to be adjusted when adjusting the neural network parameters;

[0204] In this example, the purpose of performing synchronization adjustment is to improve the efficiency of building a lightweight network.

[0205] The working principle and beneficial effects of the above technical solution are as follows: By mapping the effective recognition model into the image recognition network to construct a lightweight network, the specific functions of the effective recognition model can be endowed to the highlight recognition neural network, thereby obtaining a high-efficiency, high-quality and widely used defect recognition network.

[0206] Example 8

[0207] On the basis of Example 3, the lightweight network construction method with high-precision metal surface defect detection function, the setting process of the preset AHA module includes:

[0208] A training feature map is constructed based on the GC10-DET dataset, and the training feature map is globally averaged pooled using formula (1) to generate the first channel-level descriptor Favg :

[0209]

[0210] Wherein, H and w represent the height and width of the training feature map, and F avg (c) represents the global average pooling value of channel c, F(c,i,j) represents the pixel value of channel c at position (i,j) in feature map F, and F represents the training feature map;

[0211] Inputting the first channel-level descriptor into a multi-layer perceptron for convolution processing, and calculating the nonlinear activation range of the first channel-level descriptor in the multi-layer perceptron according to formula (2);

[0212] M c =σ(W2ReLU(W1G avg )) (2)

[0213] Wherein, W1 represents the first weight matrix of the first convolutional layer in the multilayer perceptron, W2 represents the second weight matrix of the second convolutional layer in the multilayer perceptron, σ represents the Sigmoid function, M c represents the nonlinear activation range of the channel descriptor;

[0214] According to formula (3), weighted processing of the training feature map is performed using the nonlinear activation range:

[0215]

[0216] Among them, F c ′ represents the training feature map after weighting by the nonlinear activation range, Represents an element-wise product operation;

[0217] According to formulas (4) and (5), the 3*3 convolution kernel is used to perform weighted processing on the training feature map after weighting by the nonlinear activation range:

[0218]

[0219] in, represents the intermediate transition image produced in the weighted process, f 3×3 represents a 3*3 convolution kernel, BN represents normalization, ReLU is the activation function, M s represents the channel attention feature image obtained after completing the nonlinear activation range and the 3*3 convolution kernel weighting respectively, and σ represents the Sigmoid function; according to formula (6), the channel attention feature image and the spatial attention image are input into the blank AHA module for attention training to generate a preset AHA module;

[0220]

[0221] Among them, F cs Represents the attention training output.

[0222] In this example, the effect achieved by formula (1) is as follows: This operation generates a descriptor by calculating the mean value of each channel in the feature map to capture global feature information;

[0223] In this example, the multilayer perceptron contains two convolutional layers, the first layer reduces the dimensionality, the second layer restores the dimensionality, and a nonlinear activation is applied between the two;

[0224] In this example, the purpose of deep weighting of the attention feature image is to adjust the channels with more information and suppress the less relevant channels, thereby improving the quality of the overall representation of the feature map;

[0225] In this example, the AHA module introduces a strategy combining convolution operation with BatchNorm. This ensures the effective capture of feature information in the spatial dimension, and on the other hand, stabilizes the model training process through BN and improves the generalization ability of the model. This method is more flexible in processing important spatial information and can adapt to input features in different scenarios.

[0226] In this example, the structure of the preset AHA module is: C2f_AHA structure. The C2f module is used for the extraction and fusion of multi-scale features, while the AHA module further optimizes feature selection and weight allocation. The C2f module gradually aggregates features through a multi-layer bottleneck structure, while AHA further improves the ability to capture fine-grained features and the generalization ability of the network through adaptive spatial convolution and channel weight adjustment. Through this combination, C2f_AHA not only maintains the computational efficiency of the C2f module, but also enhances the flexibility of feature selection and the adaptability of the model to complex scenes through the AHA module.

[0227] The working principle and beneficial effects of the above technical solution: By setting up the AHA module and connecting it to the model, the fine-grained features of the model can be further improved, its capture capability and the generalization ability of the network can be improved, and the flexibility of feature selection in actual recognition work and the model's adaptability to complex scenarios can be improved.

[0228] Example 9

[0229] On the basis of Example 3, the lightweight network construction method with high-precision metal surface defect detection function is characterized in that the setting process of the preset SDA-Conv module includes:

[0230] Using formula (7), the number of channels of the blank SDA-Conv module is adjusted to 2;

[0231] F bottleneck =Conv 1×1 (F,W bottleneck )(7)

[0232] Among them, F bottleneck Indicates the result of channel number adjustment, the value is 2, Conv 1×1 represents a 1*1 convolution kernel, F represents the standard feature map set for the blank SDA-Conv module, and W bottleneck Represents the original number of channels of the blank SDA-Conv module;

[0233] Using formula (8), the independent features corresponding to each channel are extracted according to the 3*3 convolution kernel;

[0234] F depthwise =DepthwiseConv(F bottleneck ,W depthwise ) (8)

[0235] Among them, F depthwise represents independent features, W depthwise Represents the depth convolution weight parameter;

[0236] Using formula (9), the channel of the blank SDA-Conv module is restored according to the 1*1 convolution kernel to obtain a preliminary SDA-Conv module;

[0237] F pointwise =Conv 1×1 (F depthwise ,W pointwise )(9)

[0238] Among them, F pointwise Indicates that the channel has been restored, F depthwise represents the depth convolution channel in the blank SDA-Conv module, W pointwise Represents the convolution weight of the 1*1 convolution kernel, Conv 1×1 Represents a 1*1 convolution kernel;

[0239] Obtaining a training feature map, inputting the training feature map into the preliminary SDA-Conv module for image compression, and determining a model channel included in the preliminary SDA-Conv module;

[0240] Calculate the second channel-level descriptor corresponding to each existing model channel in the preliminary SDA-Conv module according to formula (10);

[0241]

[0242] Among them, z c represents the average value corresponding to the cth existing model channel, S and K represent the height and width of the training feature map respectively, and F pointwise (c,i,j) represents the pixel value corresponding to the cth existing model channel at position (a,b);

[0243] According to formulas (11) and (12), the preliminary SDA-Conv module is normalized and trained;

[0244] s=σ(W2δ(W1z c )) (11)

[0245]

[0246] Among them, W1 and W2 represent the first weight matrix corresponding to the ReLU activation function and the second weight matrix corresponding to the Sigmoid activation function, δ represents the ReLU activation function, σ represents the Sigmoid activation function, μ represents the batch mean, σ 2 represents batch variance, γ and β represent learning parameters respectively;

[0247] Using formula (13), the expressive power of the preliminary SDA-Conv module is modified;

[0248] S′=ReLU(S)=max(0,S) (13) Convolution processing is performed on the model channel to obtain the weight coefficient of the model channel, and the model channel output features of the preliminary SDA-Conv module are calculated according to formula (14) in combination with the input features of the training feature map;

[0249]

[0250] Where S′ represents the model channel output features of the preliminary SDA-Conv module, F pointwise represents the input feature, F′ is the output feature, s represents the initial input data of the preliminary SDA-Conv module, ⊙ represents the element-by-element product operation, and ε represents a small constant to prevent the denominator from being zero;

[0251] The output features of the model channel are used to perform deep training on the model channel of the preliminary SDA-Conv module to obtain a preset SDA-Conv module.

[0252] In this example, the purpose of extracting independent features is to ensure that each channel is convolved only with itself to avoid information mixing. The advantage of deep convolution is that it can reduce computational complexity while capturing features in local space;

[0253] In this example, the purpose of the weighted operation is to dynamically adjust the output features of each channel so that the model retains important feature information while not losing too much computational overhead when processing features.

[0254] The working principle and beneficial effects of the above technical solution: By setting the SDA-Conv module in advance, the model's capture of key information can be enhanced while maintaining lightweight, thereby improving the capture quality of the lightweight network.

[0255] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.

Claims

1. A lightweight network construction method with high-precision metal surface defect detection function, characterized in that: include: Step 1: Obtain the GC10-DET dataset, NEU-DET dataset, and APSPC dataset from the big data, and train each dataset to obtain the defect recognition features corresponding to each dataset; Step 2: construct a defect recognition model, and use the first defect recognition feature corresponding to the NEU-DET data set to perform accuracy training on the defect recognition model to obtain an upgraded recognition model; Step 3: Performing ablation analysis on the upgraded recognition model, the functional effectiveness of each recognition function, using K-fold cross-validation to validate the overall effectiveness of the upgraded recognition model, and screening target recognition functions with insufficient functional effectiveness; Step 4: generalize the upgraded recognition model using the second defect recognition feature corresponding to the GC10-DET data set and the third defect recognition feature corresponding to the APSPC data set to generate an effective recognition model; Step 5: Map the effective recognition model to the image recognition neural network, adjust the neural network parameters of the image recognition neural network according to the mapping result, and generate a lightweight network.

2. The lightweight network construction method with high-precision metal surface defect detection function as claimed in claim 1, characterized in that: The step 1 comprises: Step 11: Obtain the GC10-DET dataset, the NEU-DET dataset and the APSPC dataset from the big data, and use a preset python script program to perform hierarchical training on the GC10-DET dataset, the NEU-DET dataset and the APSPC dataset, respectively, to obtain a training set and a test set corresponding to each of the datasets; Step 12: using the training set to train the GC10-DET dataset to obtain several metal surface defect categories corresponding to the GC10-DET dataset, using the training set to train the NEU-DET dataset to obtain several typical surface defect categories corresponding to the NEU-DET dataset, and using the training set to train the APSPC dataset to obtain several defect surface defect categories corresponding to the APSPC dataset; Step 13: using the corresponding test set to test the first defect accuracy corresponding to each of the metal surface defect categories, using the corresponding test set to test the second defect accuracy corresponding to each of the typical surface defect categories, and using the corresponding test set to test the third defect accuracy corresponding to each of the defective surface defect categories; Step 14: According to the first defect accuracy, each of the metal surface defect categories is corrected to obtain the first defect identification feature corresponding to the GC10-DET data set; according to the second defect accuracy, each of the typical surface defect categories is corrected to obtain the second defect identification feature corresponding to the NEU-DET data set; according to the third defect accuracy, each of the defect surface defect categories is corrected to obtain the third defect identification feature corresponding to the APSPC data set.

3. The lightweight network construction method with high-precision metal surface defect detection function as claimed in claim 1, characterized in that: The step 2 comprises: Step 21: Build a YOLOv8n model in a deep learning environment to obtain a model structure of the YOLOv8n model, determine a backbone network of the YOLOv8n model according to the model structure, connect the backbone network to a preset AHA module for attention training, and determine the channel attention and spatial attention of the YOLOv8n model; Step 22: determining the input network of the YOLOv8n model according to the model structure, building a plurality of training images according to the metal information, inputting each of the training images into the YOLOv8n model, and adjusting the parameters of the input network of the YOLOv8n model according to the image specifications corresponding to each of the training images; Step 23: Determine the neck network of the YOLOv8n model according to the model structure, connect the neck network to the preset SDA-Conv module for convolution training, generate several convolution channels of the YOLOv8n model, compress each of the convolution channels respectively, obtain the channel weight corresponding to each of the convolution channels, and adjust the feature capture accuracy of the corresponding convolution channel according to the channel weight; Step 24: Construct a defect recognition model according to the model structure and the training results corresponding to each network, input each of the first defect recognition features into the defect recognition model for accuracy verification, determine the accuracy error of the defect recognition model according to the verification results, and train the accuracy error to generate an upgraded recognition model.

4. The lightweight network construction method with high-precision metal surface defect detection function as claimed in claim 3, characterized in that: The step 24 comprises: Step 241: mapping the training results corresponding to each network into the model structure to generate a defect recognition model, constructing a defect verification image corresponding to each of the first defect recognition features, inputting the defect verification image into the defect recognition model for image verification, and obtaining a corresponding verification output result; Step 242: Draw corresponding verification defect features according to the verification output results, analyze the feature difference between each of the verification defect features and the corresponding first defect recognition feature, and determine the recognition accuracy of the defect recognition model for each of the first defect recognition features according to the feature difference; Step 243: Determine the accuracy error of the defect recognition model according to the recognition accuracy corresponding to each of the first defect recognition features, construct an accuracy adjustment parameter based on each of the recognition accuracy, and iteratively train the defect recognition model using the accuracy adjustment parameter until the accuracy error is within a preset range, thereby obtaining an upgraded recognition model.

5. The lightweight network construction method with high-precision metal surface defect detection function as claimed in claim 1, characterized in that: The step 3 comprises: Step 31: obtaining several model functions included in the upgraded recognition model, performing ablation experiments on each of the model functions to obtain the functional validity corresponding to each of the model functions, obtaining functional attributes corresponding to each of the model functions, and screening several recognition functions included in the upgraded recognition model according to the functional attributes; Step 32: Establishing screening conditions according to the standard effectiveness, comparing the functional effectiveness according to the screening conditions, and obtaining the target recognition function with insufficient functional effectiveness; Step 33: Divide each of the target function models into K function details respectively, perform folded cross validation on the function details, obtain the detail stability corresponding to each of the function details, count several detail stabilities corresponding to each of the recognition functions, and construct the overall effectiveness of the upgraded recognition model.

6. The lightweight network construction method with high-precision metal surface defect detection function as claimed in claim 1, characterized in that: The step 4 comprises: Step 41: establishing a plurality of generalized images according to the second defect recognition feature and the third defect recognition feature, respectively acquiring image data corresponding to each of the generalized images, generating training data, verification data and test data corresponding to each of the generalized images according to the image data, and obtaining corresponding training sets, verification sets and test sets; Step 42: using the training set to perform hyperparameter optimization training on the upgrade recognition model to obtain the optimal hyperparameters of the upgrade recognition model, inputting the optimal hyperparameters into the upgrade recognition model to generate an optimized recognition model, and inputting the test data contained in the test set into the optimized recognition model for generalization testing to obtain test data; Step 43: using the test data included in the test set to perform error analysis on the corresponding test data to obtain a test error value of the corresponding generalized image; when the test error value is outside a specified error range, correcting the corresponding training data according to the test error to obtain updated training data; using the updated training data to perform targeted optimization on the optimized recognition model to generate an effective recognition model; Step 44: When the error test values ​​are all within the specified error range, the optimized recognition model is regarded as a valid recognition model.

7. The lightweight network construction method with high-precision metal surface defect detection function as claimed in claim 1, characterized in that: The step 5 comprises: Step 51: Mapping the effective recognition model to the image recognition neural network, recording the mapped record of the image recognition neural network, and generating network change information of the image recognition neural network and model decomposition information of the effective recognition model; Step 52: Establish a mapping result according to the network change information and the model decomposition information, determine the adjustment direction and adjustment amount corresponding to each neural network parameter according to the mapping result, synchronously adjust the neural network parameters with the same adjustment direction, and generate a lightweight network.

8. The lightweight network construction method with high-precision metal surface defect detection function as claimed in claim 3, characterized in that: The setting process of the preset AHA module includes: A training feature map is constructed based on the GC10-DET dataset, and the training feature map is globally averaged pooled using formula (1) to generate the first channel-level descriptor F avg : Wherein, H and w represent the height and width of the training feature map, and F avg (c) represents the global average pooling value of channel c, F(c,i,j) represents the pixel value of channel c at position (i,j) in feature map F, and F represents the training feature map; Inputting the first channel-level descriptor into a multi-layer perceptron for convolution processing, and calculating the nonlinear activation range of the first channel-level descriptor in the multi-layer perceptron according to formula (2); M c =σ(W2ReLU(W1G avg )) (2) Wherein, W1 represents the first weight matrix of the first convolutional layer in the multilayer perceptron, W2 represents the second weight matrix of the second convolutional layer in the multilayer perceptron, σ represents the Sigmoid function, M c represents the nonlinear activation range of the channel descriptor; According to formula (3), weighted processing of the training feature map is performed using the nonlinear activation range: Among them, F′ c represents the training feature map after weighting by the nonlinear activation range, Represents an element-wise product operation; According to formulas (4) and (5), the 3*3 convolution kernel is used to perform weighted processing on the training feature map after weighting by the nonlinear activation range: in, represents the intermediate transition image produced in the weighted process, f 3×3 represents a 3*3 convolution kernel, BN represents normalization, ReLU is the activation function, M s represents the channel attention feature image obtained after completing the nonlinear activation range and the 3*3 convolution kernel weighting respectively, and σ represents the Sigmoid function; according to formula (6), the channel attention feature image and the spatial attention image are input into the blank AHA module for attention training to generate a preset AHA module; Among them, F cs Represents the attention training output.

9. The lightweight network construction method with high-precision metal surface defect detection function as claimed in claim 3, characterized in that: The setting process of the preset SDA-Conv module includes: Using formula (7), the number of channels of the blank SDA-Conv module is adjusted to 2; F bottleneck =Conv 1×1 (F,W bottleneck ) (7) Among them, F bottleneck Indicates the result of channel number adjustment, the value is 2, Conv 1×1 represents a 1*1 convolution kernel, F represents the standard feature map set for the blank SDA-Conv module, and W bottleneck Represents the original number of channels of the blank SDA-Conv module; Using formula (8), the independent features corresponding to each channel are extracted according to the 3*3 convolution kernel; F depthwise =DepthwiseConv(F bottleneck ,W depthwise )(8) Among them, F depthwise represents independent features, W depthwise Represents the depth convolution weight parameter; Using formula (9), the channel of the blank SDA-Conv module is restored according to the 1*1 convolution kernel to obtain a preliminary SDA-Conv module; F pointwise =Conv 1×1 (F depthwise ,W pointwise )(9) Among them, F pointwise Indicates that the channel has been restored, F depthwise represents the depth convolution channel in the blank SDA-Conv module, W pointwise Represents the convolution weight of the 1*1 convolution kernel, Conv 1×1 Represents a 1*1 convolution kernel; Obtaining a training feature map, inputting the training feature map into the preliminary SDA-Conv module for image compression, and determining a model channel included in the preliminary SDA-Conv module; Calculate the second channel-level descriptor corresponding to each existing model channel in the preliminary SDA-Conv module according to formula (10); Among them, z c represents the average value corresponding to the cth existing model channel, S and K represent the height and width of the training feature map respectively, and F pointwise (c,i,j) represents the pixel value corresponding to the cth existing model channel at position (a,b); According to formulas (11) and (12), the preliminary SDA-Conv module is normalized and trained; s=σ(W2δ(W1z c )) (11) Among them, W1 and W2 represent the first weight matrix corresponding to the ReLU activation function and the second weight matrix corresponding to the Sigmoid activation function, δ represents the ReLU activation function, σ represents the Sigmoid activation function, μ represents the batch mean, σ 2 represents batch variance, γ and β represent learning parameters respectively; Using formula (13), the expressive power of the preliminary SDA-Conv module is modified; S′=ReLU(S)=max(0,S) (13) Convolution processing is performed on the model channel to obtain the weight coefficient of the model channel, and the model channel output features of the preliminary SDA-Conv module are calculated according to formula (14) in combination with the input features of the training feature map; Where S′ represents the model channel output features of the preliminary SDA-Conv module, F pointwise represents the input feature, F′ is the output feature, s represents the initial input data of the preliminary SDA-Conv module, ⊙ represents the element-by-element product operation, and ε represents a small constant to prevent the denominator from being zero; The output features of the model channel are used to perform deep training on the model channel of the preliminary SDA-Conv module to obtain a preset SDA-Conv module.

Citation Information

Patent Citations

  • Fan blade surface defect detection method based on multi-feature map sharing

    CN114004797A

  • Steel product surface defect detection method based on lightweight neural network

    CN116342542A

  • Improved YOLOv5s-based injection molding part surface defect detection method

    CN116542932A

  • Lightweight photovoltaic panel defect detection method based on deep learning

    CN118212203A

  • Capacitance defect intelligent detection method based on deep learning

    WO2022120665A1