A lightweight metal surface defect detection method based on dual-source knowledge distillation

By adopting dual-source knowledge distillation technology in metal surface defect detection, the CU-Net network model is simplified, and the problem of difficult deployment of existing deep learning models in mobile terminals is solved, and fast, efficient and high-precision metal surface defect detection is achieved.

CN117540779BActive Publication Date: 2025-03-28INST OF AUTOMATION CHINESE ACAD OF SCI (LUOYANG) ROBOTICS & INTELLIGENT EQUIP INNOVATION INST
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311587008.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-11-24
Publication Date
2025-03-28
Estimated Expiration
2043-11-24

AI Technical Summary

Technical Problem

The existing metal surface defect detection methods based on deep learning are difficult to deploy in mobile terminals and run slowly, which cannot meet the needs of industrial high real-time.

Method used

The lightweight metal surface defect detection method based on dual source knowledge distillation is adopted, and the CU-Net network model is constructed and knowledge is extracted from the teacher network through knowledge distillation strategies, and the model is simplified to adapt to the resource limitations of mobile terminals.

Benefits of technology

It realizes fast, efficient and high-precision metal surface defect detection on mobile terminals, meeting the requirements of real-time and accuracy, and reducing manual inspection costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117540779B_ABST
    Figure CN117540779B_ABST
Patent Text Reader

Abstract

The present invention discloses a lightweight metal surface defect detection method based on dual-source knowledge distillation, and the steps are as follows: obtaining different types of defect images and normal images of the metal surface to be detected, and classifying the images according to the defect type; annotating the classified images using a deep learning platform, generating corresponding label files, and constructing a metal surface defect data set to be detected; performing data preprocessing on the images in the training set, and then inputting them into the constructed CU‑Net network model for training, and obtaining a pre-trained model as a teacher network; simplifying the teacher network to CU‑Net(s), and then using it as a student network, extracting different types of knowledge from the feature layer and response layer of the teacher network through a knowledge distillation strategy; optimizing the hyperparameters in the training process according to the test results of the validation set, and then deploying the trained CU‑Net(s) model to a mobile terminal to detect metal surface defects in real time. The present invention can detect metal surface defects quickly, efficiently and accurately.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of metal surface defect detection, and in particular relates to a lightweight metal surface defect detection method based on dual-source knowledge distillation. Background Art

[0002] As a vital industrial raw material, metal is widely used in many fields such as manufacturing machinery, aerospace, automobile, national defense, light industry, etc. However, in the production process of metal materials, due to factors such as raw material quality, production equipment, processing technology, production environment and human errors, metal surfaces often have defects such as scratches, edge damage, and peeling. These defects not only affect the quality and reliability of the product itself, but also increase the waste and number of unqualified products in the subsequent production process, thereby increasing production costs. Especially on high-speed continuous production lines, traditional visual inspection and manual inspection methods cannot meet the requirements of production speed and quality control. Therefore, the research on metal surface defect detection is of vital significance.

[0003] At present, most companies still use manual methods to detect metal surface defects, which not only has low detection accuracy and poor stability, but also leads to huge waste of manpower, time and resources. With the continuous development of computer technology, metal surface defect detection technology based on machine vision has become the mainstream and gradually replaced manual detection methods. Traditional methods mainly use digital image processing technology to enhance, segment and extract defects. Common technologies include edge detection, filtering, morphological processing, etc.; for example, existing methods extract three features (color, brightness and direction) of metal surface defects through Gaussian pyramid decomposition and Gabor filter, and establish Markov classification model to realize defect classification. However, due to the limitations of equipment performance, light conditions and complex production environment, the detection effect of traditional methods is not ideal, and the applicability and robustness are not strong.

[0004] In recent years, the rapid development of deep learning technology and computer vision has provided new opportunities for metal surface defect detection. As the core of deep learning, deep convolutional neural networks can adaptively extract effective features from images through automated training, and are therefore widely used in metal surface defect detection tasks. For example, existing methods use supervised and semi-supervised learning methods to improve Faster R-CNN, ResNet, and YOLO series networks by constructing corresponding metal surface defect datasets, thereby realizing the detection of metal surface defect types. The detection process has the characteristics of non-contact and non-destructive, and greatly improves the detection accuracy while improving the detection efficiency. However, although the existing deep learning-based methods have achieved good performance in metal surface defect detection tasks, they often require large models and high computing resources, resulting in slow operation and difficulty in deployment on resource-constrained mobile terminals and portable devices. At the same time, it is difficult to meet the high real-time requirements of industry.

