A rail anomaly detection method based on multi-layer feature perception of variational autoencoder

Through the methods of distillation training and multi-scale feature perception, the reconstruction features and image features of autoencoders and variational autoencoders are compared, which solves the problem of insufficient robustness in the existing technology and achieves more accurate and robust Image anomaly detection.

CN118552920BActive Publication Date: 2024-10-29GUANGZHOU EMBEDDED MASCH TECH CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202411027813.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-30
Publication Date
2024-10-29
Estimated Expiration
2044-07-30

AI Technical Summary

Technical Problem

In existing technology, in image anomaly detection, the reconstruction error comparison method of autoencoders and variational autoencoders has insufficient robustness and is prone to missed or false detections, especially in practical application scenarios where the anomalies are complex. When diverse.

Method used

Distillation training is used to perform self-supervised training on the autoencoder, and the variational autoencoder is combined for multi-scale feature perception. By comparing the multi-scale reconstruction features and image features of the autoencoder and the variational autoencoder, the features are calculated. and the mean square error of the image, min-max normalization is performed to determine abnormal areas.

Benefits of technology

It improves the robustness and accuracy of image anomaly detection, reduces false detections caused by reconstruction errors, and can detect image abnormal areas more accurately.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118552920B_ABST
    Figure CN118552920B_ABST
Patent Text Reader

Abstract

The present invention discloses a method for detecting rail anomalies based on multi-layer feature perception of a variational autoencoder, comprising the following steps: self-supervising training of the autoencoder is performed by adopting a distillation training method, and a deep convolutional neural network is used as a teacher model of the autoencoder; an image superposition method is used to synthesize rail anomaly image samples; the variational autoencoder adopts distillation training, and the trained autoencoder is used as a teacher model of the variational autoencoder; and multi-feature-perceived rail anomaly detection is performed by using the trained autoencoder and the variational autoencoder. The present invention avoids the influence of reconstruction errors by comparing the differences in the reconstructed data of the two decoders, and the comparison data comes from the reconstructed features of multiple scales of the decoder, which can improve the robustness of the algorithm.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image anomaly detection, and in particular to a rail anomaly detection method based on multi-layer feature perception of variational autoencoders. Background Art

[0002] Image anomaly detection is a technique for identifying abnormal or unusual patterns in image data. It has wide applications in computer vision, medical image analysis, industrial inspection, and security monitoring. The goal of image anomaly detection is to detect abnormal regions in an image, which may contain defects, abnormal events, unusual objects, or other abnormal conditions. Image anomaly detection plays a key role in many applications, improving production quality and reducing safety risks.

[0003] With the rapid development of deep learning technology, autoencoder (AE) and variational autoencoder (VAE) technologies have been widely used in image anomaly detection tasks.

[0004] The autoencoder uses a self-supervised training method to input normal image data, first encode it into a low-dimensional representation, then decode it, compare the error between the reconstructed image and the input image, and optimize the autoencoder through back propagation, so that the normal data can be effectively reconstructed. Since the autoencoder cannot accurately restore abnormal features, abnormal samples usually show high errors in the reconstruction process, making abnormal samples easy to identify. However, the autoencoder input image is encoded, compressed, and then decoded and reconstructed, which will inevitably cause information loss, some of which comes from normal image areas. For this reason, a reasonable error threshold needs to be set when comparing the original image with the reconstructed image. Only pixel areas greater than the threshold are considered to be abnormal areas. If the reconstruction error of the normal area is close to the error of the abnormal area, missed detection or false detection may occur.

[0005] Variational autoencoder is a generative model that combines the feature learning of autoencoders and the probabilistic modeling of generative models. It is designed to learn the latent distribution of data and is able to generate new data samples. When we train the variational autoencoder with the data of normal samples, the latent space approximately models the probability distribution of normal samples and is able to correctly reconstruct the area of ​​the normal sample image. Compared with autoencoders, VAE can approximate the probability distribution of training data and is therefore able to better represent the diversity of data. The latent space of VAE usually has a better structure, which helps to more easily distinguish normal and abnormal data points in the latent space. Secondly, the latent codes generated by VAE are usually continuous, which makes it easier to set probability thresholds to identify anomalies, while the latent codes of traditional autoencoders are discrete. Therefore, VAE provides more powerful modeling and generation capabilities in anomaly detection and better adapts to diverse data distributions, making it a more effective anomaly detection tool.

