A defect anomaly detection method for multiple types of products

By combining the FastFlow exception detection model and Cross-Scale Convolution Module, automated defect exception detection of multiple products is realized, solving the problems of low detection efficiency and high cost in the existing technology, and improving the flexibility and efficiency of detection.

CN119313658BActive Publication Date: 2025-03-18XIAMEN WEIYA INTELLIGENT TECHNOLOGY CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411847646.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-16
Publication Date
2025-03-18
Estimated Expiration
2044-12-16

AI Technical Summary

Technical Problem

It is difficult for the prior art to effectively detect defects and abnormalities in multiple categories of products, and when the production line is switched, the inspection process needs to be replaced, resulting in reduced automation efficiency and increased labor costs.

Method used

A defect exception detection method is proposed to collect multiple products. Using the FastFlow exception detection model and Cross-Scale Convolution Module, it realizes automated exception detection through image classification and pre-trained model calls.

Benefits of technology

This method can save quality inspection costs. The same quality inspection machine can be used for quality inspection of different products or different parts of the product, and does not require manual replacement of models when changing production lines or quality inspection targets, which improves inspection efficiency and flexibility.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119313658B_ABST
    Figure CN119313658B_ABST
Patent Text Reader

Abstract

The present invention discloses a defect anomaly detection method for a collection of multiple types of products. The method comprises: obtaining product image data to be detected, and classifying based on the image data; calling a pre-trained FastFlow anomaly detection model corresponding to the classification result based on the classification result; using the image data as the input of the FastFlow anomaly detection model, and the FastFlow anomaly detection model outputs an anomaly score corresponding to the image data based on the input image data; judging whether the product is abnormal based on the comparison between the anomaly score and a preset threshold; the present invention can save quality inspection costs, and the quality inspection of different products or different parts of products can use one quality inspection machine, and when the product of the production line or the quality inspection target is changed, there is no need to manually change the model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of anomaly detection technology, and in particular to a defect anomaly detection method for a combination of multiple types of products. Background Art

[0002] In industrial automation, product quality inspection is an important process. The quality of products manufactured by automated manufacturing varies, and the defects produced are also diverse. The same defect contains different forms, and in the production process, when the upstream process or equipment changes, new defects may also appear, which leads to the problem of high missed detection rate of defective products. In industrial scenarios, defect data is very small compared to normal data, and defect data usually presents a serious long-tail distribution. In some cases, there are even no defective samples. This practical shortcoming makes it difficult to collect and label a large amount of defect data in practice for supervised learning. Therefore, unsupervised anomaly detection methods that only require normal samples for training are an effective means to solve this problem.

[0003] In the lithium battery field, automation usually needs to be paired with a lithium battery vision platform. The lithium battery vision platform provides a wealth of detection methods for defect detection, including target detection, defect classification, semantic segmentation, etc. Although a few lithium battery vision platforms already support unsupervised anomaly detection, they are limited to one-to-one, that is, a complete anomaly detection process is only applicable to one product model. When the production line is switched, the detection process must also be switched, which leads to a decrease in automation efficiency and an increase in labor costs. Therefore, it is crucial to integrate defect anomaly detection methods for multiple types of products.

[0004] At present, the anomaly detection methods include: Auto-Encoder, Generative Adversarial Network (GAN), PatchCore, Normalizing Flow and other methods. Among them, the Normalizing Flow model transforms the problem of fitting the distribution of real data into the problem of fitting the logarithmic density of the transformed probability, and the logarithmic density method is more stable. Through a trainable process, the logarithmic likelihood of the normal sample image features is maximized, the normal sample image features are embedded into the standard normal distribution, and the probability is used to identify and locate anomalies. FastFlow is a Normalizing Flow model. It uses a fully convolutional network as a subnet, which can maintain the relative position in space. It solves the problem that the original Normalizing Flow model flattens the two-dimensional input features into a one-dimensional vector to estimate the distribution and destroys the inherent spatial position relationship of the two-dimensional image. However, when FastFlow uses features of different resolutions, it only calculates the logarithmic likelihood of each resolution feature separately, and fails to use the fusion information of different resolutions to enrich the logarithmic likelihood of image features. In addition, these methods train a model for each product or each component of the product after knowing the specific product, and then place them on their corresponding production lines. There is a lack of an automated way to integrate these possible models and then automatically call the corresponding models for anomaly detection. Summary of the invention

[0005] In view of this, the purpose of the present invention is to propose a defect anomaly detection method that integrates multiple types of products, which can save quality inspection costs. One quality inspection machine can be used for quality inspection of different products or different parts of products, and when the product of the production line or the quality inspection target is changed, there is no need to manually replace the model.

[0006] According to one aspect of the present invention, a method for detecting defects and anomalies of multiple types of products is provided, the method comprising:

[0007] Obtain image data of products to be inspected, and perform classification based on the image data;

[0008] Based on the classification result, a pre-trained FastFlow anomaly detection model corresponding to the classification result is called; the image data is used as an input of the FastFlow anomaly detection model, and the FastFlow anomaly detection model outputs an anomaly score corresponding to the image data based on the input image data;

[0009] Based on the comparison between the abnormality score and the preset threshold, determine whether the product is abnormal;

[0010] Among them, the FastFlow anomaly detection model includes: feature extractor, Cross-Scale Convolution module, Flow module, and fusion module;

[0011] A feature extractor configured to: extract a plurality of resolution feature maps from the product image data;

[0012] The Cross-Scale Convolution module is configured to: superimpose several resolution feature maps on each other in the channel dimension and output several fused feature maps;

[0013] The Flow module is configured to: based on several resolution feature maps and several fusion feature maps, perform secondary feature extraction on each feature map through flow operation, and output several deep-level feature maps;

[0014] The fusion module is configured to: fuse several deep-level feature maps to output a single-channel feature map; and use the pixel values ​​of the pixels of the single-channel feature map as an abnormality score indicator.

[0015] In the above technical solution, the traditional FastFlow is a Normalizing Flow model. It uses a fully convolutional network as a subnet, which can maintain the relative position of the space and solve the problem that the original Normalizing Flow model flattens the two-dimensional input features into a one-dimensional vector to estimate the distribution and destroys the inherent spatial position relationship of the two-dimensional image. However, when FastFlow uses features of different resolutions, it only obtains the log-likelihood of each resolution separately, and fails to use the fusion information of different resolutions to enrich the log-likelihood of the image features. This case improves FastFlow and integrates the anomaly detection models of multiple categories of products using a classification model, providing a defect anomaly detection method for a collection of multiple categories of products. Specifically, based on the FastFlow model, the Cross-Scale Convolution Module of CS-Flow is introduced for improvement, and the addition is changed to channel superposition, so as to fuse the feature information of different resolutions, and then input it into Flow together with the original features to obtain the log-likelihood of richer image features. In this case, the Cross-Scale Convolution Module is added to the anomaly detection model, and the fusion information of different resolutions is used to enrich the acquisition of anomalies. In addition, a classification model is used to integrate the anomaly detection models of multiple types of products, and the corresponding models can be automatically called for anomaly detection. This method can save quality inspection costs. One quality inspection machine can be used for quality inspection of different products or different parts of products. In addition, when the product of the production line or the quality inspection target is changed, there is no need to manually change the model.