[0005] Therefore, compressing the network as much as possible while ensuring the accuracy and speed of the model has become an urgent problem to be solved. Although various network compression optimization algorithms have been proposed one after another, the size and efficiency of the model have been greatly optimized, but there are still problems such as single network compression scale, limited compression range and large accuracy loss. Further improvement is needed for the deployment and application of some industrial sites. Summary of the invention

[0006] In order to solve the problem that deep learning models in the prior art are difficult to deploy on mobile terminals, the purpose of the present invention is to provide a lightweight metal surface defect detection method based on dual-source knowledge distillation, which can not only ensure the accuracy of defect detection but also lightweight the network, meeting the real-time and accuracy requirements of mobile devices.

[0007] In order to achieve the above-mentioned invention object, the present invention adopts the following technical scheme:

[0008] A lightweight metal surface defect detection method based on dual-source knowledge distillation comprises the following steps:

[0009] S1. Obtain different types of defect images and normal images of the metal surface to be inspected, and classify the images according to the defect type;

[0010] S2. Use a deep learning platform to annotate the classified images in step S1, generate corresponding label files, and construct a metal surface defect dataset to be detected;

[0011] S3, performing data preprocessing operations on the images in the training set of the data set in step S2, and then inputting them into the constructed CU-Net network model for training to obtain a pre-trained model as a teacher network;

[0012] S4, simplify the teacher network in step S3 into CU-Net(s), and then use it as the student network to extract different types of knowledge from the feature layer and response layer of the teacher network through the knowledge distillation strategy;

[0013] S5. Optimize the hyperparameters in the training process according to the test results of the validation set of the data set in step S2, and then deploy the CU-Net(s) model trained in step S4 to the mobile terminal to detect defects on the metal surface in real time.

[0014] Furthermore, the above step S2 includes the following sub-steps:

[0015] S2.1. Label the classified images through the deep learning platform and generate the corresponding png label files;

[0016] S2.2. After all images in step S2.1 are labeled, the image pair of the dataset is obtained. Among them, x i represents the acquired image, y i Represents the corresponding label, i represents the i-th image, and N represents the total number of images in the dataset;

[0017] S2.3, the image pair data obtained in step S2.2 is divided into three parts: training set D train , validation set D val and the test set D test , where the training set D train Used for model training, accounting for 80% of all data; validation set D val Used to provide feedback on the training status of the model, accounting for 10% of all data; test set D test Used to evaluate the performance of the model, accounting for 10% of the total data.

[0018] Furthermore, the above step S3 includes the following sub-steps:

[0019] S3.1, load the images and corresponding labels of the training set, resize the images to fit the model input size, and apply data augmentation operations to expand the training set;

[0020] S3.2, normalizing the data-enhanced images to ensure that the pixel values ​​of all images are within the range of 0 to 1, thereby obtaining preprocessed image pairs;

[0021] S3.3. Constructing the cascaded U-Net architecture includes the following sub-steps:

[0022] S3.31. According to the size of the training set image, set the number of cascaded layers of the CU-Net network: downsample the output features of the first encoder by 2 times and send them to the second encoder, and then downsample the output features by 2 times and send them to the third encoder; and so on, finally downsample the output features of the k-1th encoder by 2 times and send them to the kth encoder;

[0023] S3.32. Select the traditional U-Net network as the structure of the first encoder, extract the multi-scale features of the input image by downsampling, then encode the multi-scale features into high-resolution feature maps by progressive upsampling, concatenation and convolution to obtain the output features of the encoder; then reduce the number of downsampling and upsampling layers of the U-Net network in sequence as the structure of the second encoder to the k-2 encoder; in the k-1 encoder and the k encoder, use the dilated convolution operation to make the intermediate feature maps have the same resolution as their input feature maps;

[0024] S3.33, multiple decoders adopt a structure symmetrical to the multiple encoders described in step S3.32, mainly predicting feature maps, and each decoder stage takes the concatenation of the upsampled feature map from its previous stage and the upsampled feature map from its symmetrical encoder stage as input;