[0006] Patent document 1 "CN202310421371.6, an image anomaly detection method based on self-supervised learning and deep feature reconstruction": normal sample images and two-dimensional Perlin noise are used to synthesize pseudo-abnormal images in proportion. In the training stage, the pre-trained wide_resnet50_2 model is used to extract the multi-scale image features of normal sample images and pseudo-abnormal samples respectively. The multi-scale features are composed of the splicing of the output features of the first three layers of the model. The spliced ​​abnormal sample image features are also required to be reconstructed through autoencoding, and the mean square error (MSE) loss is calculated with the normal sample image features, and finally the autoencoder is optimized through back propagation. In the inference stage, the image features of the actual scene are compared with the image features after the autoencoder, and the difference area greater than a certain threshold is judged as the abnormal area.

[0007] This technical solution uses an autoencoder to compress and reconstruct the features of the pseudo-abnormal image, so that the reconstructed pseudo-abnormal image features are the same as the normal image features. However, the autoencoder is mainly used for image compression and reconstruction and does not have the ability to generate images. The image features reconstructed by the autoencoder are slightly different from the original image features. By comparing the difference between the two, it is difficult to locate the abnormal area. Secondly, the pseudo-abnormal image in the patent is obtained by superimposing a normal image with two-dimensional Perlin noise. The style of the pseudo-abnormal image is fixed. The autoencoder is prone to overfitting the training data. The abnormal situations in actual application scenarios are complex and diverse. In the inference stage, the autoencoder may not reconstruct the two-dimensional Perlin noise features, but may reconstruct abnormal features of other styles, which are slightly different from the features that have not passed through the autoencoder and are prone to missed detection.

[0008] Patent document 2 "CN202110599501.6, Image anomaly detection method based on variational autoencoder algorithm": Normal data images and abnormal data images are screened out through the reconstruction error of the autoencoder, and the variational autoencoder is trained using the normal data image. After training, the variational autoencoder reconstructs the normal data image, calculates the mean and variance parameters of the reconstructed image data, and uses the mean and variance to calculate the anomaly score above the mean threshold, which is called the reconstruction probability. The parameters of the input variable distribution are obtained based on the image reconstruction probability, and the original image is compared with the reconstructed image to obtain the anomaly detection result.

[0009] This technical solution uses a variational autoencoder to reconstruct an image and compare it with the original image, which inevitably results in a certain amount of error. This is because the normal area of ​​the image may not be completely accurately reconstructed through encoding, compression, and then decoding and reconstruction, and there will be certain differences when compared with the original image.

[0010] Both of the above technical solutions perform anomaly detection by comparing the difference between the reconstructed data and the input data. The detection accuracy depends largely on the final reconstruction effect of the decoding module, and the robustness of the algorithm is poor. Summary of the invention

[0011] The purpose of the present invention is to overcome the shortcomings and deficiencies of the prior art and to provide a rail anomaly detection method based on multi-layer feature perception of a variational autoencoder. The method avoids the influence of reconstruction errors by comparing the differences in reconstructed data of two decoders. The comparison data comes from the reconstructed features of multiple scales of the decoders, which can improve the robustness of the algorithm.

[0012] The purpose of the present invention is achieved through the following technical solutions:

[0013] A rail anomaly detection method based on multi-layer feature perception of variational autoencoder includes the following steps:

[0014] S1. Use distillation training to perform self-supervisory training on the autoencoder. Use a deep convolutional neural network as the teacher model of the autoencoder. Perform distillation training of multi-scale features in the distillation training stage.

[0015] S2, synthesizing rail abnormality image samples by using image superposition method;

[0016] S3, the variational autoencoder adopts distillation training, and the generated normal rail image and the rail abnormal image sample of step S2 are used as the input of the variational autoencoder; the autoencoder trained in step S1 is used as the teacher model of the variational autoencoder, and multi-scale feature supervision training of the decoding module of the variational autoencoder is performed, so that the decoding module of the variational autoencoder is aligned with the decoding module of the autoencoder in feature spaces of multiple scales, and different semantic information is reconstructed;

