Defect detection method and device, electronic equipment and storage medium

By extracting and integrating features of the image to be detected, combined with semantic alignment and coupled coding technology, the problem of insufficient accuracy of defect detection in the prior art is solved, and efficient defect detection in complex environments is achieved.

CN119107312APending Publication Date: 2024-12-10ZHONGKE HUIYUAN VISUAL TECHNOLOGY (LUOYANG) CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411220683.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-30
Publication Date
2024-12-10

AI Technical Summary

Technical Problem

The prior art is difficult to fully capture complex and diverse defect characteristics in defect detection in industrial scenarios, resulting in insufficient accuracy in the detection model when dealing with diversified defects.

Method used

By extracting and integrating the image to be detected, the feature vector to be detected is generated, and semantically aligned and coupled encoding is performed with the reference feature vector to obtain the encoded feature sequence, then decode it, and finally convert the decoded feature sequence into the detection result image. Clearly display the defect location.

Benefits of technology

Improves the accuracy and processing efficiency of defect detection, ensuring reliable detection results in complex environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119107312A_ABST
    Figure CN119107312A_ABST
Patent Text Reader

Abstract

The invention provides a defect detection method and device, electronic equipment and a storage medium, and the method comprises the steps: carrying out the feature extraction and integration of a to-be-detected image, and obtaining a to-be-detected feature vector; obtaining a reference feature vector, and performing semantic alignment and coupling coding on the reference feature vector and the to-be-detected feature vector to obtain a coded feature sequence and feature representation thereof; decoding the coded feature sequence based on the feature representation to obtain a decoded feature sequence; and performing image reconstruction on the decoding feature sequence to obtain a detection result image which displays a defect position in the to-be-detected image. The invention provides a more accurate and flexible defect detection method.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of image processing technology, and in particular to a defect detection method, device, electronic device and storage medium. Background Art

[0002] In industrial scenarios, due to the complexity and diversity of the production environment, it is difficult to collect a large amount of high-quality data for training detection models. The currently commonly used technical means mainly rely on comparing the feature differences between normal samples and defective samples for judgment, but this comparison method is often relatively simple and difficult to fully capture the complex and diverse defect features, thus limiting the accuracy of the detection model when dealing with diverse defects. Therefore, a more accurate and flexible defect detection method is urgently needed. Summary of the invention

[0003] The present disclosure provides a defect detection method, device, equipment and storage medium to at least solve the above technical problems existing in the prior art.

[0004] According to a first aspect of the present disclosure, a defect detection method is provided, the method comprising:

[0005] Extract and integrate features of the image to be detected to obtain a feature vector to be detected;

[0006] Acquire a reference feature vector, perform semantic alignment and coupling encoding on the reference feature vector and the feature vector to be detected, and obtain a coding feature sequence and a feature representation thereof;

[0007] Decoding the encoded feature sequence based on the feature representation to obtain a decoded feature sequence;

[0008] The decoded feature sequence is subjected to image reconstruction to obtain a detection result image, wherein the detection result image displays the defect position in the image to be detected.

[0009] In one possible implementation manner, extracting and integrating features of the image to be detected to obtain a feature vector to be detected includes:

[0010] Extracting features of the image to be detected to obtain multiple features of the image to be detected;

[0011] The multiple image features to be detected are integrated to obtain the feature vector to be detected.

[0012] In one possible implementation manner, the extracting features of the image to be detected to obtain a plurality of features of the image to be detected includes:

[0013] Segmenting the image to be detected to obtain multiple image blocks;

[0014] Performing sequence conversion on the multiple image blocks to obtain multiple feature sequences to be detected;

[0015] Based on the position of each image block in the image to be detected, determining the position information corresponding to each image block;

[0016] The plurality of image features to be detected are determined according to each feature sequence to be detected and position information thereof.

[0017] In one possible implementation manner, determining the position information corresponding to each image block based on the position of each image block in the image to be detected includes:

[0018] Based on the position of each image block in the image to be detected, the image block is subjected to horizontal scanning coding or vertical scanning coding to determine the position information corresponding to each image block.

[0019] In one possible implementation manner, the image reconstruction of the decoded feature sequence to obtain a detection result image includes:

[0020] Converting the decoded feature sequence into target image features;

[0021] The target image features are reconstructed to obtain the detection result image.

[0022] In one possible implementation manner, reconstructing the target image features to obtain the detection result image includes:

[0023] Reconstructing the target image features to obtain a restored image;

[0024] The restored image is binarized based on a set threshold to obtain the detection result image.

[0025] In one possible implementation, specifically, the reference feature vector and the feature vector to be detected are semantically aligned and coupled encoded through a self-attention layer and a cross-attention layer to obtain the encoded feature sequence and its feature representation.

[0026] In one possible implementation, specifically, the encoded feature sequence is decoded based on the feature representation through a multi-head cross attention module to obtain the decoded feature sequence.

[0027] In one embodiment, the method further comprises:

[0028] Obtain a normal image sample set;

[0029] The reference feature vector is obtained based on the normal image sample set.

[0030] In one possible implementation manner, obtaining the reference feature vector based on the normal image sample set includes:

[0031] Extracting features from the normal image sample set to obtain a reference image feature set;

[0032] Based on the type of the image to be detected, determining a reference image feature corresponding to the image in the reference image feature set;

[0033] The reference image features corresponding to the image to be detected are integrated to obtain the reference feature vector.

[0034] According to a second aspect of the present disclosure, a defect detection device is provided, the device comprising:

[0035] A feature acquisition module is used to extract and integrate features of the image to be detected to obtain a feature vector to be detected;

[0036] An encoding module is used to obtain a reference feature vector, perform semantic alignment and coupling encoding on the reference feature vector and the feature vector to be detected, and obtain a coding feature sequence and a feature representation thereof;

[0037] A decoding module, used for decoding the encoded feature sequence based on the feature representation to obtain a decoded feature sequence;

[0038] The image reconstruction module is used to perform image reconstruction on the decoded feature sequence to obtain a detection result image, wherein the detection result image displays the defect position in the image to be detected.

[0039] In one possible implementation manner, the feature acquisition module is further used to extract features from the image to be detected to obtain multiple features of the image to be detected; and integrate the multiple features of the image to be detected to obtain the feature vector to be detected.

[0040] In one possible implementation manner, the feature acquisition module is further used to segment the image to be detected to obtain multiple image blocks; perform sequence conversion on the multiple image blocks to obtain multiple feature sequences to be detected; determine the position information corresponding to each image block based on the position of each image block in the image to be detected; and determine the multiple image features to be detected based on each feature sequence to be detected and its position information.

[0041] In one possible implementation manner, the feature acquisition module is further used to perform horizontal scanning coding or vertical scanning coding on the image blocks based on the position of each image block in the image to be detected, so as to determine the position information corresponding to each image block.

[0042] In one possible implementation manner, the image reconstruction module is further used to convert the decoded feature sequence into target image features; and perform image reconstruction on the target image features to obtain the detection result image.

[0043] In one possible implementation manner, the image reconstruction module is further used to reconstruct the target image features to obtain a restored image; and binarize the restored image based on a set threshold to obtain the detection result image.

[0044] According to a third aspect of the present disclosure, a defect detection model is provided, the model comprising: a feature extraction network, an image hierarchical embedding module, a semantic alignment coupling encoding module, a context condition decoding module, a reverse image hierarchical embedding module and a reconstructed image feature module; wherein,

[0045] The feature extraction network and the image hierarchical embedding module are used to extract and integrate features of the image to be detected to obtain a feature vector to be detected;

[0046] The semantic alignment coupling coding module is used to perform semantic alignment and coupling coding on the reference feature vector and the feature vector to be detected to obtain a coding feature sequence and a feature representation thereof;

[0047] The context condition decoding module is used to decode the encoded feature sequence based on the feature representation to obtain a decoded feature sequence;

