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

By constructing a lightweight network ASV-Net and utilizing an adaptive hybrid attention module and a simplified depth convolution module, the problems of low detection accuracy and high computational complexity in metal surface defect detection are solved, achieving efficient and real-time defect detection, which is suitable for surface quality inspection of industrial metals such as steel and aluminum.

CN119600413BActive Publication Date: 2026-06-09YANCHENG INST OF TECH +1

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
YANCHENG INST OF TECH
Filing Date
2024-11-25
Publication Date
2026-06-09

Smart Images

  • Figure CN119600413B_ABST
    Figure CN119600413B_ABST
Patent Text Reader

Abstract

The application provides a lightweight network construction method with high-precision metal surface defect detection function, comprising: obtaining three known data sets in big data, training each data set to obtain corresponding defect recognition features of each data set, then constructing a defect recognition model, and performing precision training to obtain an upgraded recognition model, then performing ablation analysis on the upgraded recognition model, each recognition function corresponding to a function effectiveness, using K-fold cross-validation to verify the overall effectiveness of the upgraded recognition model, screening target recognition functions with insufficient function effectiveness, performing generalization processing on the upgraded recognition model corresponding to the third defect recognition features, generating an effective recognition model, mapping the effective recognition model to an image recognition neural network, adjusting neural network parameters of the image recognition neural network according to the mapping result, and generating a lightweight network, solving the problems of low detection precision, complex calculation and poor real-time performance in the prior art.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

[0002] Steel, as an indispensable basic material in industrial manufacturing, is widely used in many key industries such as automobiles, construction, and shipbuilding. During its production and use, the surface of steel is often affected by complex environmental conditions, resulting in defects such as scratches, cracks, and corrosion. Although these defects may seem minor, they not only affect the product's appearance but can also compromise its structural integrity, leading to more serious structural problems such as stress concentration and fatigue cracking, ultimately causing fracture or failure. Therefore, the detection of steel surface defects plays a crucial role in quality control, enabling timely detection and repair of defects, thereby effectively extending the mechanical properties and service life of products and improving overall production efficiency.

[0003] Early methods for detecting surface defects in steel mainly included manual inspection, laser scanning, and eddy current testing. Manual inspection relies on operator experience and is affected by factors such as lighting and fatigue, resulting in high false positive and false negative rates. While laser scanning offers high precision, it is easily limited by surface reflection conditions and complex working environments. Eddy current testing, based on the principle of electromagnetic induction, is suitable for detecting cracks, but it has low sensitivity to small or deeply buried defects and significant limitations in complex scenarios. These traditional methods have limited performance in high-precision inspection tasks, necessitating the development of more advanced technologies to improve their performance.

[0004] With the rapid development of machine vision technology, traditional manual visual inspection is gradually being replaced by automated surface defect detection methods. These technologies not only effectively reduce inspection costs but also significantly reduce reliance on manual operation, thereby greatly improving inspection efficiency. Currently, machine vision-based surface defect detection methods can be broadly divided into two categories: one is manual feature extraction methods based on image processing and machine learning. These methods achieved significant results in early applications, but due to their over-reliance on manually designed features, they exhibit limitations in complex environments with varying lighting, scale, and orientation, restricting their application in practical industrial scenarios. Since AlexNet's breakthrough achievement in the ImageNet challenge in 2012, deep learning technology has achieved leapfrog development, driving the rise of a new generation of surface defect detection methods. The second category of methods, deep learning-based surface defect detection methods, has been widely applied in industrial fields. These methods can not only automatically extract complex features from images, possessing excellent generalization ability and strong adaptability, but also effectively overcome the bottlenecks of traditional methods in detecting minute defects, greatly improving detection accuracy and robustness.

[0005] Currently, deep learning-based object detection algorithms are generally divided into two-stage object detection and single-stage object detection. Two-stage detection algorithms first generate candidate boxes, and then perform object regression based on the content of the candidate regions, thus achieving high detection accuracy. Typical two-stage algorithms include R-CNN, 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 enhances the understanding and parsing capabilities of complex fashion images. Mengqi Chen et al. proposed a novel "FasterGG R-CNN" model, embedding Gabor filters into the first layer of Faster R-CNN, and simultaneously optimizing the Gabor filter parameters through a genetic algorithm to improve detection accuracy. Lin Du et al. constructed a training set through preprocessing techniques such as image inpainting and data augmentation, and then used the Mask R-CNN model to identify and segment cracks.

[0006] Single-stage target detection algorithms differ from two-stage methods in that they do not rely on candidate box generation steps, directly treating target detection as a regression problem. The main advantage of these methods is their fast detection speed, making them suitable for applications with high real-time requirements. Common single-stage detection algorithms include SSD and the YOLO series. For example, Qu Zhijian et al. proposed a method for detecting cable clamp defects by combining DenseNet and Inception modules to improve the SSD model, addressing the complex environment of overhead contact line applications. This method enhances feature extraction capabilities by sharing information between feature layers and optimizes the loss function using FPN and GIoU to improve recognition performance. Xijun Ye et al. enhanced underwater images by improving CycleGAN and the multi-scale Retinex (MSR) model, and then used an improved YOLOv5 model to detect structural damage in the enhanced images. Yin Zhang et al. proposed a novel small target detection algorithm called FFCA-YOLO, which improves the detection of small targets in remote sensing images. Yukang Cao et al. proposed a lightweight YOLOv8-GD model based on an improved YOLOv8, specifically designed for defect detection in electroluminescent images of solar photovoltaic modules.