[0017] S4. Multi-feature-aware rail anomaly detection using trained autoencoders and variational autoencoders:

[0018] 1) Statistical autoencoder and variational autoencoder on the test set of different scale image features mean and variance;

[0019] 2) Input the preprocessed image to be tested, and the autoencoder and variational autoencoder output image features and reconstructed images of three different sizes respectively;

[0020] 3) Use the mean and variance of the statistics in step 1) to normalize the image features output by the autoencoder and variational autoencoder;

[0021] 4) Calculate the mean square error between the three-size image features of the autoencoder and the variational autoencoder, called the feature reconstruction error, accumulate the feature reconstruction errors according to the feature channel dimension, and perform bilinear interpolation upsampling operations to obtain the reconstructed feature error with the same width and height as the input image to be tested;

[0022] 5) Calculate the mean square error between the image reconstructed by the autoencoder and the image generated by the variational autoencoder, called the image reconstruction error, and accumulate the reconstructed image errors by channel dimension to obtain an image reconstruction error of the same dimension as the feature reconstruction error;

[0023] 6) Sum the feature reconstruction error and image reconstruction error of the three sizes, perform min-max normalization, and map the error value to In the interval, the area where the above error value is greater than the error threshold is judged as an abnormal area of ​​the rail image, otherwise it is a normal area of ​​the rail image.

[0024] The training process of the autoencoder is as follows:

[0025] Prepare large-scale open-source image data for self-supervised distillation training;

[0026] Build an autoencoder model: The encoding module of the autoencoder consists of 4 downsampling network layers, and the decoding module of the autoencoder consists of 4 upsampling network layers. Each downsampling network layer reduces the width and height of the input image features by half, and each upsampling network layer doubles the width and height of the input image features.

[0027] Image preprocessing is performed during the training phase. First, the input image is scaled to 256×256, and then image horizontal flip enhancement, HSV color gamut dithering enhancement, and small-angle image rotation enhancement are performed according to a preset ratio.

[0028] After the image is preprocessed, it is input into the autoencoder and the teacher model of the autoencoder to obtain the corresponding reconstructed image;

[0029] Calculate the mean square error between the image features of 32×32, 64×64, and 128×128 sizes output by the decoding module of the autoencoder and the image features of the corresponding scales of the teacher model of the autoencoder, and calculate the mean square error between the reconstructed image and the input image for autoencoder model training;

[0030] The loss function of the autoencoder model training is back-propagated to optimize the autoencoder model parameters to obtain a pre-trained autoencoder.

[0031] The loss function calculation formula for the autoencoder model training is as follows:

[0032] ;

[0033] in, Represents the autoencoder decoding module Image features of size, Represents the teacher model Image features of size, express Image features under size and The mean square error between represents the image reconstructed by the autoencoder, represents the input image, Representing images and The mean square error.

[0034] The teacher model of the autoencoder is one of ResNet50, VGG19, and HRNet.

[0035] The step S2 is specifically as follows:

[0036] Prepare the COCO instance segmentation dataset, use the object instances in the data as pseudo foreign objects on the rails, and extract the mask map of each instance; the COCO dataset includes common objects, animals, and pedestrians in life, which are consistent with the foreign objects that may appear on the rails;

[0037] Get normal rail image data and filter special image samples where trains pass by;

[0038] Based on the instance mask map, the instance image and the rail area are superimposed and synthesized according to a preset ratio. The synthesis formula is as follows:

[0039] ;

[0040] in, represents a COCO image, represents a normal image sample of a railway track, represents the synthetic rail pseudo-anomaly image, Indicates that an object instance is in the image The mask map of It is a mask image The negation result of is the stacking coefficient of image synthesis.

[0041] The training process of the variational autoencoder is as follows:

[0042] Prepare normal rail images and synthetic rail pseudo-abnormal images, and divide them into training sets and test sets;

[0043] Build a variational autoencoder model, which has a similar structure to the autoencoder. On the basis of the autoencoder, it adds a downsampling network layer and an upsampling network layer to encode the input image into a vector distribution in the latent space, and then reconstruct it to generate a new image.

[0044] In the image preprocessing stage, the input image is enhanced by HSV color domain dithering and small-angle horizontal rotation;