[0048] The reverse image hierarchical embedding module and the reconstructed image feature module are used to reconstruct the image of the decoded feature sequence to obtain a detection result image, and the detection result image displays the defect position in the image to be detected.

[0049] In one possible implementation, the model further includes a sample acquisition module and a normal feature storage pool;

[0050] The sample acquisition module is used to acquire a normal image sample set;

[0051] The feature extraction network is further used to extract features from the normal image sample set to obtain a reference image feature set;

[0052] The normal feature storage pool is used to store the reference image feature set, and determine the reference image feature corresponding to the image to be detected in the reference image feature set based on the type of the image to be detected;

[0053] The image hierarchical embedding module is also used to integrate the reference image features corresponding to the image to be detected to obtain the reference feature vector.

[0054] According to a fourth aspect of the present disclosure, there is provided an electronic device, including:

[0055] at least one processor; and

[0056] a memory communicatively connected to the at least one processor; wherein,

[0057] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method described in the present disclosure.

[0058] According to a fifth aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable the computer to execute the method described in the present disclosure.

[0059] The present invention discloses a defect detection method, device, equipment and storage medium. First, by extracting and integrating features of the image to be detected, the generated feature vector can fully reflect the details and overall information of the image. These feature vectors to be detected are semantically aligned and coupled with the reference feature vectors to ensure the accurate match between normal and abnormal features. Then, by decoding the encoded feature sequence, the decoded feature sequence can be recovered from the complex feature data. Finally, the decoded feature sequence is converted into an intuitive detection result image, which clearly shows the location of the defect. This process not only improves the accuracy of defect detection, but also optimizes the processing efficiency, ensuring that reliable detection results can be obtained even in complex environments.

[0060] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0061] The above and other objects, features and advantages of the exemplary embodiments of the present disclosure will become readily understood by reading the detailed description below with reference to the accompanying drawings. In the accompanying drawings, several embodiments of the present disclosure are shown in an exemplary and non-limiting manner, in which:

[0062] In the drawings, the same or corresponding reference numerals represent the same or corresponding parts.

[0063] Figure 1 A schematic diagram of an implementation flow of a defect detection method according to an embodiment of the present disclosure is shown;

[0064] Figure 2 A schematic diagram of the structure of a defect detection device according to an embodiment of the present disclosure is shown;

[0065] Figure 3A schematic diagram of the structure of a defect detection model according to an embodiment of the present disclosure is shown;

[0066] Figure 4 A schematic diagram showing the composition structure of a context condition decoding module according to an embodiment of the present disclosure is shown;

[0067] Figure 5 A schematic diagram of the structure of an electronic device according to an embodiment of the present disclosure is shown. DETAILED DESCRIPTION

[0068] In order to make the purpose, features, and advantages of the present disclosure more obvious and easy to understand, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, not all of the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present disclosure.

[0069] Figure 1 A schematic diagram of the implementation process of a defect detection method according to an embodiment of the present disclosure is shown. Figure 1 As shown, according to a first aspect of an embodiment of the present disclosure, a defect detection method is provided, and the method includes:

[0070] Step 101 , extracting and integrating features of the image to be detected to obtain a feature vector to be detected.

[0071] The image to be inspected is an image that needs to be inspected for defects, which may be a product photo from a production line, a security surveillance video frame, etc. For example, an image of a product from a five-axis defect inspection device. Feature extraction is performed on the image to be inspected, and the extracted features are integrated to obtain the feature vector to be inspected.

[0072] Step 102: obtain a reference feature vector, perform semantic alignment and coupling encoding on the reference feature vector and the feature vector to be detected, and obtain a coded feature sequence and its feature representation.

[0073] The reference feature vector is a feature vector of an image that is known to have no defects or meet specific standards. It is used to compare with the feature vector to be detected in order to identify defects in the image to be detected. The semantic consistency between the feature vector to be detected and the reference feature vector is adjusted so that they are compared in the same semantic space. Then the two are coupled and encoded to obtain a coded feature sequence. The coded feature sequence includes the relationship and structural information between the features. The feature representation includes query, key, and value.