[0007] While existing deep learning object detection algorithms have achieved significant results in some tasks, they still face numerous challenges in metal surface defect detection. First, the complex textures and varying lighting conditions of metal surface defects significantly impact the accuracy of traditional detection methods when dealing with low contrast and complex backgrounds. Furthermore, the multi-scale and aspect ratio diversity of metal surface defects increases the difficulty for feature extraction networks to comprehensively capture all defect details, leading to missed detections. To address these challenges, many researchers have proposed corresponding solutions in recent years. However, the training and testing of these deep learning-based models typically require substantial computational resources, especially when processing high-resolution images and large-scale datasets, resulting in extremely high computational costs. Simultaneously, the limited computing power of terminal devices poses a significant challenge to these methods in practical applications. Therefore, achieving efficient and lightweight surface defect detection technology while maintaining detection accuracy has become a crucial problem that urgently needs to be solved.

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

[0009] This invention presents a lightweight network construction method for high-precision metal surface defect detection. It aims to address 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 typically require significant computational resources, making it difficult to meet the real-time detection requirements of practical industrial scenarios. To solve these problems, this invention proposes a lightweight, high-precision metal surface defect detection network (ASV-Net). By introducing an adaptive hybrid attention module (AHA), a simplified depthwise convolution module (SDA-Conv), and a multi-path lightweight structure (VoV-GSCSP-GS3), this invention significantly improves defect detection accuracy, reduces the number of model parameters and computational load, enabling efficient application in resource-constrained industrial environments, meeting real-time requirements, and improving the automation level and production efficiency of steel surface defect detection. This invention is particularly suitable for surface quality inspection of industrial metals such as steel and aluminum, helping to improve product mechanical properties, extend service life, and reduce the risk of structural failure due to defects.

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

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

[0012] Step 2: Construct a defect identification model. Use the first defect identification features corresponding to the NEU-DET dataset to train the defect identification model for accuracy, and obtain an upgraded identification model.

[0013] Step 3: Perform ablation analysis on the upgraded identification model to determine the functional effectiveness of each identification function. Use K-fold cross-validation to verify the overall effectiveness of the upgraded identification model and filter out target identification functions with insufficient functional effectiveness.

[0014] Step 4: Generalize the upgraded identification model using the second defect identification features corresponding to the GC10-DET dataset and the third defect identification features corresponding to the APSPC dataset to generate an effective identification 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 feasible approach

[0017] Step 1 includes:

[0018] Step 11: Obtain the GC10-DET dataset, NEU-DET dataset, and APSPC dataset from the big data. Use a preset Python script to perform stratified training on the GC10-DET dataset, the NEU-DET dataset, and the APSPC dataset respectively to obtain the training set and test set corresponding to each dataset.

[0019] Step 12: Use the training set to train the GC10-DET dataset to obtain several metal surface defect categories corresponding to the GC10-DET dataset; use the training set to train the NEU-DET dataset to obtain several typical surface defect categories corresponding to the NEU-DET dataset; use the training set to train the APSPC dataset to obtain several flawed surface defect categories corresponding to the APSPC dataset.

[0020] Step 13: Use the corresponding test set to test the first defect accuracy corresponding to each of the metal surface defect categories, use the corresponding test set to test the second defect accuracy corresponding to each of the typical surface defect categories, and use the corresponding test set to test the third defect accuracy corresponding to each of the flawed surface defect categories.

[0021] Step 14: Correct each of the metal surface defect categories according to the first defect accuracy to obtain the first defect identification feature corresponding to the GC10-DET dataset; correct each of the typical surface defect categories according to the second defect accuracy to obtain the second defect identification feature corresponding to the NEU-DET dataset; and correct each of the flawed surface defect categories according to the third defect accuracy to obtain the third defect identification feature corresponding to the APSPC dataset.

[0022] In one feasible approach

[0023] Step 2 includes:

[0024] Step 21: Build a YOLOv8n model in a deep learning environment to obtain the model structure of the YOLOv8n model. Determine the backbone network of the YOLOv8n model based on the model structure. Connect the backbone network to the preset AHA module for attention training to determine the channel attention and spatial attention of the YOLOv8n model.

[0025] Step 22: Determine the input network of the YOLOv8n model according to the model structure, construct several training images according to the metal information, input each training image into the YOLOv8n model, and adjust the parameters of the input network of the YOLOv8n model according to the image specifications corresponding to each training image.