[0045] After the image is preprocessed, the normal rail image and the synthesized pseudo-abnormal rail image are input into the variational autoencoder to generate normal image samples, and the normal image is input into the autoencoder to obtain the reconstructed image;

[0046] Calculate the mean square error between the image features of the variational autoencoder decoding module with sizes of 32×32, 64×64, and 128×128 and the image features of the corresponding scale of the autoencoder, and calculate the mean square error between the image generated by the variational autoencoder and the normal image to obtain the feature reconstruction and image generation loss function :

[0047] ;

[0048] In the formula, Represents the variational autoencoder decoding module Image features of size, Represents the autoencoder decoding module Image features of size, express Image features under size and The mean square error between represents the normal images input into the variational autoencoder model and the autoencoder model respectively, represents a normal image generated by the variational autoencoder model, Representing images and The mean square error between

[0049] Based on the loss function of the variational autoencoder, the model parameters of the variational autoencoder are optimized so that the variational autoencoder has the ability to generate normal images when both abnormal images and normal images are input.

[0050] The loss function of the variational autoencoder is The definition is as follows:

[0051] ;

[0052] In the formula, represents the feature reconstruction and image generation loss function of the input normal image, represents the feature reconstruction and image generation loss function of the input pseudo-anomaly image, , and Represent the weight coefficients of different losses respectively, is the KL divergence loss between the normal distribution of the input data and the standard normal distribution.

[0053] Said Calculated by the following formula:

[0054] ;

[0055] in, is the dimension of the latent space vector, and They represent the latent space vector The mean and variance of the dimensions, and They represent the mean and variance of the latent space vector respectively.

[0056] At the same time, the present invention provides:

[0057] A server comprises a processor and a memory, wherein the memory stores at least one program, and the program is loaded and executed by the processor to implement the above-mentioned rail anomaly detection method based on multi-layer feature perception of variational autoencoder.

[0058] A computer-readable storage medium stores at least one program, which is loaded and executed by a processor to implement the above-mentioned rail anomaly detection method based on multi-layer feature perception of variational autoencoders.

[0059] Compared with the prior art, the present invention has the following advantages and beneficial effects:

[0060] 1. The present invention is an anomaly detection method composed of an autoencoder and a variational autoencoder. The autoencoder of the present invention is trained by self-supervised multi-scale feature distillation, and the features of the output layer of the decoding module express semantic information at different levels; the variational autoencoder is trained by feature distillation based on the pre-trained autoencoder, and at the same time constrains the vector distribution of the latent space to obey the standard normal distribution, so that the variational autoencoder can generate normal images regardless of whether the input is a normal image or an abnormal image. Due to the use of feature distillation, the decoding module of the autoencoder and the decoding module of the autoencoder align the feature space of the output layer, representing different semantic spaces. When calculating the abnormal area of ​​the image, the present invention compares the image features generated by the variational autoencoder and the image features reconstructed by the autoencoder, unlike the previous method of comparing the reconstructed data with the input data. The comparison of the reconstructed space data can reduce the false detection caused by the reconstruction loss.

[0061] 2. The present invention is a multi-feature-aware rail anomaly detection method. The rail anomaly detection results of the present invention not only compare the errors between the generated image and the reconstructed image, but also compare the image features of three sizes in the decoding stage. The image features of multiple scales represent different semantic information. Compared with the method that only compares the reconstructed image with the input image, the method of the present invention has better robustness.

[0062] 3. Compared with the prior art, the method of the present invention can detect abnormal image areas more accurately and robustly. It is more accurate because the comparison objects are often encoded and decoded, rather than directly compared with the input original image. It is more robust because the abnormality detection results not only compare the image generated by the variational autoencoder and the image reconstructed by the autoencoder, but also compare the image features of three different scales in the variational autoencoder and the autoencoder decoding stage, and comprehensively consider the semantic information of multiple scale features. BRIEF DESCRIPTION OF THE DRAWINGS

[0063] Figure 1 Schematic diagram of the training process of the autoencoder described in the present invention.

[0064] Figure 2 Schematic diagram of the training process of the variational autoencoder described in the present invention.

[0065] Figure 3 This is a schematic diagram of anomaly detection of the rail anomaly detection method based on multi-layer feature perception of variational autoencoder described in the present invention. DETAILED DESCRIPTION