[0025] S3.34, the output features of the decoder are passed through a 3×3 convolution layer and a sigmoid function to obtain segmentation result maps of different scales, and then the final segmentation result map is obtained through an attention fusion mechanism;

[0026] S3.4. Send the preprocessed image pair obtained in step 3.2 to the CU-Net network in step S3.3, and update the model parameters in the back-propagation process according to the loss between the predicted result and the true label to obtain the pre-trained weights of the training set on the teacher model.

[0027] Furthermore, the above step S3.4 includes the following sub-steps:

[0028] S3.41, the input image x is downsampled by the encoding part in the first encoder to extract multi-scale features, and the multi-scale features are encoded into a high-resolution feature map through progressive upsampling, concatenation and convolution; then the local features and the multi-scale features are fused to obtain the output of the first encoder O En_1 ;

[0029] S3.42, the output of the first encoder O En_1 Send it to the second encoder to get O En_2 , the output of the second encoder O En_2 Send it to the third encoder to get O En_3 , and so on, the output O of the k-1th encoderEn_k-1 Send it to the kth encoder to get O En_k ; Dilated convolution operations are used in the k-1th encoder and the kth encoder so that the feature maps output by these two blocks have the same resolution as their input feature maps;

[0030] S3.43, the decoder takes the concatenation of the upsampled feature map from the previous stage and the feature map from its symmetric encoder stage as input, and generates a multi-scale semantic map through 3×3 convolution and Sigmod function respectively. i (i=1,2,…,k); then the multi-scale segmentation results are fused through the attention fusion mechanism, and then the final fused semantic map is generated through 1×1 convolution and Sigmod function f ;

[0031] S3.44, the loss function of the constructed CU-Net network during the training phase is as follows:

[0032]

[0033] Among them, L BCE represents binary cross entropy loss; map i Represents the segmentation result output by the i-th encoder; map f Represents the segmentation result after fusion; label represents the true label of the sample.

[0034] Furthermore, the above step S4 includes the following sub-steps:

[0035] S4.1. Simplify the CU-Net model by reducing the number of cascade layers, the number of convolutional layers, and compressing the channel dimension to obtain its lightweight version CU-Net(s);

[0036] S4.2, load the pre-trained weights of the CU-Net model, input the same input image into the teacher network CU-Net and the lightweight student network CU-Net(s) at the same time, and extract the outputs of the corresponding feature layers and response layers of the two networks;

[0037] S4.3. The multi-scale segmentation map output by the teacher network is used as knowledge, and the true label of the sample is used to guide the student network; therefore, the distillation loss based on the response layer is defined as follows:

[0038]

[0039] Among them, β is the trade-off coefficient; and Multi-scale segmentation maps representing the teacher network and the student network respectively; and They represent the features of the teacher network and the student network after fusion; label represents the true label of the sample;

[0040] S4.4. Construct a residual learning framework so that the student features of the next layer can learn the residual between the student features and teacher features of the previous layer, helping the deep features of the student network to gradually extract useful information. Therefore, the distillation loss based on the feature layer is defined as follows:

[0041]

[0042] Among them, f t (x;n) and f s (x; n) represent the deepest feature representation of the input image x in the teacher network and the student network respectively; f t (x; j) and f s (x; j) denotes the feature representation of the jth layer in the teacher network and the student network, respectively, and μ(·) denotes the feature fusion module;

[0043] S4.5. Combining the above-mentioned dual-source knowledge distillation strategy based on the response layer and the feature layer, the student network CU-Net(s) is trained under the guidance of the teacher network to extract different types of knowledge from the feature layer and the response layer of the teacher network.

[0044] Furthermore, the above step S5 includes the following sub-steps:

[0045] S5.1. Use the validation set to verify the performance of the lightweight model CU-Net(s) trained with knowledge distillation, and tune the hyperparameters during model training to ensure that the model achieves good detection results on the validation set.

[0046] S5.2. Use the test set to perform the final performance evaluation of the model and deploy the CU-Net(s) model on the mobile terminal device for metal surface defect detection.

[0047] Due to the adoption of the above-mentioned technical solution, the present invention has the following advantages:

[0048] This lightweight metal surface defect detection method based on dual-source knowledge distillation applies deep learning technology and model lightweight technology to the field of industrial vision for metal surface defect detection, which can solve the problems of low efficiency and high false detection rate of manual detection, thereby greatly reducing the labor cost of metal product quality inspection. The constructed CU-Net model improves the U-Net model commonly used in segmentation tasks. By introducing the attention mechanism and the cascaded U-shaped structure, the accuracy of feature transfer and the ability of detail recovery are enhanced, so that defects on the metal surface can be segmented more accurately. The problem that deep learning models are difficult to deploy on mobile terminals is avoided. By designing a lighter CU-Net(s) model and migrating different types of knowledge from different positions of the teacher model, metal surface defects can be detected quickly, efficiently and with high accuracy. BRIEF DESCRIPTION OF THE DRAWINGS

[0049] Figure 1 It is a flow chart of a lightweight metal surface defect detection method based on dual-source knowledge distillation;

[0050] Figure 2 It is a structural diagram of the cascaded U-Net architecture;

[0051] Figure 3 This is the overall framework diagram of model lightweighting based on the dual-source knowledge distillation strategy. DETAILED DESCRIPTION

[0052] The technical solution of the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments.

[0053] like Figure 1 As shown, a lightweight metal surface defect detection method based on dual-source knowledge distillation includes the following steps:

[0054] S1. Use an industrial camera to photograph the metal surface to be inspected, obtain different types of defect images and normal images of the metal surface to be inspected, and ensure that at least 200 sample images are collected for each defect; classify the collected defect images according to the defect type, so that the trained deep learning model can display the defect category while detecting the defect location;

[0055] S2, using a deep learning platform to annotate the classified images in step S1, generate corresponding label files, and construct a metal surface defect dataset to be detected; specifically including the following sub-steps:

[0056] S2.1. Label the classified images through the deep learning platform and generate the corresponding png label files;

[0057] S2.2. After all images in step S2.1 are labeled, the image pair of the dataset is obtained. Among them, xi represents the acquired image, y i Represents the corresponding label, i represents the i-th image, and N represents the total number of images in the dataset;

[0058] S2.3, the image pair data obtained in step S2.2 is divided into three parts: training set D train , validation set D val and the test set D test , where the training set D train Used for model training, accounting for 80% of all data; validation set D val Used to provide feedback on the training status of the model, accounting for 10% of all data; test set D test Used to evaluate the performance of the model, accounting for 10% of the total data; if the data set is relatively small and different types of defect samples are scarce, the proportion of the training set can be appropriately increased, and the validation set and test set are only used to facilitate the evaluation of the model performance;

[0059] S3, performing data preprocessing operations on the images in the training set of the data set in step S2, and then inputting them into the constructed CU-Net network model to obtain a pre-trained model as a teacher network; specifically comprising the following sub-steps:

[0060] S3.1. Load the images and corresponding labels of the training set, resize the images to a size suitable for the model input, and apply data augmentation operations, including but not limited to random rotation, random flipping, and random scaling, to expand the training set;

[0061] S3.2, normalizing the data-enhanced images to ensure that the pixel values ​​of all images are within the range of 0 to 1, thereby obtaining preprocessed image pairs;

[0062] S3.3, if Figure 2 As shown in the figure, a cascaded U-Net (CU-Net) architecture is constructed. By introducing a cascaded U-shaped structure and an attention fusion mechanism, the model's ability to perceive defect details is improved, so that CU-Net can more accurately detect and segment small metal surface defects. The following sub-steps are included:

[0063] S3.31. According to the size of the training set image, set the number of cascaded layers of the CU-Net network: downsample the output features of the first encoder by 2 times and send them to the second encoder, and then downsample the output features by 2 times and send them to the third encoder; and so on, finally downsample the output features of the k-1th encoder by 2 times and send them to the kth encoder to extract richer context information from features of different scales;

[0064] S3.32. Select the traditional U-Net network as the structure of the first encoder, extract the multi-scale features of the input image by downsampling, then encode the multi-scale features into high-resolution feature maps by progressive upsampling, concatenation and convolution to obtain the output features of the encoder; then reduce the number of downsampling and upsampling layers of the U-Net network in sequence as the structure of the second encoder to the k-2 encoder; in the k-1 encoder and the k encoder, use dilated convolution instead of pooling and upsampling operations to make the intermediate feature maps have the same resolution as their input feature maps;

