Task-adaptive metal surface defect small sample semantic segmentation method and system equipment

Through task adaptation units, context adaptation modules and gated mask average pooling, combined with attention distillation modules, the problem that existing algorithms are difficult to adapt to diverse defect types is solved, and high-precision metal surface defect detection is achieved.

CN120431337BActive Publication Date: 2025-09-16LONGYAN UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510870637.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-06-26
Publication Date
2025-09-16
Estimated Expiration
2045-06-26

AI Technical Summary

Technical Problem

Existing general-purpose small-sample semantic segmentation algorithms for metal surface defects are difficult to adapt to diverse defect types and lack task context information perception, resulting in limited segmentation performance.

Method used

The task adaptation unit, context adaptation module and gated mask average pooling are adopted, combined with the attention distillation module to generate task adaptation factors and high-precision segmentation masks by mining task association and context features.

Benefits of technology

The model can adapt to diverse defect characteristics, improve the accuracy and efficiency of metal surface defect detection, and is suitable for assembly line operations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120431337B_ABST
    Figure CN120431337B_ABST
Patent Text Reader

Abstract

This invention discloses a task-adaptive semantic segmentation method and system for small-sample metal surface defects, relating to metal surface defect detection technology and deep learning network technology. Leveraging the principles of long-short-term memory (LSTM) recurrent neural networks, this solution employs various gating mechanisms and incorporates trainable memory seeds to achieve task-adaptive semantic segmentation of small-sample metal surface defects, facilitating efficient application in pipeline inspection operations. Furthermore, this solution leverages the gating mechanism to learn contextual knowledge of support-query pairs, guiding the model to generate high-precision segmentation masks. Furthermore, this solution utilizes an attention distillation module to facilitate and accelerate model iteration, making the technical solution more suitable for pipeline operations in high-speed metal surface defect detection, achieving highly accurate prediction results.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the fields of metal surface defect detection technology and deep learning network technology, and in particular to a task-adaptive metal surface defect small sample semantic segmentation method and system equipment. Background Art

[0002] Metal materials, as essential building blocks, are widely used across various industries. Due to the diverse environments in which metal products are used, ensuring their reliability has always been a hot research topic. In industrial production, defects often occur on the surface of metal parts or in specific areas due to machining. These defects can not only detract from the aesthetic appearance of the part, but also damage its performance, thereby affecting subsequent products. Therefore, defect detection of metal parts is a critical step in production.

[0003] Small-shot semantic segmentation, due to its rapid generalization to new classes and pixel-level segmentation capabilities, is ideal for addressing data scarcity and achieving fine-grained object description in industrial applications. However, existing general-purpose small-shot semantic segmentation algorithms for metal surface defects focus solely on changes in defect features within a single task during model iteration. They lack the perception and adaptation of task context, making them difficult to adapt to diverse defect types and resulting in limited segmentation performance. This makes existing algorithms difficult to adapt to diverse defect types in metal surface defect detection pipeline tasks. Summary of the Invention

[0004] In view of this, the purpose of the present invention is to propose a task-adaptive metal surface defect small sample semantic segmentation method and system equipment that is reliable in implementation, efficient in operation and adaptable to diverse defect types on metal surfaces.

[0005] In order to achieve the above technical objectives, the technical solution adopted by the present invention is:

[0006] A task-adaptive small-sample semantic segmentation method for metal surface defects includes a semantic segmentation model, wherein the semantic segmentation model includes a task adaptation unit, a context adaptation module, and gated mask average pooling. The small-sample semantic segmentation method includes:

[0007] The task adaptation unit generates task adaptation factors by mining the associations between previous and next tasks and predicting the dependencies between tasks and labels, enabling the model to adapt to diverse defect feature tasks.

[0008] The context adaptation module analyzes the contextual associations between high-level features through the cosine similarity interaction between support and query pairs. It also combines batch normalization operations and hyperparameters to dynamically extract contextual features within the task and obtain contextual information.

[0009] Gated mask average pooling uses a gating mechanism to enable the model to learn the effective information in the support features a priori, and then combines the support mask to perform mask average pooling to generate support information;

[0010] The information generated by the task adaptation unit, the context adaptation module and the gated mask average pooling is fused and decoded to obtain a prediction mask.

[0011] As a possible implementation method, further, the model described in this scheme also includes an attention distillation module, and the small sample semantic segmentation method also includes: the attention distillation module uses the spatial attention mechanism to jointly generate attention soft labels with query features, and then residually connects the attention soft labels with the query features, and distills them with the true labels to obtain distillation loss, so as to accelerate the memory and iteration process of the model.