[0016] In some embodiments, classification is performed based on the image data, including:

[0017] The labels of the image data are matched with the pre-built label list, and the image data is classified according to the matching results.

[0018] In the above technical solution, a product name variable can be defined and initialized to a null value. A product name list can be defined, which contains all product names for which the anomaly detection model has been trained. When inputting an image, the product name variable is assigned a product name, and the name belongs to the name in the product name list, then the anomaly detection model of the corresponding name is directly called for anomaly detection.

[0019] In some embodiments, classifying based on the image data further includes:

[0020] Match the labels of the image data with the pre-built label list, and classify the image data according to the matching results;

[0021] If the match is unsuccessful, the image data is input into a pre-trained image classification model, and the label corresponding to the image data is output;

[0022] The image data is classified based on the label.

[0023] In the above technical solution, if no new product name is assigned when inputting a picture or the assigned product name is not in the list, the input is first passed through the classification model for product identification. After obtaining the corresponding product name, the corresponding anomaly detection model is called for anomaly detection.

[0024] In some embodiments, the Cross-Scale Convolution module is specifically used to:

[0025] Perform convolution dimensionality reduction on several resolution feature maps respectively, and unify the number of feature channels;

[0026] Apply the LeakyReLU activation function to each feature map with unified channel number;

[0027] After activation by the LeakyReLu function, feature maps of different resolutions are upsampled or downsampled to match the size of other feature maps;

[0028] The upsampled or downsampled feature maps are channel-superimposed with feature maps of other resolutions to obtain multiple groups of fused feature maps;

[0029] Adaptively weight multiple groups of fused feature maps to obtain the final fused feature map.

[0030] In the above technical solution, the processing of input features of different resolutions is realized through multiple convolutional layers, and each layer performs dimensionality reduction processing on features of different resolutions. Adjusting the number of channels of features of different resolutions to a fixed value can make different feature maps have the same dimension in the subsequent fusion step, which is convenient for operation. By increasing the nonlinearity of the model through the LeakyReLu activation function, some negative axis values ​​can be retained so that the information of the negative axis will not be completely lost. By retaining the negative axis information, Leaky ReLU increases the nonlinearity of the model, enabling the model to learn more complex feature representations and improve the expressiveness of the model. Feature maps of different resolutions are matched to the size of other feature maps by upsampling (increasing the spatial dimension) or downsampling (reducing the spatial dimension), and then merged by channel superposition (concatenation) to retain feature information of different scales. Based on multiple sets of fused features, the importance of each set of fused features in the final output is determined by adaptive weighting (such as learned weights). This weighting can be a simple linear combination or a weighting based on a more complex mechanism, such as an attention mechanism (this point will be explained in subsequent embodiments and will not be repeated here). The feature fusion strategy of the above solution can help the model capture and integrate information at different scales, thereby improving the performance of the model. Especially in the field of anomaly detection, this technical solution realizes the effective fusion of multi-scale features and enhances the model's ability to integrate information at different scales, which is very helpful for improving the performance of the model in visual tasks.

[0031] In some embodiments, the Flow module is specifically used to perform the following steps on each resolution feature map and fusion feature map:

[0032] The input several resolution feature maps and several fusion feature maps are subjected to channel shuffling operation to shuffle the channel order of the original feature maps. When the channels are shuffled, each feature map is multiplied by a global coefficient. After the channels are shuffled, the feature maps are divided into feature 1 and feature 2 according to the number of channels c, and the number of channels of each feature is c / 2.

[0033] Feature 1 is sequentially processed through convolution, ReLU activation function, and convolution, with the number of channels kept at c / 2; the processing result of feature 1 is copied as feature 3 and feature 4; if the convolution is dimensioned, the feature of the number of channels before indexing c / 2 is used as feature 3, and the feature of the number of channels after indexing c / 2 is used as feature 4; feature 4 is multiplied with feature 2 through the tanh activation function, and then added to feature 3 after exponential transformation to obtain the result of feature 1;

[0034] Feature 2 is sequentially processed through convolution, ReLU activation function, and convolution, with the number of channels kept at c / 2. The processing result of feature 2 is copied as feature 5 and feature 6. If the convolution is dimensioned, the feature of the number of channels before indexing c / 2 is used as feature 5, and the feature of the number of channels after indexing c / 2 is used as feature 6. Feature 6 is multiplied with feature 1 through the tanh activation function, and then added to feature 5 after exponential transformation to obtain the result of feature 2.

[0035] The results of feature 1 and feature 2 are channel-superimposed to obtain a deep feature map.

[0036] In the above technical solution, the channel order of the input features is disrupted to ensure that different features have the opportunity to perform different operations in subsequent flow operations, thereby increasing the diversity and learning ability of the model. When the channel is disrupted, the feature will be multiplied by a global coefficient, which is a variable that can be continuously adjusted and optimized as the model learns. By adjusting the global coefficient, the representation of the feature can be further optimized, so that the model can better adapt to the training data (this point will be explained in the subsequent embodiments and will not be repeated here). After the channel is disrupted, the feature is divided into 2 parts according to the number of channels c, and the number of channels of each feature is c / 2, in preparation for subsequent feature processing and fusion operations, so that each feature can be processed independently. Feature 1 undergoes convolution, ReLU activation function, and convolution in sequence, and the number of channels remains at c / 2. The local information of the feature is extracted through convolution and nonlinear activation function and the nonlinear expression ability of the model is increased. The processing results of feature 1 are copied as features 3 and 4 to provide necessary input for subsequent feature fusion operations. If the convolution operation causes the number of channels to increase in dimension, the channel number feature of c / 2 before indexing is used as feature 3, and the channel number feature of c / 2 after indexing is used as feature 4, ensuring that the number of channels of feature 3 and feature 4 remain consistent, which is convenient for subsequent operations. Feature 4 is multiplied with another feature 2 obtained by cutting in half after the tanh activation function, and then added to feature 3 after exponential transformation to obtain the result of the first half. Nonlinearity is introduced through the tanh activation function and exponential transformation, and feature fusion is achieved through feature multiplication and addition to enhance the expression ability of the model. The second half performs the same operation as the first half, except that the object of feature multiplication after tanh activation is changed to feature 1 to obtain the result of the second half, achieving the same feature fusion effect as the first half, further enhancing the expression ability of the model. Finally, the feature fusion results of the first and second halves are integrated to obtain the final fusion feature. The above technical solution aims to enhance the model's ability to express and learn features through feature processing and fusion operations, especially when processing data with complex structures and multi-scale information. By introducing nonlinear activation functions, feature fusion and global coefficient adjustment, the model can better capture and utilize information in the data.