[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 convolution channel to obtain the channel weights corresponding to each convolution channel, and adjust the feature capture accuracy of the corresponding convolution channel according to the channel weights.

[0027] Step 24: Construct a defect recognition model based on the model structure and the training results of 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 based on the verification results. Train the model based on the accuracy error to generate an upgraded recognition model.

[0028] In one feasible approach

[0029] Step 24 includes:

[0030] Step 241: Map the training results of each network into the model structure to generate a defect recognition model, construct a defect verification image corresponding to each of the first defect recognition features, input the defect verification image into the defect recognition model for image verification, and obtain the corresponding verification output result.

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

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

[0033] In one feasible approach

[0034] Step 3 includes:

[0035] Step 31: Obtain several model functions included in the upgraded recognition model, perform ablation experiments on each model function to obtain the functional effectiveness of each model function, obtain the functional attributes corresponding to each model function, and filter several recognition functions included in the upgraded recognition model according to the functional attributes.

[0036] Step 32: Establish screening criteria based on standard validity, compare the validity of the functions based on the screening criteria, and obtain target identification functions with insufficient validity.

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

[0038] In one feasible approach

[0039] Step 4 includes:

[0040] Step 41: Establish several generalized images based on the second defect recognition feature and the third defect recognition feature, obtain image data corresponding to each generalized image, and generate training data, verification data and test data corresponding to each generalized image based on the image data to obtain the corresponding training set, verification set and test set;

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

[0042] Step 43: Analyze the test data in the test set to obtain the test error value of the corresponding generalized image. When the test error value is outside the specified error range, correct the corresponding training data according to the test error to obtain updated training data. Use the updated training data to optimize the optimized recognition model and generate an effective recognition model.

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

[0044] In one feasible approach

[0045] Step 5 includes:

[0046] Step 51: Map the effective recognition model to the image recognition neural network, record the mapped records of the image recognition neural network, and generate 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 based on the network change information and the model decomposition information, determine the adjustment direction and adjustment amount corresponding to each neural network parameter based on the mapping result, and synchronously adjust the neural network parameters with the same adjustment direction to generate a lightweight network.

[0048] In one feasible approach

[0049] The setup process for the preset AHA module includes:

[0050] A training feature map is constructed based on the GC10-DET dataset. The training feature map is then subjected to global average pooling using formula (1) to generate the first channel-level descriptor F. avg :

[0051]

[0052] Where 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] The first channel-level descriptor is input into the multilayer perceptron for convolution processing, and the nonlinear activation range of the first channel-level descriptor in the multilayer perceptron is calculated according to formula (2).

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

[0055] Where 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, and M... c This indicates the non-linear activation range of the channel descriptor;

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

[0057]

[0058] Among them, F c ′ represents the training feature map after non-linear activation range weighting. This represents the element-wise multiplication 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 nonlinear activation range weighting:

[0060]

[0061] in, f represents the intermediate transition image generated during the weighting process. 3×3 This represents a 3x3 convolution kernel, BN represents normalization, ReLU is the activation function, and M... s The channel attention feature image is obtained after weighting the nonlinear activation range and the 3*3 convolution kernel 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 the preset AHA module.

[0062]

[0063] Among them, F cs This represents the output of attention training.

[0064] In one feasible approach

[0065] The setup process for the preset SDA-Conv module includes:

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

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

[0068] Among them, F bottleneck This indicates the result of the channel number adjustment, with a value of 2. (Conv) 1×1 This represents a 1x1 convolution kernel, F represents the standard feature map that has been set in the blank SDA-Conv module, and W represents the standard feature map that has been set in the blank SDA-Conv module. bottleneck This indicates the original number of channels in the blank SDA-Conv module;

[0069] Using formula (8), extract the independent features corresponding to each channel based on the 3*3 convolution kernel;

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

[0071] Among them, F depthwise W represents an independent feature. depthwise Represents the depthwise convolution weight parameters;

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

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

[0074] Among them, F pointwise This indicates that the channel has been restored, F depthwise W represents the depthwise convolution channel in the blank SDA-Conv module. pointwise Represents the convolution weights of a 1x1 convolution kernel, Conv 1×1 This represents a 1x1 convolution kernel;

[0075] Obtain training feature maps, input the training feature maps into the preliminary SDA-Conv module for image compression, and determine the model channels 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 The c-th existing model channel represents the average value, S and K represent the height and width of the training feature map, respectively, and F represents the average value of the training feature map. pointwise (c,i,j) represents the pixel value corresponding to the c-th existing model channel at position (a,b);

[0079] The preliminary SDA-Conv module is normalized and trained according to formulas (11) and (12);

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

[0081]

[0082] Where 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, and σ 2 represents the batch variance, and γ and β represent the learning parameters, respectively;

[0083] The expressive power of the preliminary SDA-Conv module is corrected using formula (13);

[0084] S′=ReLU(S)=max(0,S)(13) Perform convolution processing on the model channels to obtain the weighting coefficients of the model channels. Combine the input features of the training feature map and calculate the model channel output features of the preliminary SDA-Conv module according to formula (14).

[0085]

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

[0087] The model channels of the initial SDA-Conv module are subjected to deep training using the output features of the model channels to obtain the preset SDA-Conv module.

[0088] The beneficial effects of the above technical solution are as follows: In order to solve the problems of low detection accuracy, computational complexity and poor real-time performance in the existing technology, defect recognition features are constructed by using the existing GC10-DET dataset, NEU-DET dataset and APSPC dataset. Then, the defect recognition model is trained multiple times using the defect recognition features to generate an effective recognition model. In order to expand the applicability of defect recognition, the effective recognition model is mapped to an image recognition neural network for processing, and finally a lightweight network is obtained. This network can simultaneously identify surface defects of multiple metals, determine their defect locations and provide corresponding reminders. By introducing an adaptive hybrid attention module (AHA), a lightweight convolution module (SDA-Conv) and a multi-path structure (VoV-GSCSP), the model achieves a significant improvement in detection accuracy while reducing the number of parameters and computational complexity. On the GC10-DET dataset, ASV-Net achieved an average accuracy improvement of 4.0% compared to the baseline model, while reducing the number of parameters and GFLOPs by 33.98% and 41.98%, respectively. Furthermore, experiments showed that the model exhibited strong generalization ability on public datasets such as NEU-DET and APSPC, further validating its application potential in complex industrial scenarios.

[0089] Other features and advantages of the invention will be set forth in the following description, and will be apparent in part from the description, or may be learned by practicing the invention. The objects and other advantages of the invention may be realized and obtained by means of the structures particularly pointed out in the written description and the accompanying drawings.

[0090] The technical solution of the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. Attached Figure Description

[0091] The accompanying drawings are provided to further illustrate the invention and form part of the specification. They are used together with the embodiments of the invention to explain the invention and do not constitute a limitation thereof. In the drawings:

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