[0074] Step 103: decode the encoded feature sequence based on the feature representation to obtain a decoded feature sequence.

[0075] Based on the feature representation, the abstract information in the encoded feature sequence is gradually converted back to the specific representation in the original feature space, thereby obtaining the decoded feature sequence.

[0076] Step 104 , reconstructing the decoded feature sequence to obtain a detection result image, wherein the detection result image displays the defect position in the image to be detected.

[0077] The inverse processing method is used to restore the features to the size and format of the image to be detected, and the detection result image is obtained. The detection result image can clearly show the abnormal area or defect area in the image to be detected, providing visualization results for practical applications.

[0078] The defect detection method of this embodiment first extracts and integrates features of the image to be detected, and the generated feature vector can fully reflect the details and overall information of the image. The feature vectors to be detected are semantically aligned and coupled with the reference feature vectors to ensure the accurate match between normal and abnormal features. Then, by decoding the encoded feature sequence, the decoded feature sequence can be recovered from the complex feature data. Finally, the decoded feature sequence is converted into an intuitive detection result image, which clearly shows the location of the defect. This process not only improves the accuracy of defect detection, but also optimizes the processing efficiency, ensuring that reliable detection results can be obtained even in complex environments.

[0079] In one possible implementation manner, extracting and integrating features of the image to be detected to obtain a feature vector to be detected includes: extracting features of the image to be detected to obtain multiple features of the image to be detected; and integrating the multiple features of the image to be detected to obtain a feature vector to be detected.

[0080] In one possible implementation manner, feature extraction is performed on an image to be detected to obtain a plurality of image features to be detected, which can be specifically achieved through the following technical means: segmenting the image to be detected to obtain a plurality of image blocks; performing sequence conversion on the plurality of image blocks to obtain a plurality of feature sequences to be detected; determining the position information corresponding to each image block based on the position of each image block in the image to be detected; and determining a plurality of image features to be detected based on each feature sequence to be detected and its position information.

[0081] The feature extraction network (ViT, Vision Transformer) is used to first divide the image to be detected into multiple smaller image blocks. Each smaller image block can capture the local features of the image in a more detailed manner. Each image block is converted into a serialized form to obtain multiple feature sequences to be detected, and each sequence corresponds to the features of an image block. According to the specific position of the image block in the image to be detected, position information is added to each feature sequence to obtain the image features to be detected with spatial reference. Then, these image features to be detected are integrated, and through screening, fusion and other means, they are merged into a feature vector to be detected that can comprehensively and compactly represent the main features of the image to be detected.

[0082] This embodiment ensures that the information of each part of the image can be captured by segmenting the image, extracting local features, adding position information, etc., and combines the spatial position information to improve the accuracy and robustness of defect detection.

[0083] In one possible implementation manner, determining the position information corresponding to each image block based on the position of each image block in the image to be detected includes: based on the position of each image block in the image to be detected, performing horizontal scanning encoding or vertical scanning encoding on the image block to determine the position information corresponding to each image block.

[0084] Horizontal coding means that for all the image blocks in each row, we code them one by one from the leftmost side, record their positions, and after the first row is coded, we code the image blocks in the second row, and so on. Vertical coding means that for all the image blocks in each column, we code them one by one from the top side, record their positions, and after the first column is coded, we code the image blocks in the second column, and so on. Through these coding methods, we can obtain the specific position of each image block in the image to be detected, and then provide the necessary spatial information for subsequent analysis.

[0085] In one possible implementation manner, performing image reconstruction on the decoded feature sequence to obtain a detection result image includes: converting the decoded feature sequence into target image features; and performing image reconstruction on the target image features to obtain a detection result image.

[0086] The decoded feature sequence is further processed or interpreted to extract target image features that can directly reflect the key information or specific attributes. Then, based on these target image features, image reconstruction is performed to form a new image, namely the detection result image. The detection result image can intuitively display the defect detection results, such as the location, shape, size, etc. of the defect. This embodiment provides an intuitive visual basis for subsequent decision-making, evaluation or further processing.