[0066] The present invention is further described in detail below in conjunction with embodiments and drawings, but the embodiments of the present invention are not limited thereto.

[0067] The rail anomaly detection method proposed in the present invention can be defined as a binary classification image semantic segmentation method to segment the abnormal area from the input image. The method consists of two models: autoencoder and variational autoencoder. The implementation process includes autoencoder distillation training, pseudo-abnormal image data synthesis, variational autoencoder distillation training and multi-feature-aware rail anomaly detection. In order to better demonstrate the effectiveness of this method, this example is explained in conjunction with the rail foreign body detection task. The specific technical solution is as follows:

[0068] 1. Autoencoder distillation training

[0069] In order to make the autoencoder have a lightweight network structure and good reconstruction ability, distillation training is used for self-supervised training, and a pre-trained model with a large number of parameters is used as the teacher model. The teacher model can be a deep convolutional neural network such as ResNet50, VGG19 and HRNet. The teacher model parameters are frozen during the training phase and no parameter update is performed. At the same time, in order to make the features extracted by the decoding module at different network layers have multiple levels of semantic information, that is, the features extracted by the shallow network describe the texture information of the image, and the features extracted by the deep network express the semantic information of the image, multi-scale feature distillation training is performed during the distillation training phase. The autoencoder training framework is as follows: Figure 1 As shown, it is divided into the following steps:

[0070] 1) Prepare large-scale open-source image data for self-supervised distillation training. This example uses ImageNet, which has rich categories and diverse backgrounds, as training data;

[0071] 2) Build an autoencoder model. The encoding module consists of 4 downsampling network layers, and the decoding module consists of 4 upsampling network layers. Each downsampling network layer reduces the width and height of the input image features by half, and each upsampling network layer doubles the width and height of the input image features.

[0072] 3) Image preprocessing is performed during the training phase. First, the input image is scaled to 256×256, and then image horizontal flip enhancement, HSV color gamut jitter enhancement, and small-angle image rotation enhancement are performed at a certain ratio;

[0073] 4) After the image is preprocessed, it is input into the autoencoder and teacher model respectively to obtain the corresponding reconstructed image;

[0074] 5) Calculate the mean square error (MSE) between the image features of the autoencoder decoding module with sizes of 32×32, 64×64, and 128×128 and the image features of the teacher model with the corresponding scales, and calculate the mean square error between the reconstructed image and the input image. The loss function calculation formula for the autoencoder model training is as follows:

[0075] ;

[0076] in, Represents the autoencoder decoding module Image features of size, Represents the teacher model Image features of size, express Image features under size and The mean square error between represents the image reconstructed by the autoencoder, represents the input image, Representing images and The mean square error.

[0077] 6) Based on the above loss function, back propagation is performed to optimize the autoencoder model parameters to obtain a pre-trained model.

[0078] Since the autoencoder is used in the present invention to reconstruct multiple levels of semantic features and input images, and is independent of the image data for anomaly detection, the pre-trained autoencoder can be repeatedly applied.

[0079] 2. Pseudo-abnormal image data synthesis

[0080] In practical applications, it is rare to obtain a sufficient number of real abnormal images for supervised training, and synthetic techniques are often used to generate pseudo abnormal images to expand training data. However, it is also necessary to be careful to ensure that the generated pseudo abnormal images are consistent with the actual scene. The task of foreign body detection on rails is no exception. It is difficult to obtain abnormal image samples in real scenes. To this end, the present invention uses an image superposition method to synthesize rail abnormal image samples, which is divided into the following steps:

[0081] 1) Prepare the COCO instance segmentation dataset, use the object instances in the data as pseudo foreign objects on the rails, and extract the mask map of each instance; the COCO dataset includes common objects, animals, and pedestrians in life, which are consistent with the foreign objects that may appear on the rails;

[0082] 2) Obtain normal image data of the railroad tracks and filter out special image samples of trains passing by;

[0083] 3) Based on the instance mask image, the instance image and the rail area are superimposed and synthesized at a certain ratio. The synthesis formula is as follows:

[0084] ;

[0085] In the formula, represents a COCO image, represents a normal image sample, represents the synthetic pseudo-abnormal image, Indicates that an object instance is in the image The mask map of It is a mask image The negation result of is the stacking coefficient of image synthesis.