[0093] Figure 2 This is a schematic diagram of the payroll process for step 3 of the lightweight network construction method with high-precision metal surface defect detection function in an embodiment of the present invention.

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

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

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

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

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

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

[0100] Figure 9 This is a structural diagram of the SDAFlow-Detect module of the present invention;

[0101] Figure 10 This is a structural diagram of the VoV-GSCSP-GS3 module of the present invention;

[0102] Figure 11 This is an example diagram of the dataset of this invention;

[0103] Figure 12 This is a comparison diagram of the algorithms of this invention;

[0104] Figure 13-14 This is a diagram showing the detection results of the present invention;

[0105] Figure 15 This is the average accuracy curve of the present invention;

[0106] Figure 16 This is the precision-recall curve of the present invention;

[0107] Figure 17 This is the K-fold cross-validation diagram of the present invention;

[0108] Figure 18 This is a generalization experiment diagram of the present invention;

[0109] Figure 19 This is a generalization experiment diagram of the present invention. Detailed Implementation

[0110] The preferred embodiments of the present invention will be described below with reference to the accompanying drawings. It should be understood that the preferred embodiments described herein are for illustration and explanation only and are not intended 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, it includes:

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

[0114] Step 2: Construct a defect identification model. Use the first defect identification features corresponding to the NEU-DET dataset to train the defect identification model for accuracy, and obtain an upgraded identification model.

[0115] Step 3: Perform ablation analysis on the upgraded identification model to determine the functional effectiveness of each identification function. Use K-fold cross-validation to verify the overall effectiveness of the upgraded identification model and filter out target identification functions with insufficient functional effectiveness.

[0116] Step 4: Generalize the upgraded identification model using the second defect identification features corresponding to the GC10-DET dataset and the third defect identification features corresponding to the APSPC dataset to generate an effective identification 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". This dataset contains ten common metallic 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), and waist_folding (Wf), totaling 2294 images, each containing one or more defect categories; the NEU-DET dataset comes from Northeast China. The university dataset contains six typical surface defects of hot-rolled strip steel: cracks (Cr), inclusions (In), patches (Pa), pits (Pd), surface creases (Ps), and scratches (Rs), with 300 samples for each defect, totaling 1800 images; the APSPC dataset comes from the 2018 Guangzhou Industrial Intelligent Big Data Innovation Competition and contains 1885 images of surface defects of aluminum profiles, covering 10 defects: dents (Ao), no fuzz (Bu), overall defects (Ca), peeling (Ju), exposed bottom (Lo), power failure (Ni), pitting (Qi), patching holes (Tf), through-hole cracking (Tu), leakage (Us), and bubbling (Za).

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

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

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

[0122] In this example, functional validity refers to the accuracy of the recognition function.

[0123] In this example, overall effectiveness refers to the effectiveness of the upgraded identification model in identifying defects;

[0124] In this example, the second defect identification feature represents the features used to identify six typical defects on the surface of hot-rolled strip steel;

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

[0126] In this example, the image recognition neural network refers to a pre-configured neural network used for image recognition.

[0127] The working principle and beneficial effects of the above technical solution are as follows: To solve the problems of low detection accuracy, computational complexity, and poor real-time performance in existing technologies, defect recognition features are constructed using existing GC10-DET, NEU-DET, and APSPC datasets. Then, the constructed defect recognition model is trained multiple times using the defect recognition features to generate an effective recognition model. To expand the applicability of defect recognition, the effective recognition model is mapped onto an image recognition neural network for processing, ultimately resulting in a lightweight network. This network can simultaneously identify surface defects in multiple metals, determine their defect locations, and provide corresponding alerts. By introducing an adaptive hybrid attention module (AHA), a lightweight convolutional module (SDA-Conv), and a multi-path structure (VoV-GSCSP), the model significantly improves detection accuracy while reducing the number of parameters and computational complexity. On the GC10-DET dataset, ASV-Net achieved an average accuracy improvement of 4.0% compared to the baseline model, while reducing the number of parameters and GFLOPs by 33.98% and 41.98%, respectively. Furthermore, experiments showed that the model exhibited strong generalization ability on public datasets such as NEU-DET and APSPC, further validating its application potential in complex industrial scenarios.

[0128] Example 2

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

[0130] Step 11: Obtain the GC10-DET dataset, NEU-DET dataset, and APSPC dataset from the big data. Use a preset Python script to perform stratified training on the GC10-DET dataset, the NEU-DET dataset, and the APSPC dataset respectively to obtain the training set and test set corresponding to each dataset.

[0131] Step 12: Use the training set to train the GC10-DET dataset to obtain several metal surface defect categories corresponding to the GC10-DET dataset; use the training set to train the NEU-DET dataset to obtain several typical surface defect categories corresponding to the NEU-DET dataset; use the training set to train the APSPC dataset to obtain several flawed surface defect categories corresponding to the APSPC dataset.

[0132] Step 13: Use the corresponding test set to test the first defect accuracy corresponding to each of the metal surface defect categories, use the corresponding test set to test the second defect accuracy corresponding to each of the typical surface defect categories, and use the corresponding test set to test the third defect accuracy corresponding to each of the flawed surface defect categories.

[0133] Step 14: Correct each of the metal surface defect categories according to the first defect accuracy to obtain the first defect identification feature corresponding to the GC10-DET dataset; correct each of the typical surface defect categories according to the second defect accuracy to obtain the second defect identification feature corresponding to the NEU-DET dataset; and correct each of the flawed surface defect categories according to the third defect accuracy to obtain the third defect identification feature corresponding to the APSPC dataset.

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