[0087] In one possible implementation manner, reconstructing the target image features to obtain a detection result image includes: reconstructing the target image features to obtain a restored image; and binarizing the restored image based on a set threshold to obtain a detection result image.

[0088] First, the target image features are reconstructed to obtain the reconstructed image, i.e. the restored image. After comparison with the set threshold, the pixel values ​​in the restored image are set to 0 or 255, so that the obtained detection result image presents a black and white effect. That is, by setting a suitable threshold, the defective part in the restored image is separated from the background, making the defect more eye-catching.

[0089] After the binary processing, the defect location is clearly displayed in the form of highlight or black, while the background is completely suppressed, so that relevant personnel can observe the test results intuitively.

[0090] In one possible implementation manner, specifically, the reference feature vector and the feature vector to be detected are semantically aligned and coupled encoded through a self-attention layer and a cross-attention layer to obtain a coded feature sequence and a feature representation thereof.

[0091] In this embodiment, a self-attention layer and a cross-attention layer are introduced to perform advanced processing on the reference feature vector and the feature vector to be detected. The main function of these two attention layers is to perform semantic alignment and coupling encoding. The self-attention layer allows different elements within the reference feature vector to be associated with each other, thereby capturing the complex dependencies within it, strengthening important feature representations and ignoring irrelevant information. The cross-attention layer promotes the information exchange between the reference feature vector and the feature vector to be detected, so that the two are aligned at the semantic level, that is, the similarities and differences between the two are identified. Through the processing of these two attention layers, the finally obtained coded feature sequence and its feature representation not only contain richer contextual information, but also realize sensitive capture of abnormal or special situations, providing strong support for subsequent detection or classification tasks.

[0092] In one possible implementation, specifically, the encoded feature sequence is decoded based on the feature representation through a multi-head cross attention module to obtain a decoded feature sequence.

[0093] In this embodiment, a multi-head cross-attention module is introduced to decode the encoded feature sequence based on the feature representation previously obtained through the self-attention and cross-attention layers to generate a decoded feature sequence. The multi-head cross-attention module can capture the complex interactions between features more comprehensively by processing the attention weights in multiple subspaces in parallel. This parallel processing not only improves the computational efficiency, but also enhances the model's sensitivity to subtle differences between features. During the decoding process, the module uses the feature representation as contextual information to guide the decoding of the encoded feature sequence, thereby generating a decoded feature sequence that retains the original feature information and incorporates contextual semantics. This process provides a richer and more accurate feature representation for subsequent tasks such as image analysis, target detection or classification.

[0094] In one possible implementation manner, the method further includes: acquiring a normal image sample set; and obtaining the reference feature vector based on the normal image sample set.

[0095] First, a set of normal image samples is obtained. Normal image samples represent the standard or expected image state without abnormalities or defects. Then, feature processing is performed on each normal image sample to obtain a reference feature vector. This can be achieved through the following technical means:

[0096] Perform feature extraction on each normal image sample in the normal image sample set to obtain the corresponding reference image features and form a reference image feature set. According to the type of reference image features, search and determine the corresponding reference image features in the pre-built reference image feature set. Then integrate the reference image features corresponding to the type of image to be detected, that is, combine these features according to certain rules or structures to form a comprehensive reference feature vector. It is used as a benchmark for subsequent image analysis to evaluate whether the image to be detected deviates from the normal state, thereby helping to identify potential anomalies or defects.

[0097] Figure 2 A schematic diagram of the structure of a defect detection device according to an embodiment of the present disclosure is shown. Figure 2 As shown, according to a second aspect of an embodiment of the present disclosure, a defect detection device is provided, and the device includes:

[0098] The feature acquisition module 201 is used to extract and integrate features of the image to be detected to obtain a feature vector to be detected;

[0099] The encoding module 202 is used to obtain a reference feature vector, perform semantic alignment and coupling encoding on the reference feature vector and the feature vector to be detected, and obtain a coding feature sequence and a feature representation thereof;