[0012] As a preferred implementation method, preferably, the task described in this scheme is an N-way K-shot task set in small sample learning, which indicates that one iteration process contains N categories and K supporting images; the supporting images are used to guide the segmentation of the query image.

[0013] As a preferred implementation method, preferably, the task of the small sample semantic segmentation method described in this solution is set to 1-way K-shot, and trained by a cross entropy loss and attention distillation loss, which are defined as follows:

[0014]

[0015] in, represents the total loss, represents the binary cross entropy loss function, represents the distillation loss, represents a hyperparameter.

[0016] As a preferred implementation method, preferably, the task adaptation unit described in this solution is provided with an FPN encoder, a basic gate, an input gate, an output gate, an output processing unit, a forget gate, a forget processing unit and a trainable memory seed.

[0017] Among them, the FPN encoder is used to extract and fuse the features of high-level support-query pairs; the basic gate is adjacent to the FPN encoder, which uses a gating mechanism to preprocess the features of the support-query pairs, and fuses them with the trainable memory seeds into task units to achieve a priori adaptation of the task; the a priori adaptation is to preprocess the task units using the memory information provided by the trainable memory seeds; wherein, the trainable memory seeds are trainable random parameters, which participate in the entire iterative process of the model and are used to memorize the task status; the input gate, output gate and forget gate are three branches, which are all connected to the task unit and consist of different convolution operations, batch normalization operations and activation functions; the input gate Used to guide the model to focus on the key features of the current task; the output gate combines the result of the input gate to generate a preprocessing task unit; the forget gate is used to guide the model to ignore the secondary features in the task; the forget processing unit uses the output of the input gate and the forget gate, combined with the trainable memory seed, to generate a state unit; the state unit contains the secondary features that need to be ignored during this iteration; the output processing unit combines the preprocessing task unit, the state unit and the attention soft label to generate a task adaptation factor; wherein, the attention soft label is generated by the query feature through the spatial attention block through the spatial attention mechanism, which is used to predict the dependency between the task and the label to achieve dynamic adaptation of the task.

[0018] Based on the above, this scheme also proposes a task-adaptive metal surface defect small sample semantic segmentation system, which includes an image acquisition system, a data preprocessing system, a model training system, a defect detection system and a result display system.

[0019] Among them, the image acquisition system is used to obtain image data of the metal surface, and it shoots the metal surface under specific lighting conditions and shooting angles so that the image data reflects the condition of the metal surface; the data preprocessing system is connected to the image acquisition system, and is responsible for performing preprocessing operations on the collected image data; the model training system is loaded with a semantic segmentation model and applies the above-mentioned small sample semantic segmentation method; the defect detection system is connected to the model training system and the data preprocessing system, and after the semantic segmentation model completes model training, the trained semantic segmentation model is used to perform defect detection on the image data of the metal surface, and then outputs the detection results; the result display system is connected to the defect detection system, and is used to generate a detection result report and display it to the user.

[0020] As a preferred embodiment, the image acquisition system of this solution is preferably equipped with a high-resolution industrial camera and a mechanical scanning device. It captures the metal surface at multiple shooting angles under specific lighting conditions to ensure that the captured image data reaches a preset clarity and reflects the condition of the metal surface, including possible defect characteristics, including one or more of scratches, holes, and cracks. The preprocessing operation includes one or more of image enhancement, denoising, and normalization.

[0021] Based on the above, this solution also proposes a metal surface defect detection method, which applies the task-adaptive metal surface defect small sample semantic segmentation system described above, and includes:

[0022] S101, an image acquisition system obtains image data of a metal surface to be inspected and sets the image data as an original image;

[0023] S102: The data processing system performs a preprocessing operation on the collected original image. The preprocessing operation includes grayscale conversion and normalization of the original image to reduce the impact of illumination unevenness and enhance image contrast, and then uses a filtering algorithm to remove noise interference in the image.

[0024] S103. The model training system is loaded with a semantic segmentation model and applies the aforementioned small sample semantic segmentation method, and trains the semantic segmentation model to obtain a converged model. During the training process, the model learns typical feature representations of normal and defective areas on the metal surface, while continuously adjusting model parameters to minimize the difference between the predicted results and the true annotations.