[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 and the second defect identification feature correspond to the classification of six typical defects on the surface of hot-rolled strip steel.

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

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

[0139] The working principle and beneficial effects of the above technical solution are as follows: To ensure the effectiveness of defect identification, it is necessary to refine the defect identification features. A script program is used to perform hierarchical training on the GC10-DET, NEU-DET, and APSPC datasets to obtain their corresponding training and test sets. Then, the training set is used to train the corresponding datasets, determining the categories of metal surface defects, typical surface defects, and flawed surface defects. The test set is then used to analyze the accuracy of each category, and the corresponding defect category is corrected based on the accuracy. This yields the defect identification features for each dataset. In this way, different types of defect categories can be uniformly planned and processed, identifying several standard and effective defect identification features, thus improving the effectiveness of defect identification.

[0140] Example 3

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

[0142] Step 21: Build a YOLOv8n model in a deep learning environment to obtain the model structure of the YOLOv8n model. Determine the backbone network of the YOLOv8n model based on the model structure. Connect the backbone network to the preset AHA module for attention training to determine the channel attention and spatial attention of the YOLOv8n model.

[0143] Step 22: Determine the input network of the YOLOv8n model according to the model structure, construct several training images according to the metal information, input each training image into the YOLOv8n model, and adjust the parameters of the input network of the YOLOv8n model according to the image specifications corresponding to each training image.

[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 convolution channel to obtain the channel weights corresponding to each convolution channel, and adjust the feature capture accuracy of the corresponding convolution channel according to the channel weights.

[0145] Step 24: Construct a defect recognition model based on the model structure and the training results of 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 based on the verification results. Train the model based on the accuracy error to generate an upgraded recognition model.

[0146] In this example, the model structure represents the network composition of the YOLOv8n model, which includes four parts: Input, Backbone, Neck, and Head.

[0147] In this example, the pre-defined AHA module borrows the channel and spatial attention mechanisms of CBAM and introduces an adaptive mechanism to further improve feature capture capabilities and adaptability to multi-task scenarios. Then, referring to the design concept of linear bottleneck structures, a lightweight SDA-Conv convolutional module is designed and applied to SDA-Flow-Detect, significantly reducing the number of model parameters while maintaining high detection accuracy. Finally, the VoV-GSCSP module is introduced into the Neck and its internal structure is reconstructed. By applying GSConv convolutional operations multiple times, redundant computation is 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 precision refers to the accuracy with which the convolutional channel captures defect recognition features of the image;

[0150] In this example, the purpose of training the accuracy error is to eliminate the error in the defect identification 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, attention analysis is performed on each model network in the YOLOv8n model to establish channel attention and spatial attention for the YOLOv8n model. Further, the accuracy of the convolution channels of the YOLOv8n model is adjusted through convolution training. Finally, a defect recognition model is established, and the defect recognition model is processed by eliminating errors to obtain an upgraded recognition model. In this way, a lightweight model can be obtained, which can recognize a variety of different defects with high accuracy.

[0152] Example 4

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

[0154] Step 241: Map the training results of each network into the model structure to generate a defect recognition model, construct a defect verification image corresponding to each of the first defect recognition features, input the defect verification image into the defect recognition model for image verification, and obtain the corresponding verification output result.

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

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

[0157] In this example, the preset range represents a range with an accuracy between 0.982 and 1.00.

[0158] The working principle and beneficial effects of the above technical solution are as follows: a defect verification image is generated based on 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 features and the first defect recognition features. Then, the recognition accuracy is adjusted to a preset range, resulting in 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, such as... Figure 2 As shown, step 3 includes:

[0161] Step 31: Obtain several model functions included in the upgraded recognition model, perform ablation experiments on each model function to obtain the functional effectiveness of each model function, obtain the functional attributes corresponding to each model function, and filter several recognition functions included in the upgraded recognition model according to the functional attributes.

[0162] Step 32: Establish screening criteria based on standard validity, compare the validity of the functions based on the screening criteria, and obtain target identification functions with insufficient validity.

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

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

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

[0166] The specific data from 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 was significantly improved, with a 2.6% increase in detection accuracy compared to the base model. The most significant improvement was in the detection capability of Waist folding defects, with a 15.1% improvement over the base model. Combining with SDAFlow-Detect, the model maintained high detection accuracy while reducing the number of parameters and GFLOPs by 18.27% and 28.40% respectively compared to the base model, and further improved the detection accuracy of Waist folding defects to 77.5%. By introducing the VOV-GSCSP module, the model was further optimized in terms of detection accuracy, number of parameters, and GFLOPs, achieving a relatively balanced improvement in the detection performance of various defects. In the final E method, the model achieved the highest detection accuracy, a 4.0% improvement over the base model, while reducing the number of parameters and GFLOPs by 33.98% and 41.98% respectively. It is worth noting that, among the ten defect categories, except for the Welding_line defect, the E method improved the detection capabilities of the model for the other nine defects, with the detection performance of six defects reaching the best results in this ablation experiment.

[0170] In this example, the number of functional details is related to the number of times cross-validation is folded.

[0171] The working principle and beneficial effects of the above technical solution are as follows: By conducting ablation experiments on the upgraded identification model, the various model functions it contains are determined, and the effectiveness of each model function is analyzed. This establishes several screening conditions for the upgraded identification model. Through screening, target identification functions are proposed. Then, the target identification functions are subjected to folded cross-validation. By processing the stability of each functional detail, the overall effectiveness of the upgraded identification model is determined, thus achieving the purpose of targeted processing and targeted analysis.

[0172] Example 6

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

[0174] Step 41: Establish several generalized images based on the second defect recognition feature and the third defect recognition feature, obtain image data corresponding to each generalized image, and generate training data, verification data and test data corresponding to each generalized image based on the image data to obtain the corresponding training set, verification set and test set;

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

[0176] Step 43: Analyze the test data in the test set to obtain the test error value of the corresponding generalized image. When the test error value is outside the specified error range, correct the corresponding training data according to the test error to obtain updated training data. Use the updated training data to optimize the optimized recognition model and generate an effective recognition model.

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

[0178] In this example, hyperparameters represent parameters that are manually set in advance in the upgraded 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 model's network weights, learning rate, batch size, and number of iterations. Specific parameters are shown in Table 1. The average precision (mAP) is primarily used as the core metric for evaluating model performance. mAP measures the model's detection accuracy across different defect types, and the specific calculation formula is as follows:

[0181]

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

[0183]

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

[0185]

[0186] Table 1

[0187] Tables 2 and 3 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] Tables 5 and 6 show that the present invention performs better on the NEU-DET and APSPC datasets, with 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, corresponding training sets, validation sets, and test sets are established. Then, the training set is used to optimize the hyperparameters of the upgraded recognition model to determine the optimal hyperparameters of the upgraded recognition model. Furthermore, the optimized recognition model is generalized and tested using the test set to obtain test data. Error analysis is performed on the test data to correct the training data, thereby obtaining an effective recognition model. This model can be used to process networks to obtain a high-precision and high-efficiency defect analysis method.

[0198] Example 7

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

[0200] Step 51: Map the effective recognition model to the image recognition neural network, record the mapped records of the image recognition neural network, and generate 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 based on the network change information and the model decomposition information, determine the adjustment direction and adjustment amount corresponding to each neural network parameter based on the mapping result, and synchronously adjust the neural network parameters with the same adjustment direction to generate a lightweight network.

[0202] In this example, the adjustment direction refers to the direction in which the neural network parameters are adjusted;

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

[0204] In this example, the purpose of the 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 effective recognition model can be given specific functions to the highlighting recognition neural network, resulting in a high-efficiency, high-quality, and widely applicable defect recognition network.

[0206] Example 8

[0207] Based on 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. The training feature map is then subjected to global average pooling using formula (1) to generate the first channel-level descriptor F.avg :

[0209]

[0210] Where 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] The first channel-level descriptor is input into the multilayer perceptron for convolution processing, and the nonlinear activation range of the first channel-level descriptor in the multilayer perceptron is calculated according to formula (2).

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