[0100] A decoding module 203, configured to decode the encoded feature sequence based on the feature representation to obtain a decoded feature sequence;

[0101] The image reconstruction module 204 is used to perform image reconstruction on the decoded feature sequence to obtain a detection result image, wherein the detection result image displays the defect position in the image to be detected.

[0102] In one possible implementation manner, the feature acquisition module 201 is further used to extract features from the image to be detected to obtain multiple features of the image to be detected; and integrate the multiple features of the image to be detected to obtain a feature vector to be detected.

[0103] In one possible implementation mode, the feature acquisition module 201 is further used to segment the image to be detected to obtain multiple image blocks; perform sequence conversion on the multiple image blocks to obtain multiple feature sequences to be detected; determine the position information corresponding to each image block based on the position of each image block in the image to be detected; and determine multiple image features to be detected based on each feature sequence to be detected and its position information.

[0104] In one possible implementation manner, the feature acquisition module 201 is further used to perform horizontal scanning coding or vertical scanning coding on the image blocks based on the position of each image block in the image to be detected, so as to determine the position information corresponding to each image block.

[0105] In one possible implementation manner, the image reconstruction module 204 is further configured to convert the decoded feature sequence into target image features; and perform image reconstruction on the target image features to obtain a detection result image.

[0106] In one possible implementation manner, the image reconstruction module 204 is further configured to reconstruct the target image features to obtain a restored image; and perform binarization processing on the restored image based on a set threshold to obtain a detection result image.

[0107] In one possible implementation, the encoding module 202 is further used to perform semantic alignment and coupling encoding on the reference feature vector and the feature vector to be detected through a self-attention layer and a cross-attention layer to obtain a coded feature sequence and a feature representation thereof.

[0108] In one possible implementation, the decoding module 203 is further used to decode the encoded feature sequence based on the feature representation through a multi-head cross attention module to obtain a decoded feature sequence.

[0109] In one possible implementation manner, the feature acquisition module 201 is further configured to acquire a normal image sample set; and obtain the reference feature vector based on the normal image sample set.

[0110] In one possible implementation, the feature acquisition module 201 is further used to extract features from the normal image sample set to obtain a reference image feature set; based on the type of the image to be detected, determine the corresponding reference image features in the reference image feature set; and integrate the reference image features corresponding to the image to be detected to obtain the reference feature vector.

[0111] Figure 3 A schematic diagram of the structure of a defect detection model according to an embodiment of the present disclosure is shown. Figure 3 As shown, according to the third aspect of the embodiment of the present disclosure, a defect detection model is provided, which includes: a feature extraction network, an image hierarchical embedding module, a semantic alignment coupling encoding module, a context condition decoding module, a reverse image hierarchical embedding module and a reconstructed image feature module; wherein,

[0112] The feature extraction network and the image hierarchical embedding module are used to extract and integrate features of the image to be detected to obtain a feature vector to be detected;

[0113] The semantic alignment coupling coding module is used to perform semantic alignment and coupling coding on the reference feature vector and the feature vector to be detected to obtain a coding feature sequence and a feature representation thereof;

[0114] The context condition decoding module is used to decode the encoded feature sequence based on the feature representation to obtain a decoded feature sequence;

[0115] The reverse image hierarchical embedding module and the reconstructed image feature module are used to reconstruct the image of the decoded feature sequence to obtain a detection result image, and the detection result image displays the defect position in the image to be detected.

[0116] In one possible implementation, the model also includes a sample acquisition module and a normal feature storage pool; the sample acquisition module is used to acquire a normal image sample set; the feature extraction network is also used to extract features from the normal image sample set to obtain a reference image feature set; the normal feature storage pool is used to store the reference image feature set, and based on the type of the image to be detected, determine the reference image features corresponding to the image to be detected in the reference image feature set; the image hierarchical embedding module is also used to integrate the reference image features corresponding to the image to be detected to obtain the reference feature vector.