[0025] S104. The defect recognition system uses the trained semantic segmentation model to perform real-time analysis on the pre-processed image data of the metal surface to be inspected, to determine whether there are defects in the image data, to determine the specific location and category of the defects, and to generate a recognition result.

[0026] S105. The result output system presents the recognition result output by the defect recognition system to the user in a preset format.

[0027] As a preferred implementation method, preferably, this solution S104 includes: inputting the preprocessed image data into a trained semantic segmentation model, the semantic segmentation model outputs the probability distribution of each pixel in the image data belonging to different defect categories based on the learned features, and then post-processing the probability distribution by setting a threshold, and finally generating a binary segmentation map of the defect to clearly identify the boundary between the defect area and the normal area.

[0028] In this solution S105, the recognition result is presented to the user in a preset form including one or more of the following:

[0029] (1) Directly mark the defect location and category on the original image of the metal surface using different colors;

[0030] (2) Generate a detailed inspection report, which includes one or more key information such as the defect type, quantity, size, and distribution location;

[0031] (3) Output the recognition results in the form of images, tables or text to a display, printer or storage device.

[0032] Based on the above, this solution also proposes an electronic device, which includes a processor, a memory, an input device, an output device and a communication interface; the memory stores an operating system, applications and various types of data, and the various types of data include the code and configuration files required by the metal surface defect detection system, as well as the intermediate data, model parameters and historical detection records generated during the training and detection process.

[0033] In which, the application is configured to execute the above-mentioned small sample semantic segmentation method or the above-mentioned metal surface defect detection method by the processor; the input device includes one or more of a keyboard, a mouse, and a touch screen, which is used for user input of information; the output device includes one or more of a display and a printer, for displaying the recognition results of metal surface defect detection or the system status of the electronic device; the communication interface is used to realize the communication connection between the electronic device and the external device or the network, which includes one or more of an Ethernet interface, a USB interface, a Wi-Fi module, and a Bluetooth module, and supports multiple communication protocols for the electronic device to exchange data with an external device or to interact with other devices in the access network.

[0034] By employing the above-mentioned technical solution, the present invention offers the following advantages over existing technologies: Leveraging the concept of long-short-term memory (LSTM) recurrent neural networks, this solution designs different gating mechanisms and incorporates trainable memory seeds to achieve task-adaptive semantic segmentation of small samples of metal surface defects, making this solution suitable for efficient operation in pipeline inspection operations. Furthermore, this solution leverages the gating mechanism to learn contextual knowledge of support-query pairs, guiding the model to generate high-precision segmentation masks. Furthermore, this solution further proposes the use of an attention distillation module to facilitate and accelerate the model iteration process, making the technical solution more suitable for pipeline operations of high-speed metal surface defect inspection, achieving high-precision prediction results. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0036] Figure 1 This is a brief connection and implementation diagram of each unit module of the semantic segmentation model in the small sample semantic segmentation method of this scheme;

[0037] Figure 2 This is a brief implementation diagram of the task adaptation unit of the semantic segmentation model in the small sample semantic segmentation method of this scheme;

[0038] Figure 3 This is a brief implementation diagram of the context adaptation module of the semantic segmentation model in the small sample semantic segmentation method of this scheme;

[0039] Figure 4 This is a brief implementation diagram of the gated mask average pooling of the semantic segmentation model in the small sample semantic segmentation method of this scheme;

[0040] Figure 5 This is a brief implementation diagram of the attention distillation module of the semantic segmentation model in the small-sample semantic segmentation method of this scheme;

[0041] Figure 6 This is a schematic diagram of the subsystem connection relationship of the small sample semantic segmentation system mentioned in this solution;

[0042] Figure 7 This is a schematic diagram of the connection relationship of some components of the electronic equipment mentioned in this solution. DETAILED DESCRIPTION

[0043] The present invention will be described in further detail below with reference to the accompanying drawings and examples. It is particularly noted that the following examples are intended only to illustrate the present invention and are not intended to limit the scope of the present invention. Similarly, the following examples are only some embodiments of the present invention and are not intended to be exhaustive. All other embodiments obtained by those of ordinary skill in the art without creative effort are intended to fall within the scope of protection of the present invention.

[0044] like Figures 1 to 5 As shown in one of the figures, this embodiment proposes a task-adaptive semantic segmentation method for small samples of metal surface defects, including a semantic segmentation model, which includes a task adaptation unit 100, a context adaptation module 200, a gated mask average pooling 300 and an attention distillation module 400.

