Image anomaly detection acceleration method and system based on transformation selection
By training multiple transformations in the image anomaly detection method and selecting the most representative transformation, replacing the fully connected layer of the deep convolutional neural network, the model inference speed is significantly improved and the problem of low acceleration speed in the existing technology is solved. problem, and improves the deployment efficiency of the model on low-computation platforms.
Patent Information
- Application Number
- CN202111530314.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-14
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2041-12-14
AI Technical Summary
Existing image anomaly detection methods based on transformation learning have low model inference acceleration speed, and the inference speed is not enough when deployed on low-computation platforms. The acceleration speed of existing methods is limited and comes at the expense of model accuracy.
Through the training phase, a normal picture set of the target task is obtained, multiple transformations are performed and self-supervised training is performed, the last fully connected layer of the deep convolutional neural network is replaced with an independent linear layer and a single input activation function, and the performance of the transformation is calculated. Indicators, the most representative transformation is selected, and only this transformation is used for model inference during the inference stage.
It achieves an M-fold increase in model inference speed, solves the problem of insufficient inference speed when the model is deployed on a low-computation platform, and avoids the problem of gradient explosion and non-independence of outputs caused by multi-input activation functions.
Smart Images

Figure CN114239713B
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of digital image processing, and more specifically, relates to an image anomaly detection acceleration method and system based on transformation selection. Background Art
[0002] With the development of image processing technology and deep learning technology, the image anomaly detection method based on transform learning has become an important method for anomaly identification of massive images. The basic structure of this method uses a multi-classification architecture based on a deep convolutional neural network. First, feature learning is performed through the pre-task of transform learning, and then the final normal-abnormal binary classification score is generated through a finely designed anomaly function. When using the trained deep convolutional neural network model, an important technology is to accelerate the model with a large number of parameters in a lightweight manner, thereby improving the model inference speed and deploying it on edge computing devices.
[0003] The main technologies for accelerating model reasoning currently include: lightweight architecture design, model quantization technology, and knowledge distillation technology. The advantage of existing methods is their strong versatility, but their acceleration speed is limited to less than 8 times, and their speed increase comes at the cost of a greater loss of model accuracy.
[0004] Image anomaly detection methods based on transformation learning rely on a large number of time-consuming and complex pre-transformations. The use of a large number of transformations exponentially increases the inference time of the model obtained by the method. Summary of the invention
[0005] In view of the defects of low inference acceleration speed of the image anomaly detection method based on transformation in the prior art and the need for improvement, the present invention provides an image anomaly detection acceleration method and system based on transformation selection, which aims to accelerate the model inference speed of the image anomaly detection method by M (M>>8) times, which helps to solve the bottleneck problem of insufficient inference speed when the model is deployed on a platform with low computing power.
[0006] To achieve the above object, according to a first aspect of the present invention, a method for accelerating image anomaly detection based on transformation selection is provided, the method comprising:
[0007] Training phase:
[0008] Get a set of normal images of the target task as a training set;
[0009] Transform each image in the training set M times;
[0010] Inputting the transformed training set into the improved deep convolutional neural network in batches for self-supervised training to obtain a trained improved deep convolutional neural network, wherein the improved deep convolutional neural network replaces the fully connected layer of the last layer of the deep convolutional neural network with M independent linear layers and M single-input activation functions, and uses binary classification cross entropy for training, wherein the linear layer and the single-input activation function are connected in series to form a classifier;
[0011] Calculate the performance indicators of each transformation in the trained model;
[0012] According to the performance indicators, the most representative transformation is selected from each transformation;
[0013] Reasoning stage:
[0014] Get the target task image to be tested, perform the most representative transformation on it, input it into the trained model, and obtain the inference result.
[0015] Preferably, before transforming the image, the following processing is performed:
[0016]
[0017]
[0018] Among them, I represents the original image, I′ represents the image after the pixel value range is restricted, and I * represents the normalized image, μ represents the mean value of the image obtained from the ImageNet dataset, and σ represents the variance of the image obtained from the ImageNet dataset.
[0019] Beneficial effect: To address the gradient explosion problem in the prior art of training deep neural networks, that is, the gradient of an unprocessed image sent to the deep neural network for back propagation will be too large, resulting in training failure, the present invention limits and normalizes the pixel value range. By limiting the pixel value range and normalizing, the size of the back propagation gradient during training is indirectly reduced, thereby achieving stable training and obtaining the effect of a good model.
[0020] Preferably, the M transformations are formed by combining the Cartesian products of multiple transformations:
[0021] T={I,T f}×{I,T v-1 , T v1}×{I,T h-1 , T h1}×{I,T 90° , T 180° , T 270°}
[0022] Among them, I represents the original image, T f represents the flip transformation, T v-1 represents a translation transformation of one quarter of the image width to the left horizontally, T v1 represents a horizontal translation transformation of one quarter of the image width to the right, T h-1 represents a vertical translation transformation of one quarter of the image height upward, T h1 represents a vertical translation transformation of one quarter of the image height downward, T 90° Indicates a 90° counterclockwise rotation transformation, T 180° Represents a 180° counterclockwise rotation transformation, T 270° Represents a rotation transformation of 270° counterclockwise.
[0023] Beneficial effect: In order to solve the problem that it is difficult to pre-prepare a set of transformations with better performance in the prior art, the present invention uses the technical means of self-supervised learning. Since the self-supervised learning using transformations can better extract features in the image, the effect of using such transformations based on self-supervised learning as a preferred set of transformations is achieved.
[0024] Preferably, the single-input activation function is a Sigmoid function.
[0025] Beneficial effect: In order to solve the problem that the prior art uses multi-input activation functions, which leads to multiple outputs being non-independent, the present invention uses a single-channel activation function such as Sigmoid to replace the multi-input activation function. Since the single-input activation function will not mix the information of other inputs, the output independence of different classifiers can be achieved.
[0026] Preferably, the calculation formula of the transformation performance indicator O-measure is as follows:
[0027]
[0028] Among them, [I1,…,I N ] is the input of the same batch of pictures, N is the number of pictures in the same batch, L j () represents the jth classifier, C() is the convolution function, T k () represents the kth transformation, and Ii represents the i-th picture.
[0029] Beneficial effect: In view of the problem that the prior art cannot judge the quality of the dependent transformation, the present invention proposes an indicator O-measure for judging the quality of the transformation through the study of ensemble learning. Since the indicator O-measure quantitatively gives the quality of the dependent transformation, the effect of judging the dependent transformation is achieved.
[0030] Preferably, the most representative transformation is selected from each transformation according to the performance index, as follows:
[0031] If O-measure is greater than the extreme threshold τ, it is excluded from the selection range; otherwise, the transformation with the largest O-measure is selected to represent the entire transformation family.
[0032] Beneficial effect: In view of the problem that the prior art cannot select the dependent transformation, the present invention selects each transformation by selecting the transformation with the largest O-measure within a threshold τ. Since the larger the O-measure of the transformation within the threshold τ, the stronger its representativeness, the effect of selecting the dependent transformation is achieved.
[0033] Preferably, the extreme threshold τ has a value range of [-0.1, -0.01].
[0034] Beneficial effect: In order to solve the problem that the prior art cannot identify degraded transformations, the present invention uses an extreme threshold τ to limit the selection process. Since transformations with O-measure greater than τ will cause training degradation, the present invention limits them and achieves the effect of excluding these degraded transformations.
[0035] To achieve the above object, according to a second aspect of the present invention, there is provided an image anomaly detection acceleration system based on transformation selection, comprising: a computer-readable storage medium and a processor;
[0036] The computer-readable storage medium is used to store executable instructions;
[0037] The processor is used to read the executable instructions stored in the computer-readable storage medium to execute the image anomaly detection acceleration method based on transformation selection described in the first aspect.
[0038] In general, the above technical solutions conceived by the present invention can achieve the following beneficial effects:
[0039] In order to solve the problem that the existing transformation-based image anomaly detection technology relies on a large number of time-consuming transformations, resulting in slow model reasoning speed, the present invention selects transformations through indicator design based on ensemble learning. Since the method can select the most representative transformation from a large number of transformations, the model reasoning speed is increased by M times. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] Figure 1 A flow chart of an image anomaly detection acceleration method based on transformation selection provided by the present invention.
[0041] Figure 2 This is a model framework diagram provided by the present invention. DETAILED DESCRIPTION
[0042] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention. In addition, the technical features involved in the various embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.
[0043] like Figure 1 As shown, the present invention discloses an image anomaly detection acceleration method based on transformation selection, comprising the following steps:
[0044] Step 1) obtain the original image taken by the camera and perform normalization processing.
[0045] Using the mean vector μ=[0.485,0.456,0.406] and variance vector σ=[0.229,0.224,0.225] calculated from the ImageNet natural image dataset with hundreds of millions of images for normalization preprocessing can avoid the gradient explosion problem of deep convolutional neural networks to a certain extent. The preprocessing steps of the original image I are as follows:
[0046]
[0047]
[0048] Among them, I represents the original image, I′ represents the image after the pixel value range is restricted, and I * Represents the normalized image.
[0049] Step 2) The image collected in step 1) is transformed into 72 different categories to obtain 72 transformed images.
[0050] The 72 transformations used are composed of the following types of geometric transformations: flip transformation T f , a translation transformation T of one quarter of the image width horizontally shifted to the left v-1 , a translation transformation T of one quarter of the image width horizontally to the right v1 , a translation transformation T that translates vertically upward by a quarter of the image height h-1 , a translation transformation T that vertically translates downward by a quarter of the image height h1 , a 90° counterclockwise rotation transformation T 90° , a rotation transformation T of 180° counterclockwise 180° , a rotation transformation T of 270° counterclockwise 270° The final family of transformations is formed by combining the Cartesian products of the above transformations:
[0051] T={I,T f}×{I,T v-1 , T v1}×{I,T h-1 , T h1}×{I,T 90° , T 180° , T 270°}
[0052] Step 3) Build Figure 2 The multi-classification model of the deep convolutional neural network shown in the figure uses an integrated learning perspective to decompose the model, that is, the last fully connected layer in the model is split into multiple independent linear layers and a Sigmoid activation function is used. The number of the linear layers is the same as the number of geometric transformations.
[0053] The forward structure of the traditional multi-classification deep convolutional neural network is expressed as follows:
[0054]
[0055] Among them, Input and Output are input and output images, Conv is a convolutional layer, BN is batch normalization, the activation function uses the RELU function, the Pooling layer uses an average pooling layer, FC represents a fully connected layer, and finally the Sofamax function is used to obtain the output image. Skip connections are used in the network to transfer global information. Note that there is an internal disassembly method in the transformation-based anomaly detection model, that is, the above structure is changed to:
[0056]
[0057] Among them, the fully connected layer is composed of M linear layers [L1, L2, ..., L M ] and use the Sigmoid activation function to produce a single transformed anomaly detection score.
[0058] This new disassembly structure can accurately extract image features and achieve excellent abnormality identification results.
[0059] Step 4) For the 72 transformed images obtained in step 2), the whole of the 72 images is used as the input of the deep convolutional neural network built in step 3), and the model is trained using the binary cross entropy loss to obtain the model before compression.
[0060] The training strategy is: use a binary cross entropy loss function for each batch of image data for training, that is, the following formula:
[0061] L BCE (y p ,y)=-yp log y-λ(1-y p )log(1-y)
[0062] Among them, y p represents the true label, y represents the output probability, and in this embodiment, the value of λ is 71.
[0063] Step 5) calculates the transformation quality index O-measure of the 72 transformations of the model obtained in step 4) on the training data set, and its design is based on ensemble learning technology.
[0064] The O-measure expression of the designed j-th transformation is:
[0065]
[0066] Among them, [x1, x2, …, x N ] is the input training picture family, [T1, T2, …, T M ] is the 72 transformation families described in detail in step 2), C is the common convolution extraction module of the structure in step 3), [L1, L2, ..., L M ] are the 72 classifiers disassembled in step 3). The larger the O-measure is, the stronger the transformation is in distinguishing abnormality. Its design is based on the combination of classifier selection technology and anomaly detection method in ensemble learning technology.
[0067] The present invention provides quantitative results for each type of transformation of the anomaly detection method by designing quantitative indicators, which helps users to flexibly balance between accuracy and speed according to actual needs.
[0068] Step 6) If O-measure is greater than the extreme threshold τ, it means that the transformation is the most representative redundant transformation and is excluded from the selection range; otherwise, the transformation with the largest O-measure is selected to represent the entire transformation family and jump to step 7).
[0069] τ is a designed threshold, which is used to adaptively calculate the redundant transformations and determine the selection strategy: if the O-measure calculated by step 5) is greater than τ, then this part of the redundant transformation is abandoned; otherwise, the transformation T with the largest O-measure is selected. s . When selecting the transformation T s In the process of selecting a classifier L in the structure of step 3) s .
[0070] Step 7) saves the most representative transformation obtained in step 6). During the model inference process, only this transformation is sent to the deep convolutional neural network model obtained in step 4), thereby achieving a 72-fold increase in model inference speed.
[0071] The specific implementation method of accelerating the inference stage is that the image only needs to be processed by the transformation selected in step 6) and then sent to the convolutional neural network trained in step 4). The final score used for abnormality discrimination is:
[0072] n s (x) = L s (C(T s (x)))
[0073] Among them, L s is the classifier selected in step 6), T s The transformation is selected for step 6). In this way, the theoretical inference speedup is 72 times.
[0074] It will be easily understood by those skilled in the art that the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for accelerating image anomaly detection based on transformation selection, characterized in that: The method includes: Training phase: Get a set of normal images of the target task as a training set; Transform each image in the training set M times; Inputting the transformed training set into the improved deep convolutional neural network in batches for self-supervised training to obtain a trained improved deep convolutional neural network, wherein the improved deep convolutional neural network replaces the fully connected layer of the last layer of the deep convolutional neural network with M independent linear layers and M single-input activation functions, and uses binary classification cross entropy for training, wherein the linear layer and the single-input activation function are connected in series to form a classifier; Calculate the performance indicators of each transformation in the trained model; According to the performance indicators, the most representative transformation is selected from each transformation; Reasoning phase: Get the target task image to be tested, perform the most representative transformation on it, input it into the trained model, and obtain the inference result.
2. The method according to claim 1, characterized in that Before transforming the image, perform the following processing: Among them, I represents the original image, I′ represents the image after the pixel value range is restricted, and I * represents the normalized image, μ represents the mean value of the image obtained from the ImageNet dataset, and σ represents the variance of the image obtained from the ImageNet dataset.
3. The method according to claim 1, characterized in that The M transformations are formed by combining the Cartesian products of multiple transformations: T={I,T f }×{I,T v-1 ,T v1 }×{I,T h-1 ,T h1 }×{I,T 90° ,T 180° ,T 270° } Among them, I represents the original image, T f represents the flip transformation, T v-1 represents a translation transformation of one quarter of the image width to the left horizontally, T v1 represents a horizontal translation to the right by a quarter of the image width, T h-1 represents a vertical translation transformation of one quarter of the image height upward, T h1 represents a vertical translation transformation of one quarter of the image height downward, T 90° Indicates a 90° counterclockwise rotation transformation, T 180° Represents a 180° counterclockwise rotation transformation, T 270° Represents a rotation transformation of 270° counterclockwise.
4. The method according to claim 1, characterized in that The single-input activation function is a Sigmoid function.
5. The method according to claim 1, characterized in that The calculation formula of the performance index O-measure of the transformation is as follows: Among them, [I1,…,I N ] is the input of the same batch of pictures, N is the number of pictures in the same batch, L j () represents the jth classifier, C() is the convolution function, T k () represents the kth transformation, I i Represents the i-th picture.
6. The method according to claim 5, characterized in that The most representative transformation is selected from each transformation according to the performance index, as follows: If O-measure is greater than the extreme threshold τ, it is excluded from the selection range; otherwise, the transformation with the largest O-measure is selected to represent the entire transformation family.
7. The method according to claim 6, characterized in that The value range of the extreme threshold τ is [-0.1, -0.01].
8. An image anomaly detection acceleration system based on transformation selection, characterized in that: include: A computer readable storage medium and a processor; The computer-readable storage medium is used to store executable instructions; The processor is used to read the executable instructions stored in the computer-readable storage medium to execute the image anomaly detection acceleration method based on transformation selection according to any one of claims 1 to 7.