[0213] Where 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, and M... c This indicates the non-linear activation range of the channel descriptor;

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

[0215]

[0216] Among them, F c ′ represents the training feature map after non-linear activation range weighting. This represents the element-wise multiplication 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 nonlinear activation range weighting:

[0218]

[0219] in, f represents the intermediate transition image generated during the weighting process. 3×3 This represents a 3x3 convolution kernel, BN represents normalization, ReLU is the activation function, and M... s The channel attention feature image is obtained after weighting the nonlinear activation range and the 3*3 convolution kernel 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 the preset AHA module.

[0220]

[0221] Among them, F cs This represents the output of attention training.

[0222] In this example, the effect that formula (1) can achieve is: this operation generates a descriptor by calculating the average value of each channel in the feature map, which is used 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 non-linear activation is applied between the two layers.

[0224] In this example, the purpose of depth-weighting the attention feature image is to: adjust the channels with more information while suppressing the less relevant channels, thereby improving the overall quality of the feature map representation;

[0225] In this example, the AHA module introduces a strategy combining convolutional operations with BatchNorm. This ensures effective capture of feature information in the spatial dimension while stabilizing the model's training process through BatchNormalization, thus improving the model's generalization ability. This method is more flexible in handling spatially important information and can adapt to input features in different scenarios.

[0226] In this example, the pre-defined AHA module structure is a C2f_AHA structure. The C2f module is used for multi-scale feature extraction and fusion, while the AHA module further optimizes feature selection and weight allocation. The C2f module aggregates features step by step through a multi-layer bottleneck structure, while AHA further enhances the ability to capture fine-grained features and the network's generalization ability 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 model's adaptability to complex scenarios through the AHA module.

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

[0228] Example 9

[0229] Based on 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] The number of channels in the blank SDA-Conv module is adjusted to 2 using formula (7);

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

[0232] Among them, F bottleneck This indicates the result of the channel number adjustment, with a value of 2. (Conv) 1×1 This represents a 1x1 convolution kernel, F represents the standard feature map that has been set in the blank SDA-Conv module, and W represents the standard feature map that has been set in the blank SDA-Conv module. bottleneck This indicates the original number of channels in the blank SDA-Conv module;

[0233] Using formula (8), extract the independent features corresponding to each channel based on the 3*3 convolution kernel;

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

[0235] Among them, F depthwise W represents an independent feature. depthwise Represents the depthwise convolution weight parameters;

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

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

[0238] Among them, F pointwise This indicates that the channel has been restored, F depthwise W represents the depthwise convolution channel in the blank SDA-Conv module. pointwise Represents the convolution weights of a 1x1 convolution kernel, Conv 1×1 This represents a 1x1 convolution kernel;

[0239] Obtain training feature maps, input the training feature maps into the preliminary SDA-Conv module for image compression, and determine the model channels 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 The c-th existing model channel represents the average value, S and K represent the height and width of the training feature map, respectively, and F represents the average value of the training feature map. pointwise (c,i,j) represents the pixel value corresponding to the c-th existing model channel at position (a,b);