[0086] 3. Variational Autoencoder Distillation Training

[0087] The variational autoencoder is used to generate normal images and is also trained using distillation. The autoencoder trained in the first stage is used as the teacher model to perform multi-scale feature supervision training on the decoding module, so that the decoding module of the variational autoencoder is aligned with the decoding module of the autoencoder in feature spaces of multiple scales and different semantic information is reconstructed. The variational autoencoder distillation training framework is as follows: Figure 2 As shown, it is divided into the following steps:

[0088] 1) Prepare normal rail images and synthetic pseudo-abnormal images, and divide them into training sets and test sets;

[0089] 2) Build a variational autoencoder model, which has a similar structure to the autoencoder. On the basis of the autoencoder, a downsampling network layer and an upsampling network layer are added to encode the input image into a vector distribution in the latent space, and then reconstruct it to generate a new image;

[0090] 3) In the image preprocessing stage, the input image is enhanced by HSV color domain dithering and small-angle horizontal rotation;

[0091] 4) After the image is preprocessed, the normal image and the pseudo-abnormal image are input into the variational autoencoder to generate normal image samples, and the normal image is input into the autoencoder to obtain the reconstructed image;

[0092] 5) Calculate the mean square error between the image features of the variational autoencoder decoding module with sizes of 32×32, 64×64, and 128×128 and the image features of the corresponding scales of the autoencoder, and calculate the mean square error between the image generated by the variational autoencoder and the normal image to obtain the feature reconstruction and image generation loss function:

[0093] ;

[0094] In the formula, Represents the variational autoencoder decoding module Image features of size, Represents the autoencoder decoding module Image features of size, express Image features under size and The mean square error between represents the normal images input into the variational autoencoder model and the autoencoder model respectively, represents a normal image generated by the variational autoencoder model, Representing images and The mean square error between .

[0095] In order to make the variational autoencoder model have the ability to generate images, the posterior distribution of the latent space is constrained to obey the standard normal distribution, and the KL divergence between the normal distribution of the input data and the standard normal distribution is increased. The loss is defined as follows:

[0096] ;

[0097] In the formula, is the dimension of the latent space vector, and They represent the latent space vector The mean and variance of the dimensions, and Represent the mean and variance of the latent space vector respectively. To this end, the loss function of the variational autoencoder is The definition is as follows:

[0098] ;

[0099] In the formula, represents the feature reconstruction and image generation loss function of the input normal image, represents the feature reconstruction and image generation loss function of the input pseudo-anomaly image, and The calculation formula and Consistent, , and Respectively represent the weight coefficients of different losses; is the KL divergence loss between the normal distribution of the input data and the standard normal distribution.

[0100] 6) Based on the above loss function, optimize the model parameters so that the variational autoencoder has the ability to generate normal images when both abnormal images and normal images are input.

[0101] 4. Rail Anomaly Detection Based on Multi-Feature Perception

[0102] After obtaining the pre-trained autoencoder and variational autoencoder, multi-feature-aware rail anomaly detection is performed. The implementation method is as follows: Figure 3 As shown, it is divided into the following steps:

[0103] 1) Statistical autoencoder and variational autoencoder on the test set of different scale image features mean and variance;

[0104] 2) Input the preprocessed image to be tested, the autoencoder outputs image features and reconstructed images of sizes 32×32, 64×64, and 128×128, and the variational autoencoder outputs image features and generated images of sizes 32×32, 64×64, and 128×128;

[0105] 3) Use the mean and variance of the statistics in step 1) to normalize the image features output by the autoencoder and variational autoencoder;

[0106] 4) Calculate the mean square error between the three-size image features of the autoencoder and the variational autoencoder, called the feature reconstruction error, accumulate the feature reconstruction errors according to the feature channel dimension, and perform bilinear interpolation upsampling operations to obtain the reconstructed feature error with the same width and height as the input image;

[0107] 5) Calculate the mean square error between the image reconstructed by the autoencoder and the image generated by the variational autoencoder, called the image reconstruction error, and accumulate the reconstructed image errors by channel dimension to obtain an image reconstruction error of the same dimension as the feature reconstruction error;

