Image anomaly detection model training methods, devices, equipment and media
By training the autoencoder with sparse constraints, distribution constraints, and a discriminator, an image anomaly detection model is constructed, which solves the problems of training relying on abnormal data and judgment criteria being singular in existing methods, and achieves fast and accurate image anomaly detection.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-13
- Publication Date
- 2026-04-03
AI Technical Summary
Existing image anomaly detection methods rely on training with abnormal data, which requires a lot of computing power and storage. Unsupervised learning methods rely on a single criterion and have insufficient generalization ability, making it difficult to quickly and accurately distinguish between normal and abnormal images.
By training the autoencoder with sparse constraints, distribution constraints, and a discriminator, and combining it with a normal sample image training set, an image anomaly detection model is constructed. The sparse constraints and distribution constraints compress the image representation to conform to a normal distribution, and the discriminator is added to improve the discrimination ability.
It does not require training with abnormal sample images, yet possesses the ability to reconstruct normal sample images. It exhibits stronger robustness and discriminative power, enabling it to quickly and accurately distinguish between normal and abnormal images.
Smart Images

Figure CN117115578B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing technology, and in particular to a method, apparatus, device and medium for training an image anomaly detection model. Background Technology
[0002] Existing research on anomaly detection based on image analysis technology can be divided into supervised learning methods and unsupervised learning methods.
[0003] Existing supervised learning methods heavily rely on outlier data for training and require significant computing power and storage. In real-world scenarios, anomalies in base station components are low-probability events, and there is a clear imbalance in the number of different types of anomalies, making it difficult to collect enough outlier data for training. Furthermore, combining multiple models necessitates greater computing power and storage space in terminal devices to ensure the algorithm's proper functioning.
[0004] Existing unsupervised learning methods rely on a single, insufficient constraint to identify anomalies. They primarily use the similarity between the reduced-dimensional vector and the reconstructed image as anomaly evaluation metrics. However, individual metrics often have limitations and cannot comprehensively assess anomalies. Furthermore, autoencoders, under insufficient constraints, tend to exhibit over-generalization, resulting in good reconstruction capabilities for anomalous images, making it difficult to distinguish between normal and anomalous images. Summary of the Invention
[0005] This application provides a method, apparatus, device, and medium for training an image anomaly detection model, aiming to quickly and accurately distinguish between normal and abnormal images.
[0006] Firstly, this application provides a method for training an image anomaly detection model, including:
[0007] The collected base station component image set is preprocessed to obtain a normal sample image training set of the base station component image set;
[0008] By combining the normal sample image training set with sparse constraints and distribution constraints, the preset autoencoder is trained to obtain the target optimized autoencoder.
[0009] The target-optimized autoencoder is retrained using a discriminator to obtain an image anomaly detection model.
[0010] In one embodiment, training a preset autoencoder using the normal sample image training set combined with sparse constraints and distribution constraints to obtain a target optimized autoencoder includes:
[0011] The preset autoencoder is reconstructed and trained by combining the inverse loss function of peak signal-to-noise ratio with the normal sample image training set to obtain the first autoencoder to be optimized.
[0012] Using KL divergence as the regularization function and the inverse loss function as the sparsity constraint, the first autoencoder to be optimized is trained to obtain the second autoencoder to be optimized.
[0013] The second autoencoder to be optimized is trained by combining the distribution constraints to obtain the target optimized autoencoder.
[0014] The step of training the second autoencoder to be optimized in conjunction with the distribution constraints to obtain the target optimized autoencoder includes:
[0015] Determine the encoding vector in the reconstruction training process, and sample vectors of the same dimension as the encoding vector by sampling through a normal distribution;
[0016] The sampling vector is determined as the distribution constraint, and the second autoencoder to be optimized is trained to obtain the target optimized autoencoder.
[0017] The step of retraining the target-optimized autoencoder through a discriminator to obtain an image anomaly detection model includes:
[0018] The encoded vector and the sampled vector are input into the discriminator, which outputs the distinguishable coefficients of the encoded vector and the sampled vector.
[0019] Each of the easily distinguishable coefficients is compared with a preset coefficient to obtain a first comparison result, and based on the first comparison result, a target distinguishable coefficient whose value is less than the preset coefficient is determined among the easily distinguishable coefficients.
[0020] Determine the discriminator coefficients corresponding to the target discrimination coefficients, and retrain the target optimized autoencoder using the discriminator coefficients to obtain the image anomaly detection model.
[0021] After retraining the target-optimized autoencoder using a discriminator to obtain the image anomaly detection model, the method further includes:
[0022] The set of sample images to be detected is input into the image anomaly detection model, and the reconstructed image set of the set of sample images to be detected is output.
[0023] The image reconstruction value of the image set to be detected is determined by combining the inverse loss function of peak signal-to-noise ratio with the image set to be detected and its reconstructed image set;
[0024] Based on the image reconstruction values and the preset abnormal image threshold, the abnormal image set in the sample image set to be detected is determined.
[0025] The step of determining the abnormal image set in the sample image set to be detected based on the reconstructed values of each image and a preset abnormal image threshold includes:
[0026] The reconstructed values of each image are compared with the preset abnormal image threshold to obtain a second comparison result.
[0027] Based on the second comparison result, determine the target image reconstruction values that are greater than or equal to the preset abnormal image threshold among the image reconstruction values;
[0028] The sample images to be detected corresponding to the reconstructed values of each target image are determined as the abnormal image set in the sample image set to be detected.
[0029] The step of preprocessing the acquired base station component image set to obtain a normal sample image training set of the base station component image set includes:
[0030] Images of the base station components of a preset base station are acquired by acquiring images of the base station components at a preset acquisition frequency, thereby obtaining an image set of the base station components;
[0031] By using preset cropping rules, preset image regions of each base station component image in the base station component image set are cropped to obtain the image set to be processed;
[0032] The images of each base station component in the image set to be processed are subjected to grayscale conversion, noise reduction, and sharpening enhancement processing to obtain the target image set;
[0033] The target image set is labeled with normal images and abnormal images to obtain the normal sample image training set.
[0034] Secondly, this application provides an image anomaly detection model training device, comprising:
[0035] The acquisition module is used to perform image preprocessing on the acquired base station component image set to obtain a normal sample image training set of the base station component image set;
[0036] The first training module is used to train the preset autoencoder by combining the normal sample image training set with sparse constraints and distribution constraints, so as to obtain the target optimized autoencoder.
[0037] The second training module is used to retrain the target optimized autoencoder through a discriminator to obtain an image anomaly detection model.
[0038] Thirdly, this application also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the image anomaly detection model training method described in the first aspect.
[0039] Fourthly, this application also provides a non-transitory computer-readable storage medium, the non-transitory computer-readable storage medium including a computer program, which, when executed by the processor, implements the image anomaly detection model training method described in the first aspect.
[0040] Fifthly, this application also provides a computer program product, which includes a computer program that, when executed by the processor, implements the image anomaly detection model training method described in the first aspect.
[0041] The image anomaly detection model training method, apparatus, device, and medium provided in this application train an autoencoder by combining a normal sample image training set, sparse constraints, distribution constraints, and a discriminator during the training process, thus obtaining the image anomaly detection model. Therefore, the image anomaly detection model does not require anomaly sample images for training, enabling it to reconstruct normal sample images but not anomaly sample images. Furthermore, the addition of sparse constraints to the model enhances its robust reconstruction capabilities. The inclusion of distribution constraints ensures that the compressed image representation conforms to a normal distribution, thereby reducing the distance between normal sample images and the model in the vector space. Finally, the inclusion of a discriminator further improves the model's performance, enabling it to more quickly and accurately distinguish between normal and anomaly images. Attached Figure Description
[0042] To more clearly illustrate the technical solutions of this application, the drawings used in the description of the embodiments or prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0043] Figure 1 This is one of the flowcharts for the image anomaly detection model training method provided in this application;
[0044] Figure 2 This is the second flowchart of the image anomaly detection model training method provided in this application;
[0045] Figure 3 This is a schematic diagram of the structure of the image anomaly detection model training device provided in this application;
[0046] Figure 4 This is a schematic diagram of the structure of the electronic device provided in this application. Detailed Implementation
[0047] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0048] Combination Figures 1 to 4 This application describes the image anomaly detection model training method, apparatus, equipment, and medium provided in this application. Figure 1 This is one of the flowcharts for the image anomaly detection model training method provided in this application; Figure 2 This is the second flowchart of the image anomaly detection model training method provided in this application; Figure 3 This is a schematic diagram of the structure of the image anomaly detection model training device provided in this application; Figure 4 This is a schematic diagram of the structure of the electronic device provided in this application.
[0049] This application provides an embodiment of an image anomaly detection model training method. It should be noted that although the logical order is shown in the flowchart, under certain data conditions, the steps shown or described may be performed in a different order than that shown here.
[0050] This application uses an electronic device as an example to illustrate the execution of the embodiments. This application uses a model training system as one of the manifestations of the electronic device, and does not impose any limitations.
[0051] Reference Figure 1 , Figure 1 This is one of the flowcharts for the image anomaly detection model training method provided in this application. The image anomaly detection model training method provided in this application includes:
[0052] Step S10: Perform image preprocessing on the collected base station component image set to obtain a normal sample image training set of the base station component image set.
[0053] It should be noted that a camera is installed at a preset location on each base station device to capture images of the base station components of each base station device. The preset location is set according to the actual situation, and the camera device includes, but is not limited to, cameras, video recorders, and camcorders.
[0054] Furthermore, the model training system acquires video footage of base station components captured by the camera equipment and analyzes the acquired video footage, identifying each frame of the video as a base station component image. Therefore, the model training system analyzes the acquired video footage of the base station components to obtain a set of base station component images. Next, the model training system performs image preprocessing on the base station component image set. Image preprocessing includes, but is not limited to, image cropping, image enhancement, and image annotation. In other words, the model training system performs image cropping, image enhancement, and image annotation on the base station component image set to obtain a normal sample image training set of the base station component image set, as described in steps S101 to S104.
[0055] Further, steps S101 to S104 are described as follows:
[0056] Step S101: Image acquisition is performed on the base station components of the preset base station using a preset acquisition frequency to obtain an image set of the base station components;
[0057] Step S102: The preset image regions of each base station component image in the base station component image set are cropped according to preset cropping rules to obtain the image set to be processed;
[0058] Step S103: Perform grayscale conversion, noise reduction, and sharpening enhancement processing on the images of each base station component in the image set to be processed to obtain the target image set;
[0059] Step S104: Perform normal image annotation and abnormal image annotation on the target image set to obtain the normal sample image training set.
[0060] Specifically, the camera device captures images of the base station components of a preset base station at a preset acquisition frequency, obtaining captured video of the base station components. The preset acquisition frequency and the preset base station are set according to actual conditions. Further, the model training system analyzes the captured video, identifying each frame as a base station component image, thus obtaining a base station component image set. Next, the model training system crops preset image regions from each base station component image in the image set using preset cropping rules, obtaining a set of images to be processed. The preset cropping rules can exclude redundant image regions other than key components, and the preset image regions are determined by the preset cropping rules.
[0061] Furthermore, the model training system performs grayscale conversion, noise reduction, and sharpening enhancement on the images of each base station component in the image set to be processed, resulting in the target image set. Finally, the model training system annotates the images of each base station component in the target image set according to whether there are defects. That is, the model training system annotates the target image set with normal images and abnormal images based on whether there are defects in the base station component images, resulting in a normal image set and an abnormal image set, and the normal image set is determined as the normal sample image training set.
[0062] In this embodiment, the normal image set is determined as the normal sample image training set, without the need for abnormal sample images to participate in the training. This enables the trained image anomaly detection model to have the ability to reconstruct normal sample images, thereby quickly and accurately distinguishing between normal and abnormal images.
[0063] Step S20: The preset autoencoder is trained by combining the normal sample image training set with sparse constraints and distribution constraints to obtain the target optimized autoencoder.
[0064] Furthermore, the model training system performs autonomous training on the preset autoencoder using a normal sample image training set to obtain an autoencoder capable of reconstructing normal sample images. Next, the model training system incorporates sparsity constraints to train the autoencoder, resulting in an autoencoder that, in addition to its ability to reconstruct normal sample images, also possesses sparsity constraint capabilities. Finally, the model training system incorporates distribution constraints to train the autoencoder, resulting in an autoencoder that, in addition to its ability to reconstruct normal sample images and its ability to impose sparsity constraints, also possesses distribution constraint capabilities. This yields a target-optimized autoencoder possessing the ability to reconstruct normal sample images, its ability to impose sparsity constraints, and its ability to impose distribution constraints, as described in steps S201 to S203.
[0065] Step S30: The target optimized autoencoder is retrained using a discriminator to obtain an image anomaly detection model.
[0066] Furthermore, the model training system incorporates a discriminator to retrain the autoencoder, which has acquired the ability to reconstruct normal sample images, sparse constraint ability, and distribution constraint ability, so that the autoencoder can deceive the discriminator and obtain an image anomaly detection model. That is, the image anomaly detection model has the ability to reconstruct normal sample images, sparse constraint ability, distribution constraint ability, and the ability to deceive the discriminator, as described in steps S301 to S303.
[0067] The image anomaly detection model training method provided in this application trains an autoencoder by combining a normal sample image training set, sparse constraints, distribution constraints, and a discriminator during the image anomaly detection model training process, thus obtaining the image anomaly detection model. Therefore, the image anomaly detection model does not require anomaly sample images for training, enabling it to reconstruct normal sample images but not anomaly sample images. Furthermore, the addition of sparse constraints to the image anomaly detection model enhances its robust reconstruction capabilities. Simultaneously, the inclusion of distribution constraints ensures that the compressed image representation conforms to a normal distribution, thereby reducing the distance between normal sample images and the model in the vector space. Finally, the inclusion of a discriminator further improves the model's performance, enabling it to more quickly and accurately distinguish between normal and anomaly images.
[0068] Further, steps S201 to S203 are described as follows:
[0069] Step S201: The preset autoencoder is reconstructed and trained by combining the inverse loss function of peak signal-to-noise ratio with the normal sample image training set to obtain the first autoencoder to be optimized.
[0070] Step S202: Using KL divergence as the regularization function and the inverse loss function as the sparsity constraint, train the first autoencoder to be optimized to obtain the second autoencoder to be optimized.
[0071] Step S203: Train the second autoencoder to be optimized in conjunction with the distribution constraints to obtain the target optimized autoencoder.
[0072] Specifically, the model training system uses the inverse of the peak signal-to-noise ratio (PSNR) loss function combined with a normal sample image training set to reconstruct and train a preset autoencoder, resulting in a first autoencoder to be optimized. This can be understood as the normal sample image training set being compressed and reconstructed by the autoencoder. The autoencoder compresses the normal sample images in the training set into encoded vectors of a preset dimension (preferably 100 dimensions in this embodiment). A decoder with a structure symmetrical to the autoencoder then reconstructs the normal sample images from the training set into reconstructed images. After image reconstruction, the normal sample images and their reconstructed images in the training set are evaluated using the inverse of the PSNR loss function, aiming to guide the image anomaly detection model to achieve better reconstruction results. Better image reconstruction results during training indicate that the image anomaly detection model parameters are more suitable for the normal sample images used in training. During the testing phase, the reconstruction results for anomaly sample images not used in training will be worse. The difference in reconstruction results allows for the differentiation between normal and anomaly sample images. The reciprocal loss function of the peak signal-to-noise ratio can be expressed as: Where MAX represents the pixel with the largest pixel value in the normal sample image. MSE (Mean-Square Error) is the mean squared error, which can be expressed as... Where m and n are the width and height of the normal sample image, x0(i,j) is the true value, and x′0(i,j) is the predicted value.
[0073] Furthermore, the model training system uses KL divergence as the regularization function combined with the reciprocal loss function as a sparsity constraint to train the first autoencoder to be optimized, resulting in the second autoencoder to be optimized. This can be understood as follows: to make the autodecoder more robust, sparse constraints on the autoencoder cause a certain probability of resetting the neuron weights to 0. This operation forces the remaining weights to perform deeper feature extraction. That is, it aims to improve the average activity of neuron j. The sparsity parameter ρ should be as close as possible to the sparsity parameter, which is typically a small value close to 0. The difference between the two is measured by the KL divergence; the smaller the value, the closer they are. The KL divergence can be expressed as... Furthermore, the model training system will incorporate KL divergence. It is added as a regularization term to the inverse loss function. In this context, as a sparsity constraint, the first autoencoder to be optimized is trained to obtain the second autoencoder to be optimized. The overall loss function during the training of the second autoencoder is...
[0074] Finally, the model training system trains the second autoencoder to be optimized by combining distribution constraints to obtain the target optimized autoencoder, as described in steps S2031 to S2032.
[0075] In this embodiment, the autoencoder is trained by combining a normal sample image training set, sparse constraints, and distribution constraints. Therefore, the target-optimized autoencoder does not require abnormal sample images for training, enabling the image anomaly detection model to reconstruct normal sample images but not abnormal ones. Furthermore, the addition of sparse constraints enhances the robustness of the reconstruction capabilities. Simultaneously, the distribution constraints ensure that the compressed image representation conforms to a normal distribution, thus reducing the distance between the target-optimized autoencoder and normal sample images in the vector space. This results in superior performance, allowing for faster and more accurate differentiation between normal and abnormal images.
[0076] Further, steps S2031 to S2032 are described as follows:
[0077] Step S2031: Determine the encoding vector in the reconstruction training process, and sample vectors of the same dimension as the encoding vector by normal distribution;
[0078] Step S2032: The sampling vector is determined as the distribution constraint, and the second autoencoder to be optimized is trained to obtain the target optimized autoencoder.
[0079] Specifically, the model training system determines the encoding vector during the reconstruction training process and samples a vector of the same dimension as the encoding vector using a normal distribution. Then, the model training system uses the sampled vectors as distribution constraints to train the second autoencoder to be optimized, obtaining the target optimized autoencoder. It can be understood that during the training of the second autoencoder to be optimized, if the encoding vector follows a uniform distribution in space, the encoding vectors of abnormal images will be very similar to those of normal images, making them difficult to distinguish. Therefore, this embodiment of the application suppresses the uniformity of vector distribution by constraining the encoding vector to follow a normal distribution. That is, it samples a vector of the same dimension as the encoding vector from the normal distribution and feeds both into a discriminator composed of a convolutional neural network for training. When the discriminator cannot accurately distinguish between the two, it indicates that the encoding vector conforms to a normal distribution. The input source for the normal distribution sampling is a normal distribution. When the probability density of the normal distribution is known, n numbers can be randomly sampled from the normal distribution. These n numbers follow a uniform distribution and can be written as an n-dimensional vector, with the same dimension as the n-dimensional encoding vector obtained by the encoder. The goal of training is to make it difficult for the discriminator to distinguish between the two, meaning that the encoded vectors also follow a normal distribution. Here, the normal distribution is denoted as x ~ N(0,1), and its probability density is as follows: The loss function used for training the discriminator references the loss function of the generative adversarial network (GAN) discriminator (D), which can be expressed as maxV(D) = E. z~Pdata(z) [log(D(z))]+E z′~N(0,1) [log(1-D(z′))].
[0080] In the training process of the target-optimized autoencoder, the autoencoder is trained by combining distribution constraints to obtain the target-optimized autoencoder. This makes the representation of the compressed image conform to a normal distribution, thereby increasing the distance between normal sample images in the vector space and giving the target-optimized autoencoder better performance. Thus, the target-optimized autoencoder can more quickly and accurately distinguish between normal and abnormal images.
[0081] Further, steps S301 to S303 are described as follows:
[0082] Step S301: Input the encoded vector and the sampled vector into the discriminator, and output the distinguishable coefficients of the encoded vector and the sampled vector;
[0083] Step S302: Compare the values of each of the easily distinguishable coefficients with the preset coefficients to obtain a first comparison result, and determine the target distinguishable coefficient among the easily distinguishable coefficients whose value is less than the preset coefficient based on the first comparison result;
[0084] Step S303: Determine the discriminator coefficients corresponding to the target discrimination coefficients, and retrain the target optimized autoencoder using the discriminator coefficients to obtain the image anomaly detection model.
[0085] Specifically, the model training system inputs the encoded vector and the sampled vector into the discriminator. The discriminator parameters in the discriminator can be adjusted. Therefore, the various distinguishability coefficients of the output encoded vector and sampled vector can be understood as the distinguishability coefficients corresponding to the discriminator parameters. Different discriminator parameter settings will result in different output distinguishability coefficients.
[0086] Furthermore, the model training system compares the values of each easily distinguishable coefficient with preset coefficients to obtain a first comparison result. This first comparison result can be either an easily distinguishable coefficient with a value less than the preset coefficient, or an easily distinguishable coefficient with a value greater than or equal to the preset coefficient. Next, based on the first comparison result, the model training system determines the easily distinguishable coefficients with values less than the preset coefficient; these are designated as the target distinguishable coefficients. Finally, the model training system determines the discriminator coefficients corresponding to the target distinguishable coefficients and retrains the target optimized autoencoder using these discriminator coefficients to obtain the image anomaly detection model.
[0087] Further, this can be understood as follows: in each training cycle, after the two training phases in step S20, the image anomaly detection model achieves image reconstruction, sparsity constraints, and distribution constraints. Next, based on the idea of adversarial learning, the discriminator parameters need to be fixed, and the autoencoder needs to be retrained to enable the autoencoder to deceive the discriminator. The purpose of autoencoder retraining is to make the discriminator unable to distinguish whether the input vector is extracted from the image or sampled from a normal distribution. When this objective is achieved, it indicates that the feature vector extracted by the autoencoder from the image conforms to a normal distribution. When the distribution follows a normal distribution, it indicates poor uniformity, resulting in a larger vector distance between normal samples and abnormal samples, making them easier to distinguish. During the process of optimizing the autoencoder retraining, the loss function used for autoencoder retraining references the loss function of the generative adversarial network (G) generator, which can be expressed as: The training process from step S20 to step S30 is repeated continuously until the end of the entire training cycle.
[0088] In the training process of the image anomaly detection model, this application incorporates a discriminator into the model, enabling it to deceive the discriminator and thus more quickly and accurately distinguish between normal and abnormal images.
[0089] Reference Figure 2 , Figure 2 This is the second flowchart of the image anomaly detection model training method provided in this application, which includes steps S40 to S60 after step S30:
[0090] Step S40: Input the set of sample images to be detected into the image anomaly detection model and output the reconstructed image set of the set of sample images to be detected;
[0091] Step S50: Determine the image reconstruction value of the image set to be detected by combining the reciprocal loss function of peak signal-to-noise ratio with the image set to be detected and its reconstructed image set;
[0092] Step S60: Determine the abnormal image set in the sample image set to be detected based on the image reconstruction values and the preset abnormal image threshold.
[0093] Specifically, the model training system inputs the set of sample images to be detected into the image anomaly detection model and outputs the reconstructed image set corresponding to the set of sample images to be detected, that is, it outputs the reconstructed image corresponding to each sample image to be detected in the set of sample images to be detected. It should be noted that since the training process of the image anomaly detection model involves the inverse of the peak signal-to-noise ratio (PSNR) loss function, the model training system processes the set of sample images to be detected and its reconstructed image set through the inverse of the PSNR loss function in the image anomaly detection model. That is, it processes each sample image to be detected and its reconstructed image through the inverse of the PSNR loss function in the image anomaly detection model to obtain the image reconstruction value of each sample image to be detected in the set of sample images to be detected. Further, the model training system compares the value of each image reconstruction with a preset anomaly image threshold to obtain a comparison result, wherein the preset anomaly image threshold is set by an expert. Finally, the model training system determines the set of anomaly images in each sample image to be detected in the set of sample images to be detected based on the comparison result, as described in steps S601 to S603.
[0094] This application embodiment uses an image anomaly detection model that possesses the ability to reconstruct normal sample images, sparse constraint ability, distribution constraint ability, and the ability to deceive the discriminator to detect the image set to be detected, thereby enabling a faster and more accurate distinction between normal and abnormal images in the image set to be detected.
[0095] Further, steps S601 to S603 are described as follows:
[0096] Step S601: Compare the numerical values of each image reconstruction value with the preset abnormal image threshold to obtain a second comparison result;
[0097] Step S602: Based on the second comparison result, determine the reconstruction values of each target image that are greater than or equal to the preset abnormal image threshold among the reconstruction values of each image;
[0098] Step S603: The sample images to be detected corresponding to the reconstructed values of each target image are determined as the abnormal image set in the sample image set to be detected.
[0099] Specifically, the model training system compares the reconstructed values of each image with a preset abnormal image threshold to obtain a second comparison result. This second comparison result can be either an image reconstructed value with a value greater than or equal to the preset abnormal image threshold, or an image reconstructed value with a value less than the preset abnormal image threshold. Next, based on the second comparison result, the model training system determines the image reconstructed values among the various image reconstructed values that are greater than or equal to the preset abnormal image threshold, thus identifying these as the target image reconstructed values. Finally, the model training system identifies the sample images to be detected corresponding to each target image reconstructed value as the abnormal image set within the sample image set to be detected.
[0100] This application embodiment uses an image anomaly detection model that possesses the ability to reconstruct normal sample images, sparse constraint ability, distribution constraint ability, and the ability to deceive the discriminator to detect the image set to be detected, thereby enabling a faster and more accurate distinction between normal and abnormal images in the image set to be detected.
[0101] Furthermore, the image anomaly detection model training apparatus provided in this application is described, and the image anomaly detection model training apparatus and the image anomaly detection model training method correspond to each other.
[0102] like Figure 3 As shown, Figure 3 This is a schematic diagram of the image anomaly detection model training device provided in this application. The image anomaly detection model training device includes:
[0103] The acquisition module 301 is used to perform image preprocessing on the acquired base station component image set to obtain a normal sample image training set of the base station component image set;
[0104] The first training module 302 is used to train the preset autoencoder by combining the normal sample image training set with sparse constraints and distribution constraints to obtain the target optimized autoencoder.
[0105] The second training module 303 is used to retrain the target optimized autoencoder through a discriminator to obtain an image anomaly detection model.
[0106] Furthermore, the acquisition module 301 is also used for:
[0107] Images of the base station components of a preset base station are acquired by acquiring images of the base station components at a preset acquisition frequency, thereby obtaining an image set of the base station components;
[0108] By using preset cropping rules, preset image regions of each base station component image in the base station component image set are cropped to obtain the image set to be processed;
[0109] The images of each base station component in the image set to be processed are subjected to grayscale conversion, noise reduction, and sharpening enhancement processing to obtain the target image set;
[0110] The target image set is labeled with normal images and abnormal images to obtain the normal sample image training set.
[0111] Furthermore, the first training module 302 is also used for:
[0112] The preset autoencoder is reconstructed and trained by combining the inverse loss function of peak signal-to-noise ratio with the normal sample image training set to obtain the first autoencoder to be optimized.
[0113] Using KL divergence as the regularization function and the inverse loss function as the sparsity constraint, the first autoencoder to be optimized is trained to obtain the second autoencoder to be optimized.
[0114] The second autoencoder to be optimized is trained by combining the distribution constraints to obtain the target optimized autoencoder.
[0115] Furthermore, the first training module 302 is also used for:
[0116] Determine the encoding vector in the reconstruction training process, and sample vectors of the same dimension as the encoding vector by sampling through a normal distribution;
[0117] The sampling vector is determined as the distribution constraint, and the second autoencoder to be optimized is trained to obtain the target optimized autoencoder.
[0118] Furthermore, the second training module 303 is also used for:
[0119] The encoded vector and the sampled vector are input into the discriminator, which outputs the distinguishable coefficients of the encoded vector and the sampled vector.
[0120] Each of the easily distinguishable coefficients is compared with a preset coefficient to obtain a first comparison result, and based on the first comparison result, a target distinguishable coefficient whose value is less than the preset coefficient is determined among the easily distinguishable coefficients.
[0121] Determine the discriminator coefficients corresponding to the target discrimination coefficients, and retrain the target optimized autoencoder using the discriminator coefficients to obtain the image anomaly detection model.
[0122] Furthermore, the image anomaly detection model training device also includes a detection module, used for:
[0123] The set of sample images to be detected is input into the image anomaly detection model, and the reconstructed image set of the set of sample images to be detected is output.
[0124] The image reconstruction value of the image set to be detected is determined by combining the inverse loss function of peak signal-to-noise ratio with the image set to be detected and its reconstructed image set;
[0125] Based on the image reconstruction values and the preset abnormal image threshold, the abnormal image set in the sample image set to be detected is determined.
[0126] Furthermore, the detection module is also used for:
[0127] The reconstructed values of each image are compared with the preset abnormal image threshold to obtain a second comparison result.
[0128] Based on the second comparison result, determine the target image reconstruction values that are greater than or equal to the preset abnormal image threshold among the image reconstruction values;
[0129] The sample images to be detected corresponding to the reconstructed values of each target image are determined as the abnormal image set in the sample image set to be detected.
[0130] The specific embodiments of the image anomaly detection model training device provided in this application are basically the same as the embodiments of the image anomaly detection model training method described above, and will not be repeated here.
[0131] Figure 4 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 4 As shown, the electronic device may include: a processor 410, a communication interface 420, a memory 430, and a communication bus 440, wherein the processor 410, the communication interface 420, and the memory 430 communicate with each other through the communication bus 440. The processor 410 can call logical instructions in the memory 430 to execute an image anomaly detection model training method, which includes:
[0132] The collected base station component image set is preprocessed to obtain a normal sample image training set of the base station component image set;
[0133] By combining the normal sample image training set with sparse constraints and distribution constraints, the preset autoencoder is trained to obtain the target optimized autoencoder.
[0134] The target-optimized autoencoder is retrained using a discriminator to obtain an image anomaly detection model.
[0135] Furthermore, the logical instructions in the aforementioned memory 430 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0136] On the other hand, this application also provides a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium. The computer program includes program instructions, and when the program instructions are executed by a computer, the computer is able to execute the image anomaly detection model training method provided by the above methods. This method includes:
[0137] The collected base station component image set is preprocessed to obtain a normal sample image training set of the base station component image set;
[0138] By combining the normal sample image training set with sparse constraints and distribution constraints, the preset autoencoder is trained to obtain the target optimized autoencoder.
[0139] The target-optimized autoencoder is retrained using a discriminator to obtain an image anomaly detection model.
[0140] Furthermore, this application also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to perform the image anomaly detection model training methods provided above, the method comprising:
[0141] The collected base station component image set is preprocessed to obtain a normal sample image training set of the base station component image set;
[0142] By combining the normal sample image training set with sparse constraints and distribution constraints, the preset autoencoder is trained to obtain the target optimized autoencoder.
[0143] The target-optimized autoencoder is retrained using a discriminator to obtain an image anomaly detection model.
[0144] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0145] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0146] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application.
Claims
1. A method for training an image anomaly detection model, characterized in that, include: The collected base station component image set is preprocessed to obtain a normal sample image training set of the base station component image set; By combining the normal sample image training set with sparse constraints and distribution constraints, the preset autoencoder is trained to obtain the target optimized autoencoder. The target-optimized autoencoder is retrained by a discriminator to obtain an image anomaly detection model; The step of training a preset autoencoder using the normal sample image training set, combined with sparse constraints and distribution constraints, to obtain a target optimized autoencoder includes: The preset autoencoder is reconstructed and trained by combining the inverse loss function of peak signal-to-noise ratio with the normal sample image training set to obtain the first autoencoder to be optimized. Using KL divergence as the regularization function and the inverse loss function as the sparsity constraint, the first autoencoder to be optimized is trained to obtain the second autoencoder to be optimized. The second autoencoder to be optimized is trained by combining the distribution constraints to obtain the target optimized autoencoder; The step of training the second autoencoder to be optimized in conjunction with the distribution constraints to obtain the target optimized autoencoder includes: Determine the encoding vector in the reconstruction training process, and sample vectors of the same dimension as the encoding vector by sampling through a normal distribution; The sampling vector is determined as the distribution constraint, and the second autoencoder to be optimized is trained to obtain the target optimized autoencoder; The step of retraining the target-optimized autoencoder through a discriminator to obtain an image anomaly detection model includes: The encoded vector and the sampled vector are input into the discriminator, which outputs the distinguishable coefficients of the encoded vector and the sampled vector. Each of the easily distinguishable coefficients is compared with a preset coefficient to obtain a first comparison result, and based on the first comparison result, a target distinguishable coefficient whose value is less than the preset coefficient is determined among the easily distinguishable coefficients. Determine the discriminator coefficients corresponding to the target discrimination coefficients, and retrain the target optimized autoencoder using the discriminator coefficients to obtain the image anomaly detection model.
2. The image anomaly detection model training method according to claim 1, characterized in that, After retraining the target-optimized autoencoder using a discriminator to obtain the image anomaly detection model, the method further includes: The set of sample images to be detected is input into the image anomaly detection model, and the reconstructed image set of the set of sample images to be detected is output. The image reconstruction value of the image set to be detected is determined by combining the inverse loss function of peak signal-to-noise ratio with the image set to be detected and its reconstructed image set; Based on the image reconstruction values and the preset abnormal image threshold, the abnormal image set in the sample image set to be detected is determined.
3. The image anomaly detection model training method according to claim 2, characterized in that, The step of determining the abnormal image set in the sample image set to be detected based on the reconstructed values of each image and a preset abnormal image threshold includes: The reconstructed values of each image are compared with the preset abnormal image threshold to obtain a second comparison result. Based on the second comparison result, determine the target image reconstruction values that are greater than or equal to the preset abnormal image threshold among the image reconstruction values; The sample images to be detected corresponding to the reconstructed values of each target image are determined as the abnormal image set in the sample image set to be detected.
4. The image anomaly detection model training method according to claim 1, characterized in that, The step of preprocessing the acquired base station component image set to obtain a normal sample image training set of the base station component image set includes: Images of the base station components of a preset base station are acquired by acquiring images of the base station components at a preset acquisition frequency, thereby obtaining an image set of the base station components; By using preset cropping rules, preset image regions of each base station component image in the base station component image set are cropped to obtain the image set to be processed; The images of each base station component in the image set to be processed are subjected to grayscale conversion, noise reduction, and sharpening enhancement processing to obtain the target image set; The target image set is labeled with normal images and abnormal images to obtain the normal sample image training set.
5. An image anomaly detection model training device, characterized in that, Using the image anomaly detection model training method according to any one of claims 1 to 4, the image anomaly detection model training device includes: The acquisition module is used to perform image preprocessing on the acquired base station component image set to obtain a normal sample image training set of the base station component image set; The first training module is used to train the preset autoencoder by combining the normal sample image training set with sparse constraints and distribution constraints, so as to obtain the target optimized autoencoder. The second training module is used to retrain the target optimized autoencoder through a discriminator to obtain an image anomaly detection model.
6. An electronic device, the electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the image anomaly detection model training method according to any one of claims 1 to 4.
7. A non-transitory computer-readable storage medium, the non-transitory computer-readable storage medium comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the image anomaly detection model training method according to any one of claims 1 to 4.
Citation Information
Patent Citations
Image generation model training method and image generation method
CN110163267A
Unsupervised learning image anomaly detection method based on auto-encoder
CN112101426A
Optical glass anomaly detection method and device
CN113870204A