[0045] On this basis, the small sample semantic segmentation method described in this solution includes:

[0046] The task adaptation unit 100 generates task adaptation factors by mining the associations between previous and next tasks and predicting the dependencies between tasks and labels, so as to achieve model adaptation to diverse defect feature tasks.

[0047] The context adaptation module 200 analyzes the contextual associations between high-level features through the cosine similarity interaction between support and query pairs, and combines batch normalization operations and hyperparameters to achieve dynamic extraction of contextual features within the task and obtain contextual information;

[0048] Gated mask average pooling 300 uses a gating mechanism to enable the model to learn the effective information in the support features a priori, and then combines the support mask to perform mask average pooling to generate support information;

[0049] The task adaptation factor generated by the task adaptation unit 100, the context information generated by the context adaptation module 200, and the support information generated by the gated mask average pooling 300 are fused and subjected to decoding processing to obtain a prediction mask; wherein the decoding processing work consists of a residual layer and a classification head.

[0050] Furthermore, the attention distillation module 400 uses the spatial attention mechanism to jointly generate the attention soft label 113 with the query feature, and then performs a residual connection between the attention soft label 113 and the query feature, and distills it with the true label to obtain the distillation loss to accelerate the memory and iteration process of the model.

[0051] In this solution, the context adaptation module 200 obtains the context feature representation of the support-query pair through high-level cosine similarity interaction, where the high level refers to the deep features extracted by the backbone network.

[0052] In this solution, the task adaptation unit 100 is inspired by the Long Short-Term Memory (LSTM) recurrent neural network, and adapts to diverse defect features by mining the associations between previous and next tasks and the dependencies between tasks and labels.

[0053] In this solution, a support-query pair is a combination of data with a corresponding category relationship between the support set and the query set. Support information, also referred to in the art as support prototype, support information, or support information, is used to express the semantic knowledge provided by the support set.

[0054] In this solution, the source of the true label is the annotation data of the support set and query set corresponding to the support-query pair; the attention distillation module 400 uses the spatial attention mechanism to combine the query features to generate the attention soft label 113.

[0055] As a preferred implementation method, preferably, the task described in this scheme is an N-way K-shot task set in small sample learning, which indicates that one iteration process contains N categories and K supporting images; the supporting images are used to guide the segmentation of the query image.

[0056] In terms of model iteration, as a preferred implementation method, the task of the small sample semantic segmentation method described in this solution is preferably set to 1-way K-shot, and trained by a cross entropy loss and attention distillation loss, which are defined as follows:

[0057]

[0058] in, represents the total loss, represents the binary cross entropy loss function, represents the distillation loss, Represents a hyperparameter; wherein, the binary cross entropy loss function is used to jointly perform the true label and the predicted mask to realize the training and retraining of the model, which is existing public information and will not be described in detail here.

[0059] Focus on combination Figure 2 As shown, the task adaptation unit 100 of this embodiment is provided with a Feature Pyramid Network (FPN) encoder, namely, an FPN encoder 101. In addition, preferably, the task adaptation unit 100 of this embodiment is further provided with a basic gate 102, an input gate 103, an output gate 104, an output processing unit 105, a forget gate 106, a forget processing unit 107, and a trainable memory seed 108.

[0060] The FPN encoder 101 is used to extract and fuse high-level support-query pair features to obtain support-query pair features 109. On this basis, the basic gate 102, located adjacent to the FPN encoder 101, pre-processes the support-query pair features 109 using a gating mechanism and fuses them with the trainable memory seed 108 into a task unit 110, thereby achieving a priori task adaptation. The a priori adaptation utilizes the memory information provided by the trainable memory seed 108 to pre-process the task unit 110. The trainable memory seed 108 is a trainable random parameter that participates in the entire iterative process of the model and is used to dynamically memorize the task state. Similar to the memory cell (cell state) of an LSTM (which uses a gating mechanism to achieve long-term information retention and dynamic updating), it can achieve long-term information retention and dynamic updating.

[0061] The input gate 103, output gate 104, and forget gate 106 serve as three branches, all connected to the task unit and composed of different convolution operations, batch normalization operations, and activation functions. The input gate 103 is used to guide the model to focus on the key features of the current task. The output gate 104 combines the results of the input gate 103 to generate a preprocessing task unit 111. The forget gate 106 is used to guide the model to ignore minor features in the task. The forget processing unit 107 uses the outputs of the input gate 103 and forget gate 106, combined with the trainable memory seed 108, to generate a state unit 112. The state unit 112 contains the minor features to be ignored during this iteration.

