Anomaly detection using dynamic density estimation
By using convolutional neural networks and support vector sets for modeling, and by gradually improving anomaly detection performance through cold start and incremental training phases, the poor performance of machine learning models when training data lacks diversity is addressed, thus achieving fast and efficient anomaly detection.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- HONG KONG APPLIED SCI & TECH RES INST
- Filing Date
- 2023-02-02
- Publication Date
- 2026-04-10
AI Technical Summary
Existing machine learning models perform poorly in anomaly detection when training data lacks diversity, resulting in slow detection speeds and a lack of continuous improvement capabilities. This is particularly problematic in the quality control of manufactured goods due to low computer memory efficiency.
Convolutional Neural Networks (CNNs) are used for feature extraction, combined with support vector sets for modeling. Anomaly detection performance is gradually improved through a cold start phase and an incremental training phase. In the cold start phase, a pre-trained CNN and normal samples are used to generate feature maps. In the incremental training phase, the CNN is fine-tuned and the support vector set is updated by generating its own anomaly samples, and dynamic density estimation is used to reduce computational cost.
It improves the performance of anomaly detection, enables continuous improvement of detection capabilities even in the absence of an initial training set of anomaly samples, enhances detection speed and computer memory efficiency, and adapts to the characteristics of manufactured items.
Smart Images