[0065] S3.33, multiple decoders adopt a structure symmetrical to the multiple encoders described in step S3.32, and mainly predict feature maps. Each decoder stage takes the concatenation of the upsampled feature map from its previous stage and the upsampled feature map from its symmetrical encoder stage as input, so that the deep decoder integrates more shallow encoder features, improving the clarity and accuracy of defect detail prediction;

[0066] S3.34, the output features of the decoder are passed through a 3×3 convolution layer and a sigmoid function to obtain segmentation result maps of different scales, and then the final segmentation result map is obtained through an attention fusion mechanism;

[0067] S3.4, sending the preprocessed image pair obtained in step 3.2 to the CU-Net network in step S3.3, and updating the model parameters in the back propagation process according to the loss between the predicted result and the true label, to obtain the pre-trained weights of the training set on the teacher model; including the following sub-steps:

[0068] S3.41, the input image x is downsampled by the encoding part in the first encoder to extract multi-scale features, and the multi-scale features are encoded into a high-resolution feature map through progressive upsampling, concatenation and convolution; then the local features and the multi-scale features are fused to obtain the output of the first encoder O En_1 ;

[0069] S3.42, the output of the first encoder O En_1 Send it to the second encoder to get O En_2 , the output of the second encoder O En_2 Send it to the third encoder to get O En_3 , and so on, the output O of the k-1th encoder En_k-1 Send it to the kth encoder to get O En_k; Since the resolution of feature maps is relatively low, further downsampling these feature maps will lose useful contextual information; therefore, dilated convolutions are used in the k-1th encoder and the kth encoder to replace the merging and upsampling operations, so that the feature maps output by these two blocks have the same resolution as their input feature maps;

[0070] S3.43, the decoder takes the concatenation of the upsampled feature map from the previous stage and the feature map from its symmetric encoder stage as input, and generates a multi-scale semantic map through 3×3 convolution and Sigmod function respectively. i (i=1,2,…,k); then the multi-scale segmentation results are fused through the attention fusion mechanism, and then the final fused semantic map is generated through 1×1 convolution and Sigmod function f ;

[0071] S3.44, the loss function of the constructed CU-Net network during the training phase is as follows:

[0072]

[0073] Among them, L BCE Represents binary cross entropy loss, which is usually used in pixel-level segmentation tasks to measure the difference between the classification prediction and the label of each pixel; map i Represents the segmentation result output by the i-th encoder; map f Represents the segmentation result after fusion; label represents the true label of the sample;

[0074] S4, such as Figure 3 As shown, the teacher network in step S3 is simplified to CU-Net(s), which is then used as the student network to extract different types of knowledge from the feature layer and response layer of the teacher network through the knowledge distillation strategy; including the following sub-steps:

[0075] S4.1. Simplify the CU-Net model by reducing the number of cascade layers, the number of convolutional layers, and compressing the channel dimension to obtain its lightweight version CU-Net(s);

[0076] S4.2, load the pre-trained weights of the CU-Net model, input the same input image into the teacher network CU-Net and the lightweight student network CU-Net(s) at the same time, and extract the outputs of the corresponding feature layers and response layers of the two networks;

[0077] S4.3. The multi-scale segmentation map output by the teacher network is used as knowledge, and the true label of the sample is used to guide the student network; therefore, the distillation loss based on the response layer is defined as follows:

[0078]

[0079] Among them, β is the trade-off coefficient; and Multi-scale segmentation maps representing the teacher network and the student network respectively; and They represent the features of the teacher network and the student network after fusion; label represents the true label of the sample;

[0080] S4.4. Construct a residual learning framework so that the student features of the next layer can learn the residual between the student features and teacher features of the previous layer, helping the deep features of the student network to gradually extract useful information. Therefore, the distillation loss based on the feature layer is defined as follows:

[0081]

[0082] Among them, f t (x;n) and f s (x; n) represents the deepest feature representation of the input image x in the teacher network and the student network respectively; μ(·) represents the feature fusion module, that is, Figure 3 ABF module in;