[0117] This embodiment constructs a "normal feature storage pool". The main function of this storage pool is to store reference image features previously extracted from a normal image sample set. These reference image features represent the image characteristics without abnormalities or defects, and are important benchmarks for subsequent image analysis, comparison, or detection. By constructing such a storage pool, these features can be easily retrieved and accessed when needed, so as to quickly and accurately evaluate new image samples. At the same time, as new normal image samples are added, the reference image features in the storage pool will also be continuously updated and expanded to maintain their representativeness and accuracy.

[0118] The defect detection model is described below through a specific embodiment:

[0119] First, a normal image sample set is obtained; features are extracted from the normal image sample set to obtain reference image features, and the reference image features are input into a normal feature storage pool.

[0120] The image to be detected is input into the feature extraction network to obtain the image feature Fi to be detected. The reference image feature F0 corresponding to the image feature Fi to be detected is queried in the normal feature storage pool. Fi and F0 are input into the image hierarchical embedding module together to convert them into the feature vector Fip to be detected and the reference feature vector F0p.

[0121] During the training phase of the feature extraction network, horizontal encoding is used for the first image, vertical encoding is used for the second image, and so on, alternating between them, which helps the model restore the spatial sense of the image.

[0122] Fip and F0p are input into the semantic alignment coupling encoding module, where the semantic information is coupled and encoded to establish semantic dependencies between different feature sequences. The semantic alignment coupling encoding module also involves contextual semantic alignment fusion to provide sufficient context information for contextual conditional decoding. After the semantic alignment coupling encoding module, the encoded feature sequence and its feature representation, namely the key, value and query corresponding to Fip and F0p respectively, are output.

[0123] The key, value and query corresponding to Fip and F0p are input to the context conditional decoding module. As the core part of the decoding stage, the context conditional decoding module uses the encoding feature sequence generated by the semantic alignment coupling encoding module to perform decoding by absorbing the fused contextual semantics. Figure 4 As shown in Figure 1, this process involves using the feature blocks of the dual-stream input as queries and using aligned semantic tokens as key values ​​to perform operations, thereby ensuring that the decoded features can reflect the unique attributes and prior normality of the samples, effectively preventing the "same mapping" problem and improving the performance of anomaly detection.

[0124] The context condition decoding module outputs the decoding feature sequence Fic and F0c. The decoding feature sequence Fic is input to the reverse hierarchical embedding module, and the reverse method of the image hierarchical embedding module is performed on it to obtain the target image features. Then the target image features are input to the reconstructed image feature module, and the reverse method of the feature extraction network is performed on it to obtain the detection result image, that is, the defect detection result.

[0125] The context-conditional decoding module outputs the decoding feature sequence F0c, which is used to assist in calculating the loss during model training.

[0126] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device and a readable storage medium.

[0127] Figure 5 A schematic block diagram of an example electronic device 800 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.

[0128] like Figure 5 As shown, the device 800 includes a computing unit 801, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 802 or a computer program loaded from a storage unit 808 into a random access memory (RAM) 803. In the RAM 803, various programs and data required for the operation of the device 800 can also be stored. The computing unit 801, the ROM 802, and the RAM 803 are connected to each other via a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.

[0129] A number of components in the device 800 are connected to the I / O interface 805, including: an input unit 806, such as a keyboard, a mouse, etc.; an output unit 807, such as various types of displays, speakers, etc.; a storage unit 808, such as a disk, an optical disk, etc.; and a communication unit 809, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 809 allows the device 800 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0130] The computing unit 801 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 801 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 801 performs the various methods and processes described above, such as a defect detection method. For example, in some embodiments, a defect detection method may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 808. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 800 via the ROM 802 and / or the communication unit 809. When the computer program is loaded into the RAM 803 and executed by the computing unit 801, one or more steps of a defect detection method described above may be performed. Alternatively, in other embodiments, the computing unit 801 may be configured to perform a defect detection method in any other appropriate manner (e.g., by means of firmware).

[0131] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0132] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

[0133] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0134] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).