[0062] Based on the above, the output processing unit 105 combines the preprocessing task unit 111, the state unit 112 and the attention soft label 113 to generate a task adaptation factor 114; wherein, the attention soft label 113 is generated by the query feature through the spatial attention block 115 through the spatial attention mechanism, which is used to predict the dependency between the task and the label to achieve dynamic adaptation of the task.

[0063] Focus on combination Figure 3 As shown, in this solution, the context adaptation module 200 analyzes the context association between high-level features through the interaction of high-level cosine similarity 201 of support-query pairs, and combines batch normalization 202 operation and hyperparameters 203 to achieve dynamic extraction of context features within the task.

[0064] Focus on combination Figure 4 As shown, the gated mask average pooling 300 is an improvement to the existing mask average pooling technology. It enables the model to learn the effective information in the support features a priori through the gating mechanism 301, and then combines the support mask 302 to perform mask average pooling 303, which can optimize the knowledge extracted from the support set and achieve the generation of high-precision segmentation masks.

[0065] Based on the above scheme, this scheme fuses the information generated by the task adaptation unit 100, the context adaptation module 200 and the gated mask average pooling 300, and obtains the final prediction mask through processing by the decoder module.

[0066] In terms of model iteration, combined with Figure 5 As shown, the attention distillation module 400 generates an attention soft label 113 by using the spatial attention mechanism in conjunction with the query feature through the spatial attention block 115, and then performs a residual connection between the attention soft label 113 and the query feature, and distills it with the true label 401 to obtain the distillation loss , to accelerate the model's memory and iteration process, which is conducive to the rapid processing of the model application in metal surface defect pipeline detection operations.

[0067] The following table illustrates the performance of each module instance of this solution in a 3-fold cross-validation on the general metal surface defect dataset Surface Defect-4i.

[0068] The 3-fold cross-validation method divides the dataset into three equal parts. During the model iteration process, one fold is used as the test set, and the other two folds are used as the training set. The task adaptation unit, a key module of this solution, improves the mean Intersection over Union (MIOU) of the baseline by 5.69% on the 1-shot task. The baseline consists of only the backbone network and decoder, representing a basic level of performance for this dataset. The mean Intersection over Union (MIOU) is the average intersection over union (MIOU), which measures the model's overall performance across different metal surface defect categories.

[0069] Performance of each module in the semantic segmentation model in 3-fold cross validation

[0070]

[0071] In summary, the task adaptation unit of this scheme uses a gating mechanism and trainable memory seeds to achieve small sample task adaptation; it further proposes gated mask average pooling, which uses the gating mechanism to priori learn the support set knowledge to guide the precise segmentation of the query set; it also uses the context adaptation module to perform contextual interaction of high-level features within the task to improve the model's dynamic context perception and adaptability; finally, the attention distillation module uses spatial attention to generate soft labels, and combines them with real labels for feature distillation to accelerate the model iteration process.

[0072] Based on the above, combined Figure 6 As shown, this scheme also proposes a task-adaptive metal surface defect small sample semantic segmentation system, which includes an image acquisition system, a data preprocessing system, a model training system, a defect detection system and a result display system.

[0073] The image acquisition system is used to obtain image data of the metal surface. The image acquisition system photographs the metal surface under specific lighting conditions and shooting angles so that the image data reflects the condition of the metal surface.

[0074] The data preprocessing system is connected to the image acquisition system and is responsible for performing preprocessing operations on the acquired image data.

[0075] The model training system is loaded with a semantic segmentation model and applies the small sample semantic segmentation method described above.

[0076] The defect detection system is connected to the model training system and the data preprocessing system, and after the semantic segmentation model completes model training, it uses the trained semantic segmentation model to perform defect detection on the image data of the metal surface, and then outputs the detection results.

[0077] The result display system is connected to the defect detection system and is used to generate a detection result report and display it to the user.

[0078] As a preferred embodiment, the image acquisition system described in this solution is preferably equipped with a high-resolution industrial camera and a mechanical scanning device, which shoots the metal surface at multiple shooting angles under specific lighting conditions so that the collected image data reaches a preset clarity and reflects the condition of the metal surface, including possible defect characteristics, and the defect characteristics include one or more of scratches, holes, and cracks.

[0079] In terms of image preprocessing operations, the data preprocessing system includes at least one of image enhancement, denoising and normalization.