[0243] The preliminary SDA-Conv module is normalized and trained according to formulas (11) and (12);

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

[0245]

[0246] Where 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, and σ 2 represents the batch variance, and γ and β represent the learning parameters, respectively;

[0247] The expressive power of the preliminary SDA-Conv module is corrected using formula (13);

[0248] S′=ReLU(S)=max(0,S)(13) Perform convolution processing on the model channels to obtain the weighting coefficients of the model channels. Combine the input features of the training feature map and calculate the model channel output features of the preliminary SDA-Conv module according to formula (14).

[0249]

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

[0251] The model channels of the initial SDA-Conv module are subjected to deep training using the output features of the model channels to obtain the 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, avoiding information mixing. The advantage of depthwise convolution is that it can reduce computational complexity while capturing features in the local space;

[0253] In this example, the purpose of the weighting 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 are as follows: By setting the SDA-Conv module in advance, the model's ability to capture key information can be enhanced while maintaining its lightweight nature, thus improving the capture quality of the lightweight network.

[0255] Obviously, those skilled in the art can make various modifications and variations to this invention without departing from its spirit and scope. Therefore, if these modifications and variations fall within the scope of the claims of this invention and their equivalents, this invention also intends 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 on each dataset to obtain the defect identification features corresponding to each dataset. Step 2: Construct a defect identification model. Use the first defect identification features corresponding to the NEU-DET dataset to train the defect identification model for accuracy, and obtain an upgraded identification model. Step 3: Perform ablation analysis on the upgraded identification model to determine the functional effectiveness of each identification function. Use K-fold cross-validation to verify the overall effectiveness of the upgraded identification model and filter out target identification functions with insufficient functional effectiveness. Step 4: Generalize the upgraded identification model using the second defect identification features corresponding to the GC10-DET dataset and the third defect identification features corresponding to the APSPC dataset to generate an effective identification 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; Step 2 includes: Step 21: Build a YOLOv8n model in a deep learning environment to obtain the model structure of the YOLOv8n model. Determine the backbone network of the YOLOv8n model based on the model structure. Connect the backbone network to the preset AHA module for attention training to determine the channel attention and spatial attention of the YOLOv8n model. Step 22: Determine the input network of the YOLOv8n model according to the model structure, construct several training images according to the metal information, input each training image into the YOLOv8n model, and adjust the parameters of the input network of the YOLOv8n model according to the image specifications corresponding to each training image. 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 convolution channel to obtain the channel weights corresponding to each convolution channel, and adjust the feature capture accuracy of the corresponding convolution channel according to the channel weights. Step 24: Construct a defect recognition model based on the model structure and the training results of 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 based on the verification results. Train the model based on the accuracy error to generate an upgraded recognition model.

2. The lightweight network construction method with high-precision metal surface defect detection function as described in claim 1, characterized in that, Step 1 includes: Step 11: Obtain the GC10-DET dataset, NEU-DET dataset, and APSPC dataset from the big data. Use a preset Python script to perform stratified training on the GC10-DET dataset, the NEU-DET dataset, and the APSPC dataset respectively to obtain the training set and test set corresponding to each dataset. Step 12: Use the training set to train the GC10-DET dataset to obtain several metal surface defect categories corresponding to the GC10-DET dataset; use the training set to train the NEU-DET dataset to obtain several typical surface defect categories corresponding to the NEU-DET dataset; use the training set to train the APSPC dataset to obtain several flawed surface defect categories corresponding to the APSPC dataset. Step 13: Use the corresponding test set to test the first defect accuracy corresponding to each of the metal surface defect categories, use the corresponding test set to test the second defect accuracy corresponding to each of the typical surface defect categories, and use the corresponding test set to test the third defect accuracy corresponding to each of the flawed surface defect categories. Step 14: Correct each of the metal surface defect categories according to the first defect accuracy to obtain the first defect identification feature corresponding to the GC10-DET dataset; correct each of the typical surface defect categories according to the second defect accuracy to obtain the second defect identification feature corresponding to the NEU-DET dataset; and correct each of the flawed surface defect categories according to the third defect accuracy to obtain the third defect identification feature corresponding to the APSPC dataset.

3. The lightweight network construction method with high-precision metal surface defect detection function as described in claim 1, characterized in that, Step 24 includes: Step 241: Map the training results of each network into the model structure to generate a defect recognition model, construct a defect verification image corresponding to each of the first defect recognition features, input the defect verification image into the defect recognition model for image verification, and obtain the corresponding verification output result. Step 242: Draw the corresponding verification defect features based on the verification output results, analyze the feature differences between each verification defect feature and the corresponding first defect identification feature, and determine the recognition accuracy of the defect identification model for each first defect identification feature based on the feature differences; Step 243: Determine the accuracy error of the defect recognition model based on the recognition accuracy corresponding to each of the first defect recognition features, construct accuracy adjustment parameters based on each recognition accuracy, and use the accuracy adjustment parameters to iteratively train the defect recognition model until the accuracy error is within a preset range, thereby obtaining an upgraded recognition model.

4. The lightweight network construction method with high-precision metal surface defect detection function as described in claim 1, characterized in that, Step 3 includes: Step 31: Obtain several model functions included in the upgraded recognition model, perform ablation experiments on each model function to obtain the functional effectiveness of each model function, obtain the functional attributes corresponding to each model function, and filter several recognition functions included in the upgraded recognition model according to the functional attributes. Step 32: Establish screening criteria based on standard validity, compare the validity of the functions based on the screening criteria, and obtain target identification functions with insufficient validity. Step 33: Divide each target function model into K functional details, perform folded cross-validation on the functional details to obtain the detail stability corresponding to each functional detail, count the stability of several details corresponding to each recognition function, and construct the overall effectiveness of the upgraded recognition model.