[0083] S4.5. Combining the above-mentioned dual-source knowledge distillation strategy based on the response layer and the feature layer, the student network CU-Net(s) is trained under the guidance of the teacher network to extract different types of knowledge from the feature layer and the response layer of the teacher network;

[0084] S5, optimizing the hyperparameters in the training process according to the test results of the validation set of the data set in step S2, and then deploying the CU-Net(s) model trained in step S4 to the mobile terminal to detect defects on the metal surface in real time; comprising the following sub-steps:

[0085] S5.1. Use the validation set to verify the performance of the lightweight model CU-Net(s) trained with knowledge distillation, and tune the hyperparameters during model training to ensure that the model achieves good detection results on the validation set.

[0086] S5.2. Use the test set to perform the final performance evaluation of the model, deploy the CU-Net(s) model on the mobile terminal device, and send the frame image captured by the camera into the CU-Net(s) model to obtain the segmented defect result information, thereby realizing real-time metal surface defect detection.

[0087] The above description is only a preferred embodiment of the present invention, and is not intended to limit the present invention. Without departing from the spirit and scope of the present invention, all equivalent changes and modifications made within the scope of the patent application of the present invention shall fall within the scope of patent protection of the present invention.

Claims

1. A lightweight metal surface defect detection method based on dual-source knowledge distillation, characterized by: It includes the following steps: S1. Obtain different types of defect images and normal images of the metal surface to be inspected, and classify the images according to the defect type; S2. Use a deep learning platform to annotate the classified images in step S1, generate corresponding label files, and construct a metal surface defect dataset to be detected; S3, performing data preprocessing operations on the images in the training set of the data set in step S2, and then inputting them into the constructed CU-Net network model for training to obtain a pre-trained model as a teacher network; S4, simplify the teacher network in step S3 into CU-Net(s), and then use it as the student network to extract different types of knowledge from the feature layer and response layer of the teacher network through the knowledge distillation strategy; It includes the following sub-steps: S4.

1. Simplify the CU-Net model by reducing the number of cascade layers, the number of convolutional layers, and compressing the channel dimension to obtain its lightweight version CU-Net(s); S4.2, load the pre-trained weights of the CU-Net model, input the same input image into the teacher network CU-Net and the lightweight student network CU-Net(s) at the same time, and extract the outputs of the corresponding feature layers and response layers of the two networks; S4.

3. The multi-scale segmentation map output by the teacher network is used as knowledge, and the true label of the sample is used to guide the student network; therefore, the distillation loss based on the response layer is defined as follows: Among them, β is the trade-off coefficient; and Multi-scale segmentation maps representing the teacher network and the student network respectively; and They represent the features of the teacher network and the student network after fusion; label represents the true label of the sample; S4.

4. Construct a residual learning framework so that the student features of the next layer can learn the residual between the student features and teacher features of the previous layer, helping the deep features of the student network to gradually extract useful information. Therefore, the distillation loss based on the feature layer is defined as follows: Among them, f t (x;n) and f s (x; n) represent the deepest feature representation of the input image x in the teacher network and the student network respectively; f t (x; j) and f s (x; j) denotes the feature representation of the jth layer in the teacher network and the student network, respectively, and μ(·) denotes the feature fusion module; S4.

5. Combining the above-mentioned dual-source knowledge distillation strategy based on the response layer and the feature layer, the student network CU-Net(s) is trained under the guidance of the teacher network to extract different types of knowledge from the feature layer and the response layer of the teacher network; S5. Optimize the hyperparameters in the training process according to the test results of the validation set of the data set in step S2, and then deploy the CU-Net(s) model trained in step S4 to the mobile terminal to detect defects on the metal surface in real time.

2. The lightweight metal surface defect detection method based on dual-source knowledge distillation according to claim 1 is characterized by: The step S2 comprises the following sub-steps: S2.

1. Label the classified images through the deep learning platform and generate corresponding png label files; S2.

2. After all images in step S2.1 are labeled, the image pair of the dataset is obtained. Among them, x i represents the acquired image, y i Represents the corresponding label, i represents the i-th image, and N represents the total number of images in the dataset; S2.3, divide the image pair data obtained in step 2.2 into three parts: training set D train , validation set D val and the test set D test , where the training set D train Used for model training, accounting for 80% of all data; validation set D val Used to provide feedback on the training status of the model, accounting for 10% of all data; test set D test Used to evaluate the performance of the model, accounting for 10% of the total data.