[0080] Based on the above, this solution also proposes a metal surface defect detection method, which applies the task-adaptive metal surface defect small sample semantic segmentation system described above, and includes:

[0081] S101, an image acquisition system obtains image data of a metal surface to be inspected and sets the image data as an original image;

[0082] S102: The data processing system performs a preprocessing operation on the collected original image. The preprocessing operation includes grayscale conversion and normalization of the original image to reduce the impact of illumination unevenness and enhance image contrast, and then uses a filtering algorithm to remove noise interference in the image.

[0083] S103. The model training system is loaded with a semantic segmentation model and applies the aforementioned small sample semantic segmentation method, and trains the semantic segmentation model to obtain a converged model. During the training process, the model learns typical feature representations of normal and defective areas on the metal surface, while continuously adjusting model parameters to minimize the difference between the predicted results and the true annotations.

[0084] S104. The defect recognition system uses the trained semantic segmentation model to perform real-time analysis on the pre-processed image data of the metal surface to be inspected, to determine whether there are defects in the image data, to determine the specific location and category of the defects, and to generate a recognition result.

[0085] S105. The result output system presents the recognition result output by the defect recognition system to the user in a preset format.

[0086] Specifically, in S101 of this solution, the image acquisition system is the starting point of the entire inspection process. Its primary task is to acquire image data of the metal surface to be inspected. This system, composed of a high-resolution industrial camera and a mechanical scanning device, can capture images of the metal surface from all directions and angles, ensuring that the images captured accurately and in detail reflect the physical properties of the metal surface and any defects it may contain, such as scratches, pits, cracks, and holes.

[0087] In step S102, the data processing system, which follows the image acquisition system, preprocesses the captured raw images. The system performs grayscale conversion and normalization on the images to reduce the effects of uneven illumination, enhance image contrast, and enable more efficient and accurate feature extraction. Specific filtering algorithms are then used to remove noise from the images, such as Gaussian noise and salt-and-pepper noise.

[0088] In step S103, the model training system is a core component of the metal surface defect detection system. Its primary function is to train the adaptive small-sample semantic segmentation model for the task described in this article. During training, the model learns the typical feature representations of normal and defective areas on the metal surface, while continuously adjusting the model parameters to minimize the difference between the predicted results and the actual annotations.

[0089] In step S104, the preprocessed image data is input into a trained semantic segmentation model. Based on the learned features, the semantic segmentation model outputs a probability distribution of each pixel in the image data belonging to different defect categories. This probability distribution is then post-processed by setting a threshold, ultimately generating a binary segmentation map of the defects to clearly identify the boundaries between defective and normal areas. In other words, the defect recognition system uses a trained deep learning model to perform real-time analysis on the preprocessed metal surface image to determine whether defects are present in the image and determine the specific location and category of the defects.

[0090] In step S105 of this solution, the result output system is responsible for presenting the final recognition result of the defect recognition to the user in an intuitive and easy-to-understand form.

[0091] The recognition result is presented to the user in a preset form including one or more of the following forms:

[0092] (1) Directly mark the defect location and category on the original image of the metal surface using different colors (e.g., red for severe defects, yellow for minor defects);

[0093] (2) Generate a detailed inspection report, which includes one or more key information such as the defect type, quantity, size, and distribution location;

[0094] (3) Output the recognition results in the form of images, tables or text to a display, printer or storage device, providing a strong basis for subsequent quality assessment and maintenance decisions.

[0095] Based on the above, combined Figure 7 As shown, the present solution also proposes an electronic device, which includes a processor, a memory, an input device, an output device, and a communication interface.

[0096] The processor, as the core component of the electronic device, possesses powerful data processing capabilities and can efficiently execute various computing tasks. The memory stores the operating system, applications, and various data, including the code and configuration files required by the metal surface defect detection system, as well as intermediate data, model parameters, and historical detection records generated during the training and detection processes. The memory can be selected from commercially available products to ensure sufficient capacity and fast read and write speeds, ensuring smooth system operation and timely data delivery.

[0097] The application is configured to execute the aforementioned small sample semantic segmentation method or the aforementioned metal surface defect detection method on a processor; that is, the processor can be used to perform operations including, but not limited to, running the task-adaptive metal surface defect small sample semantic segmentation model for image processing and executing logical judgments. This can be achieved by selecting a commercially available product that utilizes an advanced multi-core architecture and supports parallel computing, effectively improving the speed of model training and defect detection.