[0108] 6) Sum the feature reconstruction error and image reconstruction error of the three sizes, perform min-max normalization, and map the error value to On the interval;

[0109] 7) Set the error threshold , the above error value is greater than The area is judged as the abnormal image area, otherwise it is the normal image area.

[0110] The above embodiments are preferred implementation modes of the present invention, but the implementation modes of the present invention are not limited to the above embodiments. Any other changes, modifications, substitutions, combinations, and simplifications that do not deviate from the spirit and principles of the present invention should be equivalent replacement methods and are included in the protection scope of the present invention.

Claims

1. A rail anomaly detection method based on multi-layer feature perception of variational autoencoder, characterized in that: The following steps are involved: S1. Use distillation training to perform self-supervisory training on the autoencoder. Use a deep convolutional neural network as the teacher model of the autoencoder. Perform distillation training of multi-scale features in the distillation training stage. S2, synthesizing rail abnormality image samples by using image superposition method; S3, the variational autoencoder adopts distillation training, and the generated normal rail image and the rail abnormal image sample of step S2 are used as the input of the variational autoencoder; the autoencoder trained in step S1 is used as the teacher model of the variational autoencoder, and multi-scale feature supervision training of the decoding module of the variational autoencoder is performed, so that the decoding module of the variational autoencoder is aligned with the decoding module of the autoencoder in feature spaces of multiple scales, and different semantic information is reconstructed; S4, rail anomaly detection with multi-feature perception through trained autoencoders and variational autoencoders; The step S4 is specifically as follows: 1) Statistical autoencoder and variational autoencoder on the test set of different scale image features mean and variance; 2) Input the preprocessed image to be tested, and the autoencoder and variational autoencoder output image features and reconstructed images of three different sizes respectively; 3) Use the mean and variance of the statistics in step 1) to normalize the image features output by the autoencoder and variational autoencoder; 4) Calculate the mean square error between the three-size image features of the autoencoder and the variational autoencoder, called the feature reconstruction error, accumulate the feature reconstruction errors according to the feature channel dimension, and perform bilinear interpolation upsampling operations to obtain the reconstructed feature error with the same width and height as the input image to be tested; 5) Calculate the mean square error between the image reconstructed by the autoencoder and the image generated by the variational autoencoder, called the image reconstruction error, and accumulate the reconstructed image errors by channel dimension to obtain an image reconstruction error of the same dimension as the feature reconstruction error; 6) Sum the feature reconstruction error and image reconstruction error of the three sizes, perform min-max normalization, and map the error value to In the interval, the area where the error value is greater than the error threshold is judged as an abnormal area of ​​the rail image, otherwise it is a normal area of ​​the rail image.

2. According to claim 1, the rail anomaly detection method based on multi-layer feature perception of variational autoencoder is characterized in that: The training process of the autoencoder is as follows: Prepare large-scale open-source image data for self-supervised distillation training; Build an autoencoder model: The encoding module of the autoencoder consists of 4 downsampling network layers, and the decoding module of the autoencoder consists of 4 upsampling network layers. Each downsampling network layer reduces the width and height of the input image features by half, and each upsampling network layer doubles the width and height of the input image features. Image preprocessing is performed during the training phase. First, the input image is scaled to 256×256, and then image horizontal flip enhancement, HSV color gamut dithering enhancement, and small-angle image rotation enhancement are performed according to a preset ratio. After the image is preprocessed, it is input into the autoencoder and the teacher model of the autoencoder to obtain the corresponding reconstructed image; Calculate the mean square error between the image features of 32×32, 64×64, and 128×128 sizes output by the decoding module of the autoencoder and the image features of the corresponding scales of the teacher model of the autoencoder, and calculate the mean square error between the reconstructed image and the input image for autoencoder model training; The loss function of the autoencoder model training is back-propagated to optimize the autoencoder model parameters to obtain a pre-trained autoencoder.

3. According to claim 1, the rail anomaly detection method based on multi-layer feature perception of variational autoencoder is characterized in that: The loss function calculation formula for the autoencoder model training is as follows: ; in, Represents the autoencoder decoding module Image features of size, Represents the teacher model Image features of size, express Image features under size and The mean square error between represents the image reconstructed by the autoencoder, represents the input image, Representing images and The mean square error.