[0037] In some embodiments, the fusion module is specifically used to:

[0038] Square the value of each pixel on each deep feature map, superimpose all deep feature maps, calculate the mean of each pixel value, and obtain a single-channel feature map;

[0039] Multiply the pixel values ​​on the single-channel feature map by -0.5, then perform an exponential transformation on each value, negate the value of the entire single-channel feature map, and then upsample to the image data size;

[0040] The pixel value of the pixel point of the single-channel feature map is used as the abnormal score indicator.

[0041] In the above technical solution, by squaring and averaging the values ​​of the feature map, the model can strengthen the important information in the feature map and reduce the redundant information between different channels, thereby obtaining a more representative feature representation. At the same time, the squaring operation will amplify the outliers in the feature map, making the abnormal area easier to detect in the subsequent mean calculation. The exponential transformation and multiplication by -0.5 operations help to normalize the data, making the range of feature values ​​more suitable for anomaly detection. Converting the multi-channel feature map to a single-channel feature map simplifies the calculation, reduces the complexity of the model, and retains enough information for effective anomaly detection. The upsampling operation increases the resolution of the feature map to the model input size, which helps to locate the abnormal area more accurately in space. The above technical solution enables the model to be better generalized to different data sets and anomaly types. And the single-channel feature map finally generated can be used as an anomaly score map to intuitively display the degree of abnormality of each pixel, which is convenient for subsequent analysis and processing. The above scheme improves the expressiveness of the features, enhances the sensitivity of the model to anomalies, and retains the spatial resolution through upsampling, ultimately achieving efficient and accurate anomaly detection.

[0042] In some embodiments, the pixel value of the pixel point of the single-channel feature map is used as an abnormal score indicator, specifically: the maximum abnormal score of all the pixel points of the single-channel feature map is used as the first abnormal score; the pixel value of the pixel point is used as the second abnormal score corresponding to the pixel point;

[0043] Setting an anomaly score threshold, and comparing the first anomaly score, and / or the second anomaly score, with the anomaly score threshold;

[0044] If the first anomaly score, and / or the second anomaly score, is less than the threshold, the image is deemed to be a normal image, and / or there is no abnormal region in the image;

[0045] If the first anomaly score, and / or the second anomaly score, is greater than a threshold, the image is determined to be an abnormal image, and / or an abnormal region exists in the image;

[0046] In the above technical solution, after obtaining the anomaly score, it is necessary to determine whether the input is abnormal and the range of the anomaly. Therefore, it is necessary to set an anomaly score threshold and make a judgment based on this threshold. The anomaly detection model can output the anomaly score of each pixel. Generally, the maximum anomaly score of all pixels in an image is used as the anomaly score of the image. The threshold can be set according to the maximum and mean values ​​of the anomaly scores of the training set, or a validation set data can be divided and set using the results of the validation set. If the anomaly score of the entire image is less than the threshold, the image is considered to be a normal image, and if it is greater than the threshold, it is considered to be an abnormal image; similarly, if the anomaly score of a pixel is less than the threshold, it is considered to be a normal area, and if it is greater than the threshold, it is considered to be an abnormal area.

[0047] According to another aspect of the present invention, a defect anomaly detection device for multiple types of products is provided, comprising the following modules connected in sequence:

[0048] Acquisition module: used to acquire the image data of the product to be inspected and classify it based on the image data;

[0049] Anomaly detection module: used to call the pre-trained FastFlow anomaly detection model corresponding to the classification result based on the classification result; the image data is used as the input of the FastFlow anomaly detection model, and the FastFlow anomaly detection model outputs the anomaly score corresponding to the image data based on the input image data;

[0050] Judgment module: used to judge whether the product is abnormal based on the comparison between the abnormality score and the preset threshold;

[0051] Among them, the FastFlow anomaly detection model includes: feature extractor, Cross-Scale Convolution module, Flow module, and fusion module;

[0052] A feature extractor configured to: extract a plurality of resolution feature maps from the product image data;

[0053] The Cross-Scale Convolution module is configured to: superimpose several resolution feature maps on each other in the channel dimension and output several fused feature maps;

[0054] The Flow module is configured to: based on several resolution feature maps and several fusion feature maps, perform secondary feature extraction on each feature map through flow operation, and output several deep-level feature maps;

[0055] The fusion module is configured to: fuse several deep-level feature maps to output a single-channel feature map; and use the pixel values ​​of the pixels of the single-channel feature map as an abnormality score indicator.

[0056] In the above technical solution, in order to better use the above method, the present application proposes a defect anomaly detection device that integrates multiple types of products, each module corresponds to each step of the above method, and its specific principles have been described above and will not be repeated here.

[0057] According to another aspect of the present invention, there is provided a defect anomaly detection device for a collection of multiple types of products, comprising: at least one processor and a memory in communication with the at least one processor;

[0058] 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 so that the at least one processor can perform the above method.

[0059] In the above technical solution, in order to better run and process the method, the above method is stored in a memory, and the stored method is executed by a processor. It should be noted that the principle and effect of each step have been described above and will not be described in detail here.

[0060] According to another aspect of the present invention, a computer-readable storage medium is provided, storing a computer program, wherein the computer program implements the above method when executed by a processor.

[0061] In the above technical solution, in order to better run and use the method, the above method is stored in a computer-readable storage medium, and the above method is implemented using a processor. It should be noted that the principle and effect of each step have been described above and will not be described in detail here. BRIEF DESCRIPTION OF THE DRAWINGS

[0062] 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 work.

[0063] Figure 1 It is a flow chart of an embodiment of a method for detecting defects and anomalies of multiple types of products according to the present invention;

[0064] Figure 2 1 is a schematic diagram of the structure of a Cross-Scale Convolution module of an embodiment of a method for detecting defects and anomalies of multiple types of products of the present invention;

[0065] Figure 3 It is a schematic diagram of the structure of the Flow module of an embodiment of the method for detecting defects and anomalies of multiple types of products of the present invention;

[0066] Figure 4 It is a flow operation process diagram of an embodiment of a method for detecting defects and anomalies of multiple types of products of the present invention;

[0067] Figure 5 It is a general schematic diagram of an embodiment of a method for detecting defects and anomalies of multiple types of products of the present invention;

[0068] Figure 6 It is a structural schematic diagram of an embodiment of a device for detecting defects and anomalies of multiple types of products according to the present invention. DETAILED DESCRIPTION