[0098] Input devices include, but are not limited to, keyboards, mice, touch screens, and the like, and are used for user input; for example, they are used to enter operational instructions, set test parameters, and enter other relevant information. Using these input devices, users can conveniently interact with the electronic device to initiate test processes, adjust system configurations, or enter specific queries.

[0099] The output device includes but is not limited to a display, a printer, etc., which is used to display the identification results of metal surface defect detection or the system status of the electronic device; in this solution, the output device displays the detection results, system status and other information to the user. When it is a display, it can intuitively present the metal surface image and the detected defect area in a graphical manner; when a printer is used, a detailed detection report can be output, which is convenient for the user to archive or further analyze.

[0100] The communication interface is used to realize the communication connection between the electronic device and the external device or network, which includes but is not limited to Ethernet interface, USB interface, Wi-Fi module, Bluetooth module, etc. It supports multiple communication protocols for the electronic device to exchange data with external devices or interact with other devices in the access network, such as exchanging data with external storage devices, working in collaboration with other devices in the network, or accessing the Internet to obtain updated model parameters or software patches.

[0101] The above descriptions are only some embodiments of the present invention and do not limit the scope of protection of the present invention. Any equivalent device or equivalent process transformation made by using the contents of the description and drawings of the present invention, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.

Claims

1. A task-adaptive small-sample semantic segmentation method for metal surface defects, comprising a semantic segmentation model comprising a task-adaptive unit, a context-adaptive module, and gated mask average pooling. The task is an N-way K-shot task set in small-sample learning, which indicates that one iteration process contains N categories and K supporting images; the supporting images are used to guide the segmentation of the query image; and the method is characterized by: The small sample semantic segmentation method includes: The task adaptation unit generates task adaptation factors by mining the associations between previous and next tasks and predicting the dependencies between tasks and labels, enabling the model to adapt to diverse defect feature tasks. The context adaptation module analyzes the contextual associations between high-level features through the cosine similarity interaction between support and query pairs. It also combines batch normalization operations and hyperparameters to dynamically extract contextual features within the task and obtain contextual information. Gated mask average pooling uses a gating mechanism to enable the model to learn the effective information in the support features a priori, and then performs mask average pooling in combination with the support mask to generate support information; The information generated by the task adaptation unit, the context adaptation module and the gated mask average pooling is fused and decoded to obtain a predicted mask; The task adaptation unit is provided with an FPN encoder, a basic gate, an input gate, an output gate, an output processing unit, a forget gate, a forget processing unit and a trainable memory seed; The FPN encoder is used to extract and fuse features of high-level support-query pairs; The basic gate is adjacent to the FPN encoder and uses a gating mechanism to preprocess the features of the support-query pair and fuse them with the trainable memory seed into a task unit to achieve a priori adaptation of the task; the a priori adaptation is to preprocess the task unit using the memory information provided by the trainable memory seed; wherein the trainable memory seed is a trainable random parameter, which participates in the entire iterative process of the model and is used to remember the task state; The input gate, output gate, and forget gate are three branches, all of which are connected to the task unit and consist of different convolution operations, batch normalization operations, and activation functions. The input gate is used to guide the model to focus on the key features of the current task. The output gate combines the results of the input gate to generate a preprocessing task unit. The forget gate is used to guide the model to ignore minor features in the task. The forgetting processing unit uses the output of the input gate and the forgetting gate, combined with the trainable memory seed, to generate a state unit; the state unit contains the secondary features that need to be ignored in this iteration; The output processing unit combines the preprocessing task unit, the state unit and the attention soft label to generate a task adaptation factor; wherein, the attention soft label is generated by the query feature through the spatial attention block through the spatial attention mechanism, which is used to predict the dependency between the task and the label to achieve dynamic adaptation of the task.

2. The task-adaptive small sample semantic segmentation method for metal surface defects according to claim 1, characterized in that: The model further includes an attention distillation module, and the small sample semantic segmentation method further includes: The attention distillation module uses the spatial attention mechanism to jointly generate attention soft labels with query features, then performs a residual connection between the attention soft labels and the query features, and distills them with the true labels to obtain the distillation loss to accelerate the memory and iteration process of the model.

3. The task-adaptive small sample semantic segmentation method for metal surface defects according to claim 2, characterized in that: The task of the few-shot semantic segmentation method is set to 1-way K-shot and trained with a cross entropy loss and attention distillation loss, which are defined as follows: in, represents the total loss, represents the binary cross entropy loss function, represents the distillation loss, represents a hyperparameter.

