Industrial quality inspection method and device
By using diffusion models and feature pyramid networks in industrial quality inspection for feature extraction and dynamic cross-fusion, combined with correlation matching models, the problem of low detection accuracy in the existing technology is solved, and the accuracy of industrial quality inspection is improved.
Patent Information
- Application Number
- CN202410943197.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-15
- Publication Date
- 2024-12-13
- Estimated Expiration
- 2044-07-15
AI Technical Summary
Due to the difficulty in data acquisition and high data labeling costs, existing industrial quality inspection technologies have limited generalization capabilities of deep learning segmentation models and lack of semantic information, resulting in low detection accuracy and are susceptible to non-significant defects in errors or missed inspections. Influence.
The preset diffusion model and the preset feature pyramid network are used to extract the image blocks to be detected, and multi-scale fusion features are generated through dynamic cross-fusion of features, and industrial quality inspection results are generated using the preset correlation matching model to reduce errors with non-significant defects. Or missed detection.
By acquiring multi-scale fusion features containing higher-order semantics, the accuracy of industrial quality inspection is improved, errors and missed inspections are reduced in the detection process, and the overall accuracy of quality inspection is improved.
Smart Images

Figure CN118628477B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of industrial defect detection, and in particular to an industrial quality inspection method and device. Background Art
[0002] The popularization of the industrial Internet has promoted the transformation of the industrial and intelligent manufacturing industry chain. Through the Internet of Things, big data, cloud computing and other technical means, various elements such as production equipment, sensors, and workpieces have been connected in an information and intelligent manner. This has provided unprecedented opportunities for industrial quality inspection. By combining with intelligence, the quality inspection system can be more efficient and accurate, and better deal with various quality problems in production.
[0003] Industrial quality inspection can be understood as the quality inspection of workpieces or products in various processes of industrial manufacturing and production. For example, it can detect tiny scratches and pits on the surface of products, which may lead to major accidents. For example, surface defects such as aircraft tires will directly affect the use effect and even cause irreparable losses to passengers. It can be seen that industrial quality inspection is very important in modern manufacturing.
[0004] Most existing industrial quality inspection technologies use deep learning segmentation algorithms for industrial quality inspection. However, due to various factors such as the difficulty in collecting data and the high cost of data annotation, the generalization ability of deep learning segmentation models trained based on a small amount of data is limited. In addition, due to the lack of semantic information, the detection process is easily affected by errors or omissions of non-significant defects, resulting in low quality inspection accuracy. Summary of the invention
[0005] The present invention provides an industrial quality inspection method and device, which are used to solve the technical problem that the quality inspection accuracy is low due to the existing industrial quality inspection technology.
[0006] The first aspect of the present invention provides an industrial quality inspection method, comprising:
[0007] Acquire an industrial image to be detected, preprocess the industrial image to be detected, and output a plurality of image blocks to be detected;
[0008] respectively using a preset diffusion model and a preset feature pyramid network to extract features from each of the image blocks to be detected, and generating a plurality of first image block features and a plurality of second image block features;
[0009] Performing dynamic cross-fusion of features on each of the first image block features and each of the second image block features to generate a plurality of multi-scale fusion features;
[0010] Determine a plurality of abnormal image blocks according to each of the multi-scale fusion features and each of the image blocks to be detected;
[0011] A preset correlation matching model is used to generate industrial quality inspection results based on each of the abnormal image blocks.
[0012] Optionally, the industrial image to be detected includes a product image to be detected and a template image to be detected corresponding to the product image to be detected; the image block to be detected includes a template image block and a product image block; the step of preprocessing the industrial image to be detected and outputting a plurality of image blocks to be detected includes:
[0013] Performing grayscale processing on the product image to be detected and the template image to be detected respectively, generating a grayscale product image and a grayscale template image corresponding to the grayscale product image;
[0014] The grayscale product image and the grayscale template image are divided respectively, and a plurality of product image blocks and a plurality of template image blocks are output.
[0015] Optionally, the first image block features include high-dimensional product image block features and high-dimensional template image block features; the second image block features include enhanced product image block features and enhanced template image block features; the step of respectively using a preset diffusion model and a preset feature pyramid network to extract features from each of the image blocks to be detected to generate a plurality of first image block features and a plurality of second image block features comprises:
[0016] Adding noise to each of the product image blocks and each of the template image blocks respectively to determine a plurality of noisy product image blocks and a plurality of noisy template image blocks;
[0017] Using the preset diffusion model to perform noise prediction on each of the noise product image blocks and each of the noise template image blocks, and outputting a plurality of high-dimensional product image block features and a plurality of high-dimensional template image block features;
[0018] The preset feature pyramid network is used to perform feature enhancement extraction on each of the product image blocks and each of the template image blocks, and a plurality of enhanced product image block features and a plurality of enhanced template image block features are output.
[0019] Optionally, the multi-scale fusion feature includes a product multi-scale fusion feature and a template multi-scale fusion feature; the step of dynamically cross-fusing the first image block features and the second image block features to generate a plurality of multi-scale fusion features includes:
[0020] Performing linear transformation on each of the high-dimensional product image block features and each of the enhanced product image block features, respectively, and outputting a plurality of high-dimensional product feature vectors and a plurality of enhanced product feature vectors;
[0021] Performing linear transformation on each of the high-dimensional template image block features and each of the enhanced template image block features, respectively, and outputting a plurality of high-dimensional template feature vectors and a plurality of enhanced template feature vectors;
[0022] Based on a preset subspace set and a preset cross-attention model, feature fusion is performed on each of the high-dimensional product feature vectors and each of the enhanced product feature vectors, and multi-scale fusion features of multiple products are output;
[0023] Based on the preset subspace set and the preset cross-attention model, feature fusion is performed on each of the high-dimensional template feature vectors and each of the enhanced template feature vectors, and a plurality of template multi-scale fusion features are output.
[0024] Optionally, the abnormal image block includes a product abnormal image block and a template abnormal image block; the step of determining a plurality of abnormal image blocks according to each of the multi-scale fusion features and each of the image blocks to be detected includes:
[0025] respectively embedding the multi-scale fusion features of the products into the position information of the product image blocks corresponding to the multi-scale fusion features of the products, and determining the product position fusion features corresponding to the multi-scale fusion features of the products;
[0026] Performing linear transformation on each of the product position fusion features respectively, and outputting a plurality of product position feature vectors;
[0027] Using a preset encoder to calculate the attention score value corresponding to each of the product position feature vectors according to each of the product position feature vectors;
[0028] Comparing each of the attention score values with a preset attention score threshold respectively;
[0029] Taking any product image block corresponding to an attention score value less than or equal to the preset attention score threshold as a product abnormal image block;
[0030] The template image block corresponding to each of the product abnormal image blocks is used as the template abnormal image block.
[0031] Optionally, the industrial quality inspection result includes a normal quality inspection result and an abnormal quality inspection result; the step of using a preset correlation matching model to generate the industrial quality inspection result according to each of the abnormal image blocks includes:
[0032] Taking the product multi-scale fusion features corresponding to each of the product abnormal image blocks as the input of the preset converter, and outputting the product fusion feature vector corresponding to each of the product multi-scale fusion features;
[0033] Taking the template multi-scale fusion features corresponding to each template abnormal image block as the input of the preset converter, and outputting the template fusion feature vector corresponding to each template multi-scale fusion feature;
[0034] Using a preset convolutional neural network to perform convolution operations on each of the product fusion feature vectors and each of the template fusion feature vectors, respectively, and outputting a product homography matrix corresponding to each of the product fusion feature vectors and a template homography matrix corresponding to each of the template fusion feature vectors;
[0035] Performing homography mapping on the product abnormality image blocks corresponding to each product homography matrix through each product homography matrix, and outputting product mapping image blocks corresponding to each product abnormality image block;
[0036] Performing homography mapping on the template abnormal image blocks corresponding to each template homography matrix through each template homography matrix, and outputting the template mapping image blocks corresponding to each template abnormal image block;
[0037] Calculating a correlation matching value according to each of the product mapping image blocks and each of the template mapping image blocks using the preset correlation matching model;
[0038] Comparing the correlation matching value with a preset matching threshold;
[0039] If the correlation match value is greater than or equal to the preset match threshold, a normal quality inspection result is generated;
[0040] If the correlation matching value is less than the preset matching threshold, an abnormal quality inspection result is generated.
[0041] A second aspect of the present invention provides an industrial quality inspection device, comprising:
[0042] An acquisition module is used to acquire an industrial image to be detected, pre-process the industrial image to be detected, and output a plurality of image blocks to be detected;
[0043] An adopting module is used to respectively use a preset diffusion model and a preset feature pyramid network to extract features from each of the image blocks to be detected, and generate a plurality of first image block features and a plurality of second image block features;
[0044] A fusion module, used for dynamically cross-fusing the features of each of the first image blocks and the features of each of the second image blocks to generate a plurality of multi-scale fusion features;
[0045] According to the module, it is used to determine a plurality of abnormal image blocks according to each of the multi-scale fusion features and each of the image blocks to be detected;
[0046] A generation module is used to generate industrial quality inspection results according to each abnormal image block by using a preset correlation matching model.
[0047] A third aspect of the present invention provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the industrial quality inspection method as described in any one of the above items.
[0048] A fourth aspect of the present invention provides a computer-readable storage medium having a computer program / instruction stored thereon, wherein the computer program / instruction, when executed by a processor, implements the steps of the industrial quality inspection method as described in any one of the above items.
[0049] A fifth aspect of the present invention provides a computer program product, comprising a computer program / instruction, which, when executed by a processor, implements the steps of the industrial quality inspection method as described in any one of the above items.
[0050] It can be seen from the above technical solutions that the present invention has the following advantages:
[0051] The above technical scheme of the present invention provides an industrial quality inspection method, which first obtains an industrial image to be inspected, pre-processes the industrial image to be inspected, and outputs a plurality of image blocks to be inspected; then, respectively, a preset diffusion model and a preset feature pyramid network are used to extract features of each image block to be inspected, and a plurality of first image block features and a plurality of second image block features are generated; the first image block features and the second image block features are dynamically cross-fused to generate a plurality of multi-scale fusion features; multiple abnormal image blocks are determined according to the multi-scale fusion features and each image block to be inspected; finally, an industrial quality inspection result is generated according to each abnormal image block using a preset correlation matching model; based on the above scheme, based on the preset diffusion model and the preset feature pyramid network, the process of extracting features and dynamically cross-fusion of features of the acquired image blocks to be inspected can obtain multi-scale fusion features containing high-order semantics, reduce the influence of errors or missed detections of non-significant defects in the detection process, and further improve the accuracy of quality inspection. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. 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 creative labor.
[0053] Figure 1 A flowchart of the steps of an industrial quality inspection method provided by an embodiment of the present invention;
[0054] Figure 2 A flowchart of another industrial quality inspection method provided by an embodiment of the present invention;
[0055] Figure 3 A framework diagram of an industrial quality inspection method provided by an embodiment of the present invention;
[0056] Figure 4 A schematic diagram of a process flow of an industrial quality inspection method provided by an embodiment of the present invention;
[0057] Figure 5 A structural block diagram of an industrial quality inspection device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0058] The embodiments of the present invention provide an industrial quality inspection method and device, which are used to solve the technical problem that the quality inspection accuracy is low due to the existing industrial quality inspection technology.
[0059] In order to make the purpose, features and advantages of the present invention more obvious and easy to understand, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the embodiments described below are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0060] See also Figure 1 , Figure 1 A flowchart of the steps of an industrial quality inspection method provided by an embodiment of the present invention.
[0061] The present invention provides an industrial quality inspection method, comprising:
[0062] Step 101: Acquire an industrial image to be detected, preprocess the industrial image to be detected, and output a plurality of image blocks to be detected.
[0063] The industrial image to be detected includes a product image to be detected and a template image to be detected corresponding to the product image to be detected.
[0064] The image blocks to be detected include template image blocks and product image blocks.
[0065] Specifically, the product image to be detected and the template image to be detected are gray-processed respectively to generate a gray-scale product image and a gray-scale template image corresponding to the gray-scale product image; the gray-scale product image and the gray-scale template image are divided respectively to output a plurality of product image blocks and a plurality of template image blocks.
[0066] In this embodiment, an industrial image to be detected is acquired, and preprocessed to output a plurality of image blocks to be detected.
[0067] Step 102: Use a preset diffusion model and a preset feature pyramid network to extract features from each image block to be detected, and generate a plurality of first image block features and a plurality of second image block features.
[0068] The first image block features include high-dimensional product image block features and high-dimensional template image block features.
[0069] The second image block features include enhanced product image block features and enhanced template image block features.
[0070] Specifically, each product image block and each template image block are denoised to determine a plurality of noisy product image blocks and a plurality of noisy template image blocks; a preset diffusion model is used to perform noise prediction on each noisy product image block and each noisy template image block to output a plurality of high-dimensional product image block features and a plurality of high-dimensional template image block features; a preset feature pyramid network is used to perform feature enhancement extraction on each product image block and each template image block to output a plurality of enhanced product image block features and a plurality of enhanced template image block features; wherein the preset diffusion model is a pre-trained DDPM network (Diffusion Probability Density Estimation Model), and the image features extracted by the UNet module in the DDPM network are collected to obtain high-dimensional features (high-dimensional product image block features and high-dimensional template image block features).
[0071] In this embodiment, a preset diffusion model and a preset feature pyramid network are respectively used to extract features from each image block to be detected, so as to generate a plurality of first image block features and a plurality of second image block features.
[0072] Step 103: Dynamically cross-fuse the features of each first image block and each second image block to generate a plurality of multi-scale fusion features.
[0073] Multi-scale fusion features include product multi-scale fusion features and template multi-scale fusion features.
[0074] It should be noted that each high-dimensional product image block feature and each enhanced product image block feature are linearly transformed to output multiple high-dimensional product feature vectors and multiple enhanced product feature vectors; wherein the high-dimensional product feature vector includes a high-dimensional product query vector, a high-dimensional product key vector and a high-dimensional product value vector; the enhanced product feature vector includes an enhanced product query vector, an enhanced product key vector and an enhanced product value vector; wherein the linear transformation process is specifically as follows:
[0075] ;
[0076] in, is the query vector; is the image block feature; is the key vector; is a value vector; is a linear function.
[0077] Furthermore, each high-dimensional template image block feature and each enhanced template image block feature are linearly transformed respectively, and multiple high-dimensional template feature vectors and multiple enhanced template feature vectors are output; wherein the high-dimensional template feature vector includes a high-dimensional template query vector, a high-dimensional template key vector and a high-dimensional template value vector; and the enhanced template feature vector includes an enhanced template query vector, an enhanced template key vector and an enhanced template value vector.
[0078] Furthermore, in order to realize the feature filtering of the diffusion model features, the X features (enhanced product feature vector, enhanced template image block features) and Y features (high-dimensional product feature vector, high-dimensional template image block features) corresponding to each image block (product image block, template image block) are fused, that is, based on the preset subspace set and the preset cross-attention model, the features of each high-dimensional product feature vector and each enhanced product feature vector are fused respectively, and multiple product multi-scale fusion features are output, wherein the preset subspace set includes multiple subspaces, each subspace corresponds to a head, each head is similar but independent, so each head has its own linear transformation parameters, and the captured feature information may be different.
[0079] Specifically, firstly, a high-dimensional product key vector and a high-dimensional product value vector in a high-dimensional product feature vector corresponding to a product image block and an enhanced product query vector in an enhanced product feature vector are selected and projected into a preset subspace set respectively to obtain a plurality of projected high-dimensional product key vectors, a plurality of projected high-dimensional product value vectors and a plurality of projected enhanced product query vectors corresponding to the product image block. Then, the plurality of projected high-dimensional product key vectors, a plurality of projected high-dimensional product value vectors and a plurality of projected enhanced product query vectors are input into a preset cross-attention model to obtain a multi-scale fusion feature (multi-head cross-attention) of the product corresponding to the product image block. The preset cross-attention model is specifically:
[0080] ;
[0081] in, For head attention; is the attention score value of the projected high-dimensional product; is the Softmax activation function; Strengthen product query vector for projection; is the transpose of the projected high-dimensional product key vector; is the projected high-dimensional product value vector; is the dimension size of the projected high-dimensional product key vector; It is the product of multi-scale fusion features; is the splicing function; For the first head attention; For the fourth head attention.
[0082] Furthermore, based on the preset subspace set and the preset cross-attention model, feature fusion is performed on each high-dimensional template feature vector and each enhanced template feature vector, respectively, to output multiple template multi-scale fusion features; among which, the processing principle of the template multi-scale fusion feature is consistent with the processing principle of the multi-scale fusion feature of the above-mentioned product, which will not be elaborated here.
[0083] In this embodiment, dynamic cross-fusion of features is performed on each first image block feature and each second image block feature to generate a plurality of multi-scale fusion features.
[0084] Step 104: Determine a plurality of abnormal image blocks according to each multi-scale fusion feature and each image block to be detected.
[0085] The abnormal image blocks include product abnormal image blocks and template abnormal image blocks.
[0086] It should be noted that after obtaining the fusion features of the product image block and the template image block (product multi-scale fusion features, template multi-scale fusion features) through the above steps, the fusion features of each product image block are embedded with position information. Specifically, the multi-scale fusion features of each product are embedded with the position information of the product image block corresponding to each product multi-scale fusion feature. After determining the product position fusion features corresponding to each product multi-scale fusion feature, they are sent to the transformer encoder model with shared weights; wherein the transformer encoder model includes a preset encoder and a preset transformer.
[0087] Furthermore, each product position fusion feature is linearly transformed to output multiple product position feature vectors, and a preset encoder is used to calculate the attention score value corresponding to each product position feature vector according to each product position feature vector; wherein the product position feature vector includes a product position query vector, a product position key vector and a product position value vector; the processing process of the attention score value is specifically as follows:
[0088] ;
[0089] in, is the attention score value; is the product location query vector; is the transpose of the product position key vector; is the product position value vector; is the dimension size of the product position key vector; is the Softmax activation function.
[0090] Furthermore, each attention score value is compared with a preset attention score threshold; any product image block corresponding to an attention score value less than or equal to the preset attention score threshold is used as a product abnormal image block, and the template image block corresponding to each product abnormal image block is used as a template abnormal image block; any product image block corresponding to an attention score value greater than the preset attention score threshold and the template image block corresponding to the product image block are retained; wherein the preset attention score threshold is the optimal value obtained through preliminary experimental training as the default threshold.
[0091] In this embodiment, a plurality of abnormal image blocks are determined according to each multi-scale fusion feature and each image block to be detected.
[0092] Step 105: Generate industrial quality inspection results based on each abnormal image block using a preset correlation matching model.
[0093] Industrial quality inspection results include normal quality inspection results and abnormal quality inspection results.
[0094] Specifically, the product multi-scale fusion features corresponding to each product abnormal image block are used as the input of the preset converter, and the product fusion feature vector corresponding to each product multi-scale fusion feature is output; the template multi-scale fusion features corresponding to each template abnormal image block are used as the input of the preset converter, and the template fusion feature vector corresponding to each template multi-scale fusion feature is output; the preset convolutional neural network is used to perform convolution operations on each product fusion feature vector and each template fusion feature vector, respectively, and the product homography matrix corresponding to each product fusion feature vector and the template homography matrix corresponding to each template fusion feature vector are output; wherein the homography matrix can be expressed as:
[0095] ;
[0096] in, is the homography matrix, which includes the product homography matrix and the template homography matrix; is the matrix element of the first row and first column in the homography matrix; is the matrix element in the first row and second column of the homography matrix; is the matrix element in the first row and third column of the homography matrix; is the matrix element in the second row and first column of the homography matrix; is the matrix element of the second row and second column in the homography matrix; is the matrix element in the second row and third column of the homography matrix; is the matrix element in the third row and first column of the homography matrix; is the matrix element in the third row and second column of the homography matrix; is the matrix element in the third row and third column of the homography matrix.
[0097] Further, homography mapping is performed on the product abnormal image blocks corresponding to each product homography matrix through each product homography matrix, and the product mapping image blocks corresponding to each product abnormal image block are output, that is, each pixel point in the product abnormal image block is mapped to obtain multiple new pixel points and constitute the product mapping image block; homography mapping is performed on the template abnormal image blocks corresponding to each template homography matrix through each template homography matrix, and the template mapping image blocks corresponding to each template abnormal image block are output; wherein, the processing process of homography mapping can be expressed as:
[0098] ;
[0099] in, is the horizontal coordinate of the pixel point in the mapped image block; is the vertical coordinate of the pixel point in the mapped image block; is the horizontal coordinate of the pixel point in the abnormal image block; is the ordinate of the pixel in the abnormal image block; is the matrix element of the first row and first column in the homography matrix; is the matrix element in the first row and second column of the homography matrix; is the matrix element in the first row and third column of the homography matrix; is the matrix element in the second row and first column of the homography matrix; is the matrix element of the second row and second column in the homography matrix; is the matrix element in the second row and third column of the homography matrix; is the matrix element in the third row and first column of the homography matrix; is the matrix element in the third row and second column of the homography matrix; is the matrix element in the third row and third column of the homography matrix.
[0100] Furthermore, a preset correlation matching model is used to calculate a correlation matching value according to each product mapping image block and each template mapping image block; wherein the preset correlation matching model is specifically:
[0101] ;
[0102] in, is the correlation matching value; is the height of the mapped image block; is the width of the mapped image block; The pixel number index from top to bottom for the mapped image block; The pixel number index from left to right for the mapped image block; The index is i row The vector of product mapping image patches of column j; The index is i row The vector of the template map image patch of column j; The average value of pixels in the window of the product map image patch; The average pixel value within the window of the template mapping image block; is the vector of the template image patch with index at row i and column j.
[0103] Furthermore, the correlation match value is compared with the preset match threshold; if the correlation match value is greater than or equal to the preset match threshold, a normal quality inspection result is generated, indicating that the product is normal; if the correlation match value is less than the preset match threshold, an abnormal quality inspection result is generated, indicating that the product is abnormal, and the non-matching area is marked; wherein, the value range of the correlation match value (NCC value) is [ − 1 , 1 ] When the NCC value is 1, it indicates that the product is highly correlated with the template, and when the NCC value is -1, it indicates that the product is completely unrelated to the template. The value range of the preset matching threshold is set to [ − 0 . 5 , 1 ] .
[0104] In this embodiment, a preset correlation matching model is used to generate industrial quality inspection results according to each abnormal image block.
[0105] In an embodiment of the present invention, the present invention provides an industrial quality inspection method, firstly, an industrial image to be inspected is acquired, and the industrial image to be inspected is preprocessed to output a plurality of image blocks to be inspected; then, a preset diffusion model and a preset feature pyramid network are respectively used to extract features of each image block to be inspected, and a plurality of first image block features and a plurality of second image block features are generated; the first image block features and the second image block features are dynamically cross-fused to generate a plurality of multi-scale fusion features; according to the multi-scale fusion features and each image block to be inspected, a plurality of abnormal image blocks are determined; finally, an industrial quality inspection result is generated according to each abnormal image block using a preset correlation matching model; based on the above scheme, based on the preset diffusion model and the preset feature pyramid network, the process of extracting features and dynamically cross-fusion of features of the acquired image blocks to be inspected can obtain multi-scale fusion features containing high-order semantics, reduce the influence of errors or missed detections of non-significant defects in the detection process, and further improve the accuracy of quality inspection.
[0106] See also Figure 2 , Figure 2 A flowchart of the steps of another industrial quality inspection method provided by an embodiment of the present invention.
[0107] The present invention provides an industrial quality inspection method, comprising:
[0108] Step 201 : Acquire an industrial image to be inspected, and perform grayscale processing on the product image to be inspected and the template image to be inspected respectively, to generate a grayscale product image and a grayscale template image corresponding to the grayscale product image.
[0109] The industrial image to be detected includes a product image to be detected and a template image to be detected corresponding to the product image to be detected.
[0110] The image blocks to be detected include template image blocks and product image blocks.
[0111] See also Figure 3 The industrial quality inspection framework proposed in this invention is mainly divided into five parts: image preprocessing module, feature extraction and fusion module, attention screening module, homography estimation module and discrimination module; the image preprocessing module is configured to: And the template image to be detected Perform grayscale processing to convert the image of the product to be tested And the template image to be detected Decompose into overlapping areas of the same scale; the feature extraction and fusion module is configured to: use the diffusion model and the feature pyramid network to extract multi-scale features from the obtained image blocks respectively, and fuse the extracted features; the attention screening module is configured to: based on the fused features, embed the position information, and use the obtained attention scores through the converter model to selectively identify the key image blocks and screen out the abnormal image blocks; the homography estimation module is configured to: after the feature vector pairs obtained by the converter pass through the convolutional neural network, a paired homography estimation matrix is obtained, and the screened abnormal image block pairs are subjected to homography transformation according to the obtained homography estimation matrix; the discrimination module is configured to: according to the template image block, perform similarity calculation on the abnormal image block, and judge whether an abnormal defect occurs according to the similarity metric.
[0112] In this embodiment, an industrial image to be inspected is acquired, and grayscale processing is performed on the product image to be inspected and the template image to be inspected respectively to generate a grayscale product image and a grayscale template image corresponding to the grayscale product image.
[0113] Step 202: divide the grayscale product image and the grayscale template image respectively, and output a plurality of product image blocks and a plurality of template image blocks.
[0114] It should be noted that the product image to be tested And the template image to be detected After grayscale processing to obtain grayscale product image and grayscale template image, it is necessary to convert the image of the product to be tested into And the template image to be detected Decompose into overlapping areas of the same scale, that is, divide the grayscale product image and the grayscale template image respectively. Specifically, decompose the obtained grayscale product image and grayscale template image into overlapping areas of the same scale. For pixel overlap, there are s blocks along the dimension with the smallest length, usually s = 3. Interpolation is used to scale the image blocks, the default decomposition step is pixels, and the overlap is adjusted according to actual conditions to reduce the total number of blocks and avoid blocks in the bottom row and the rightmost column covering discontinuous image areas.
[0115] In this embodiment, the grayscale product image and the grayscale template image are divided respectively, and a plurality of product image blocks and a plurality of template image blocks are output.
[0116] Step 203 : extracting features from each image block to be detected by using a preset diffusion model and a preset feature pyramid network, respectively, to generate a plurality of first image block features and a plurality of second image block features.
[0117] The first image block features include high-dimensional product image block features and high-dimensional template image block features.
[0118] The second image block features include enhanced product image block features and enhanced template image block features.
[0119] Further, step 203 may include the following sub-steps:
[0120] S31, adding noise to each product image block and each template image block respectively, to determine a plurality of noisy product image blocks and a plurality of noisy template image blocks;
[0121] S32, using a preset diffusion model to perform noise prediction on each noise product image block and each noise template image block, and outputting a plurality of high-dimensional product image block features and a plurality of high-dimensional template image block features;
[0122] S33, using a preset feature pyramid network to perform feature enhancement extraction on each product image block and each template image block, and output multiple enhanced product image block features and multiple enhanced template image block features.
[0123] It should be noted that for image blocks (product image blocks and template image blocks), the preset feature pyramid network and the preset diffusion model are used to extract features respectively, and dynamically cross-fused. In the feature extraction process, the feature extractors of the product image block and the template image block have the same structure and share the same weights; among them, the preset feature pyramid network is composed of two residual convolution layers and 3×3 convolution; for the feature extraction process of the preset diffusion model, for example, noise is first added to the image block In, obtain Then it is sent to the pre-trained DDPM network for noise prediction, in which the image features extracted by UNet are collected to obtain high-dimensional features.
[0124] In this embodiment, a preset diffusion model and a preset feature pyramid network are respectively used to extract features from each image block to be detected, so as to generate a plurality of first image block features and a plurality of second image block features.
[0125] Step 204: Dynamically cross-fuse the features of each first image block and each second image block to generate a plurality of multi-scale fusion features.
[0126] Multi-scale fusion features include product multi-scale fusion features and template multi-scale fusion features.
[0127] Further, step 204 may include the following sub-steps:
[0128] S41, performing linear transformation on each high-dimensional product image block feature and each enhanced product image block feature, and outputting a plurality of high-dimensional product feature vectors and a plurality of enhanced product feature vectors;
[0129] S42, performing linear transformation on each high-dimensional template image block feature and each enhanced template image block feature, and outputting a plurality of high-dimensional template feature vectors and a plurality of enhanced template feature vectors;
[0130] S43, based on the preset subspace set and the preset cross attention model, feature fusion is performed on each high-dimensional product feature vector and each enhanced product feature vector, and multi-scale fusion features of multiple products are output;
[0131] S44. Based on the preset subspace set and the preset cross-attention model, feature fusion is performed on each high-dimensional template feature vector and each enhanced template feature vector respectively, and multiple template multi-scale fusion features are output.
[0132] It should be noted that the features extracted by the preset feature pyramid network and the preset diffusion model are fused by cross attention, that is, the high-dimensional product feature vector and the enhanced product feature vector corresponding to the fused product image block, and the high-dimensional template feature vector and the enhanced template feature vector corresponding to the fused template image block are fused; illustratively, by fusion of the features extracted by the preset feature pyramid network and features extracted by the preset diffusion model Perform a linear transformation to obtain the query vector ( ), key vector ( ), value vector ( ), in the dynamic cross-fusion of features, the features are and Use self-attention to smooth the features extracted by the preset diffusion model Perform cross-attention processing, where From , and From , to achieve feature filtering of diffusion model features, select the query vector generated by the features extracted by the feature pyramid network, and generate key vectors and value vectors by the features extracted by the diffusion model, which can better extract some features that are beneficial to quality inspection tasks.
[0133] Further, in and The self-attention is calculated between the two heads, and multi-head cross attention is obtained by replicating in multiple subspaces. The 4-head version is used to calculate the multi-head cross attention. Compared with the single-head attention, the 4-head version provides a significant performance improvement without significantly increasing the computational complexity. Compared with using more heads, the 4-head version requires relatively low computational resources, does not introduce too much redundancy, and can prevent the model from overfitting.
[0134] In this embodiment, dynamic cross-fusion of features is performed on each first image block feature and each second image block feature to generate a plurality of multi-scale fusion features.
[0135] Step 205: Determine a plurality of abnormal image blocks according to each multi-scale fusion feature and each image block to be detected.
[0136] The abnormal image blocks include product abnormal image blocks and template abnormal image blocks.
[0137] Further, step 205 may include the following sub-steps:
[0138] S51, embedding the multi-scale fusion features of each product into the position information of the product image blocks corresponding to the multi-scale fusion features of each product, and determining the product position fusion features corresponding to the multi-scale fusion features of each product;
[0139] S52, performing linear transformation on each product position fusion feature respectively, and outputting multiple product position feature vectors;
[0140] S53, using a preset encoder to calculate the attention score value corresponding to each product position feature vector according to each product position feature vector;
[0141] S54, respectively comparing each attention score value with a preset attention score threshold;
[0142] S55, taking any product image block corresponding to an attention score value less than or equal to a preset attention score threshold as a product abnormal image block;
[0143] S56: Use the template image block corresponding to each product abnormal image block as the template abnormal image block.
[0144] It should be noted that after the above steps, the fusion features of the product image block and the template image block (product multi-scale fusion features, template multi-scale fusion features) are obtained, and the position information of each fusion feature is embedded and sent to the shared weight converter encoder model. In the preset encoder, multi-head attention is used to calculate the paired attention score values, that is, each attention head projects the input to the query vector ( ), key vector ( ), value vector ( ), thereby obtaining the corresponding attention score value.
[0145] Furthermore, in order to minimize the computational complexity, the image blocks are filtered according to the acquired attention scores to refine the selection, and the product image blocks whose attention score values exceed a predefined threshold (preset attention score threshold) and the corresponding template image blocks are retained, and the product image blocks corresponding to the attention score values less than or equal to the preset attention score threshold are taken as product abnormal image blocks, and the template image blocks corresponding to the product abnormal image blocks are taken as template abnormal image blocks.
[0146] In this embodiment, a plurality of abnormal image blocks are determined according to each multi-scale fusion feature and each image block to be detected.
[0147] Step 206: Generate industrial quality inspection results based on each abnormal image block using a preset correlation matching model.
[0148] Industrial quality inspection results include normal quality inspection results and abnormal quality inspection results.
[0149] Further, step 206 may include the following sub-steps:
[0150] S61, taking the product multi-scale fusion features corresponding to the abnormal image blocks of each product as the input of the preset converter, and outputting the product fusion feature vector corresponding to the multi-scale fusion features of each product;
[0151] S62, taking the template multi-scale fusion features corresponding to each template abnormal image block as the input of the preset converter, and outputting the template fusion feature vector corresponding to each template multi-scale fusion feature;
[0152] S63, using a preset convolutional neural network to perform convolution operations on each product fusion feature vector and each template fusion feature vector, respectively, and output a product homography matrix corresponding to each product fusion feature vector and a template homography matrix corresponding to each template fusion feature vector;
[0153] S64, performing homography mapping on the product abnormality image blocks corresponding to each product homography matrix through each product homography matrix, and outputting the product mapping image blocks corresponding to each product abnormality image block;
[0154] S65, performing homography mapping on the template abnormal image blocks corresponding to each template homography matrix through each template homography matrix, and outputting the template mapping image blocks corresponding to each template abnormal image block;
[0155] S66, using a preset correlation matching model to calculate a correlation matching value according to each product mapping image block and each template mapping image block;
[0156] S67, comparing the correlation matching value with a preset matching threshold;
[0157] S68. If the correlation matching value is greater than or equal to the preset matching threshold, a normal quality inspection result is generated;
[0158] S69. If the correlation matching value is less than the preset matching threshold, an abnormal quality inspection result is generated.
[0159] It should be noted that after the feature vector pairs obtained by the preset converter pass through the preset convolutional neural network, paired homography estimation matrices are obtained, namely, the product homography matrix and the template homography matrix; in industrial defect detection, due to the possible positional offset and rotation when placing the detection parts, the acquired product image to be detected may have a different viewpoint from the corresponding template image to be detected. The purpose of homography transformation is to map points in one image to another image. Therefore, homography transformation is performed on the image blocks that may be abnormal, and the image blocks to be detected are adjusted.
[0160] Furthermore, based on the theory of multi-view geometry, the homography matrix can be used to associate two images showing the same planar scene. can be expressed as Homogeneous coordinates and represents the same point; so when two points are given and , you can use Non-singular matrix (homography estimation matrix) represents the homography table conversion mapping .
[0161] Furthermore, even if multiplied by any non-zero scaling factor, The projection table will not be changed, and only the ratio of matrix elements is meaningful. , The 8 independent ratios are 8 degrees of freedom, that is, the homography matrix It can be solved by 4 pairs of non-collinear corresponding points in the two images; however, the product image to be detected may have different viewpoints from the corresponding template image to be detected, which will lead to the failure of subsequent matching. Therefore, adjusting the image through homography transformation is the basis for subsequent template matching.
[0162] Furthermore, similarity calculation is performed based on the product mapping image block and the template mapping image block, correlation matching is performed on the image block pairs, the mismatched areas are marked, and the results of whether there are abnormal defects are obtained. Correlation matching is performed using a preset correlation matching model; Value range [ − 1 , 1 ] If the sample data match each other, then A value of 1 indicates a high correlation; if If the value is -1, it means it is completely irrelevant. Therefore, according to the correlation matching, the mismatched area is obtained and marked to determine whether an abnormal defect result occurs.
[0163] In this embodiment, a preset correlation matching model is used to generate industrial quality inspection results according to each abnormal image block.
[0164] For further information, see Figure 4 , for example, the product image to be detected And the template image to be detected Perform grayscale processing and convert the grayscale processed image and Decompose into overlapping areas of the same scale to obtain multiple product image blocks and multiple template image blocks, use a preset diffusion model and a preset feature pyramid network to extract multi-scale features from the obtained image blocks, and fuse the extracted features; based on the fused features, embed the position information, and use the preset encoder and the obtained attention scores to selectively identify key image blocks and filter out abnormal image blocks; after the feature vector pairs obtained by the preset converter pass through the convolutional neural network, a paired homography estimation matrix is obtained, and the screened abnormal image block pairs are subjected to homography transformation according to the obtained homography estimation matrix to obtain product mapping image blocks and template mapping image blocks; and based on the template image blocks, similarity calculation is performed on the abnormal image blocks, that is, similarity calculation is performed based on the product mapping image blocks and the template mapping image blocks, and whether abnormal defects occur is judged based on the similarity measurement, that is, an industrial quality inspection result is generated.
[0165] As a comparison of technical effects, we can refer to existing technologies. In existing industrial quality inspections, defects on the surface of products may exist at different scales and have very different performance characteristics. Existing intelligent detection networks are very efficient, but due to the lack of semantic information, they are susceptible to errors or missed detections of non-significant defects. Diffusion models are widely used in the field of image processing, and the extracted features contain high-order semantics that can be used for tasks such as semantic segmentation. In addition, in industrial quality inspection scenarios, the proportion of defect category data is low, and the types of defects are uncertain, making it difficult to ensure that deep learning models will not have overfitting problems.
[0166] In view of the above problems, the present invention introduces the diffusion model and attention mechanism into the industrial quality inspection system, establishes an industrial quality inspection system based on template matching under multi-scale fusion features, and designs an attention threshold to screen the matching area to improve efficiency. The template matching method is used for discrimination to achieve the high accuracy and high flexibility of industrial quality inspection required when the data samples of various defect categories are scarce. At the same time, the semantic information contained in the features is improved to achieve accurate and efficient matching.
[0167] In an embodiment of the present invention, in an embodiment of the present invention, the present invention provides an industrial quality inspection method, firstly, an industrial image to be inspected is acquired, and the industrial image to be inspected is preprocessed to output a plurality of image blocks to be inspected; then, a preset diffusion model and a preset feature pyramid network are respectively used to extract features of each image block to be inspected, and a plurality of first image block features and a plurality of second image block features are generated; the first image block features and the second image block features are dynamically cross-fused to generate a plurality of multi-scale fusion features; according to the multi-scale fusion features and each image block to be inspected, a plurality of abnormal image blocks are determined; finally, an industrial quality inspection result is generated according to each abnormal image block using a preset correlation matching model; based on the above scheme, based on the preset diffusion model and the preset feature pyramid network, the process of feature extraction and dynamic cross-fusion of features of the acquired image blocks to be inspected can obtain multi-scale fusion features containing high-order semantics, reduce the influence of errors or missed detections of non-significant defects in the detection process, and further improve the accuracy of quality inspection.
[0168] See also Figure 5 , Figure 5 A structural block diagram of an industrial quality inspection device provided in an embodiment of the present invention.
[0169] The present invention provides an industrial quality inspection device, comprising:
[0170] The acquisition module 501 is used to acquire the industrial image to be detected, pre-process the industrial image to be detected, and output a plurality of image blocks to be detected;
[0171] Adopting module 502, for respectively using a preset diffusion model and a preset feature pyramid network to extract features from each image block to be detected, and generating a plurality of first image block features and a plurality of second image block features;
[0172] A fusion module 503 is used to dynamically cross-fuse the features of each first image block and each second image block to generate a plurality of multi-scale fusion features;
[0173] According to module 504, a plurality of abnormal image blocks are determined according to each multi-scale fusion feature and each image block to be detected;
[0174] The generation module 505 is used to generate industrial quality inspection results according to each abnormal image block by using a preset correlation matching model.
[0175] Further, the detected industrial image includes a product image to be detected and a template image to be detected corresponding to the product image to be detected; the image block to be detected includes a template image block and a product image block; the acquisition module 501 is specifically used to:
[0176] Perform grayscale processing on the product image to be detected and the template image to be detected respectively, and generate a grayscale product image and a grayscale template image corresponding to the grayscale product image;
[0177] The grayscale product image and the grayscale template image are divided respectively, and a plurality of product image blocks and a plurality of template image blocks are output.
[0178] Further, the first image block feature includes a high-dimensional product image block feature and a high-dimensional template image block feature; the second image block feature includes an enhanced product image block feature and an enhanced template image block feature; the module 502 is used specifically for:
[0179] Noising each product image block and each template image block respectively to determine a plurality of noisy product image blocks and a plurality of noisy template image blocks;
[0180] A preset diffusion model is used to perform noise prediction on each noise product image block and each noise template image block, and multiple high-dimensional product image block features and multiple high-dimensional template image block features are output;
[0181] A preset feature pyramid network is used to perform feature enhancement extraction on each product image block and each template image block, and multiple enhanced product image block features and multiple enhanced template image block features are output.
[0182] Furthermore, the multi-scale fusion feature includes a product multi-scale fusion feature and a template multi-scale fusion feature; the fusion module 503 is specifically used for:
[0183] Performing linear transformation on each high-dimensional product image block feature and each enhanced product image block feature respectively, and outputting a plurality of high-dimensional product feature vectors and a plurality of enhanced product feature vectors;
[0184] Performing linear transformation on each high-dimensional template image block feature and each enhanced template image block feature respectively, and outputting a plurality of high-dimensional template feature vectors and a plurality of enhanced template feature vectors;
[0185] Based on the preset subspace set and the preset cross-attention model, feature fusion is performed on each high-dimensional product feature vector and each enhanced product feature vector, and multi-scale fusion features of multiple products are output;
[0186] Based on the preset subspace set and the preset cross-attention model, feature fusion is performed on each high-dimensional template feature vector and each enhanced template feature vector respectively, and multiple template multi-scale fusion features are output.
[0187] Further, the abnormal image block includes a product abnormal image block and a template abnormal image block; according to module 504, it is specifically used for:
[0188] The multi-scale fusion features of each product are respectively embedded with the position information of the product image blocks corresponding to the multi-scale fusion features of each product, and the product position fusion features corresponding to the multi-scale fusion features of each product are determined;
[0189] Perform linear transformation on the fusion features of each product position respectively, and output multiple product position feature vectors;
[0190] A preset encoder is used to calculate the attention score value corresponding to each product position feature vector according to each product position feature vector;
[0191] Compare each attention score value with a preset attention score threshold;
[0192] Any product image block corresponding to an attention score value less than or equal to a preset attention score threshold is regarded as a product abnormal image block;
[0193] The template image block corresponding to each product abnormal image block is used as the template abnormal image block.
[0194] Furthermore, the industrial quality inspection results include normal quality inspection results and abnormal quality inspection results; the generation module 505 is specifically used for:
[0195] The multi-scale fusion features of the products corresponding to the abnormal image blocks of each product are used as the input of the preset converter, and the product fusion feature vector corresponding to the multi-scale fusion features of each product is output;
[0196] The template multi-scale fusion features corresponding to each template abnormal image block are used as the input of the preset converter, and the template fusion feature vector corresponding to each template multi-scale fusion feature is output;
[0197] Use the preset convolutional neural network to perform convolution operations on each product fusion feature vector and each template fusion feature vector, and output the product homography matrix corresponding to each product fusion feature vector and the template homography matrix corresponding to each template fusion feature vector;
[0198] Perform homography mapping on the product abnormal image blocks corresponding to each product homography matrix through each product homography matrix, and output the product mapping image blocks corresponding to each product abnormal image block;
[0199] Performing homography mapping on the template abnormal image blocks corresponding to each template homography matrix through each template homography matrix, and outputting the template mapping image blocks corresponding to each template abnormal image block;
[0200] A preset correlation matching model is used to calculate a correlation matching value according to each product mapping image block and each template mapping image block;
[0201] Comparing the correlation match value with the preset match threshold;
[0202] If the correlation match value is greater than or equal to the preset match threshold, a normal quality inspection result is generated;
[0203] If the correlation match value is less than the preset match threshold, an abnormal quality inspection result is generated.
[0204] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described devices and modules can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0205] An embodiment of the present invention further provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory; when the computer program is executed by the processor, the processor executes the steps of the industrial quality inspection method of any of the above embodiments.
[0206] An embodiment of the present invention further provides a computer-readable storage medium on which a computer program / instruction is stored. When the computer program / instruction is executed by a processor, the steps of the industrial quality inspection method as in any of the above embodiments are implemented.
[0207] An embodiment of the present invention further provides a computer program product, including a computer program / instruction, which implements the steps of the industrial quality inspection method of any of the above embodiments when the computer program / instruction is executed by a processor.
[0208] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0209] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0210] As described above, the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features thereof may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. An industrial quality inspection method, characterized in that: include: Acquire an industrial image to be detected, preprocess the industrial image to be detected, and output a plurality of image blocks to be detected; respectively using a preset diffusion model and a preset feature pyramid network to extract features from each of the image blocks to be detected, and generating a plurality of first image block features and a plurality of second image block features; Performing dynamic cross-fusion of features on each of the first image block features and each of the second image block features to generate a plurality of multi-scale fusion features; Determine a plurality of abnormal image blocks according to each of the multi-scale fusion features and each of the image blocks to be detected; Using a preset correlation matching model to generate industrial quality inspection results according to each of the abnormal image blocks; The first image block features include high-dimensional product image block features and high-dimensional template image block features; the second image block features include enhanced product image block features and enhanced template image block features; The abnormal image blocks include product abnormal image blocks and template abnormal image blocks; The multi-scale fusion features include product multi-scale fusion features and template multi-scale fusion features; the step of dynamically cross-fusing the first image block features and the second image block features to generate a plurality of multi-scale fusion features includes: Performing linear transformation on each of the high-dimensional product image block features and each of the enhanced product image block features, respectively, and outputting a plurality of high-dimensional product feature vectors and a plurality of enhanced product feature vectors; Performing linear transformation on each of the high-dimensional template image block features and each of the enhanced template image block features, respectively, and outputting a plurality of high-dimensional template feature vectors and a plurality of enhanced template feature vectors; Based on a preset subspace set and a preset cross-attention model, feature fusion is performed on each of the high-dimensional product feature vectors and each of the enhanced product feature vectors, and multi-scale fusion features of multiple products are output; Based on the preset subspace set and the preset cross attention model, feature fusion is performed on each of the high-dimensional template feature vectors and each of the enhanced template feature vectors, and a plurality of template multi-scale fusion features are output; The industrial quality inspection results include normal quality inspection results and abnormal quality inspection results; the step of using a preset correlation matching model to generate industrial quality inspection results according to each abnormal image block includes: Taking the product multi-scale fusion features corresponding to each of the product abnormal image blocks as the input of the preset converter, and outputting the product fusion feature vector corresponding to each of the product multi-scale fusion features; Taking the template multi-scale fusion features corresponding to each template abnormal image block as the input of the preset converter, and outputting the template fusion feature vector corresponding to each template multi-scale fusion feature; Using a preset convolutional neural network to perform convolution operations on each of the product fusion feature vectors and each of the template fusion feature vectors, respectively, and outputting a product homography matrix corresponding to each of the product fusion feature vectors and a template homography matrix corresponding to each of the template fusion feature vectors; Performing homography mapping on the product abnormality image blocks corresponding to each product homography matrix through each product homography matrix, and outputting product mapping image blocks corresponding to each product abnormality image block; Performing homography mapping on the template abnormal image blocks corresponding to each template homography matrix through each template homography matrix, and outputting the template mapping image blocks corresponding to each template abnormal image block; Calculating a correlation matching value according to each of the product mapping image blocks and each of the template mapping image blocks using the preset correlation matching model; Comparing the correlation matching value with a preset matching threshold; If the correlation match value is greater than or equal to the preset match threshold, a normal quality inspection result is generated; If the correlation matching value is less than the preset matching threshold, an abnormal quality inspection result is generated.
2. The industrial quality inspection method according to claim 1, characterized in that: The industrial image to be detected includes a product image to be detected and a template image to be detected corresponding to the product image to be detected; the image block to be detected includes a template image block and a product image block; the step of preprocessing the industrial image to be detected and outputting a plurality of image blocks to be detected includes: Performing grayscale processing on the product image to be detected and the template image to be detected respectively, generating a grayscale product image and a grayscale template image corresponding to the grayscale product image; The grayscale product image and the grayscale template image are divided respectively, and a plurality of product image blocks and a plurality of template image blocks are output.
3. The industrial quality inspection method according to claim 2, characterized in that: The step of respectively using a preset diffusion model and a preset feature pyramid network to extract features from each of the image blocks to be detected to generate a plurality of first image block features and a plurality of second image block features comprises: Adding noise to each of the product image blocks and each of the template image blocks respectively to determine a plurality of noisy product image blocks and a plurality of noisy template image blocks; Using the preset diffusion model to perform noise prediction on each of the noise product image blocks and each of the noise template image blocks, and outputting a plurality of high-dimensional product image block features and a plurality of high-dimensional template image block features; The preset feature pyramid network is used to perform feature enhancement extraction on each of the product image blocks and each of the template image blocks, and a plurality of enhanced product image block features and a plurality of enhanced template image block features are output.
4. The industrial quality inspection method according to claim 1, characterized in that: The step of determining a plurality of abnormal image blocks according to each of the multi-scale fusion features and each of the image blocks to be detected comprises: respectively embedding the multi-scale fusion features of the products into the position information of the product image blocks corresponding to the multi-scale fusion features of the products, and determining the product position fusion features corresponding to the multi-scale fusion features of the products; Performing linear transformation on each of the product position fusion features respectively, and outputting a plurality of product position feature vectors; Using a preset encoder to calculate the attention score value corresponding to each of the product position feature vectors according to each of the product position feature vectors; Comparing each of the attention score values with a preset attention score threshold respectively; Taking any product image block corresponding to an attention score value less than or equal to the preset attention score threshold as a product abnormal image block; The template image block corresponding to each of the product abnormal image blocks is used as the template abnormal image block.
5. An industrial quality inspection device, characterized in that: include: An acquisition module is used to acquire an industrial image to be detected, pre-process the industrial image to be detected, and output a plurality of image blocks to be detected; An adopting module is used to respectively use a preset diffusion model and a preset feature pyramid network to extract features from each of the image blocks to be detected, and generate a plurality of first image block features and a plurality of second image block features; A fusion module, used for dynamically cross-fusing the features of each of the first image blocks and the features of each of the second image blocks to generate a plurality of multi-scale fusion features; According to the module, it is used to determine a plurality of abnormal image blocks according to each of the multi-scale fusion features and each of the image blocks to be detected; A generation module, used to generate industrial quality inspection results according to each of the abnormal image blocks by using a preset correlation matching model; The first image block features include high-dimensional product image block features and high-dimensional template image block features; the second image block features include enhanced product image block features and enhanced template image block features; The abnormal image blocks include product abnormal image blocks and template abnormal image blocks; The multi-scale fusion features include product multi-scale fusion features and template multi-scale fusion features; the fusion module is specifically used for: Performing linear transformation on each of the high-dimensional product image block features and each of the enhanced product image block features, respectively, and outputting a plurality of high-dimensional product feature vectors and a plurality of enhanced product feature vectors; Performing linear transformation on each of the high-dimensional template image block features and each of the enhanced template image block features, respectively, and outputting a plurality of high-dimensional template feature vectors and a plurality of enhanced template feature vectors; Based on a preset subspace set and a preset cross-attention model, feature fusion is performed on each of the high-dimensional product feature vectors and each of the enhanced product feature vectors, and multi-scale fusion features of multiple products are output; Based on the preset subspace set and the preset cross attention model, feature fusion is performed on each of the high-dimensional template feature vectors and each of the enhanced template feature vectors, and a plurality of template multi-scale fusion features are output; The industrial quality inspection results include normal quality inspection results and abnormal quality inspection results; the generation module is specifically used to: Taking the product multi-scale fusion features corresponding to each of the product abnormal image blocks as the input of the preset converter, and outputting the product fusion feature vector corresponding to each of the product multi-scale fusion features; Taking the template multi-scale fusion features corresponding to each template abnormal image block as the input of the preset converter, and outputting the template fusion feature vector corresponding to each template multi-scale fusion feature; Using a preset convolutional neural network to perform convolution operations on each of the product fusion feature vectors and each of the template fusion feature vectors, respectively, and outputting a product homography matrix corresponding to each of the product fusion feature vectors and a template homography matrix corresponding to each of the template fusion feature vectors; Performing homography mapping on the product abnormality image blocks corresponding to each product homography matrix through each product homography matrix, and outputting product mapping image blocks corresponding to each product abnormality image block; Performing homography mapping on the template abnormal image blocks corresponding to each template homography matrix through each template homography matrix, and outputting the template mapping image blocks corresponding to each template abnormal image block; Calculating a correlation matching value according to each of the product mapping image blocks and each of the template mapping image blocks using the preset correlation matching model; Comparing the correlation matching value with a preset matching threshold; If the correlation matching value is greater than or equal to the preset matching threshold, a normal quality inspection result is generated; If the correlation matching value is less than the preset matching threshold, an abnormal quality inspection result is generated.
6. An electronic device, characterized in that: It comprises a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the industrial quality inspection method according to any one of claims 1 to 4.
7. A computer-readable storage medium having a computer program / instruction stored thereon, characterized in that: When the computer program / instructions are executed by a processor, the steps of the industrial quality inspection method according to any one of claims 1 to 4 are implemented.
8. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the steps of the industrial quality inspection method according to any one of claims 1 to 4 are implemented.
Citation Information
Patent Citations
Printing quality defect detection method and storage medium
CN113034492A
Complex background image defect detection method and system based on combination of frequency domain and spatial domain
CN113487569A
Industrial product anomaly detection method, system and device and storage medium
CN114066811A
Sample generation method and related equipment
CN117911258A
Defect detection method and apparatus, electronic device, and storage medium
WO2022088663A1