[0069] The present invention will be further described in detail below in conjunction with the accompanying drawings and examples. It is particularly noted that the following examples are only used to illustrate the present invention, but are not intended to limit the scope of the present invention. Similarly, the following examples are only partial embodiments of the present invention rather than all embodiments, and all other embodiments obtained by those of ordinary skill in the art without creative work are within the scope of protection of the present invention.

[0070] The present invention provides a defect anomaly detection method for multiple types of products, which can save quality inspection costs. One quality inspection machine can be used for quality inspection of different products or different parts of products, and when the product of the production line or the quality inspection target is changed, there is no need to manually replace the model.

[0071] Embodiment 1

[0072] See also Figure 1 , a defect anomaly detection method for a collection of multiple types of products, the method comprising:

[0073] A. Obtain image data of the product to be inspected and classify it based on the image data;

[0074] In this embodiment, two sets of identification schemes are set for identification, which are as follows:

[0075] Solution 1: Match the label of the image data with the pre-built label list and classify the image data according to the matching results. This solution defines a product name variable and initializes it to a null value. It also defines a product name list that contains all the product names that have been trained with the anomaly detection model. When inputting an image, the product name variable is assigned a product name, and the name belongs to the name in the product name list, then the anomaly detection model of the corresponding name is directly called for anomaly detection.

[0076] Solution 2: Match the label of the image data with the pre-built label list, and classify the image data according to the matching result; if the match is unsuccessful, input the image data into a pre-trained image classification model, output the label corresponding to the image data, and classify the image data based on the label. In this solution, if no new product name is assigned when inputting the picture or the assigned product name is not in the list, the input is first passed through the classification model for product identification, and after obtaining the corresponding product name, the corresponding anomaly detection model is called for anomaly detection.

[0077] B. Based on the classification result, a pre-trained FastFlow anomaly detection model corresponding to the classification result is called; the image data is used as the input of the FastFlow anomaly detection model, and the FastFlow anomaly detection model outputs an anomaly score corresponding to the image data based on the input image data;

[0078] In this embodiment, the classification results include products with different processes such as top cover welding, sealing nails, and bare cells, as well as products of different models such as square shell batteries, cylindrical batteries, and blade batteries. A FastFlow anomaly detection model is pre-trained for each type of product, so that the corresponding model can be called for identification according to the type in this step.

[0079] In this embodiment, the FastFlow anomaly detection model includes: a feature extractor, a Cross-Scale Convolution module, a Flow module, and a fusion module;

[0080] A feature extractor configured to: extract a plurality of resolution feature maps from the product image data;

[0081] The Cross-Scale Convolution module is configured to: superimpose several resolution feature maps on each other in the channel dimension and output several fused feature maps; the module is specifically used to: perform convolution dimensionality reduction on several resolution feature maps respectively and unify the number of feature channels; apply the LeakyReLU activation function to each feature map after the channel number is unified; after activation by the LeakyReLu function, upsample or downsample the feature maps of different resolutions to match the size of other feature maps; superimpose the upsampled or downsampled feature maps with the feature maps of other resolutions through channels to obtain multiple groups of fused feature maps; and adaptively weight the multiple groups of fused feature maps to obtain the final fused feature map. This module processes input features of different resolutions through multiple convolutional layers, and each layer performs dimensionality reduction processing on features of different resolutions. Adjusting the number of channels of features of different resolutions to a fixed value can make different feature maps have the same dimension in subsequent fusion steps, which is convenient for operation. By increasing the nonlinearity of the model through the LeakyReLu activation function, some negative axis values ​​can be retained, so that the information of the negative axis will not be completely lost. By retaining the negative axis information, Leaky ReLU increases the nonlinearity of the model, allowing the model to learn more complex feature representations and improve the model's expressiveness. Feature maps of different resolutions are matched to the size of other feature maps by upsampling (increasing the spatial dimension) or downsampling (reducing the spatial dimension), and then merged by channel superposition (concatenation) to retain feature information of different scales. Based on multiple sets of fused features, the importance of each set of fused features in the final output is determined by adaptive weighting (such as learned weights). This weighting can be a simple linear combination or a weighting based on a more complex mechanism, such as an attention mechanism (this point will be explained in the subsequent embodiments and will not be repeated here). The feature fusion strategy of the above scheme can help the model capture and integrate information at different scales, thereby improving the performance of the model. Especially in the field of anomaly detection, this technical solution realizes the effective fusion of multi-scale features and enhances the model's ability to integrate information of different scales, which is very helpful for improving the performance of the model in visual tasks.

[0082] The Flow module is configured to: based on several resolution feature maps and several fusion feature maps, perform secondary feature extraction on each feature map through flow operation, and output several deep-level feature maps; the module is specifically used to perform the following steps on each resolution feature map and fusion feature map:

[0083] The input feature maps of several resolutions and several fusion feature maps are shuffled to shuffle the channel order of the original feature maps. When the channels are shuffled, each feature map is multiplied by a global coefficient. After the channels are shuffled, the feature maps are divided into feature 1 and feature 2 according to the number of channels c, and the number of channels of each feature is c / 2. Feature 1 is sequentially subjected to convolution, ReLU activation function, and convolution, and the number of channels remains c / 2. The processing results of feature 1 are copied as features 3 and 4. If the convolution dimension is increased, the channel number feature of c / 2 before indexing is used as feature 3, and the channel number feature of c / 2 after indexing is used as feature 4. Feature 4 is subjected to tanh activation function and Feature 2 is multiplied, and then after exponential transformation, it is added to feature 3 to obtain the result of feature 1; feature 2 is sequentially subjected to convolution, ReLU activation function, and convolution, and the number of channels is kept at c / 2; the processing result of feature 2 is copied as feature 5 and feature 6; if the convolution is dimensioned, the channel number feature of c / 2 before indexing is used as feature 5, and the channel number feature of c / 2 after indexing is used as feature 6; feature 6 is multiplied with feature 1 through the tanh activation function, and then after exponential transformation, it is added to feature 5 to obtain the result of feature 2; the result of feature 1 and the result of feature 2 are channel-superimposed to obtain a deep feature map. This module shuffles the channel order of the input features to ensure that different features have the opportunity to perform different operations in subsequent flow operations, thereby increasing the diversity and learning ability of the model. When the channels are shuffled, the features will be multiplied by a global coefficient, which is a variable that can be adjusted and optimized as the model learns. By adjusting the global coefficient, the representation of the features can be further optimized, so that the model can better adapt to the training data (this point will be explained in the subsequent embodiments and will not be repeated here). After the channels are shuffled, the features are divided into two equal parts according to the number of channels c, and the number of channels of each feature is c / 2, in preparation for the subsequent feature processing and fusion operations, so that each feature can be processed independently. Feature 1 is sequentially subjected to convolution, ReLU activation function, and convolution, and the number of channels is kept at c / 2. The local information of the feature is extracted through convolution and nonlinear activation function and the nonlinear expression ability of the model is increased. The processing result of feature 1 is copied as feature 3 and feature 4 to provide the necessary input for the subsequent feature fusion operation. If the convolution operation causes the number of channels to increase in dimension, the channel number feature of c / 2 before indexing is used as feature 3, and the channel number feature of c / 2 after indexing is used as feature 4 to ensure that the number of channels of feature 3 and feature 4 is consistent, which is convenient for subsequent operations. Feature 4 is multiplied with the other feature 2 obtained by cutting in half after the tanh activation function, and then added to feature 3 after exponential transformation to obtain the result of the first half. Nonlinearity is introduced through the tanh activation function and exponential transformation, and feature fusion is achieved through feature multiplication and addition to enhance the expression ability of the model.The second half performs the same operation as the first half, except that the object of feature multiplication after tanh activation is changed to feature 1, and the result of the second half is obtained, achieving the same feature fusion effect as the first half, further enhancing the expression ability of the model. Finally, the feature fusion results of the first and second halves are integrated to obtain the final fusion feature. The above technical solution aims to enhance the model's ability to express and learn features through feature processing and fusion operations, especially when processing data with complex structures and multi-scale information. By introducing nonlinear activation functions, feature fusion and global coefficient adjustment, the model can better capture and utilize information in the data.