Figure CN116324877B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present disclosure relates to an anomaly detection technique for detecting abnormal patterns or data points that do not conform to an expected distribution. The present invention particularly relates to a technique that can continuously improve anomaly detection performance when there are more abnormal or unusual data, solve the cold start problem, and can evolve gradually as more and more abnormal examples appear. BACKGROUND
[0002] Anomaly detection is concerned with identifying anomalies, i.e. abnormal patterns or data points that do not conform to an expected distribution. One popular approach in the industry is to apply machine learning techniques to anomaly detection. Since abnormal data is very rare in most practical anomaly detection scenarios, machine learning models are usually learned with normal data, sometimes with an additional small amount of abnormal data. Due to the lack of diversity in training data, it leads to poor anomaly detection performance. In addition to poor performance, it also leads to other problems, such as slow detection speed due to the low memory efficiency of computer implementation of machine learning techniques, and the lack of ability to continuously improve anomaly detection performance. There is a need in the art for an improved machine learning technique to solve the above technical problems.
[0003] The technique has many industrial applications, particularly in the field of manufacturing items on a test production line. Solving the problem of poor anomaly detection performance enables the technique to be used more effectively for detection and quality control of manufactured items. Solving the problem of slow detection speed enables the technique to speed up product detection. Having the ability to continuously improve anomaly detection performance enables testing and quality control to be adaptive or personalized to the characteristics of the manufactured items. SUMMARY
[0004] One aspect of the present disclosure is to provide a computer-implemented method for detecting anomalies in samples in a plurality of samples.
[0005] In the method, a plurality of samples are processed in an inference phase for anomaly detection. A cold start phase is inserted before the inference phase. The inference phase is divided into a plurality of inference phase sessions. A retraining session is inserted between any two consecutive inference phase sessions. In the inference phase, a convolutional neural network (CNN) is used to extract features of a single sample to generate a feature map. One or more support vector set modeled machine learning classifiers are used to process the feature map to determine whether the single sample is anomalous. In the cold start phase, the one or more support vector sets are initialized according to a feature map initial training set generated by processing a set of normal samples with the CNN after the CNN is pre-trained. In the retraining session, the CNN is fine-tuned according to at least one set of interim self-generated anomalous samples identified in an inference phase session prior to the retraining session. The one or more support vector sets are updated according to a feature map interim training set generated by processing the set of normal samples with the CNN after the CNN is fine-tuned. Thus, the anomaly detection performance is continuously improved as new identified self-generated anomalous samples are introduced in incrementally training the CNN and the classifiers, while avoiding the need to find an initial training set of anomalous samples to initialize the CNN and the classifiers in the cold start phase.
[0006] In the cold start phase, preferably, a first plurality of feature k-centers is generated from features extracted from the feature map initial training set. Each support vector in the initialized one or more support vector sets is selected from the first plurality of feature k-centers.
[0007] Although in the retraining session, the one or more support vector sets can be determined directly from the feature map intermediate training set by using the k-center algorithm as in the cold start phase, it is more preferable to update the one or more support vector sets from the feature map intermediate training set with the knowledge of the existing support vectors to reduce the computation. Therefore, a dynamic density estimation for dynamically selecting feature k-centers to represent normal data is disclosed. According to the dynamic density estimation, firstly, it is determined whether a single support vector in the one or more support vector sets is no longer a feature k-center according to the feature map intermediate training set. Therefore, the individual support vectors in the one or more support vector sets are divided into retainable support vectors and discardable support vectors to update the one or more support vector sets. Then, a second plurality of feature k-centers is generated from the features extracted from the feature map intermediate training set on the condition that the retainable support vectors are located in the second plurality of feature k-centers. Therefore, it reduces the amount of computation compared to generating the second plurality of feature k-centers from scratch. Finally, the individual support vectors in the updated one or more support vector sets are selected from the second plurality of feature k-centers. Preferably, the entire second plurality of feature k-centers is fully utilized in forming the individual support vectors to avoid wasting some computational effort in generating the second plurality of feature k-centers.
[0008] In certain embodiments, the first and second plurality of feature k-centers are obtained by using a greedy k-center algorithm.
[0009] In certain embodiments, the one or more support vector sets consist of a plurality of support vector sets, wherein a single support vector set collects the individual support vectors located on a preselected region of the feature map, and the individual preselected regions of the plurality of support vector sets are non-overlapping. Furthermore, in the inference phase, each of the plurality of support vector sets is used to process the feature map to determine any location on the individual sample where an anomaly occurs.
[0010] In certain embodiments, the one or more support vector sets consist of a single support vector set.
[0011] In certain embodiments, the CNN comprises an average pooling layer to reduce the feature map into one feature vector. Furthermore, the one or more support vector sets consist of a single support vector set.
[0012] In the cold start phase, the CNN can be pre-trained by loading the pre-stored CNN model parameters into the CNN.
[0013] In the retraining session, the fine-tuning of the CNN can include: augmenting the normal sample set with the set of self-generated abnormal samples by copying the selected abnormal portion of each abnormal sample in the set of self-generated abnormal samples onto one or more normal samples in the normal sample set, thereby creating a set of synthetic training samples to enrich the variety of the training set for fine-tuning the CNN; and updating the model parameters of the CNN based on the set of synthetic training samples by performing multiple iterations of optimization of the model parameters to minimize the loss function in each iteration and alternating and recursively using the center loss and the diversity loss as the loss function in the iterations of optimization of the model parameters.
[0014] Embodiments of the disclosed method are developed for the specific case where the individual samples are images. In this case, the CNN is typically implemented using two-dimensional convolution operations. The individual abnormal samples in the abnormal sample set can be manually pixelwise labelled to improve the accuracy of the CNN model. In this case, the individual synthetic training samples are also automatically pixelwise labelled.
[0015] In some embodiments, the individual samples are images, and the fine-tuning of the CNN further includes: receiving the set of self-generated abnormal samples, wherein the individual abnormal samples are pixelwise labelled to increase the accuracy of the CNN model when retraining the CNN.
[0016] In some embodiments, the classifier employs L2 distance as the classification criterion.
[0017] Other aspects of the disclosure are disclosed as follows. BRIEF DESCRIPTION OF DRAWINGS
[0018] Figure 1 A process flow diagram for detecting abnormalities in samples in a plurality of samples is shown for an exemplary embodiment of the method of the present invention, where the process is divided into a cold start phase, an incremental training phase, and an inference phase.
[0019] Figure 2 A schematic diagram of the three phases is shown to illustrate the operations performed in and across the three phases.
[0020] Figure 3 An illustrative example of the copy-paste augmentation technique for creating a set of synthetic training samples from a set of normal samples and a set of temporary self-generated abnormal samples is provided.
[0021] Figure 4 A performance comparison between a fine-tuning procedure using synthetic data and custom loss and a conventional training procedure not using synthetic data and custom loss in CNN training is provided.
[0022] Figure 5An exemplary step flow diagram showing the dynamic density estimation operation and the second build operation performed in a retraining session of the incremental training phase is shown.
[0023] Figure 6 Conceptual diagrams showing three arrangements of one or more support vector sets for achieving different detection speed requirements under different computer memory constraints are shown.
[0024] Those skilled in the art will understand that the elements in the figures are shown for the purpose of simplicity and clarity and are not necessarily to scale. DETAILED DESCRIPTION
[0025] The present disclosure relates to detecting anomalies in samples based on machine learning. A single sample considered in the present disclosure is a one-dimensional or multi-dimensional signal, as described below. One industrial application of anomaly detection is related to testing manufactured products. In one practical scenario, an automated test machine takes pictures of a manufactured product and analyzes the pictures to detect defective items. Thus, a single sample is a two-dimensional (2D) image. In another scenario, a sensor is used to test a certain functionality of a manufactured product. A single sample is simply a one-dimensional (1D) data stream given by a time series of sensor data, measuring the performance of the item on one activity. For example, the item is a car and the activity is braking, and a time series of sensor data gives the deceleration curve of the car. In another scenario, a robotic arm is tested to perform a complex motion-based task. A single sample is simply a video clip recording the motion of the robotic arm during operation. The video clip is a three-dimensional (3D) signal, with three dimensions of width, height, and number of frames. Similarly, the action of opening a car door automatically can be tested by taking a video clip of the action.
[0026] Disclosed herein is a computer-implemented method for detecting anomalies in samples of a plurality of samples. A machine learning model is used for anomaly detection.
[0027] The method is illustrated by means of Figure 1 and Figure 2 Figure 1 A flowchart of a process 100 for detecting anomalies in each sample of a plurality of samples of an exemplary embodiment of the method of the present disclosure is shown. The process 100 is divided into a cold start phase 110, an incremental training phase 120, and an inference phase 130. Figure 2 A schematic diagram of the three phases 110, 120, 130 is shown to illustrate the operations performed in and across the three phases 110, 120, 130.
[0028] Since a machine learning model is used in the process 100, a plurality of samples (295) is processed in the inference phase 130 for anomaly detection. The cold start phase 110 before the inference phase 130 is an initialization phase for initializing variables used in the process 100 and training the machine learning model before the inference phase 130 starts. In the process 100, the inference phase 130 is divided into a plurality of inference phase sessions 130:1-n, where n is the number of inference phase sessions in the inference phase 130. Therefore, the processing of the plurality of samples 295 for anomaly detection is distributed into the n inference phase sessions 130:1-n. The incremental training phase 120 is used to retrain or update the machine learning model to improve the anomaly detection performance. The incremental training phase 120 is divided into a plurality of retraining sessions 120:1-(n-1). In the process 100, a retraining session is inserted between two consecutive inference phase sessions. For example, the retraining session 120:1 is located in time between the two inference phase sessions 130:1, 130:2. Since the inference phase 130 is divided into n inference phase sessions, there are n-1 retraining sessions.
[0029] Since each sample 295 is a one-dimensional or multi-dimensional signal, a convolution operation is useful for extracting features of the signal. In the present disclosure, a CNN 232 is used to process the signal for feature extraction 234.
[0030] In the inference phase 130, the CNN 232 is used to extract features of a single sample of the plurality of samples 295, thereby generating a feature map 235. Then, a machine learning classifier 239 modeled with one or more support vector sets 246 is used to process the feature map 235 to determine whether the single sample is anomalous. Each support vector set includes one or more support vectors. Functions of support vectors and support vector sets can be found in literature related to clustering. In the classifier 239, a feature vector distance computation 236 is performed between the feature map 235 and each support vector set to produce one or more distances. The one or more distances are used to determine whether the single sample under test is anomalous (238). The one or more support vector sets 246 are initially obtained in the cold start phase 110 and iteratively updated in the incremental training phase 120.
[0031] The classifier 239 can employ L2 distance as the criterion for classification. Each of the one or more distances computed in the feature vector distance computation 236 is an L2 distance. The one or more L2 distances computed are used in the determination step 238 described above. Any other distance metric can also be used as the criterion for the classifier 239.
[0032] In the cold start phase 110, the one or more support vector sets 246 are initialized from a feature map initial training set 215. The feature map initial training set 215 is generated by processing a set of normal samples 290 using a pre-trained CNN 212, where the pre-trained CNN 212 is trained for feature extraction 214. Note that the normal sample set 290 is a training data set. The CNN 212 is pre-trained by loading pre-stored CNN model parameters into the CNN 212.
[0033] In a single retraining session of the incremental training phase 120, the CNN 232 is fine-tuned (resulting in a fine-tuned CNN 222) by the fine-tuning procedure 210 from at least one set of temporary self-generated abnormal samples 296 identified during an inference phase session immediately preceding the single retraining session. Then, the one or more support vector sets 246 are updated from a feature map intermediate training set 225 generated by processing the normal sample set 290 using the fine-tuned CNN 222, which is generated in the single retraining session.
[0034] For illustration, consider the ith retraining session 120:i, where 1 < i < n. The set of abnormal samples identified during the ith inference phase session 130:i constitutes the temporary collection of self-generated abnormal samples 296 to be used in the ith retraining session 120:i. Thus, the CNN 232 used in the ith inference phase session 130:i has been trained using training samples obtained from the normal sample set 290 and the collection of abnormal samples identified during the first to (i-1)th inference phase sessions 130:1-(i-1) in detecting abnormalities in the plurality of samples 295. In the ith retraining session 120:i, the CNN 232 is improved or fine-tuned by further training using the additional abnormal samples newly identified during the ith inference phase session 130:i. The fine-tuned CNN 222 obtained in the ith retraining session 120:i is then used to perform feature extraction 224 by processing the normal sample set 290 to generate the feature map intermediate training set 225. Note that the normal sample set 290 used in the ith retraining session 120:i is the same as used in the cold start phase 110 and the first to (i-1)th retraining sessions 120:1-(i-1). The one or more support vector sets 246 are then updated using the feature map intermediate training set 225.
[0035] In contrast to the cold start phase 110, in which only the normal sample set 290 is used for training, the incremental training phase 120 uses abnormal samples to update the CNN 232, which are self-generated from inspecting the possible abnormality of the plurality of samples 295. With this arrangement, even if there are no abnormal samples for training in the cold start phase 110, it provides diversity of training samples. Advantageously, this arrangement of the incremental training phase 120 results in continuously improving abnormality detection performance, as newly identified self-generated abnormal samples are introduced in the incremental training of the CNN 232 and the classifier 239, while avoiding the need to find an initial training set of abnormal samples for initializing the CNN 232 and the classifier 239 in the cold start phase 110.
[0036] Since the respective temporary set of self-generated abnormal samples of different retraining sessions likely have different and variable number of abnormal samples, developing a fine-tuning procedure 210 that is efficient and achieves good training performance is generally not straightforward. In the fine-tuning procedure 210, preferably, the CNN 232 is fine-tuned according to both the normal sample set 290 and the temporary set of self-generated abnormal samples 296, but not the latter set alone. In particular, the normal sample set 290 is augmented with the temporary set of self-generated abnormal samples 296 by a copy-paste augmentation technique to create a synthetic training data. In the copy-paste augmentation technique, selected abnormal portions of each abnormal sample in the temporary set of self-generated abnormal samples 296 are copied onto one or more normal samples in the normal sample set 290, thereby creating a set of synthetic training samples for enriching the diversity of the training set in fine-tuning the CNN 232.
[0037] Figure 3 An illustrative example is provided to create a synthetic training sample set 300 from the normal sample set 290 and the temporary set of self-generated abnormal samples 296 by the copy-paste augmentation technique. The normal sample set 290 has eight normal samples 311-318. The synthetic training sample set 300 has eight samples 331-338. The temporary set of self-generated abnormal samples 296 has eight abnormal samples 321-328. Selected abnormal portions 321a, 322a, 323a, 324a, 325a, 326a, 327a, 328a of the abnormal samples 321-328 are copied and pasted onto the corresponding normal samples 311-318, respectively, to form the synthetic training samples 331-338 of the synthetic training sample set 300.
[0038] After the synthetic training sample set is prepared, the model parameters of the CNN 232 are preferably and advantageously updated according to the synthetic training sample set. In particular, the model parameters are updated by performing multiple iterations of optimization of the model parameters to minimize a loss function in each iteration, and alternatingly and recursively using the center loss and the diversity loss as the loss function in the iterations of optimization of the model parameters. The purpose of using the center loss in the optimization of the model parameters is to increase the similarity of the feature maps obtained for different normal samples. Let C be the center of the normal images. The center loss L C is given by
[0039]
[0040] where y i = 0 indicates that instance i belongs to the abnormal case; if s is true, then δ(s) = 1, otherwise δ(s) = 0; m is the number of synthetic training samples in the synthetic training sample set. The purpose of using the diversity loss in the optimization of the model parameters is to increase the difference between the normal case and the abnormal case. The diversity loss L D is given by
[0041]
[0042] where y i = 1 indicates that instance i belongs to the normal case. Note that C is updated in each optimization instance. With the above arrangement of the selection of the loss functions for the optimization of the model parameters, the fine-tuned CNN 222 is advantageously enabled to more effectively detect fine-grained defects. The number of iterations of the optimization of the model parameters can be selected as 2, 4, or any even number deemed appropriate by those skilled in the art. The number of iterations can also be selected as an odd number greater than 1.
[0043] Figure 4 A performance comparison between the fine-tuning procedure 210 disclosed herein using synthetic data and custom loss (i.e., alternatingly and recursively using the center loss and the diversity loss) and a conventional training procedure not using synthetic data and custom loss is provided. The performance of the fine-tuning procedure 210 and the conventional training procedure are plotted as curves 420 and 410, respectively. It is clear that the fine-tuning procedure 210 outperforms the conventional training procedure.
[0044] As mentioned above, one or more support vector sets 246 need to be determined in both the cold start phase 110 and the incremental training phase 120. In the cold start phase, the one or more support vector sets 246 are initialized by the first building operation 216 from the feature map initial training set 215. In separate retraining sessions, the one or more support vector sets 246 are updated by the second building operation 226 from the feature map intermediate training set 225. The first and second building operations 216, 226 are detailed below.
[0045] The first and second building operations 216, 226 can be implemented according to techniques known in the art to select appropriate support vectors from the feature map initial training set 215 and the feature map intermediate training set 225, respectively.
[0046] The first building operation 216 can be implemented by first generating a first plurality of feature k-centers from the extracted features of the feature map initial training set, and then selecting one or more support vectors of the respective support vector set 246 from the first plurality of feature k-centers. The first plurality of feature k-centers can be obtained from the extracted features by using a k-center algorithm known in the art. The k-center algorithm can be a greedy k-center algorithm.
[0047] The second building operation 226 can be implemented by the same method as implementing the first building operation 216. That is, the one or more support vector sets 246 are determined directly from the feature map intermediate training set 225 by using a k-center algorithm. However, if the knowledge of the existing support vectors is utilized when updating the one or more support vector sets 246 from the feature map intermediate training set 225, the amount of computation required can be advantageously reduced. Based on this approach, it is advantageous to perform the operation of dynamic density estimation 227 for dynamically selecting feature k-centers to represent normal data before performing the second building operation 226.
[0048] Figure 5 An exemplary step flowchart of the dynamic density estimation operation 227 and the second building operation 226 in the ith retraining session 120:i is shown. At the beginning of the ith retraining session 120:i, the one or more support vector sets 246 used in the ith inference session 130:i are available. For the sake of clarity, these one or more support vector sets 246 are denoted as the current one or more support vector sets 246. The dynamic density estimation operation 227 includes steps 510 and 520. The second building operation includes step 530.
[0049] Step 510 determines whether a single support vector of the current one or more support vector sets 246 is no longer a feature k-center according to the feature map intermediate training set 225. The original feature k-centers in the previous one or more support vector sets generated in the (i-1)th retraining session 120:(i-1) can not be k-centers of the feature map intermediate training set 225 obtained in the ith retraining session 120:i due to the changes of the feature map. Therefore, the respective support vectors of the current one or more support vector sets 246 are divided into retainable support vectors and discardable support vectors for updating the one or more support vector sets 246. For the sake of convenience, the updated one or more support vector sets 246 are denoted as the updated one or more support vector sets 246.
[0050] Step 520 generates a second plurality of feature k-centers from the features extracted in the intermediate feature map training set 225, under the condition that the retainable support vectors are located in the second plurality of feature k-centers. Since the retainable support vectors are known, only the remaining feature k-centers in the second plurality of feature k-centers need to be computed. Therefore, it reduces the amount of computation required compared to generating the second plurality of feature k-centers from scratch. In some embodiments, the second plurality of feature k-centers is obtained by using a greedy k-center algorithm.
[0051] In step 530, individual support vectors to be included in the updated one or more support vector sets 246 are selected from the second plurality of feature k-centers. Preferably, all individual feature k-centers in the second plurality of feature k-centers are used as individual support vectors, so that all individual feature k-centers are fully utilized to avoid wasting computation in computing the second plurality of feature k-centers.
[0052] In practice, the disclosed method is particularly useful in an industry where any defective items can be identified from image files containing one or more items to be inspected. Various embodiments of the disclosed method can be developed for this industry application.
[0053] In this application, the individual samples in the plurality of samples 295 for anomaly detection are images, and the CNN 232 is implemented by two-dimensional convolution operations.
[0054] Optionally, to improve the accuracy of the CNN model when retraining the CNN 232, the individual anomaly samples in the anomaly sample set 296 are manually pixel-labeled. In this case, the individual synthetic training samples in the synthetic training sample set are also automatically pixel-labeled. In the fine-tuning procedure 210, the process 100 first receives the anomaly sample set 296, in which the individual anomaly samples are pixel-labeled. The received pixel-labeled anomaly sample set is used to obtain the fine-tuned CNN 222. In addition to using the pixel-labeled anomaly sample set, the normal sample set 290 can also be (manually) labeled to improve the accuracy of the CNN model in obtaining the fine-tuned CNN 222.
[0055] The first and second construction operations 216, 226 for constructing the one or more support vector sets 246 can be designed for the above-mentioned industrial application of identifying defective items from 2D images, with the additional advantage of adapting the disclosed method to practical implementation under certain detection speed requirements and computer memory limitations. The main idea is to arrange the one or more support vector sets 246 as a single support vector set or multiple support vector sets.
[0056] Figure 6Conceptual diagrams showing three arrangements of the one or more sets of support vectors 246 for achieving different detection speed requirements under different computer memory constraints, where the three arrangements form different bases when designing the second build operation 226. The first build operation 216 is designed similarly. Those skilled in the art will appreciate that the first build operation 216 can be designed according to the teachings related to the second build operation 226 disclosed herein.
[0057] In the first arrangement 610, the one or more sets of support vectors 246 consists of a single set of support vectors, such that all the respective support vectors in the one or more sets of support vectors 246 are collected in the single set of support vectors. Therefore, the Euclidean transformation of the input image does not affect the output result. Since the rotation of the input image does not affect the output result, the classifier 229 can make the classification without the need to align the item under test in the input image with a certain reference frame. It allows for "position unawareness" of the item when preparing the input image. The disclosed method using the first arrangement 610 can produce a segmentation result and provide the location on the input image where the anomaly occurs. Therefore, the disclosed method provides the following information: if the sample under test contains multiple items, which item imaged in the sample under test is defective; or if the sample under test contains a single item, which particular part(s) of the item is defective. It is thus seen that the disclosed method produces a segmentation result and a classification result for the input image (i.e. the sample under test).
[0058] In the second arrangement 620, the one or more sets of support vectors 246 consists of multiple sets of support vectors. A single set of support vectors collects respective support vectors that are located on a preselected region of the feature map. The preselected region has a corresponding region on the input image that is the sample under test. Furthermore, the respective preselected regions of the multiple sets of support vectors are non-overlapping, such that the multiple sets of support vectors are disjoint. Therefore, the Euclidean transformation of the input sample has a critical impact on the output result. Since the rotation of the input image affects the output result, in order to achieve good classification performance, the item under test in the input image must be aligned with a certain reference frame. "Position awareness" of the item is required when preparing the input image. The disclosed method using the second arrangement 620 can produce a segmentation result and provide the location on the input image where the anomaly occurs. Furthermore, the disclosed method provides faster training and higher inference speed. However, the disadvantage of the second arrangement 620 is that more memory is required to store the multiple sets of support vectors. Note that in response to using the second arrangement 620 in the incremental training phase 120 and the cold start phase 110, the inference phase 130 is also arranged to use each of the multiple sets of support vectors to process the feature map to determine any location on the single sample where the anomaly occurs.
[0059] In the third arrangement 630, the one or more support vector sets 246 consists of a single support vector set. In addition, the support vectors in the single support vector set are features in one-dimensional vector form after average pooling. The features in one-dimensional vector form are obtained by first processing the output feature maps 650 in the middle training set 225 in the feature maps with average pooling 660 to form output feature vectors 665, and then processing the output feature vectors 665 with dynamic density estimation 227 to produce features k-centers as vectors. The disclosed method using the third arrangement 630 can only provide a classification result of whether the whole of the test sample is abnormal, but cannot provide any segmentation result. On the other hand, since features vectors are used instead of feature maps, the disclosed method is extremely fast in retraining (incremental training phase 120) and making inferences (inference phase 130). Note that to implement the third arrangement 630, the CNN 232 is designed to include one average pooling layer so that the feature maps 235 are simplified to one feature vector. Note also that similar to the first arrangement 610 employing a single support vector set, using the third arrangement 630 allows for "location-unknown" of the item when preparing the input image.
[0060] Experimental results for comparing the first, second, and third arrangements 610, 620, 630 were obtained. Table 1 provides a performance comparison of inference speed (i.e., detection speed) and retraining speed between the first, second, and third arrangements 610, 620, 630. It is clear that the third arrangement 630 is extremely fast in retraining and inference, while the second arrangement 620 can achieve better performance in terms of inference speed and retraining speed.
[0061] Table 1
[0062]
[0063] To compare the disclosed method and the anomaly detection performance of the supervised baseline model (based on US9,964,607B1 and CN110555467A), experiments were conducted. Table 2 lists the area under the receiver operating characteristic curve (AUC-ROC) values as performance measurement indicators of the disclosed method and the supervised baseline model. Since incremental training is used in the disclosed method, the AUC-ROC values are measured at four selected time points: (1) the end of the cold start phase 110; (2) the end of the first to third retraining sessions 120:1-3. In the experiments, the cold start phase 110 uses 300 normal samples as training data; in the first, second, and third retraining sessions 120:1-3, an additional 100, 200, and 300 defect images are added as training data, respectively. In particular, the additional defect images are first passed to the disclosed method and the supervised baseline model for inference. The disclosed method uses the newly identified defect images for incremental training. On the other hand, the supervised baseline model is trained in the cold start phase, but the training data used to train the supervised baseline model is synthetic training data augmented with normal and abnormal images. The center loss and diversity loss are used as loss functions to train the supervised baseline model. As can be clearly seen from Table 2, the performance of the disclosed method gradually improves if there are more abnormal images as training data. In contrast, the performance of the supervised baseline model gradually deteriorates. The comparison results show that the disclosed method is improved over the supervised baseline model.
[0064] Table 2
[0065]
[0066] The disclosed subject matter can be embodied in other specific forms without departing from the spirit or essential characteristics thereof. Thus, the present embodiments are to be considered in all respects as illustrative and not restrictive, the scope of the application being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein.
Claims
1. A computer-implemented method for detecting sample anomalies among multiple samples, wherein the samples are images or video clips, the method comprising: Multiple samples are processed for anomaly detection during the inference phase. A cold start phase is inserted before the inference phase. The inference phase is divided into multiple inference phase sessions. A retraining session is inserted between any two consecutive inference phase sessions. During the inference phase, features of individual samples are extracted using a convolutional neural network (CNN) to generate feature maps, and the feature maps are processed using a machine learning classifier modeled with one or more support vector sets to determine whether the individual samples are anomalous. During the cold start phase, the one or more support vector sets are initialized based on the initial training set of feature maps generated by processing a set of normal samples with a CNN after CNN pre-training; In the retraining session, the CNN is fine-tuned based on at least one set of temporarily generated anomalous samples identified during an inference phase session immediately preceding the retraining session, and the one or more support vector sets are updated based on the intermediate training set of feature maps generated by processing the normal sample set with the CNN after fine-tuning. This allows the anomaly detection performance to be continuously improved by introducing newly identified generated anomalous samples during incremental training of the CNN and classifier, while avoiding the need to find an initial training set of anomalous samples to initialize the CNN and classifier during the cold start phase. During the cold start phase, features extracted from the initial training set of the feature maps generate a first plurality of feature k-centers, and support vectors to be included in the one or more initialized support vector sets are selected from the first plurality of feature k-centers; and In the retraining session: Based on the intermediate training set of the feature map, determine whether a single support vector in the one or more support vector sets is no longer a feature k-center. Accordingly, divide each support vector in the one or more support vector sets into retainable support vectors and discardable support vectors to update the one or more support vector sets. Under the condition that the retainable support vectors are located at the second plurality of feature k-centers, the second plurality of feature k-centers are generated from the features extracted from the training set in the middle of the feature map, thereby reducing the amount of computation compared to generating the second plurality of feature k-centers from scratch; and Select each support vector to be included in the updated set of one or more support vectors from the second plurality of feature k-centers.
2. The method of claim 1, wherein each of the first and second plurality of feature k-centers is obtained by using a greedy k-center algorithm.
3. The method according to claim 1, wherein the one or more support vector sets are composed of multiple support vector sets, a single support vector set collects support vectors located on pre-selected regions of the feature map, the pre-selected regions of the multiple support vector sets are non-overlapping, and the method further comprises: During the inference phase, the feature map is processed using each of the plurality of support vector sets to determine any location on the individual sample where an anomaly occurs.
4. The method of claim 1, wherein the one or more support vector sets consist of a single support vector set.
5. The method according to claim 1, wherein: The CNN includes an average pooling layer, which simplifies the feature map into a feature vector. The one or more support vector sets consist of a single support vector set.
6. The method according to claim 1, further comprising: During the cold start phase, the pre-stored CNN model parameters are loaded into the CNN to pre-train it.
7. The method according to claim 1, wherein, In the retraining session, fine-tuning the CNN includes: By copying selected anomalous portions of each anomalous sample in the self-generated temporary set of anomalous samples to one or more normal samples in the normal sample set, the normal sample set is enhanced with the self-generated temporary set of anomalous samples, thereby creating a synthetic training sample set to enrich the diversity of the training set when fine-tuning the CNN. The CNN model parameters are updated based on the synthetic training sample set by performing multiple iterations of optimization on the model parameters, minimizing the loss function in each iteration, and alternately and recursively using center loss and diversity loss as loss functions in the iterations of model parameter optimization.
8. The method of claim 1, wherein the single sample is an image, and the CNN is implemented through two-dimensional convolution operations.
9. The method of claim 1, wherein the single sample is an image, and wherein the fine-tuning of the CNN further comprises: Receive the self-generated temporary set of anomalous samples, wherein individual anomalous samples are labeled pixel by pixel in order to improve the accuracy of the CNN model when retraining the CNN.
10. The method according to claim 1, wherein the classifier uses L2 distance as the classification criterion.
Citation Information
Patent Citations
Industrial data classification method based on model migration
CN110555467A
Recognizing and identifying defect patterns on magnetic media
US9964607B1
Abnormality detection method and device, electronic equipment and computer readable storage medium
CN113688889A
Anomaly detection method
CN114092478A