5. The lightweight network construction method with high-precision metal surface defect detection function as described in claim 1, characterized in that, Step 4 includes: Step 41: Establish several generalized images based on the second defect recognition feature and the third defect recognition feature, obtain image data corresponding to each generalized image, and generate training data, verification data and test data corresponding to each generalized image based on the image data to obtain the corresponding training set, verification set and test set; Step 42: Use the training set to perform hyperparameter optimization training on the upgrade recognition model to obtain the optimal hyperparameters of the upgrade recognition model. Input the optimal hyperparameters into the upgrade recognition model to generate an optimized recognition model. Input the test data contained in the test set into the optimized recognition model for generalization testing to obtain test data. Step 43: Analyze the test data in the test set to obtain the test error value of the corresponding generalized image. When the test error value is outside the specified error range, correct the corresponding training data according to the test error to obtain updated training data. Use the updated training data to optimize the optimized recognition model and generate an effective recognition model. Step 44: When all the error test values ​​are within the specified error range, the optimized recognition model is considered a valid recognition model.

6. The lightweight network construction method with high-precision metal surface defect detection function as described in claim 1, characterized in that, Step 5 includes: Step 51: Map the effective recognition model to the image recognition neural network, record the mapped records of the image recognition neural network, and generate network change information of the image recognition neural network and model decomposition information of the effective recognition model; Step 52: Establish a mapping result based on the network change information and the model decomposition information, determine the adjustment direction and adjustment amount corresponding to each neural network parameter based on the mapping result, and synchronously adjust the neural network parameters with the same adjustment direction to generate a lightweight network.

7. The lightweight network construction method with high-precision metal surface defect detection function as described in claim 1, characterized in that, The setup process for the preset AHA module includes: A training feature map is constructed based on the GC10-DET dataset. The training feature map is then subjected to global average pooling using formula (1) to generate the first channel-level descriptor. : (1) in, , This represents the height and width of the training feature map. This represents the global average pooling value for channel c. Representation of feature map Central Channel In position Pixel value at that location, This represents the training feature map; The first channel-level descriptor is input into the multilayer perceptron for convolution processing, and the nonlinear activation range of the first channel-level descriptor in the multilayer perceptron is calculated according to formula (2). (2) in, This represents the first weight matrix of the first convolutional layer in the multilayer perceptron. Let represent the second weight matrix of the second convolutional layer in the multilayer perceptron. express function, This indicates the non-linear activation range of the channel descriptor; According to formula (3), the training feature map is weighted using the nonlinear activation range: (3) in, This represents the training feature map after non-linear activation range weighting. This represents the element-wise multiplication operation; According to formulas (4) and (5), the 3*3 convolution kernel is used to perform weighted processing on the training feature map after nonlinear activation range weighting: (4) (5) in, This represents the intermediate transition image generated during the weighting process. This represents a 3x3 convolution kernel. This indicates normalization processing. It is an activation function. This represents the channel attention feature image obtained after weighting by the non-linear activation range and the 3*3 convolution kernel. express 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 the preset AHA module; (6) in, This represents the output of attention training.

8. The lightweight network construction method with high-precision metal surface defect detection function as described in claim 1, characterized in that, The setup process for the preset SDA-Conv module includes: The number of channels in the blank SDA-Conv module is adjusted to 2 using formula (7); (7) in, This indicates the result of the channel number adjustment, with a value of 2. This represents a 1x1 convolution kernel. This indicates that the blank SDA-Conv module has a standard feature map that has been set. This indicates the original number of channels in the blank SDA-Conv module; Using formula (8), extract the independent features corresponding to each channel based on the 3*3 convolution kernel; (8) in, Indicates independent characteristics, Represents the depthwise convolution weight parameters; Using formula (9), channel recovery is performed on the blank SDA-Conv module according to the 1*1 convolution kernel to obtain the preliminary SDA-Conv module; (9) in, This indicates that the channel has been restored. This represents the depthwise convolution channel in the blank SDA-Conv module. This represents the convolution weights of a 1x1 convolution kernel. This represents a 1x1 convolution kernel; Obtain training feature maps, input the training feature maps into the preliminary SDA-Conv module for image compression, and determine the model channels 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); (10) in, S represents the average value corresponding to the c-th existing model channel, and S and K represent the height and width of the training feature map, respectively. This represents the pixel value corresponding to the c-th existing model channel at position (a, b); The preliminary SDA-Conv module is normalized and trained according to formulas (11) and (12); (11) (12) in, and express The first weight matrix corresponding to the activation function and The second weight matrix corresponding to the activation function, express Activation function express Activation function This represents the batch average. Indicates batch variance. and These represent the learning parameters; The expressive power of the preliminary SDA-Conv module is corrected using formula (13); (13) Perform convolution processing on the model channels to obtain the weighting coefficients of the model channels. Combine the input features of the training feature map and calculate the output features of the model channels of the preliminary SDA-Conv module according to formula (14). (14) in, This represents the model channel output characteristics of the initial SDA-Conv module. This represents the input feature. It is the output feature. This represents the initial input data of the preliminary SDA-Conv module. This indicates an element-wise multiplication operation. This represents a small constant to prevent the denominator from being zero; The model channels of the initial SDA-Conv module are subjected to deep training using the output features of the model channels to obtain the preset SDA-Conv module.