[0084] A fusion module is configured to: fuse several deep-level feature maps and output a single-channel feature map; use the pixel value of the single-channel feature map pixel as an anomaly score indicator. The module is specifically used to: square each pixel value on each deep-level feature map, superimpose all deep-level feature maps, calculate the mean of each pixel value, and obtain a single-channel feature map; multiply the pixel value on the single-channel feature map by -0.5, then perform an exponential transformation on each value, and negate the value of the entire single-channel feature map, and then upsample to the image data size; use the pixel value of the single-channel feature map pixel as an anomaly score indicator. By squaring and averaging the values ​​of the feature map, the model can strengthen the important information in the feature map and reduce the redundant information between different channels, thereby obtaining a more representative feature representation. At the same time, the squaring operation will amplify the outliers in the feature map, making the abnormal area easier to detect in the subsequent mean calculation. The exponential transformation and multiplication by -0.5 operations help to normalize the data, making the range of feature values ​​more suitable for anomaly detection. Converting a multi-channel feature map to a single-channel feature map simplifies the calculation and reduces the complexity of the model, while retaining enough information for effective anomaly detection. The upsampling operation increases the resolution of the feature map to the model input size, which helps to locate the abnormal area more accurately in space. The above technical solution enables the model to better generalize to different data sets and anomaly types. And the final generated single-channel feature map can be used as an anomaly score map to intuitively display the degree of abnormality of each pixel, which is convenient for subsequent analysis and processing. The above scheme improves the expressiveness of features, enhances the sensitivity of the model to anomalies, and retains spatial resolution through upsampling, ultimately achieving efficient and accurate anomaly detection.

[0085] C. Determine whether the product is abnormal based on the comparison between the abnormality score and the preset threshold;

[0086] In this embodiment, the pixel value of the pixel of the single-channel feature map is used as an abnormal score indicator, specifically: the maximum abnormal score of all pixels of the single-channel feature map is used as the first abnormal score; the pixel value of the pixel is used as the second abnormal score corresponding to the pixel; the abnormal score threshold is set, and the first abnormal score, and / or the second abnormal score, is compared with the abnormal score threshold; if the first abnormal score, and / or the second abnormal score, is less than the threshold, the image is considered to be a normal image, and / or there is no abnormal area in the image; if the first abnormal score, and / or the second abnormal score, is greater than the threshold, the image is considered to be an abnormal image, and / or there is an abnormal area in the image; after obtaining the abnormal score, it is necessary to determine whether the input is abnormal and the range of the abnormality, therefore, it is necessary to set an abnormal score threshold, and make a judgment based on this threshold. The abnormal detection model can output the abnormal score of each pixel, and generally the maximum abnormal score of all pixels in an image is used as the abnormal score of the image. The threshold can be set according to the maximum value and mean value of the abnormal score of the training set, or a validation set data can be divided and set using the results of the validation set. If the anomaly score of the entire image is less than the threshold, the image is considered to be a normal image, and if it is greater than the threshold, it is considered to be an abnormal image; similarly, if the anomaly score of a pixel is less than the threshold, it is considered to be a normal area, and if it is greater than the threshold, it is considered to be an abnormal area.

[0087] In this embodiment, the traditional FastFlow is a Normalizing Flow model, which uses a fully convolutional network as a subnet and can maintain the relative position of the space, solving the problem that the original Normalizing Flow model flattens the two-dimensional input features into a one-dimensional vector to estimate the distribution and destroys the inherent spatial position relationship of the two-dimensional image. However, when FastFlow uses features of different resolutions, it only obtains the log-likelihood for each resolution separately, and fails to use the fusion information of different resolutions to enrich the log-likelihood of the image features. This case improves FastFlow, and uses a classification model to integrate the anomaly detection models of multiple categories of products, providing a defect anomaly detection method for a collection of multiple categories of products. Specifically, based on the FastFlow model, the Cross-Scale Convolution Module of CS-Flow is introduced for improvement, and the addition is changed to channel superposition, so as to fuse the feature information of different resolutions, and then input it into Flow together with the original features to obtain the log-likelihood of richer image features. In this case, the Cross-Scale Convolution Module is added to the anomaly detection model, and the fusion information of different resolutions is used to enrich the acquisition of anomalies. In addition, a classification model is used to integrate the anomaly detection models of multiple types of products, and the corresponding models can be automatically called for anomaly detection. This method can save quality inspection costs. One quality inspection machine can be used for quality inspection of different products or different parts of products. In addition, when the product of the production line or the quality inspection target is changed, there is no need to manually change the model.

[0088] In order to better explain the solution of the present invention, the following will be described in detail:

[0089] In view of the problems described in the background technology, the present invention improves FastFlow and integrates the anomaly detection models of multiple types of products using a classification model, thereby providing a defect anomaly detection method for multiple types of products. The method comprises the following steps:

[0090] S1. Obtain normal image data of products that need abnormality detection, and classify them according to different products or components;

[0091] S2. Clean the data and remove abnormal images. Abnormal images can be used for later testing, and images with incorrect category labels can be relabeled. After data cleaning is completed, scale the image to the model input size of 256×256, or keep the original image aspect ratio, scale the long side to 256, and fill the short side with 0 values ​​to 256 pixels. The processing method of input images should be consistent. Training images can be processed while training, or they can be scaled and saved in advance, thereby reducing the memory used to store data during model training and reducing the time to read images;

[0092] S3. Build an anomaly detection model based on the FastFlow model, introduce the Cross-Scale Convolution Module of CS-Flow for improvement, and change the addition into channel superposition to fuse feature information of different resolutions, and then input it into Flow together with the original features to obtain the log-likelihood of richer image features.