4. According to claim 1, the rail anomaly detection method based on multi-layer feature perception of variational autoencoder is characterized in that: The teacher model of the autoencoder is one of ResNet50, VGG19, and HRNet.

5. According to claim 1, the rail anomaly detection method based on multi-layer feature perception of variational autoencoder is characterized in that: The step S2 is specifically as follows: Prepare the COCO instance segmentation dataset, use the object instances in the data as pseudo foreign objects on the rails, and extract the mask map of each instance; the COCO dataset includes foreign objects that may appear on the rails; Get normal rail image data and filter special image samples where trains pass by; Based on the instance mask map, the instance image and the rail area are superimposed and synthesized according to a preset ratio. The synthesis formula is as follows: ; in, represents a COCO image, represents a normal image sample of a railway track, represents the synthetic rail pseudo-anomaly image, Represents an object instance in an image The mask map of It is a mask image The negation result of is the stacking coefficient of image synthesis.

6. The rail anomaly detection method based on multi-layer feature perception of variational autoencoder according to claim 1 is characterized in that: The training process of the variational autoencoder is as follows: Prepare normal rail images and synthetic pseudo-abnormal rail images, and divide them into training sets and test sets; Build a variational autoencoder model, which has a similar structure to the autoencoder. On the basis of the autoencoder, it adds a downsampling network layer and an upsampling network layer to encode the input image into a vector distribution in the latent space, and then reconstruct it to generate a new image. In the image preprocessing stage, the input image is enhanced by HSV color domain dithering and small-angle horizontal rotation; After the image is preprocessed, the normal rail image and the synthesized pseudo-abnormal rail image are input into the variational autoencoder to generate normal image samples, and the normal image is input into the autoencoder to obtain the reconstructed image; Calculate the mean square error between the image features of the variational autoencoder decoding module with sizes of 32×32, 64×64, and 128×128 and the image features of the corresponding scale of the autoencoder, and calculate the mean square error between the image generated by the variational autoencoder and the normal image to obtain the feature reconstruction and image generation loss function : ; In the formula, Represents the variational autoencoder decoding module Image features of size, Represents the autoencoder decoding module Image features of size, express Image features under size and The mean square error between represents the normal images input into the variational autoencoder model and the autoencoder model respectively, represents a normal image generated by the variational autoencoder model, Representing images and The mean square error between Based on the loss function of the variational autoencoder, the model parameters of the variational autoencoder are optimized so that the variational autoencoder has the ability to generate normal images when both abnormal images and normal images are input.

7. The rail anomaly detection method based on multi-layer feature perception of variational autoencoder according to claim 1 is characterized in that: The loss function of the variational autoencoder is The definition is as follows: ; In the formula, represents the feature reconstruction and image generation loss function of the input normal image, represents the feature reconstruction and image generation loss function of the input pseudo-anomaly image, , and Represent the weight coefficients of different losses respectively, is the KL divergence loss between the normal distribution of the input data and the standard normal distribution.

8. The rail anomaly detection method based on multi-layer feature perception of variational autoencoder according to claim 7 is characterized in that: Said Calculated by the following formula: ; in, is the dimension of the latent space vector, and They represent the latent space vector The mean and variance of the dimensions, and They represent the mean and variance of the latent space vector respectively.

9. A server, comprising a processor and a memory, characterized in that: At least one program is stored in the memory, and the program is loaded and executed by the processor to implement the rail anomaly detection method based on multi-layer feature perception of variational autoencoder as described in any one of claims 1 to 8.

10. A computer-readable storage medium, wherein at least one program is stored in the storage medium, characterized in that: The program is loaded and executed by a processor to implement the rail anomaly detection method based on multi-layer feature perception of variational autoencoder as described in any one of claims 1 to 8.

Citation Information

Patent Citations

  • Data processing method, device and equipment and computer readable storage medium

    CN111967573A

  • Image anomaly detection method based on soft mask contrast loss

    CN114565594A

  • 6G satellite image landslide detection method based on multistage Transform network

    CN115713695A

  • Radar altimeter height measurement method based on image noise suppression

    CN116523784A

  • Index anomaly detection method for intelligent operation and maintenance application of power grid supercomputing center

    CN116910559A