[0135] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.

[0136] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship with each other. The server may be a cloud server, a server of a distributed system, or a server combined with a blockchain.

[0137] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.

[0138] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of the features. In the description of the present disclosure, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.

[0139] The above is only a specific embodiment of the present disclosure, but the protection scope of the present disclosure is not limited thereto. Any person skilled in the art who is familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present disclosure, which should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be based on the protection scope of the claims.

Claims

1. A defect detection method, characterized in that: The method comprises: Extract and integrate features of the image to be detected to obtain a feature vector to be detected; Acquire a reference feature vector, perform semantic alignment and coupling encoding on the reference feature vector and the feature vector to be detected, and obtain a coding feature sequence and a feature representation thereof; Decoding the encoded feature sequence based on the feature representation to obtain a decoded feature sequence; The decoded feature sequence is subjected to image reconstruction to obtain a detection result image, wherein the detection result image displays the defect position in the image to be detected.

2. The method according to claim 1, characterized in that The feature extraction and integration of the image to be detected to obtain the feature vector to be detected includes: Extracting features of the image to be detected to obtain multiple features of the image to be detected; The multiple image features to be detected are integrated to obtain the feature vector to be detected.

3. The method according to claim 2, characterized in that The step of extracting features from the image to be detected to obtain a plurality of features of the image to be detected includes: Segmenting the image to be detected to obtain multiple image blocks; Performing sequence conversion on the multiple image blocks to obtain multiple feature sequences to be detected; Based on the position of each image block in the image to be detected, determining the position information corresponding to each image block; The plurality of image features to be detected are determined according to each feature sequence to be detected and position information thereof.

4. The method according to claim 3, characterized in that The determining, based on the position of each image block in the image to be detected, position information corresponding to each image block includes: Based on the position of each image block in the image to be detected, the image block is subjected to horizontal scanning coding or vertical scanning coding to determine the position information corresponding to each image block.

5. The method according to claim 1, characterized in that The step of reconstructing the image of the decoded feature sequence to obtain a detection result image includes: Converting the decoded feature sequence into target image features; The target image features are reconstructed to obtain the detection result image.

6. The method according to claim 5, characterized in that The step of reconstructing the target image features to obtain the detection result image includes: Reconstructing the target image features to obtain a restored image; The restored image is binarized based on a set threshold to obtain the detection result image.

7. A defect detection device, characterized in that: The device comprises: A feature acquisition module is used to extract and integrate features of the image to be detected to obtain a feature vector to be detected; An encoding module is used to obtain a reference feature vector, perform semantic alignment and coupling encoding on the reference feature vector and the feature vector to be detected, and obtain a coding feature sequence and a feature representation thereof; A decoding module, used for decoding the encoded feature sequence based on the feature representation to obtain a decoded feature sequence; The image reconstruction module is used to perform image reconstruction on the decoded feature sequence to obtain a detection result image, wherein the detection result image displays the defect position in the image to be detected.

8. A defect detection model, characterized in that: The model includes: a feature extraction network, an image hierarchical embedding module, a semantic alignment coupling encoding module, a context condition decoding module, a reverse image hierarchical embedding module and a reconstructed image feature module; wherein, The feature extraction network and the image hierarchical embedding module are used to extract and integrate features of the image to be detected to obtain a feature vector to be detected; The semantic alignment coupling coding module is used to perform semantic alignment and coupling coding on the reference feature vector and the feature vector to be detected to obtain a coding feature sequence and a feature representation thereof; The context condition decoding module is used to decode the encoded feature sequence based on the feature representation to obtain a decoded feature sequence; The reverse image hierarchical embedding module and the reconstructed image feature module are used to perform image reconstruction on the decoded feature sequence to obtain a detection result image, and the detection result image displays the defect position in the image to be detected.

9. An electronic device, characterized in that: include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 6.

10. A non-transitory computer-readable storage medium storing computer instructions, characterized in that: The computer instructions are used to make a computer execute the method according to any one of claims 1-6.