[0093] S31. First, the input is standardized by using the normalized pixel mean and variance of ImageNet, a large image benchmark database covering 1,000 object categories in many fields. The mean values ​​of the three channels of ImageNet are 0.485, 0.456, and 0.406, and the variances are 0.229, 0.224, and 0.225, respectively. The normalization formula is:

[0094]

[0095] in, Indicates that the input corresponds to after normalization c The value of the channel, Indicates the value of the input corresponding to the c channel, Indicates ImageNet corresponding c The mean of the channel, Indicates ImageNet corresponding c Variance of the channel.

[0096] S32. The input is normalized and passed to FastFlow. FastFlow first passes through a feature extractor. The feature extractor is a basic network, generally a ResNet or Vision Transformer (ViT) structure, which can be ResNet18, Wide-ResNet50-2, CaiT-M48, DeiT, etc. If ViT is used as a feature extractor, only the features of a certain layer in the network are used to input into Flow. If ResNet is used, the features output by the first three residual layers are selected and input into Flow. The choice of feature extractor can be determined according to the actual usage scenario and device performance. ResNet18 is a relatively lightweight network. The present invention takes Wide-ResNet50-2 as an example. Wide-ResNet50-2 expands the output features of the first two 1×1 convolutional layers and 3×3 convolutional layers in the bottleneck structure of the ResNet50 residual layer to 2 times.

[0097] Wide-ResNet50-2 consists of 1 convolutional layer with 64 convolution kernels, a kernel size of 7×7, and a stride of 2; 1 maximum pooling layer with a size of 3×3 and a stride of 2; residual layer 1 consisting of 3 layers of Bottleneck with a width of 128; residual layer 2 consisting of 4 layers of Bottleneck with a width of 256; residual layer 3 consisting of 6 layers of Bottleneck with a width of 512; residual layer 4 consisting of 3 layers of Bottleneck with a width of 1024. Among them, the Bottleneck with a width of 128 in the residual layer 1 sequentially includes 1 convolution layer with 128 convolution kernels, a convolution kernel size of 1×1, and a stride of 1, 1 convolution layer with 128 convolution kernels, a convolution kernel size of 3×3, and a stride of 1, and 1 convolution layer with 256 convolution kernels, a convolution kernel size of 1×1, and a stride of 1. The input of the Bottleneck is dimensionally increased to 256 through the convolution with a convolution kernel size of 1×1 and a stride of 1, and the result of this layer is added to the result of this layer to obtain the final output of the Bottleneck. The first layer of Bottleneck with a width of 256 (or 512 or 1024) in the residual layer 2 (or 3 or 4) includes one layer of convolution kernels with 256 (or 512 or 1024), a convolution kernel size of 1×1, and a stride of 1, one layer of convolution kernels with 256 (or 512 or 1024), a convolution kernel size of 3×3, and a stride of 2, one layer of convolution kernels with 512 (or 1024 or 2048), a convolution kernel size of 1×1, and a stride of 1, and the input of the Bottleneck is dimensionally increased to 512 (or 1024 or 2048) through the convolution kernel size of 1×1 and a stride of 2, and the result of the convolution kernel size of 1×1 and a stride of 2 is added to the result of the layer to obtain the final output of the Bottleneck. The convolution kernel stride of the subsequent layers of Bottleneck can be changed to 1. Each convolutional layer is followed by batch normalization and Relu activation. The overall parameters of the Wide-ResNet50-2 network are shown in Table 1, where the square brackets in the network layer parameters of the residual layer represent a bottleneck; the parameters of the convolution operation similar to "64, 7×7, 2" respectively represent the number of convolution kernels of 64, the size of the convolution kernel of 7×7, and the step size of 2; the "3×3, 2" of the pooling layer respectively represents the pooling layer size and step size. The output features of residual layers 1, 2, and 3 are selected as the input of subsequent operations.

[0098] S33, input the features obtained by the feature extractor into the Cross-Scale Convolution Module to fuse the feature information of different resolutions. The specific operation is as follows Figure 2As shown in the figure, firstly, the features of the three resolutions are convolved to reduce the dimension, and the number of channels is reduced to a uniform 256. Then, the nonlinearity of the model is increased by the LeakyReLu activation function. The formula of the LeakyReLu activation function is as follows:

[0099]

[0100] in, α is a very small constant, which retains some values ​​of the negative axis so that the information of the negative axis will not be completely lost. After LeakyReLu activation, each resolution feature needs to be convolved again and channel-superimposed with the features of other resolution features after upsampling or downsampling. After convolution of high-resolution features, channel-superimpose with the features of upsampled medium-resolution features; after convolution of medium-resolution features, channel-superimpose with the features of downsampled high-resolution features and the features of upsampled low-resolution features; after convolution of low-resolution features, channel-superimpose with the features of downsampled medium-resolution features. The upsampling method is 2x bilinear interpolation plus 1 convolution with a step size of 1, and the downsampling method is convolution with a step size of 2. After obtaining the three sets of fused features, adaptive weighting operation needs to be performed to obtain the final fused features.

[0101] Table 1. Wide-ResNet50-2 network overall parameter details

[0102]

[0103] Adaptive weighting means that as the network learns and updates, the corresponding weight coefficient will also be continuously adaptively adjusted and automatically adjusted to the optimal state. The initial weight coefficient of each fusion feature is 0, and the fusion feature is not used by default. The network can automatically call the fusion feature with the appropriate weight for subsequent calculations as it learns.

[0104] S34, the obtained fusion features and original features are respectively input into the subsequent Flow module to obtain their respective results. Figure 3 As shown in the figure, it is composed of 3×3 and 1×1 flow operations alternating, including 4 3×3 and 4 1×1 flow operations. Among them, 3×3 and 1×1 refer to the convolution kernel size of the convolution layer in the flow operation is 3×3 or 1×1. The specific process of the flow operation is as follows Figure 4As shown in the figure, the input feature is first subjected to a channel shuffle operation to shuffle the channel order of the original feature, so that different features have the opportunity to perform different operations each time the flow operation is performed. After the channels are shuffled, the features are divided into two equal parts according to the number of channels c, and the number of channels in each feature is c / 2. The first feature 1 first undergoes convolution, ReLu activation function, and convolution in sequence. In this process, the number of channels is kept constant by default, and the number of channels is kept at c / 2. At this time, the results of this process are copied as features 3 and 4. If the convolution is dimensioned, the feature with the number of channels c / 2 before indexing is used as feature 3, and the feature with the number of channels c / 2 after indexing is used as feature 4. Feature 4 is multiplied by the tanh activation function with the other feature 2 obtained by cutting in half, and then added to feature 3 after exponential transformation to obtain the result of the first half. The second half performs the same operation, except that the object of feature multiplication after tanh activation is changed to feature 1, and finally the result of the first half is channel superimposed with the result of the second half to obtain the final output. Among them, when the channel is shuffled, the feature will be multiplied by a global coefficient, and the calculation formula of the coefficient is as follows:

[0105]

[0106] This coefficient is a variable that can be adjusted and optimized as the model learns. It is a learnable parameter, which is initialized to 1 by default. The result of the global coefficient acting on the feature is used for subsequent calculations. When the model is back-propagated, the learnable parameter will be adjusted to adjust the global coefficient.

[0107] S34. After the features obtain their respective results through the Flow module, they need to be further fused to obtain the final result of the model. First, the values ​​on the feature map are squared. Since the feature map has multiple channels, a mean is calculated for each pixel, that is, the values ​​of different channels of each pixel are averaged to obtain a feature map with a channel number of 1. Then the values ​​on the feature map are multiplied by -0.5, and then each value is exponentially transformed; finally, the value of the entire feature map is negative, and then upsampled to the model input size. The formula is expressed as follows:

[0108]

[0109] in, represents upsampling, Indicates the mean value, subscript Indicates the number of channels, and Respectively represent the row and column where the pixel is located. After the above operations, each set of features from the Flow module has been unified in size, and then the mean of each pixel is calculated for these features to obtain a feature with a channel number of 1 and a resolution of the input size as the final output. The value on the output can be used as an anomaly score indicator. The larger the value, the greater the possibility of anomaly.

[0110] S35. After obtaining the anomaly score, it is necessary to determine whether the input is abnormal and the range of the anomaly. Therefore, it is necessary to set an anomaly score threshold and make a judgment based on the threshold. The anomaly detection model can output the anomaly score of each pixel. Generally, the maximum anomaly score of all pixels in an image is used as the anomaly score of the image. The threshold can be set according to the maximum and mean values ​​of the anomaly scores of the training set, or a validation set data can be divided and set using the results of the validation set. If the anomaly score of the entire image is less than the threshold, the image is considered to be a normal image. If it is greater than the threshold, it is considered to be an abnormal image. Similarly, if the anomaly score of a pixel is less than the threshold, it is considered to be a normal area. If it is greater than the threshold, it is considered to be an abnormal area.

[0111] S4. After all products have trained the above anomaly detection models, build a product classification model and bring these anomaly detection models together.

[0112] S41. To build a product classification model, a data set must be constructed first. Each product image in the above cleaned pictures is assigned a corresponding category label, and then divided into a training set and a test set in a ratio of 5:5, 7:3 or 8:2 to verify the performance of the classification model.

[0113] S42, data processing is also required before input into the training model, which is the same as the processing method S2 for anomaly detection. And the standardization operation is also consistent with its method S31. After standardization, it is input into the classification network for classification. The classification network can use the above-mentioned Wide-ResNet50-2, or the more lightweight ResNet18 or MobileNet. The category with the highest probability after softmax of the result from the fully connected layer of the classification network is the corresponding category of the input.

[0114] S5. After training the classification network, connect the classification model with the anomaly detection model during inference to obtain a defect anomaly detection method that collects multiple categories of products. First, define a product name variable and initialize it to a null value. And define a product name list that contains all product names that have trained the anomaly detection model. If a product name is assigned to the product name variable when inputting the image, and the name belongs to the name in the product name list, the input skips the classification model and directly calls the anomaly detection model of the corresponding name for anomaly detection; if a new product name is not assigned when inputting the image or the assigned product name is not in the list, the input first passes through the classification model for product identification, and after obtaining the corresponding product name, the corresponding anomaly detection model is called for anomaly detection. The specific process is as follows: Figure 5 As shown, the abnormal mask in the figure refers to the identified defect abnormal area.

[0115] The present invention adds a Cross-Scale Convolution Module to the anomaly detection model, and uses fusion information of different resolutions to enrich the acquisition of anomalies. In addition, a classification model is used to integrate the anomaly detection models of multiple types of products, and the corresponding models can be automatically called for anomaly detection. This method can save quality inspection costs. The quality inspection of different products or different parts of products can use one quality inspection machine, and when the product of the production line or the quality inspection target is changed, there is no need to manually change the model.

[0116] Embodiment 2

[0117] See also Figure 6 , a defect anomaly detection device for multiple types of products, including the following modules connected in sequence:

[0118] Acquisition module: used to acquire the image data of the product to be inspected and classify it based on the image data;

[0119] Anomaly detection module: used to call the pre-trained FastFlow anomaly detection model corresponding to the classification result based on the classification result; the image data is used as the input of the FastFlow anomaly detection model, and the FastFlow anomaly detection model outputs the anomaly score corresponding to the image data based on the input image data;

[0120] Judgment module: used to judge whether the product is abnormal based on the comparison between the abnormality score and the preset threshold;

[0121] Among them, the FastFlow anomaly detection model includes: feature extractor, Cross-Scale Convolution module, Flow module, and fusion module;

[0122] A feature extractor configured to: extract a plurality of resolution feature maps from the product image data;

[0123] The Cross-Scale Convolution module is configured to: superimpose several resolution feature maps on each other in the channel dimension and output several fused feature maps;

[0124] The Flow module is configured to: based on several resolution feature maps and several fusion feature maps, perform secondary feature extraction on each feature map through flow operation, and output several deep-level feature maps;

[0125] The fusion module is configured to: fuse several deep-level feature maps to output a single-channel feature map; and use the pixel values ​​of the pixels of the single-channel feature map as an abnormality score indicator.

[0126] In this embodiment, in order to better use the method described in one of the embodiments, the present application proposes a defect anomaly detection device that combines multiple types of products. Each module corresponds to each step of the method described in one of the embodiments. The specific principles have been described above and will not be repeated here.

[0127] Embodiment 3

[0128] A defect anomaly detection device for a collection of multiple types of products includes: at least one processor and a memory that is 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 so that the at least one processor can execute the method described in one of the embodiments.

[0129] In this embodiment, in order to better run and process the method described in one of the embodiments, the above method is stored in a memory, and a processor is used to execute the stored method. It should be noted that the principle and effect of each step have been described above and will not be described in detail here.

[0130] Embodiment 4

[0131] A computer-readable storage medium stores a computer program, wherein when the computer program is executed by a processor, the method described in one of the embodiments is implemented.

[0132] In this embodiment, in order to better run and use the method described in one of the embodiments, the method described in one of the embodiments is stored in a computer-readable storage medium, and the above method is implemented using a processor. It should be noted that the principle and effect of each step have been described above and will not be described in detail here.

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

Claims