4. A task-adaptive metal surface defect small sample semantic segmentation system, characterized by: It includes image acquisition system, data preprocessing system, model training system, defect detection system and result display system. The image acquisition system is used to obtain image data of the metal surface. The image acquisition system photographs the metal surface under specific lighting conditions and shooting angles so that the image data reflects the condition of the metal surface. The data preprocessing system is connected to the image acquisition system and is responsible for performing preprocessing operations on the acquired image data; The model training system is loaded with a semantic segmentation model and applies the small sample semantic segmentation method according to any one of claims 1 to 3; The defect detection system is connected to the model training system and the data preprocessing system, and after the semantic segmentation model completes model training, uses the trained semantic segmentation model to perform defect detection on the image data of the metal surface, and then outputs the detection results; The result display system is connected to the defect detection system and is used to generate a detection result report and display it to the user.

5. The task-adaptive metal surface defect small sample semantic segmentation system according to claim 4, characterized in that: The image acquisition system is equipped with a high-resolution industrial camera and a mechanical scanning device, which photographs the metal surface at multiple shooting angles under specific lighting conditions, so that the collected image data reaches a preset clarity and reflects the condition of the metal surface, including possible defect characteristics, and the defect characteristics include one or more of scratches, holes, and cracks; The preprocessing operation includes one or more of image enhancement, denoising and normalization.

6. A metal surface defect detection method, which uses the task-adaptive metal surface defect small sample semantic segmentation system according to claim 4 or 5, characterized in that: It includes: S101, an image acquisition system obtains image data of a metal surface to be inspected and sets the image data as an original image; S102: The data processing system performs a preprocessing operation on the collected original image. The preprocessing operation includes grayscale conversion and normalization of the original image to reduce the impact of illumination unevenness and enhance image contrast, and then uses a filtering algorithm to remove noise interference in the image. S103. A model training system is loaded with a semantic segmentation model and applies the small sample semantic segmentation method according to any one of claims 1 to 3, and trains the semantic segmentation model to obtain a converged model. During the training process, the model learns typical feature representations of normal areas and defective areas on the metal surface, while continuously adjusting model parameters to minimize the difference between the predicted results and the true annotations. S104. The defect recognition system uses the trained semantic segmentation model to perform real-time analysis on the pre-processed image data of the metal surface to be inspected, to determine whether there are defects in the image data, to determine the specific location and category of the defects, and to generate a recognition result. S105. The result output system presents the recognition result output by the defect recognition system to the user in a preset format.

7. A metal surface defect detection method according to claim 6, characterized in that: S104 includes: inputting the pre-processed image data into a trained semantic segmentation model, which outputs a probability distribution of each pixel in the image data belonging to different defect categories based on the learned features, and then post-processes the probability distribution by setting a threshold, and finally generates a binary segmentation map of the defect to clearly identify the boundary between the defect area and the normal area; In S105, the recognition result is presented to the user in a preset form including one or more of the following: (1) Directly mark the defect location and category on the original image of the metal surface using different colors; (2) Generate a detailed inspection report, which includes one or more key information such as the defect type, quantity, size, and distribution location; (3) Output the recognition results in the form of images, tables or text to a display, printer or storage device.

8. An electronic device comprising a processor, a memory, an input device, an output device, and a communication interface; characterized in that: The memory stores an operating system, application programs, and various data, including codes and configuration files required by the metal surface defect detection system, as well as intermediate data, model parameters, and historical detection records generated during training and detection; The application is configured to execute, by a processor, the small sample semantic segmentation method according to one of claims 1 to 3 or the metal surface defect detection method according to claim 6 or 7; The input device includes one or more of a keyboard, a mouse, and a touch screen, which is used for the user to input information; The output device includes one or more of a display and a printer, for displaying the identification results of metal surface defect detection or the system status of the electronic device; The communication interface is used to realize the communication connection between the electronic device and the external device or network. It includes one or more of an Ethernet interface, a USB interface, a Wi-Fi module, and a Bluetooth module. The communication interface supports multiple communication protocols for the electronic device to exchange data with the external device or to interact with other devices in the access network.

Citation Information

Patent Citations

  • Small sample segmentation method, system, medium and equipment for eliminating intra-class defects of metal surface defects

    CN118314345A

  • Rolling metal surface defect automatic labeling method based on multi-task self-adaptive model

    CN119444759A