3. The lightweight metal surface defect detection method based on dual-source knowledge distillation according to claim 1 or 2 is characterized in that: The step S3 comprises the following sub-steps: S3.1, load the images and corresponding labels of the training set, resize the images to fit the model input size, and apply data augmentation operations to expand the training set; S3.2, normalizing the data-enhanced images to ensure that the pixel values ​​of all images are within the range of 0 to 1, thereby obtaining preprocessed image pairs; S3.

3. Constructing the cascaded U-Net architecture includes the following sub-steps: S3.

31. According to the size of the training set image, set the number of cascaded layers of the CU-Net network: downsample the output features of the first encoder by 2 times and send them to the second encoder, and then downsample the output features by 2 times and send them to the third encoder; and so on, finally downsample the output features of the k-1th encoder by 2 times and send them to the kth encoder; S3.

32. Select the traditional U-Net network as the structure of the first encoder, extract the multi-scale features of the input image by downsampling, then encode the multi-scale features into high-resolution feature maps by progressive upsampling, concatenation and convolution to obtain the output features of the encoder; then reduce the number of downsampling and upsampling layers of the U-Net network in sequence as the structure of the second encoder to the k-2 encoder; in the k-1 encoder and the k encoder, use the dilated convolution operation to make the intermediate feature maps have the same resolution as their input feature maps; S3.33, multiple decoders adopt a structure symmetrical to the multiple encoders in step S3.32 to predict the feature map, and each decoder stage takes the concatenation of the upsampled feature map from its previous stage and the upsampled feature map from its symmetrical encoder stage as input; S3.34, the output features of the decoder are passed through a 3×3 convolution layer and a sigmoid function to obtain segmentation result maps of different scales, and then the final segmentation result map is obtained through an attention fusion mechanism; S3.

4. Send the preprocessed image pair obtained in step 3.2 to the CU-Net network in step S3.3, and update the model parameters in the back-propagation process according to the loss between the predicted result and the true label to obtain the pre-trained weights of the training set on the teacher model.

4. The lightweight metal surface defect detection method based on dual-source knowledge distillation according to claim 3 is characterized by: The step S3.4 comprises the following sub-steps: S3.41, the input image x is downsampled by the encoding part in the first encoder to extract multi-scale features, and the multi-scale features are encoded into a high-resolution feature map through progressive upsampling, concatenation and convolution; then the local features and the multi-scale features are fused to obtain the output of the first encoder O En_1 ; S3.42, the output of the first encoder O En_1 Send it to the second encoder to get O En_2 , the output of the second encoder O En_2 Send it to the third encoder to get O En_3 , and so on, the output O of the k-1th encoder En_k-1 Send it to the kth encoder to get O En_k ; Dilated convolution operations are used in the k-1th encoder and the kth encoder so that the feature maps output by these two blocks have the same resolution as their input feature maps; S3.43, the decoder takes the concatenation of the upsampled feature map from the previous stage and the feature map from its symmetric encoder stage as input, and generates a multi-scale semantic map through 3×3 convolution and Sigmod function respectively. i (i=1,2,…,k); then the multi-scale segmentation results are fused through the attention fusion mechanism, and then the final fused semantic map is generated through 1×1 convolution and Sigmod function f ; S3.44, the loss function of the constructed CU-Net network during the training phase is as follows: Among them, L BCE represents binary cross entropy loss; map i Represents the segmentation result output by the i-th encoder; map f Represents the segmentation result after fusion; label represents the true label of the sample.

5. The lightweight metal surface defect detection method based on dual-source knowledge distillation according to claim 1 or 2 is characterized in that: The step S5 comprises the following sub-steps: S5.

1. Use the validation set to verify the performance of the lightweight model CU-Net(s) trained with knowledge distillation, and tune the hyperparameters during model training. S5.

2. Use the test set to perform the final performance evaluation of the model and deploy the CU-Net(s) model on the mobile terminal device for metal surface defect detection.

Citation Information

Patent Citations

  • Surface defect detection method based on multi-scale attention guidance and knowledge distillation

    CN113947590A

  • Magnetic shoe surface defect detection method

    CN115841447A