Industrial defect detection model processing method and device, equipment and storage medium
The industrial defect detection model trained through color image occlusion technology and cross-attention mechanism solves the problem of low detection accuracy of existing models in different industrial scenes and achieves more accurate and versatile defect detection results.
Patent Information
- Application Number
- CN202410804089.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-20
- Publication Date
- 2024-09-10
AI Technical Summary
Existing industrial defect detection models lack versatility and generalization in different industrial scenarios, and it is easy to judge normal data as defects, resulting in low detection accuracy.
By obtaining the prompt image and the image to be detected, we use color image occlusion technology and cross-attention mechanism to train the industrial defect detection model, learn the distinction between defects and background and the distinction between different defects, and avoid the model degenerating into a foreground and background segmentation task. , improve detection accuracy.
It achieves more accurate industrial defect detection, enhances the versatility and portability of the model, reduces overkill in defect detection, and adapts to the defect detection needs of different industrial scenarios.
Smart Images

Figure CN118628463A
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to a processing method, device, equipment and storage medium for an industrial defect detection model. Background Art
[0002] Defect detection is an important part of ensuring product quality and production efficiency in industrial scenarios. Traditional manual inspection methods are subjective and inefficient, while automated defect detection technologies based on computer vision and deep learning are being widely used in various industrial fields, including manufacturing, electronics, and automotive industries. However, these defect detection technologies are only applicable to fixed defect types and industrial environments, and cannot be migrated to different industrial scenarios, lacking versatility and generalization. Therefore, exploring universal and transferable defect detection technologies in different industrial scenarios has become a very important research direction.
[0003] Traditional industrial defect detection methods are usually based on industrial defect detection models such as Transformer to unify different modes and different tasks of natural scenes to detect defects in industrial scenes. However, traditional industrial defect detection models are prone to judge normal industrial data as industrial defects, and there is a problem of low accuracy of industrial defect detection models. Summary of the invention
[0004] Based on this, it is necessary to provide a processing method, device, computer equipment, computer-readable storage medium and computer program product for an industrial defect detection model to address the above-mentioned technical problems, so as to obtain a more accurate industrial defect detection model.
[0005] In a first aspect, the present application provides a method for processing an industrial defect detection model, comprising:
[0006] Acquire a prompt image and an image to be detected; the prompt image and the image to be detected both include defect masks and objects of the same category, and the prompt image includes at least two different industrial defects;
[0007] Mapping the defect mask in the prompt image into a first color image, and masking the first color image to obtain a first masked image;
[0008] Mapping the defect mask in the image to be detected into a second color image, and masking the second color image to obtain a second masked image;
[0009] Based on the first occluded image, the second occluded image, the prompt image and the image to be detected, the industrial defect detection model to be trained is trained to obtain a first target industrial defect detection model.
[0010] In a second aspect, the present application provides a processing device for an industrial defect detection model, comprising:
[0011] An acquisition module is used to acquire a prompt image and an image to be detected; the prompt image and the image to be detected both include a defect mask and objects of the same category, and the prompt image includes at least two different industrial defects;
[0012] A masking module, used for mapping the defect mask in the prompt image into a first color image, and masking the first color image to obtain a first masked image;
[0013] The masking module is further used to map the defect mask in the image to be detected into a second color image, and mask the second color image to obtain a second masked image;
[0014] The training module is used to train the industrial defect detection model to be trained based on the first occluded image, the second occluded image, the prompt image and the image to be detected to obtain a first target industrial defect detection model.
[0015] In a third aspect, the present application provides a computer device, the computer device comprising a memory and a processor, the memory storing a computer program, and the processor implementing the steps in the above method when executing the computer program.
[0016] In a fourth aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, which implements the steps in the above method when executed by a processor.
[0017] In a fifth aspect, the present application provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, it implements the steps in the above method.
[0018] The processing method, device, computer equipment, computer-readable storage medium and computer program product of the above-mentioned industrial defect detection model, when the prompt image includes at least two different industrial defects, the industrial defect detection model can learn the distinction between industrial defects and background, as well as the distinction between different industrial defects through the corresponding color mapping relationship in the color image, so as to avoid the model being degraded into a foreground-background segmentation task due to the presence of only a single industrial defect in the prompt image. Therefore, based on the first occluded image, the second occluded image, the prompt image and the image to be detected, the industrial defect detection model to be trained can be trained more accurately to obtain a first target industrial defect detection model that is trained and more accurate. The first target industrial defect detection model can more accurately detect industrial defects in the image. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Figure 1 A schematic flow chart of a processing method for a first industrial defect detection model provided in an embodiment of the present application;
[0020] Figure 2 A schematic flow chart of a second processing method of an industrial defect detection model provided in an embodiment of the present application;
[0021] Figure 3 A schematic flow chart of a processing method for a third industrial defect detection model provided in an embodiment of the present application;
[0022] Figure 4 A structural block diagram of a processing device for an industrial defect detection model provided in an embodiment of the present application;
[0023] Figure 5 An internal structure diagram of a computer device provided in an embodiment of the present application;
[0024] Figure 6 An internal structure diagram of another computer device provided in an embodiment of the present application;
[0025] Figure 7 An internal structure diagram of a computer-readable storage medium provided in an embodiment of the present application. DETAILED DESCRIPTION
[0026] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0027] like Figure 1 As shown, an embodiment of the present application provides a processing method for an industrial defect detection model, and the method is applied to a computer device as an example for explanation. It is understandable that the computer device may include at least one of a terminal and a server. Among them, the terminal may be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, Internet of Things devices and portable wearable devices. The Internet of Things devices may be smart speakers, smart TVs, smart air conditioners, smart car-mounted devices, etc. Portable wearable devices may be smart watches, smart bracelets, head-mounted devices, etc. The server may be implemented as an independent server or a server cluster consisting of multiple servers.
[0028] The processing method of the industrial defect detection model includes the following steps:
[0029] S102, obtaining a prompt image and an image to be detected; the prompt image and the image to be detected both include a defect mask and objects of the same category, and the prompt image includes at least two different industrial defects.
[0030] The prompt image is an image used to prompt the model to detect the industrial defect category. The defect mask (segmentation mask) is a mask where the industrial defect location is located.
[0031] The computer device collects industrial scene images of different industrial scenes, and obtains prompt images and images to be detected from the industrial scenes; wherein the industrial scene images contain industrial defect masks.
[0032] Exemplarily, computer equipment collects a large number of industrial scene images of different industrial scenes, and the industrial scene images contain annotations of millions of defect masks, including 24 categories of common industrial defects such as dirt, scratches, foreign matter, etc.
[0033] Wherein, the computer device generates a prompt image based on a defective slice queue; the defective slice queue includes at least two defective slices with different defects.
[0034] In some embodiments, a computer device obtains at least two defect slices with different defects from a defect slice queue, and splices the at least two defect slices with different defects into an industrial scene image to obtain a prompt image.
[0035] Wherein, the computer device obtains the image to be detected from the industrial scene image; the image to be detected includes one or at least two different industrial defects.
[0036] It is understandable that the prompt image and the image to be detected both include objects of the same category, which can ensure that the first color image and the second color image after defect mask mapping have partially overlapping colors. Wherein, the prompt image and the image to be detected both include objects of the same category, that is, the prompt image and the image to be detected both include objects of the same example.
[0037] S104 : Map the defect mask in the prompt image into a first color image, and block the first color image to obtain a first blocked image.
[0038] In each iterative training process, the computer device randomly maps the defect mask in the prompt image to a first color image of a different color and generates a first random mask; the first color image is blocked using the first random mask to obtain a first blocked image.
[0039] The computer device may use the first random mask to cover part of the first color image, or may cover all of the first color image, which is not limited here.
[0040] S106 : Map the defect mask in the image to be detected into a second color image, and block the second color image to obtain a second blocked image.
[0041] In each iterative training process, the computer device randomly maps the defect mask in the image to be detected to a second color image of a different color and generates a second random mask; the second color image is blocked using the second random mask to obtain a second blocked image.
[0042] The computer device may use the second random mask to cover part of the second color image, or may cover all of the second color image, which is not limited here.
[0043] S108. Based on the first occluded image, the second occluded image, the prompt image and the image to be detected, the industrial defect detection model to be trained is trained to obtain a first target industrial defect detection model.
[0044] The industrial defect detection model is used to detect industrial defects in industrial scene images, and can also be used to segment industrial defects in industrial scene images. The industrial defect detection model can be a SegGPT model or other artificial intelligence models, which are not limited here.
[0045] Among them, the computer equipment splices the first occluded image, the second occluded image, the prompt image and the image to be detected to obtain a spliced image, and inputs the spliced image into the industrial defect detection model to be trained for training to obtain a first target industrial defect detection model.
[0046] Among them, the computer device reconstructs the color of the occluded area in the first occluded image or the second occluded image through a loss function, adjusts the model parameters based on the reconstructed color of the occluded area and the object corresponding to the occluded area in the prompt image is mapped to the color in the first color image, and performs the next iterative training with the adjusted model parameters until the training cutoff condition is met to obtain the first target industrial defect detection model.
[0047] It is understandable that the computer equipment reconstructs the color of the occluded area through the loss function, which allows the industrial defect detection model to learn the contextual information between different images and then correctly predict the color of the occluded area. The random color mapping in the training mechanism forces the industrial defect detection model to learn the contextual information rather than the previous association between color and category. By prompting the defect mask in the image, the industrial defect detection model can focus on the object corresponding to the defect mask during training, avoiding over-detection of non-defects belonging to small parts in the industrial image as suspected defects, so that the industrial defect detection model can be trained more accurately.
[0048] The computer device loads the model parameters (weight parameters) provided by the industrial defect detection model to be trained to obtain a pre-trained industrial defect detection model; based on the first occluded image, the second occluded image, the prompt image and the image to be detected, the pre-trained industrial defect detection model is trained to obtain the first target industrial defect detection model. The model parameters from the original industrial defect detection model (SegGPT) are crucial and can help the industrial defect detection model converge better. Some training parameters also need to be further adjusted to obtain the best effect, such as reducing the learning rate, adjusting the batch size, etc.
[0049] The computer device transfers the trained industrial defect detection model to the target industrial scene, and in the target industrial scene, the first target industrial defect detection model is used to perform defect detection on the target industrial scene image. The first target industrial defect detection model can quickly detect / segment the industrial defects corresponding to the prompts in the new target industrial scene according to the small amount of defect prompts provided.
[0050] It is understandable that industrial data has the characteristic of sparse defect information density. In many cases, the area of industrial defects may be less than 1% of the original image area. Therefore, the scaling operation of computer equipment on industrial scene images may make the defects disappear. In this case, the industrial defect area can only be cropped to the training size for training. However, industrial defects are sparsely distributed in the original industrial scene images, and the cropping method often leaves only a single defect in the image. When training the model in this way, the model cannot learn the distinction between different defects and degenerates into a foreground-background segmentation task (resulting in a lot of overkill).
[0051] Another problem caused by the small defect area of industrial defects is that the generated random mask may completely block a certain type of defect. At this time, the reconstruction loss function will prompt the model to predict a color / category that does not exist in the prompt image. Therefore, if the computer device sets a completely blocked type of defect area as an ignored area, the loss function will ignore the calculation of the ignored area to avoid overkilling of the industrial defect detection model.
[0052] It can be seen that in the embodiment of the present application, the prompt image includes at least two different industrial defects, and the industrial defect detection model can learn the distinction between industrial defects and backgrounds, as well as the distinction between different industrial defects through the corresponding color mapping relationship in the color image, so as to avoid the model from degenerating into a foreground-background segmentation task due to the presence of only a single industrial defect in the prompt image. Therefore, based on the first occluded image, the second occluded image, the prompt image and the image to be detected, the industrial defect detection model to be trained can be trained more accurately to obtain a first target industrial defect detection model that is trained and more accurate. The first target industrial defect detection model can more accurately detect industrial defects in the image. In addition, optimizing the industrial defect detection algorithm based on the sparse density characteristics of industrial data defect information can increase the defect information density and help reduce the overkill of the industrial defect detection model, so that the industrial defect detection model can achieve good defect segmentation (defect detection) effects in different downstream industrial scenarios.
[0053] In some embodiments, obtaining a prompt image includes:
[0054] Get defective slice queue;
[0055] Obtain at least two defect slices of different defects from the defect slice queue; the defect slice is an image region including industrial defects;
[0056] A prompt image is generated based on defect slices of at least two different defects and an industrial scene image.
[0057] Among them, the defective slice queue is a queue composed of defective slices with at least two different defects.
[0058] Among them, the computer equipment maintains a defect slice queue, and in each iterative training, obtains at least two defect slices with different defects from the defect slice queue; splices the at least two defect slices with different defects into the industrial scene image to generate a prompt image.
[0059] When the computer device obtains a defect slice of a new industrial defect, it adds the defect slice of the new industrial defect to the defect slice queue to obtain a new defect slice queue.
[0060] It is understandable that different defects in the defect slice queue are random and come from different workpieces in different data sets, which introduces randomness. Therefore, the generalization of the trained industrial defect detection model is also stronger.
[0061] It can be seen that in the embodiment of the present application, at least two defective slices with different defects are obtained from the defective slice queue, and then based on the defective slices with at least two different defects and the industrial scene image, a prompt image can be generated more accurately.
[0062] In some embodiments, obtaining a defective slice queue includes:
[0063] From industrial scene images, crop defect slices with different defects;
[0064] Defect slices based on different defects form a defect slice queue.
[0065] Among them, the target size of the defective slice is smaller than the preset size; the preset size can be set as needed.
[0066] It is understandable that when the computer equipment cuts out defect slices with different defects and smaller than a preset size from the industrial scene image, the industrial defects in the defect slices will account for a larger proportion, avoiding the disappearance of defects due to scaling operations.
[0067] The computer device cuts out defect slices of different defects from the industrial scene image, organizes the defect slices of different defects into a defect slice queue, and maintains the defect slice queue.
[0068] It is understandable that the computer device maintains the defective slice queue, can add new defective slices, can delete defective slices in the defective slice queue, and can also update defective slices in the defective slice queue, which is not limited here.
[0069] The computer equipment cuts out defect slices of different defects from industrial scene images of different data sets, and forms a defect slice queue based on the defect slices of each different defect. The computer equipment can use the hints across data sets to predict defects in new industrial scenes, which greatly increases the generalization performance of the industrial defect detection model in general scenes.
[0070] It can be seen that in the embodiments of the present application, defect slices of different defects are cut out from the industrial scene image, and defect slices based on each different defect can more accurately form a defect slice queue.
[0071] In some embodiments, based on the first occluded image, the second occluded image, the prompt image and the image to be detected, the industrial defect detection model to be trained is trained to obtain the first target industrial defect detection model, and the method further includes:
[0072] Obtain global features; global features are learned through gradient back propagation in different industrial scenarios;
[0073] A cross-attention mechanism is added between the backbone network and the head network in the first-target industrial defect detection model to obtain a new first-target industrial defect detection model;
[0074] Based on the global features, the first occluded image, the second occluded image, the prompt image and the image to be detected, a new first target industrial defect detection model is trained to obtain a second target industrial defect detection model.
[0075] Among them, global features are learnable model parameters (model parameters are obtained by gradient update). The backbone network is the main part of the neural network used to extract features. The head network is the top part of the neural network, that is, the layer after the backbone network. The head network is used to map the features extracted by the backbone network to the final output. The cross-attention mechanism is a variant of the neural network attention mechanism, which is used to process the correlation information between multiple input sequences.
[0076] Among them, the computer equipment obtains global features through gradient back propagation learning in different industrial scenarios through the first target industrial defect detection model.
[0077] Among them, in the new target industrial scenario, the computer equipment obtains global features through the gradient back propagation learning of the first target industrial defect detection model. Then, the global features are learned through a small amount of training, and the model's defect cognition is supplemented through the cross-attention module, which improves the defect detection accuracy and the reasoning speed.
[0078] Among them, the first target industrial defect detection model includes a backbone network and a head network, and the computer device adds a cross-attention mechanism between the backbone network and the head network in the first target industrial defect detection model to obtain a new first target industrial defect detection model; the new first target industrial defect detection model includes a backbone network, a head network and a cross-attention mechanism.
[0079] It is understandable that the above-mentioned global feature learning method is more suitable for industrial scenarios than the In-Context Tuning method in traditional technology, and only requires less computing cost to approach the performance of fine-tuned defect detection algorithms. In addition, this technical solution has good results in different industrial fields and has better versatility and transferability.
[0080] The trained industrial defect detection model can quickly detect / segment the corresponding industrial defects in new industrial scenarios based on a small amount of defect prompts provided.
[0081] It can be seen that in the embodiment of the present application, the global features obtained by gradient back propagation learning in different industrial scenarios are obtained. The global features can learn information about industrial defects of different forms. Then, through the cross-attention mechanism in the new first-target industrial defect detection model, the global features are interacted to more accurately train the second-target industrial defect detection model, and at the same time, the industrial defect detection model can achieve a better balance between computational cost and model migration effect. In addition, by learning global features, industrial defects with different morphological features can be quickly detected. The global features help the industrial defect detection model learn different morphological feature information of the defects to be detected through the newly added cross-attention mechanism, thereby improving the defect detection accuracy and the reasoning speed.
[0082] In some embodiments, based on the global features, the first occluded image, the second occluded image, the prompt image, and the image to be detected, a new first target industrial defect detection model is trained to obtain a second target industrial defect detection model, including:
[0083] In each iterative training process, the first occluded image, the second occluded image, the prompt image and the image to be detected are processed by the backbone network in the new first target industrial defect detection model to obtain intermediate features;
[0084] Through the cross attention mechanism, the intermediate features and global features are interactively processed to obtain interactive features;
[0085] Through the head network in the new first target industrial defect detection model, the intermediate features and interactive features are processed, the current iterative training results are output, and the next iterative training is performed based on the current iterative training results until the second target industrial defect detection model is obtained.
[0086] In each iterative training process, the computer device splices the intermediate features and the interactive features through the head network in the new first target industrial defect detection model to obtain new intermediate features; processes the new intermediate features and outputs the current iterative training results; matches the current iterative training results with the reference results, and adjusts the model parameters in the new first target industrial defect detection model according to the matching results, and performs the next iterative training with the adjusted model parameters until the training cutoff condition is met to obtain the second target industrial defect detection model. The training cutoff condition can be set as needed, such as the number of iterative training times, the matching degree of the matching results reaching a preset degree, etc., which are not limited here.
[0087] Among them, the computer device obtains new intermediate features through the following formula:
[0088]
[0089] in, is the new intermediate feature, is an intermediate feature, are learnable model parameters, is a learnable global feature, Represents the cross attention mechanism.
[0090] It should be noted that the training learning rate of the new first target industrial defect detection model can be slightly larger to obtain a more accurate second target industrial defect detection model.
[0091] like Figure 2 As shown, in each iterative training process, the computer device processes the first occluded image, the second occluded image, the prompt image and the image to be detected through the backbone network (fixed parameters) in the new first target industrial defect detection model to obtain multiple layers of intermediate features; obtains multiple layers of learnable global features; through the cross-attention module, the multiple layers of intermediate features and the multiple layers of learnable global features are interactively processed to obtain interactive features; through the head network in the new first target industrial defect detection model, the intermediate features and the interactive features are processed to output the current iterative training results.
[0092] It can be seen that in the embodiment of the present application, by interactively processing intermediate features and global features through the cross-attention mechanism, more accurate interactive features can be obtained, and then the new first-target industrial defect detection model is trained to obtain a more accurate second-target industrial defect detection model.
[0093] In some embodiments, the method further comprises:
[0094] In the target industrial scene, industrial defect detection is performed on the target industrial scene image through the second target industrial defect detection model to obtain the industrial defects in the target industrial scene image.
[0095] Among them, the target industrial scene image is an industrial image in the target industrial scene, and the target industrial scene can be a cloth scene, an aluminum scene, etc., but is not limited thereto.
[0096] like Figure 3As shown, the computer equipment collects a large amount of industrial data from different scenarios (including millions of defect segmentation mask annotations), including 24 common defect categories such as dirt, scratches, foreign matter, etc.; the model weights provided by the industrial defect detection model (SegGPT) are loaded as pre-trained weights to obtain a pre-trained industrial defect detection model, and the pre-trained industrial defect detection model is trained to obtain a trained industrial defect detection model; the trained industrial defect detection model can be a first target industrial defect detection model or a second target industrial defect detection model; the trained industrial defect detection model is migrated to the target industrial scene, and industrial defect detection is performed on the target industrial scene image.
[0097] For example, as shown in Table 1 below, the accuracy performance of the second target industrial defect detection model and SegGPT in traditional technology on multiple industrial project data is compared, where the test indicators are IOU, Precision, Recall and other indicators commonly used in segmentation tasks.
[0098] Among them, the IOU indicator is a common indicator for measuring the performance of image segmentation models, and its full name is Intersection over Union. It is mainly used to measure the degree of overlap between the model's predicted segmentation results and the true segmentation results. The IOU indicator is calculated by calculating the ratio between the intersection and union of the predicted results and the true results. Precision is one of the commonly used evaluation indicators in machine learning, which is used to measure the accuracy of classification models. The Recall indicator is an important indicator for measuring model performance, which reflects the accuracy of the model in predicting positive examples. It refers to the proportion of positive examples correctly predicted by the model, that is, the ratio of the number of correctly predicted positive examples to the number of all positive examples.
[0099] Table 1:
[0100]
[0101] It can be observed from Table 1 that the general segmentation algorithm SegGPT of traditional technology is not suitable for industrial scenarios and performs very poorly in multiple project data sets. This is because the algorithm ignores the characteristics of industrial data, while the second-target industrial defect detection model is optimized for the characteristics of industrial data and realizes general industrial scenario defect detection.
[0102] Exemplarily, as shown in Table 2, the first target industrial defect detection model, the second target industrial defect detection model and the traditional technology using In-Context Tuning are compared on multiple project data to show their accuracy performance when adapting to new industrial scenarios.
[0103] Table 2:
[0104]
[0105] It can be seen from Table 2 that the second-target industrial defect detection model can further improve the performance in new industrial scenarios compared to the first-target industrial defect detection model, and is better than the In-Context Tuning training strategy in traditional technologies.
[0106] Exemplarily, as shown in Table 3, the performance of the second target industrial defect detection model and the fine-tuning defect detection algorithm in traditional technology when adapting to new industrial scenarios are compared on multiple project data.
[0107] Table 3:
[0108]
[0109] It can be seen from Table 3 that the second-target industrial defect detection model can adapt to new industrial scenarios under the constraint of a small amount of training data, and has consistent or even better performance when the annotation cost and computing cost are much lower than the fine-tuning algorithm of traditional technology. That is, the above-mentioned second-target industrial defect detection model has higher versatility and transferability.
[0110] In some embodiments, another method for processing an industrial defect detection model is provided, which is applied to a computer device, and the method includes the following steps:
[0111] Step A1, cropping defect slices of different defects from the industrial scene image; the defect slice is an image area including industrial defects; and forming a defect slice queue based on the defect slices of different defects;
[0112] Step A2, obtaining at least two defective slices with different defects from the defective slice queue; generating a prompt image based on the at least two defective slices with different defects and the industrial scene image;
[0113] Step A3, obtaining a prompt image and an image to be detected; the prompt image and the image to be detected both include a defect mask and objects of the same category, and the prompt image includes at least two different industrial defects;
[0114] Step A4, mapping the defect mask in the prompt image into a first color image, and blocking the first color image to obtain a first blocked image; mapping the defect mask in the image to be detected into a second color image, and blocking the second color image to obtain a second blocked image;
[0115] Step A5, training the industrial defect detection model to be trained based on the first occluded image, the second occluded image, the prompt image and the image to be detected to obtain a first target industrial defect detection model;
[0116] Step A6, in the target industrial scene, using the first target industrial defect detection model to perform industrial defect detection on the target industrial scene image to obtain industrial defects in the target industrial scene image;
[0117] Step A7, obtaining global features; the global features are obtained by gradient back propagation learning in different industrial scenarios; adding a cross attention mechanism between the backbone network and the head network in the first target industrial defect detection model to obtain a new first target industrial defect detection model; based on the global features, the first occluded image, the second occluded image, the prompt image and the image to be detected, the new first target industrial defect detection model is trained to obtain a second target industrial defect detection model;
[0118] Step A8: In the target industrial scene, industrial defect detection is performed on the target industrial scene image by using a second target industrial defect detection model to obtain industrial defects in the target industrial scene image.
[0119] It should be understood that, although the steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indications of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear description in this article, there is no strict order restriction on the execution of these steps, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments may include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0120] Based on the same inventive concept, the embodiment of the present application also provides a processing device for an industrial defect detection model. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in the embodiments of the processing device for one or more industrial defect detection models provided below can refer to the limitations of the processing method for the industrial defect detection model above, and will not be repeated here.
[0121] like Figure 4 As shown, the embodiment of the present application provides a processing device 400 for an industrial defect detection model, including:
[0122] The acquisition module 402 is used to acquire a prompt image and an image to be detected; the prompt image and the image to be detected both include a defect mask and objects of the same category, and the prompt image includes at least two different industrial defects;
[0123] The masking module 404 is used to map the defect mask in the prompt image into a first color image, and mask the first color image to obtain a first masked image; map the defect mask in the image to be detected into a second color image, and mask the second color image to obtain a second masked image;
[0124] The training module 406 is used to train the industrial defect detection model to be trained based on the first occlusion image, the second occlusion image, the prompt image and the image to be detected to obtain a first target industrial defect detection model.
[0125] In some embodiments, in terms of acquiring the prompt image, the acquisition module 402 is specifically used to:
[0126] Get defective slice queue;
[0127] Obtain at least two defect slices of different defects from the defect slice queue; the defect slice is an image region including industrial defects;
[0128] A prompt image is generated based on defect slices of at least two different defects and an industrial scene image.
[0129] In some embodiments, in terms of obtaining a defective slice queue, the obtaining module 402 is specifically used to:
[0130] From industrial scene images, crop defect slices with different defects;
[0131] Defect slices based on different defects form a defect slice queue.
[0132] In some embodiments, the training module 406 is further configured to:
[0133] Obtain global features; global features are learned through gradient back propagation in different industrial scenarios;
[0134] A cross-attention mechanism is added between the backbone network and the head network in the first-target industrial defect detection model to obtain a new first-target industrial defect detection model;
[0135] Based on the global features, the first occluded image, the second occluded image, the prompt image and the image to be detected, a new first target industrial defect detection model is trained to obtain a second target industrial defect detection model.
[0136] In some embodiments, in training a new first target industrial defect detection model based on the global features, the first occluded image, the second occluded image, the prompt image, and the image to be detected to obtain a second target industrial defect detection model, the training module 406 is specifically used to:
[0137] In each iterative training process, the first occluded image, the second occluded image, the prompt image and the image to be detected are processed by the backbone network in the new first target industrial defect detection model to obtain intermediate features;
[0138] Through the cross attention mechanism, the intermediate features and global features are interactively processed to obtain interactive features;
[0139] Through the head network in the new first target industrial defect detection model, the intermediate features and interactive features are processed, the current iterative training results are output, and the next iterative training is performed based on the current iterative training results until the second target industrial defect detection model is obtained.
[0140] In some embodiments, the device 400 also includes: an industrial defect detection module, which is used to perform industrial defect detection on the target industrial scene image in the target industrial scene through a second target industrial defect detection model to obtain industrial defects in the target industrial scene image.
[0141] Each module in the processing device of the above industrial defect detection model can be implemented in whole or in part by software, hardware, or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.
[0142] In some embodiments, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 5 As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. Among them, the processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data related to the processing of the industrial defect detection model. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, the steps in the above-mentioned processing method of the industrial defect detection model are implemented.
[0143] In some embodiments, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Figure 6As shown. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit and an input device. Among them, the processor, the memory and the input / output interface are connected through a system bus, and the communication interface, the display unit and the input device are connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and the external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be implemented through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, the steps in the processing method of the above-mentioned industrial defect detection model are implemented. The display unit of the computer device is used to form a visually visible picture, which can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen; the input device of the computer device can be a touch layer covering the display screen, or a key, trackball or touchpad provided on the computer device housing, or an external keyboard, touchpad or mouse, etc.
[0144] Those skilled in the art will understand that Figure 5 or Figure 6 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0145] In some embodiments, a computer device is provided. The computer device includes a memory and a processor. The memory stores a computer program. When the processor executes the computer program, the steps in the above method embodiments are implemented.
[0146] In some embodiments, Figure 7 The figure shows an internal structure diagram of a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.
[0147] In some embodiments, a computer program product is provided. The computer program product includes a computer program. When the computer program is executed by a processor, the steps in the above method embodiments are implemented.
[0148] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards of relevant countries and regions.
[0149] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.
[0150] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0151] The above embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A processing method for an industrial defect detection model, characterized in that: include: Acquire a prompt image and an image to be detected; the prompt image and the image to be detected both include defect masks and objects of the same category, and the prompt image includes at least two different industrial defects; Mapping the defect mask in the prompt image into a first color image, and masking the first color image to obtain a first masked image; Mapping the defect mask in the image to be detected into a second color image, and masking the second color image to obtain a second masked image; Based on the first occluded image, the second occluded image, the prompt image and the image to be detected, the industrial defect detection model to be trained is trained to obtain a first target industrial defect detection model.
2. The method according to claim 1, characterized in that The step of obtaining the prompt image comprises: Get defective slice queue; Acquire at least two defect slices with different defects from the defect slice queue; the defect slice is an image area including industrial defects; A prompt image is generated based on the defect slices of the at least two different defects and the industrial scene image.
3. The method according to claim 2, characterized in that The step of obtaining a defective slice queue includes: Cutting out defect slices of different defects from the industrial scene image; A defective slice queue is formed based on the defective slices with different defects.
4. The method according to claim 1, characterized in that: After training the industrial defect detection model to be trained based on the first occluded image, the second occluded image, the prompt image and the image to be detected to obtain a first target industrial defect detection model, the method further includes: Obtaining global features; the global features are learned by gradient back propagation in different industrial scenarios; Adding a cross attention mechanism between the backbone network and the head network in the first target industrial defect detection model to obtain a new first target industrial defect detection model; Based on the global features, the first occluded image, the second occluded image, the prompt image and the image to be detected, the new first target industrial defect detection model is trained to obtain a second target industrial defect detection model.
5. The method according to claim 4, characterized in that The method of training the new first target industrial defect detection model based on the global feature, the first occluded image, the second occluded image, the prompt image and the image to be detected to obtain the second target industrial defect detection model includes: In each iterative training process, the first occluded image, the second occluded image, the prompt image and the image to be detected are processed by the backbone network in the new first target industrial defect detection model to obtain intermediate features; Through the cross attention mechanism, the intermediate features and the global features are interactively processed to obtain interactive features; The intermediate features and the interactive features are processed through the head network in the new first target industrial defect detection model, the current iterative training result is output, and the next iterative training is performed based on the current iterative training result until the second target industrial defect detection model is obtained.
6. The method according to claim 4 or 5, characterized in that: The method further comprises: In the target industrial scene, industrial defect detection is performed on the target industrial scene image using the second target industrial defect detection model to obtain industrial defects in the target industrial scene image.
7. A processing device for an industrial defect detection model, characterized in that: include: An acquisition module, used for acquiring a prompt image and an image to be detected; the prompt image and the image to be detected both include a defect mask and objects of the same category, and the prompt image includes at least two different industrial defects; A masking module, used for mapping the defect mask in the prompt image into a first color image, and masking the first color image to obtain a first masked image; The masking module is further used to map the defect mask in the image to be detected into a second color image, and mask the second color image to obtain a second masked image; A training module is used to train the industrial defect detection model to be trained based on the first occluded image, the second occluded image, the prompt image and the image to be detected to obtain a first target industrial defect detection model.
8. The device according to claim 7, characterized in that In terms of acquiring the prompt image, the acquisition module is specifically used for: Get defective slice queue; Acquire at least two defect slices with different defects from the defect slice queue; the defect slice is an image area including industrial defects; A prompt image is generated based on the defect slices of the at least two different defects and the industrial scene image.
9. A computer device, comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Product defect detection method based on parallel multi-scale fusion network
CN114841930A
Transform-based lightweight cross-image information interaction cervical cell target detection method
CN117830272A
Defect image generation method and device, computer equipment and storage medium
CN117953321A
Defect detection method and device, computer equipment and computer readable storage medium
CN118071719A
Defect detection method and apparatus
US20210374928A1