1. A defect anomaly detection method for multiple types of products, characterized in that: The method comprises: Obtain image data of products to be inspected, and perform classification based on the image data; Based on the classification result, a pre-trained FastFlow anomaly detection model corresponding to the classification result is called; the image data is used as an input of the FastFlow anomaly detection model, and the FastFlow anomaly detection model outputs an anomaly score corresponding to the image data based on the input image data; Based on the comparison between the abnormality score and the preset threshold, determine whether the product is abnormal; Among them, the FastFlow anomaly detection model includes: feature extractor, Cross-Scale Convolution module, Flow module, and fusion module; A feature extractor configured to: extract a plurality of resolution feature maps from the product image data; The Cross-Scale Convolution module is configured to: superimpose several resolution feature maps on each other in the channel dimension and output several fused feature maps; The Cross-Scale Convolution module is specifically used for: Perform convolution dimensionality reduction on several resolution feature maps respectively, and unify the number of feature channels; Apply the LeakyReLU activation function to each feature map with unified channel number; After activation by the LeakyReLu function, feature maps of different resolutions are upsampled or downsampled to match the size of other feature maps; The upsampled or downsampled feature maps are channel-superimposed with feature maps of other resolutions to obtain multiple groups of fused feature maps; Adaptively weight multiple groups of fused feature maps to obtain the final fused feature map; The Flow module is configured to: based on several resolution feature maps and several fusion feature maps, perform secondary feature extraction on each feature map through flow operation, and output several deep-level feature maps; The fusion module is configured to: fuse several deep-level feature maps to output a single-channel feature map; and use the pixel values ​​of the pixels of the single-channel feature map as an abnormality score indicator.

2. A defect anomaly detection method for multiple types of products as claimed in claim 1, characterized in that: Classification based on the image data includes: The labels of the image data are matched with the pre-built label list, and the image data is classified according to the matching results.

3. A defect anomaly detection method for multiple types of products as claimed in claim 1 or 2, characterized in that: Classification based on the image data also includes: Match the labels of the image data with the pre-built label list, and classify the image data according to the matching results; If the match is unsuccessful, the image data is input into a pre-trained image classification model, and the label corresponding to the image data is output; The image data is classified based on the label.

4. A defect anomaly detection method for multiple types of products as claimed in claim 1, characterized in that: The Flow module is specifically used to perform the following steps on each resolution feature map and fusion feature map: The input several resolution feature maps and several fusion feature maps are subjected to channel shuffling operation to shuffle the channel order of the original feature maps. When the channels are shuffled, each feature map is multiplied by a global coefficient. After the channels are shuffled, the feature maps are divided into feature 1 and feature 2 according to the number of channels c, and the number of channels of each feature is c / 2. Feature 1 is sequentially processed through convolution, ReLU activation function, and convolution, and the number of channels remains c / 2; the processing result of feature 1 is copied as feature 3 and feature 4; if the convolution is dimensioned, the channel number feature of c / 2 before indexing is used as feature 3, and the channel number feature of c / 2 after indexing is used as feature 4; Feature 4 is multiplied by feature 2 through the tanh activation function, and then added to feature 3 after exponential transformation to obtain the result of feature 1; Feature 2 is sequentially processed through convolution, ReLU activation function, and convolution, and the number of channels remains c / 2; the processing results of feature 2 are copied as features 5 and 6; if the convolution is dimensioned, the channel number feature of c / 2 before indexing is used as feature 5, and the channel number feature of c / 2 after indexing is used as feature 6; Feature 6 is multiplied by feature 1 through the tanh activation function, and then added to feature 5 after exponential transformation to obtain the result of feature 2; The results of feature 1 and feature 2 are channel-superimposed to obtain a deep feature map.

5. The defect anomaly detection method for multiple types of products as claimed in claim 1, characterized in that: The fusion module is specifically used for: Square the value of each pixel on each deep feature map, superimpose all deep feature maps, calculate the mean of each pixel value, and obtain a single-channel feature map; Multiply the pixel values ​​on the single-channel feature map by -0.5, then perform an exponential transformation on each value, negate the value of the entire single-channel feature map, and then upsample to the image data size; The pixel value of the pixel point of the single-channel feature map is used as the abnormal score indicator.

6. A defect anomaly detection method for multiple types of products as claimed in claim 1 or 5, characterized in that: The pixel value of the single-channel feature map pixel is used as the abnormal score indicator, specifically: The maximum anomaly score of all pixels of the single-channel feature map is used as the first anomaly score; the pixel value of the pixel is used as the second anomaly score corresponding to the pixel; Setting an anomaly score threshold, and comparing the first anomaly score, and / or the second anomaly score, with the anomaly score threshold; If the first anomaly score, and / or the second anomaly score, is less than the threshold, the image is deemed to be a normal image, and / or there is no abnormal region in the image; If the first anomaly score, and / or the second anomaly score, is greater than a threshold, the image is determined to be an abnormal image, and / or an abnormal region exists in the image.

7. A defect anomaly detection device for multiple types of products, characterized in that: Includes the following modules connected in sequence: Acquisition module: used to acquire the image data of the product to be inspected and classify it based on the image data; Anomaly detection module: used to call the pre-trained FastFlow anomaly detection model corresponding to the classification result based on the classification result; the image data is used as the input of the FastFlow anomaly detection model, and the FastFlow anomaly detection model outputs the anomaly score corresponding to the image data based on the input image data; Judgment module: used to judge whether the product is abnormal based on the comparison between the abnormality score and the preset threshold; Among them, the FastFlow anomaly detection model includes: feature extractor, Cross-Scale Convolution module, Flow module, and fusion module; A feature extractor configured to: extract a plurality of resolution feature maps from the product image data; The Cross-Scale Convolution module is configured to: superimpose several resolution feature maps on each other in the channel dimension and output several fused feature maps; The Cross-Scale Convolution module is specifically used for: Perform convolution dimensionality reduction on several resolution feature maps respectively, and unify the number of feature channels; Apply the LeakyReLU activation function to each feature map with unified channel number; After activation by the LeakyReLu function, feature maps of different resolutions are upsampled or downsampled to match the size of other feature maps; The upsampled or downsampled feature maps are channel-superimposed with feature maps of other resolutions to obtain multiple groups of fused feature maps; Adaptively weight multiple groups of fused feature maps to obtain the final fused feature map; The Flow module is configured to: based on several resolution feature maps and several fusion feature maps, perform secondary feature extraction on each feature map through flow operation, and output several deep-level feature maps; The fusion module is configured to: fuse several deep-level feature maps to output a single-channel feature map; and use the pixel values ​​of the pixels of the single-channel feature map as an abnormality score indicator.

8. A defect anomaly detection device for multiple types of products, characterized in that: include: at least one processor and a memory communicatively coupled to the at least one processor; 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 so that the at least one processor can execute the method as claimed in any one of claims 1 to 6.

9. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Abnormal image detection method based on self-supervised learning

    CN113344875A

  • Method for constructing receptive field self-adaptive transformer substation insulator defect detection neural network

    CN114419413A