Industrial Abnormal Pollution Control Method Based on Dual-Perspective Core Filtering
By employing dual-view core filtering technology, unknown and abnormal samples in industrial defect detection are screened and supplemented to construct a pure core set, thus solving the detection challenge under unlabeled training data and improving detection performance.
Patent Information
- Application Number
- CN202411179793.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-27
- Publication Date
- 2025-12-02
- Estimated Expiration
- 2044-08-27
AI Technical Summary
Existing industrial defect detection technologies struggle to effectively filter out unknown real anomalies in unlabeled training data environments, resulting in poor detection performance.
A dual-view core filtering method is adopted, which combines feature extraction and core set sampling with global and local view filters to screen potential anomalies, and uses far-point balanced sampling technology to supplement normal cores, thus constructing a purer core set.
It significantly improves the accuracy and effectiveness of industrial defect detection in unlabeled training data environments, making it suitable for more complex industrial production environments.
Smart Images

Figure CN119068288B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of industrial defect detection and data governance, specifically to an industrial abnormal pollution control method based on dual-view core filtering. Background Technology
[0002] Industrial defect detection involves identifying defective industrial products and segmenting the defective regions to determine the degree of abnormality of each pixel in the original image. In recent years, industrial defect detection technology has increasingly relied on training with only positive examples, meaning training on a single class and inference on an unseen test set containing anomalous samples. However, real-world industrial production environments contain unknown anomalous samples; obtaining pure, uncontaminated training data in unlabeled scenarios is difficult. Existing industrial defect detection technologies are limited by idealized scenarios, thus necessitating new solutions for more realistic and challenging training with interfering data. Summary of the Invention
[0003] (a) Technical problems to be solved
[0004] To address the shortcomings of existing technologies, this invention provides a method for controlling industrial anomaly contamination based on dual-view core filtering. Addressing the issue that existing core set-based industrial defect detection methods are not applicable to non-pure training environments, this invention proposes a method to remove as many unknown true anomaly samples as possible from the unlabeled industrial image training set. Specifically, under the premise that the unlabeled data follows the single-class assumption, this invention investigates how to utilize the feature space information of the samples to filter out the small number of mixed-in true anomalies, thereby purifying the existing training sample pool as much as possible to obtain a purer normal core set and improve its defect detection performance on unknown industrial images.
[0005] (II) Technical Solution
[0006] To address the aforementioned issues, this invention proposes an abnormal core filtering scheme. This scheme involves modeling the feature space after core sampling, employing both global and local perspectives to dual-screen and eliminate potential anomalies, and utilizing far-point balanced sampling technology to compensate for some missing normal cores. The specific technical solution is as follows:
[0007] An industrial abnormal pollution control method based on dual-view core filtration includes the following steps:
[0008] S1: Feature Extraction and Core Set Sampling: Given an unlabeled industrial image training set X = {X1, ..., X...} n}, where X contains real anomalous images X. a , where |X a|<<|X|; Following the approach of PatchCore, the corresponding feature tensors are extracted from each network layer of WideResNet, denoted as F. i F is the feature tensor extracted from the i-th layer of WideResNet. i The dimension is (b i ,l i ,l i ), b i Let l be the number of feature channels in the i-th network layer. i For F i Regarding the feature map size of the image, F i By b i each l i ×l i It consists of feature maps of different sizes.
[0009] For F i From a single feature map, we iterate through the elements at each position, sampling P×P neighbors centered on each element. Using edge padding, we obtain a new set of block-level feature maps, totaling c. i =l i ×l i indivual;
[0010] The i-th layer of WideResNet has a dimension of (c i ,b i The characteristic tensor F of P, P) i ', Obviously, as i increases, the network layers become deeper, c i continuously decreasing, b i The value increases continuously. Let the minimum value of the actual WideResNet network layer i be i. min The maximum value is i max For F i 'Along c i and b i Interpolation is performed between two dimensions, and the dimensions are converted to ( P,P), then average pooling along the last two dimensions yields a dimension of The aggregation tensor F i Finally, assign the corresponding F values to each layer. i "After concatenation and pooling, the final block-level embedding set Z = {Z1, ..., Zn} is obtained." m},in, m is the total number of block-level embeddings in Z. Let m be the number of the above feature extraction and aggregation operations. Single sample X i go through The operation can result in multiple block-level embeddings.
[0011] Based on the embedding set Z, a stochastic linear mapping is used to reduce the dimensionality to a lower embedding space, resulting in a new embedding set Z′. Then, the Core-set algorithm is used to sample Z′ to extract the core set to be processed. M represents the index of the core set element in Z′. During the startup phase of the Core-set algorithm, a portion of the embeddings are randomly selected from Z′. The average distance from other embeddings to the selected embeddings is calculated. The embedding with the furthest average distance is used to initialize M, thereby starting the Core-set algorithm. The algorithm iterates and samples until the number of embeddings in M reaches the expected target.
[0012] S2: Based on the core set M obtained in S1, select the potential anomaly infiltration set from the perspectives of overall distribution and local correlation.
[0013] S3: Supplement sampling of the lost normal cores; the number of samples is the same as M. a The number of elements in the set is the same, and the sampling method is to iteratively expand the set, selecting an embedding from the original embedding set Z′ each time. This embedding is the same as the one in M. a and the remaining core embedded M\M a The furthest embedding is added to the core set. The above steps are repeated until the predetermined number is reached, resulting in the final core set M′.
[0014] S4: First, test a single new test image x test Using the description in S1 The operation extracts and aggregates features to obtain their block-level embeddings. Then, based on M′, calculate the block-level embedding z. test The abnormal score, i.e. z test The nearest distance to the embedding in M′, all block-level embeddings z test The maximum value of the abnormal score is defined as x. test The abnormal score s:
[0015]
[0016] A higher s indicates a higher value for the test sample x test The more likely an anomaly is, the lower the block-level anomaly score can be compared to an image-level anomaly score to obtain a low-size anomaly segmentation map. To facilitate comparison with the original pixel-level annotations, the anomaly segmentation map needs further processing to restore it to the original input image size. (Test image x) test From input to the final anomaly segmentation map H′, according to... Figure 6 The above steps involve bilinear interpolation to obtain a segmentation image H of the same size as the original input, followed by smoothing with a Gaussian filter (σ=4) to finally obtain a smoothed version of the segmentation image H′. Brighter pixels are more likely to be defects.
[0017] Preferably, the potential anomaly infiltration set M is selected in S2. a The process is as follows:
[0018] S2-1: Use a global filter to establish global associations among the elements of M, and set a threshold to find potential anomalies that are far from the vast majority of points, and index them. Record the data, where n represents the total number of samples in the training set X.
[0019] S2-2: Using a local filter, edge points are first grouped into the same subset as the main cluster. Based on the initialization of a series of small clusters, adjacent clusters are continuously merged by comparing the density of each cluster, ultimately resulting in several main clusters and discrete small clusters. The smaller clusters are then filtered as a whole, with the index of the selected core denoted as [index of the selected core].
[0020] S2-3: Merging of Dual-Filter Detection Results. The two filters initially operate independently, without any order or input-output coupling. The intersection of the candidate indices selected by the global and local filters is then calculated.
[0021] C f =C g ∩C l
[0022] According to C f The index in M is used to extract the corresponding embedding from M, thus forming the potential anomaly infiltration set M. a .
[0023] Preferably, the S2-1 global filter includes the following steps:
[0024] To quantify the overall sparse distribution relationship between anomalous cores and other cores, the similarity between any two core embeddings is defined based on their distance. Specifically, for each core embedding M... i First, determine its relationship with other core embedded M. j Euclidean distance similarity:
[0025]
[0026] The softmax normalization process is used here to construct an asymmetric similarity matrix. This is because for any two points Z′... i and They are not necessarily neighbors, so Z i With Z j The similarity between them is not equal to Z. j With Z iThe similarity between two points needs to be compared with the distances to other points to obtain their respective one-way similarity. Here, D(·,·) is used to represent the similarity between the two points, and the following formula is used to calculate it uniformly:
[0027]
[0028] Where ||·||² represents the l² norm, corresponding to the calculation of Euclidean distance. ∈ represents the minimum value, preventing calculation errors due to a zero denominator, corresponding to two points being too close. Z′ i The similarity to itself is set to negative infinity to prevent it from interfering with the normalization calculation.
[0029] Based on the above analysis, we can obtain the similarity matrix Sim for the one-way relationship, where each row i represents Z′. i The similarity is compared to other points. Next, the summation is performed on each column j to calculate the similarity of other points to Z′. j The total similarity can be seen as the overall association between other members and the core. All cumulative results are sorted from smallest to largest, and the top α% of embeddings are selected and defined as global latent anomalies.
[0030]
[0031] ArgLastK(·,α) represents the index of the last α% member.
[0032] Preferably, the S2-2 local filter includes the following steps:
[0033] First, focusing only on the interrelationships within the core set, we cluster the embeddings into multiple smaller clusters. Without relying on other algorithms, this invention uses the PatchCore sampling method, selecting cores again from the initially obtained core set M, using the preferred embeddings as cluster centers to obtain smaller core sets, while other core set members are assigned to the clusters corresponding to their nearest neighbors. To avoid some isolated discrete points being misassigned to the nearest main cluster due to insufficient cluster centers, we need to set as many cluster centers as possible to subdivide into different smaller clusters. To achieve this, we sample γ% of the cluster centers from the core set, resulting in an average of approximately 1 / γ% of core points per cluster; in the worst case, each cluster may have only one cluster center.
[0034] Clustering of core embeddings is performed here, using the PatchCore sampling algorithm. The core set M is further sampled using the PatchCore algorithm to obtain a smaller core set. γ% of the cores are selected, and the selected core embeddings are used as cluster centers of M. Unselected members in M are assigned to the clusters corresponding to their nearest neighbors. On average, each cluster receives approximately 1 / γ% of core embeddings. Adjacent small clusters are then merged into one, so that edge embeddings are incorporated into the main cluster. Specifically, the "cluster density" ρ of each small cluster is first calculated, which is defined as the average distance between all embeddings in the current cluster and their nearest neighbors within the cluster, i.e.:
[0035]
[0036] Here, Q represents the index of the core embedding in the current cluster. When there is only one cluster member, ρ = 0. Then, the k nearest cluster centers are found based on the distance between each cluster center. Each cluster compares its correlation only with its neighboring clusters, and the comparison principle is to calculate the "cluster density" ρ within the two clusters. i and ρ j If the nearest distance between two clusters (i.e., the nearest distance between all points in the two clusters) d is greater than ρ i and ρ j If both are small, it means they belong to the same distribution, so the two clusters are merged, and the new index set is denoted as Q′. i =Q i ∪Q j The total number of new clusters is denoted as m′.
[0037] The above merging process only requires one round because each cluster only needs to focus on its associations with neighboring clusters. After the loop ends, the entire core set will then construct different network structures. At this point, the number of embeddings of each cluster is compared with the total number of clusters in the core set. Clusters that do not exceed β% of the total number of clusters are defined as local potential anomalies, and their embedding indices are:
[0038]
[0039] Where C l The embeddings in the corresponding initial core set M are local potential anomalies.
[0040] Preferably, the S3 supplementary sampling includes the following steps:
[0041] The goal is to supplement the missing embeddings by selecting points that differ from the anomalous embeddings that were removed, while simultaneously aiming to replenish the diverse normal core points lost—that is, to expand the diversity of the remaining core set as much as possible. However, these two objectives need to be balanced, and it's difficult to always select the embedding that is furthest from both. Therefore, based on the core set Z after removal... r ={Z′ j |j∈C\Cf} and the core set of potential anomalies that were filtered out f ={Z′ j |j∈C f}, from the remaining embedding Z fr ={Z′ i In |i∈[n]\C}, iteratively select the distance Z at the same time. f and Z r The furthest embedding:
[0042]
[0043] Where λ is the balance coefficient, and C represents the index of the core set element in Z′, C f The index of the core set of potential anomalies that have been filtered out in Z′.
[0044] Compared with the prior art, the present invention has at least the following advantages:
[0045] This invention proposes a dual-view core filtering method for industrial anomaly pollution control, applicable to more complex industrial production environments. It designs a feature space-based dual-view model to filter potential anomalies, constructing a purer core set for industrial defect detection. Specifically, building upon existing feature extraction and sampling methods, a global and local dual-view filtering mechanism is established for the further sampled core set to filter outliers both globally and locally. While this dual mechanism reduces the loss of normal cores, to further ensure the representativeness of the core set, this invention proposes a far-point balancing supplementary sampling scheme. This supplements normal cores while minimizing the selection of potential anomalies in their vicinity. This invention employs a dual mechanism of potential anomaly filtering and core supplementary sampling, extracting more normal and representative core embeddings compared to existing schemes, resulting in a significant improvement in industrial defect detection under impure training environments. Attached Figure Description
[0046] To more clearly illustrate the technical solutions in the embodiments of the present invention and the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0047] Figure 1 This is a simplified flowchart of the method of the present invention.
[0048] Figure 2 This is a schematic diagram of the potential anomaly global filtering module.
[0049] Figure 3 This is a schematic diagram of a potential anomaly local filtering module.
[0050] Figure 4 This is a schematic diagram of the far-point balance supplemental sampling.
[0051] Figure 5 This is a visualization of the anomaly filtering effect for some categories in the MVTec-AD dataset.
[0052] Figure 6 This is the calculation method for the anomaly segmentation map. Detailed Implementation
[0053] The present invention will now be described in further detail.
[0054] This invention designs an industrial anomaly pollution control method based on dual-view core filtering. It filters block-level features of anomaly pollution mixed into unlabeled industrial image sets to address real-world production environments. Specifically, given an unlabeled industrial image training set X = {X1, ..., X...} n Input to obtain the final core set This governance framework requires three steps: feature extraction and sampling, core set filtering, and core set supplementary sampling. Here... The index representing the core set element indicates that the core set M is derived from the embedding set Z = {Z1, ..., Zn}. n It was sampled from}.
[0055] The present invention will now be further described in conjunction with the accompanying drawings and embodiments, such as... Figure 1 As shown, an industrial abnormal pollution control method based on dual-view core filtration includes the following steps.
[0056] S1: Feature extraction and core set sampling. Given an unlabeled industrial image training set X = {X1, ..., X...} n}, where X contains real anomalous images X. a , where |X a |<<|X|。 Most past deep anomaly detection methods opted to fine-tune pre-trained features to adapt to the task. However, existing research has found that pre-trained intermediate layer features can actually be directly applied to industrial detection data because shallow features lack sufficient semantic abstraction, while deep features are more biased towards the pre-trained image set and deviate significantly from the target domain. This invention follows the PatchCore approach, extracting the corresponding feature tensors from each layer of WideResNet, denoted as F. i F is the feature tensor extracted from the i-th layer of WideResNet. i The dimension is (b i ,l i ,l i ), b iLet l be the number of feature channels in the i-th network layer. i For F i Regarding the feature map size of the image, F i By b i each l i ×l i The feature map is composed of size. For F i From a single feature map, we iterate through the elements at each position, sampling P×P neighbors centered on each element. Using edge padding, we obtain a new set of block-level feature maps, totaling c. i =l i ×l i indivual;
[0057] The i-th layer of WideResNet has a dimension of (c i ,b i The characteristic tensor F of P, P) i ', Obviously, as i increases, the network layers become deeper, c i continuously decreasing, b i The value increases continuously. Let the minimum value of the actual WideResNet network layer i be i. min The maximum value is i max For F i 'Along c i and b i Interpolation is performed between two dimensions, and the dimensions are transformed... Then, average pooling is performed along the last two dimensions to obtain the dimension as follows. The aggregation tensor F i Finally, assign the corresponding F values to each layer. i "After concatenation and pooling, the final block-level embedding set Z = {Z1, ..., Zn} is obtained." m},in, m is the total number of block-level embeddings in Z. Let m be the number of the above feature extraction and aggregation operations. Single sample X i Multiple block-level embeddings can be obtained through the P(·) operation. In subsequent experimental verification, P is set to 3, and i... min Take 2,i max Take 3.
[0058] For all the embeddings Z extracted from the samples above, a random linear mapping is first used to reduce the dimensionality to a lower embedding space Z′. Because the similarity of industrial inspection image data is very high, and the high-dimensional semantic vectors obtained in the above process contain a lot of redundant information, the random linear mapping can successfully compress them. Next, the Core-set algorithm is used to sample the core set of the dimensionality-reduced vector set, obtaining the indices of the core set elements. The core set M to be processed is then extracted from the embedding set Z. It is important to note that no elements are selected at the start of the algorithm, so a subset of embeddings is randomly selected, the average distance from other embeddings to the selected points is calculated, and the element with the furthest average distance is added to the initial set to start the Core-set. This method is a greedy approach and does not select the global optimum, but it starts quickly and requires fewer computational resources.
[0059] Based on the embedding set Z, a stochastic linear mapping is used to reduce the dimensionality to a lower embedding space, resulting in a new embedding set Z′. Then, the Core-set algorithm is used to sample Z′ to extract the core set to be processed. M represents the index of the core set element in Z′. During the startup phase of the Core-set algorithm, a portion of the embeddings are randomly selected from Z′. The average distance from other embeddings to the selected embeddings is calculated. The embedding with the furthest average distance is used to initialize M, thereby starting the Core-set algorithm. The algorithm iterates and samples until the number of embeddings in M reaches the expected target.
[0060] S2: Based on the assumption of outlier distribution in anomaly embeddings, this invention selects potential contamination points from both the perspective of overall embedding distribution and local correlation. Because the input image yields a series of feature embeddings after extracting abstract features from the pre-trained network, each corresponding to the abstract semantics of a block-level region of the input. Due to potential anomaly interference, defective regions of the anomalous input are also mapped into this space, and the anomaly embeddings are often located in the marginal distribution. The sampling principle of the core set is to select as many diverse samples as possible, thus making it highly likely to hit these block-level features from the anomalous image. From the dual perspectives of overall and local regions, potential block-level anomaly features can be searched more comprehensively and accurately without unsupervised signals.
[0061] It is important to note that the proposed dual-view filter only needs to be based on the core set itself, without using the entire embedding set Z to calculate associations, thus improving the efficiency of the filtering computation. Secondly, for a single anomalous image, not all regions are defective; therefore, its normal block-level features do not actually affect detection and may even provide new patterns not present in the original training set. Based on this, this invention only needs to filter features, not samples; the following filtering operations are performed only at the feature level.
[0062] Based on the core set M obtained from S1, we select potential anomalous infiltration sets from the perspectives of overall distribution and local correlation.
[0063] S2-1: Global Filter. PatchCore is based on the assumption that the feature embeddings of anomalies are spatially far from those of normal embeddings. In other words, anomalies are sparsely distributed, existing far from most normal points. Therefore, anomaly scores can be defined based on the distance between test points and typical points in the core set. Following PatchCore's sampling process, each algorithm selects the point farthest from the core set from the remaining candidate points. Therefore, once an anomaly is selected, other nearby anomalies are unlikely to be selected in subsequent rounds. Furthermore, different types of anomalies are significantly different and do not affect each other during selection, exhibiting a multi-cluster distribution. In summary, the distribution of the core set converges with the distribution of all embeddings. Therefore, this invention suggests that the global filtering algorithm only needs to observe the distance distribution of the core set.
[0064] S2-1-1: Use a global filter to establish global associations among the elements of M, and set a threshold to find potential anomalies that are far from the vast majority of points, and index them. Record the data, where n represents the total number of samples in the training set X.
[0065] The points closest to the anomalous cores in the core set are actually relatively few, and overall, the anomalous points still exhibit outlier dispersion. To quantify this relationship, we first define the similarity between any two core embeddings using the distance between them. Specifically, for each core embedding M... i First, determine its relationship with other core embedded M. j Euclidean distance similarity:
[0066]
[0067] The softmax normalization process is used here to construct an asymmetric similarity matrix. This is because for any two points Z′... i With Z′ j (i≠j), they are not necessarily neighbors, so Z i With Z j The similarity between them is not equal to Z. j With Z i The similarity between two points needs to be compared with the distances to other points to obtain their respective one-way similarity. Here, D(·,·) is used to represent the similarity between the two points, and the following formula is used to calculate it uniformly:
[0068]
[0069] Where ||·||² represents the l² norm, corresponding to the calculation of Euclidean distance. ∈ represents the minimum value, preventing calculation errors due to a zero denominator, corresponding to two points being too close. Z′ i The similarity to itself is set to negative infinity to prevent it from interfering with the normalization calculation.
[0070] S2-1-2: Based on the above analysis, the algorithm can obtain the similarity matrix Sim for one-way relationships, where each row i represents Z′. i The similarity is compared to other points. Next, the summation is performed on each column j to calculate the similarity of other points to Z′. j The total similarity can be seen as the overall association between other members and the core. All cumulative results are sorted from smallest to largest, and the top α% of embeddings are selected and defined as global latent anomalies.
[0071]
[0072] ArgLastK(·, α) represents the index of the last α% member. For illustration, as shown... Figure 2 As shown, the solid gray dots in the two-dimensional space represent normal core embeddings, while the gray circled dots represent embeddings from anomalous samples. Even in the sampled core set, anomalous embeddings are still fewer in number than normal points. In the final global relation candidate set, most easily identifiable anomalies will be included.
[0073] S2-2: Local Filter. After filtering based on global relationships among the core set embeddings, the pre-removed embeddings actually include two types: outliers and normally distributed edge points. The latter refers to normal embeddings that are difficult to identify, corresponding to features that appear less frequently in normal images. If the number of these difficult normal embeddings that are filtered is not reduced, it is easy for similar rare normal features appearing in the test to be misjudged, because the original nearest embedding does not exist in the core set, and it is replaced by other core embeddings, which widens the distance between similar normal features and the core set, and the anomaly score becomes higher. Outliers and difficult normal points have in common that they are generally deviated from the central main cluster. The difference is that the former mostly presents an island distribution, while the latter is mainly located on the peninsula or edge area extending from the main cluster. Therefore, based on such prior knowledge, clustering can be used to study local clustered distributions. However, traditional clustering does not deliberately distinguish between isolated clusters and peninsula clusters. This invention specifically groups peninsula clusters together with the main cluster, and therefore designs a small cluster filtering method based on local association. Based on the initialization of a series of small clusters, by comparing the density of each cluster, adjacent clusters are continuously merged, and finally several main clusters and discrete small clusters are obtained. The small clusters with a small number of clusters are filtered as a whole.
[0074] Local filters are used to first group edge points into the same subset as the main cluster. Based on the initialization of a series of small clusters, adjacent clusters are continuously merged by comparing their densities, ultimately resulting in several main clusters and discrete small clusters. The smaller clusters are then filtered as a whole, with the index of the selected core cluster denoted as [index].
[0075] S2-2-1: Focusing only on the interrelationships within the core set, we first cluster the elements, dividing the embeddings into smaller clusters with fewer internal points. Without relying on other algorithms, this invention uses the PatchCore sampling method. It re-selects cores from the initially obtained core set M, using the preferred embeddings as cluster centers to obtain smaller core sets. Other core set members are assigned to their nearest neighbors. To avoid isolated discrete points being misassigned to the nearest main cluster due to insufficient cluster centers, we need to set as many cluster centers as possible to subdivide the core set into smaller clusters. To achieve this, we sample γ% of the cluster centers from the core set M, resulting in an average of approximately 1 / γ% of core embeddings per cluster; in the worst case, each cluster may have only one cluster center.
[0076] S2-2-2: Next, the local filtering algorithm needs to merge the small clusters obtained in the previous step, combining adjacent small clusters into one so that the peninsula cluster can be incorporated into the main cluster. Specifically, first, the "cluster density" ρ of each small cluster is calculated, which is defined as the average distance between all embeddings in the current cluster and their nearest neighbors within the cluster, i.e.
[0077]
[0078] Here, Q represents the set of indexes embedded in the core of the current cluster. When there is only one cluster member, ρ = 0. Then, the k nearest cluster centers are found based on the distance between each cluster center. Each cluster compares its correlation only with its neighboring clusters, and the comparison principle is to calculate the "cluster density" ρ within the two clusters. i and ρ j If the nearest distance between two clusters (i.e., the nearest distance between all points in the two clusters) d is greater than ρ i and ρ j If both are small, it means they belong to the same distribution, so the two clusters are merged, and the new index set is denoted as Q′. i =Q i ∪Q j The total number of new clusters is denoted as m′. For example... Figure 3 As shown, when calculating the "cluster density" within the original cluster, each point only focuses on its nearest embedding point, ignoring the furthest distance. This is to prevent some clusters from having too many members during the initial partitioning, as the furthest distance would interfere with the density calculation. Hollow circles represent the closest points between clusters, forming bridges connecting two different clusters.
[0079] S2-2-3: The above merging process only needs to be performed in one round, because each cluster only needs to focus on its association with neighboring clusters. After the loop ends, the entire core set will then construct different network structures. At this point, the number of embeddings of each cluster is compared with the total number of clusters in the core set. Clusters that do not exceed β% of the total number of clusters are defined as outliers and isolated clusters, and their embedding indices are...
[0080]
[0081] C l The embeddings in the corresponding initial core set M are local potential anomalies.
[0082] S2-3: Dual-filter collaboration. The two filters work independently, without any sequential order or input-output coupling. Both are based on the complete unfiltered core set for selection. Because they consider different aspects, they both need to utilize the entire initial core set M. Finally, the intersection of the two selected candidate indices is calculated.
[0083] C f =C g ∩C l .
[0084] According to C f The index in M is used to extract the corresponding embedding from M, thus forming the potential anomaly infiltration set M. a It is important to note that we do not use global or local filters separately, but rather evaluate both global and local filters simultaneously. This approach helps to reduce the number of normal filters that are incorrectly filtered out.
[0085] S3: Due to the lack of supervised information, the selected core set may lack normal core points, especially in scenarios with relatively little anomalous noise. In such cases, a single-class model might be sufficient for detection. Therefore, this invention proposes an additional method for supplementing the core set driven by potential anomalies. For example... Figure 4 As shown, different clusters can exist in the high-dimensional hyperspace centered on each core set element. Hollow circles represent normal clusters, and gray dots represent clusters centered on anomalous embeddings. Similar anomalies are more likely to concentrate in this region. To avoid new embeddings being sampled too close to filtered-out anomalies, the algorithm needs to select as few points within their clusters as possible; otherwise, the embedding filtering will lose its meaning. Simultaneously, it aims to supplement points that are different from the filtered-out normal embeddings, that is, to expand the diversity of the remaining core set as much as possible. However, these two objectives need to be balanced; it is difficult to always select the embedding that is furthest from both at the same time.
[0086] Supplementing sampling with the lost normal core components, the number of samples is related to M. aThe number of elements in the set is the same, and the sampling method is to iteratively expand the set, selecting an embedding from the original embedding set Z′ each time. This embedding is the same as the one in M. a and the remaining core embedded M\M a The furthest embedding is added to the core set. The above steps are repeated until the predetermined number is reached, resulting in the final core set M′.
[0087] The supplementary sampling process is as follows: based on the core set Z after filtering... r ={Z′ j |j∈C\C f} and the core set of potential anomalies that were filtered out f ={Z′ j |j∈C f}, from the remaining embedding Z fr ={Z′ i In |i∈[n]\C}, iteratively select the distance Z at the same time. f and Z r The furthest embedding:
[0088]
[0089] Where λ is the balance coefficient, and C represents the index of the core set element in Z′, C f λ is the index of the core set of potential anomalies that have been filtered out in Z′. In actual verification, λ is set to 0.1 because the number of anomalies filtered out is small, preventing them from interfering too much with the diversity.
[0090] S4: During the inference phase, for a single new test image x test Using the description in S1 The operation extracts and aggregates features to obtain their block-level embeddings. Then, based on M′, calculate the block-level embedding z. test The abnormal score, i.e. z test The nearest distance to the embedding in M′, all block-level embeddings z test The maximum value of the abnormal score is defined as x. test The abnormal score s:
[0091]
[0092] Compared to image-level scores, block-level scores constitute a low-size anomaly segmentation map h. To facilitate comparison with the original-size pixel set annotations, the block-level segmentation map needs to be divided into... Figure 6 The above steps involve bilinear interpolation to obtain a segmentation image H of the same size as the original input, followed by smoothing with a Gaussian filter (σ=4) to finally obtain a smoothed version of the segmentation image H′. In this process, brighter pixels are more likely to be at defect locations, while darker pixels are more likely to be normal.
[0093] This invention uses the MVTec-AD dataset to verify the rationality of its content. The MVTec-AD dataset is widely used in various industrial image defect detection applications. It contains 15 sub-datasets, including 5 texture categories (carpet, mesh, leather, tile, and wood) and 10 object categories (glass bottle, cable, capsule, hazelnut, metal nut, pill, screw, toothbrush, transistor, and zipper). The number of samples in each training set ranges from 60 to 391. Following most industrial defect detection research, AUC is used to measure the anomaly score predicted by the model. AUC values need to be compared at both the instance level and the pixel level. For ease of distinction, instance-level AUC is denoted as IAUC, and pixel-level AUC is denoted as PAUC, recorded as a percentage (%). This section selects PatchCore (PC), SPADE, and SimpleNet (SN) as comparison objects for this invention. All three methods are defect detection methods based on pre-trained embeddings. PatchCore obtains features based on deep pre-training by comparing distances in the embedding space after sampling from the core set. SPADE extends nearest neighbor retrieval from instance-level recognition to subgraph-level recognition, obtaining classification results for different regions. SimpleNet uses PatchCore's feature extractor to add Gaussian noise to normal embeddings to generate pseudo-anomaly embeddings, and then trains a discriminator to identify anomalies.
[0094] Table 1. Comparison of instance-level detection performance (IAUC) on the MVTec-AD dataset
[0095]
[0096]
[0097] Since MVTec-AD only has normal training samples, to create a training set with anomalous noise, the validation experiment randomly samples a certain number of negative example images from the test set and mixes them with the original training set. The ratio of normal to anomalous samples in the new training set is set to 1:η (η<1). Because the ratio of normal to anomalous samples in the test set is disrupted, this chapter sets two different settings to test the model's performance:
[0098] Original (ORG): The original test set is used because its ratio of normal to abnormal samples is appropriate, and the image-level AUC results are more meaningful. Furthermore, both this invention and its comparative methods follow a completely unsupervised training environment. Although there is overlap between the training and test sets, the model does not know the true labels of the sampled abnormal samples, essentially performing a direct learning process to verify the impact of abnormal noise on model performance.
[0099] Inductive (IND): Another approach follows the common inductive comparison method. The data sampled for training is no longer used for inference. The test set consists of the remaining samples after sampling and does not overlap with the training set.
[0100] Table 2. Comparison of pixel-level detection performance (PAUC) on the MVTec-AD dataset.
[0101]
[0102]
[0103] Table 1 shows the instance-level detection (IAUC) results of this invention and other comparative methods on all categories of the MVTec-AD dataset, where the proportion of anomalous noise in the total training set, η, is 0.1. The best result for each category is marked in bold, and the next best is underlined (the same applies to subsequent tables). Observations show that the proposed method achieves the best detection performance in both class settings. On the original test set, the new method shows a significant improvement (6.62% higher than the baseline method PatchCore), leveraging the advantage of removing a small number of potential anomalies from the core set. In particular, although SimpleNet outperforms PatchCore at this point, this invention significantly improves upon it and performs better. Similarly, under the inductive setting, the proposed method remains strong, outperforming in up to 11 categories. Regardless of the test setting, the proposed method ranks first in almost all texture categories. These results demonstrate the significant performance improvement in instance-level defect detection after the proposed method removes potential anomalous features.
[0104] Table 2 shows the performance (PAUC) of each method on the pixel-level defect detection task, which is the anomaly score inference performance of all pixels in all test samples. First, in the original inference setting, although the proposed method is not as good as SimpleNet, the difference is not significant. This is because the core set is sampled from the training set features and is then used for inference; the contaminated embedding space is more detrimental. However, compared to the baseline version PatchCore, the improvements in this invention are effective and feasible. Inductively, the core set sampling method (this invention and PatchCore) is significantly more effective than SimpleNet and SPADE, demonstrating the high-performance detection of this type of method. Furthermore, this invention further improves upon PatchCore.
[0105] Figure 5Further research into the effectiveness of the proposed core embedding filter was conducted. Glass bottles, hazelnuts, carpets, and tiles from the MVTec-AD dataset were selected for visualization, representing object and texture classes, respectively. Block-level feature representations were sampled from both training sets, and the t-SNE tool was used to map the high-dimensional core embeddings to a two-dimensional space, resulting in the effect shown in the figure. Here, the number 0 represents the normal core embedding (NE). Since not all regions of anomaly images are defective, the core embeddings taken from them are called anomaly candidates (AC), represented by the number 1. Light gray and dark gray hollow circles correspond to the filtered normal embeddings (FN) and anomaly candidates (FA), respectively. First, observing only the relationship between the selected samples and the overall data distribution, it is clear that in both classes, the global correlator does not only focus on discretely distributed embedding points but also selects some main cluster points. The local correlator, on the other hand, focuses more on regions with lower relational density, especially small clusters unrelated to their surroundings. Second, in the glass bottle class, the global filter outperforms the local filter. Both filters incorrectly remove a similar number of normal embeddings, but the global filter discovers more anomaly candidates, while the local filter discovers far fewer. This is because the image feature patterns of this object class are more numerous, and the corresponding embedding space presents different main clusters, lacking a cluster with overwhelming numerical superiority, making local correlators prone to failure. At the same time, object classes occasionally exhibit logical anomalies, such as changes in object placement. These anomalies are connected to the main clusters and do not exist in isolation. Using global correlation to study the similarity between most normal pattern points and these anomalies helps to discover the location of such anomalies. Hazelnuts, also an object class, are easily distinguishable due to their obvious defects, such as cracks and holes; therefore, local anomalies can be separated into their corresponding isolated embeddings. Observing carpet and tile images reveals that their feature patterns are relatively simple, with repetitive textures throughout the images, and the corresponding embedding space is also relatively concentrated. Defects in this type of data are mostly structural anomalies, such as cracks and oil stains, and the corresponding features are isolated from the main clusters of textures in the embedding space. In this case, local correlators are more effective. Compared to using global and local correlators separately, using both simultaneously can avoid more normal elements being mistakenly filtered out while retaining most of the main anomaly candidates. Although this invention uses secondary sampling to supplement some cores, based on the balancing strategy, it is still difficult to select points near the difficult normal embeddings, and can only alleviate the loss of normal cores to a certain extent. However, when global and local correlations are considered together, the hit rate of abnormal candidates will be greatly improved.
Claims
1. An industrial abnormal pollution control method based on dual-view core filtration, characterized in that: Includes the following steps: S1: Feature Extraction and Core Set Sampling: Given an unlabeled industrial image training set X = {X1, ..., X...} n }, where X contains real anomalous images X. a , where |X a |<<|X|; Following the approach of PatchCore, the corresponding feature tensors are extracted from each network layer of WideResNet, denoted as F. i F is the feature tensor extracted from the i-th layer of WideResNet. i The dimension is (b i ,l i ,l i ), b i Let l be the number of feature channels in the i-th network layer. i For F i Regarding the feature map size of the image, F i By b i each l i ×l i The feature map is composed of size; For F i From a single feature map, we iterate through the elements at each position, sampling P×P neighbors centered on each element. Using edge padding, we obtain a new set of block-level feature maps, totaling c. i =l i ×l i indivual; The i-th layer of WideResNet has a dimension of (c i ,b i The characteristic tensor F of P, P) i As i increases, the network layers become deeper, and c... i continuously decreasing, b i Increasing continuously; let the minimum value of the actual WideResNet network layer i be i. min The maximum value is i max ; For F i 'Along c i and b i Interpolation is performed between two dimensions, and the dimensions are transformed... Then, average pooling is performed along the last two dimensions to obtain the dimension as follows. The aggregation tensor F i Finally, assign the corresponding F values to each layer. i "After concatenation and pooling, the final block-level embedding set Z = {Z1, ..., Zn} is obtained." m },in, m is the total number of block-level embeddings in Z. Let m be the number of the above feature extraction and aggregation operations. Single sample X i go through The operation can result in multiple block-level embeddings; Based on the embedding set Z, a stochastic linear mapping is used to reduce the dimensionality to a lower embedding space, resulting in a new embedding set Z′; then, the Core-set algorithm is used to sample Z′ to extract the core set to be processed. The index of the core set element in Z′ represents the index of the core set element. In the initial stage of the Core-set algorithm, a portion of the embeddings are randomly selected from Z′, the average distance of the other embeddings to the selected embeddings is calculated, and the embedding with the furthest average distance is used to initialize M. This is used to start the Core-set algorithm. The sampling is iterated until the number of embeddings in M reaches the expected target. S2: Based on the core set M obtained in S1, select the potential anomaly infiltration set from the perspectives of overall distribution and local correlation. S3: Supplement sampling of the lost normal cores; the number of samples is the same as M. a The number of elements in the set is the same, and the sampling method is to iteratively expand the set, selecting an embedding from the original embedding set Z′ each time. This embedding is the same as the one in M. a and the remaining core embedded M\M a The furthest embedding is added to the core set. The above steps are repeated until the predetermined number is reached, resulting in the final core set M′. S4: For a single new test image x test Using the description in S1 The operation extracts and aggregates features to obtain their block-level embeddings. Then, based on M′, calculate the block-level embedding z. test The abnormal score, i.e. z test The nearest distance to the embedding in M′, all block-level embeddings z test The maximum value of the abnormal score is defined as x. test The abnormal score s: i.e.
2. The industrial abnormal pollution control method based on dual-view core filtration as described in claim 1, characterized in that: The potential anomaly infiltration set M is selected in S2. a The process is as follows: S2-1: Use a global filter to establish global associations among the elements of M, and set a threshold to find potential anomalies that are far from the vast majority of points, and index them. Record the data, where n represents the total number of samples in the training set X; S2-2: Using a local filter, edge points are first grouped into the same subset as the main cluster. Based on the initialization of a series of small clusters, adjacent clusters are continuously merged by comparing the density of each cluster, ultimately resulting in several main clusters and discrete small clusters. The smaller clusters are then filtered as a whole, with the index of the selected core denoted as [index of the selected core]. S2-3: Find the intersection of the candidate indices selected by the global filter and the local filter, i.e. C f =C g ∩C l According to C f The index in M is used to extract the corresponding embedding from M, thus forming the potential anomaly infiltration set M. a .
3. The industrial abnormal pollution control method based on dual-view core filtration as described in claim 2, characterized in that: The S2-1 global filter includes the following steps: For each core embedded M i First, determine its relationship with other core embedded M. j Euclidean distance similarity: Where softmax represents the normalization process, and D(·,·) represents the similarity between the two, that is: Where ||·||2 represents the l2 norm, corresponding to the calculation of Euclidean distance, ∈ represents the minimum value, and Z′ i The similarity to itself is set to negative infinity; based on this, the similarity matrix Sim of the one-way relationship is obtained, where each row i represents Z′. i Compared to the similarity of other points, summate for each column j to statistically determine the similarity of other points to Z′. j The total similarity is used to sort all cumulative results in ascending order, and the top α% of the embedded parts are selected as global latent anomalies. ArgLastK(·,α) represents the index of the last α% member.
4. The industrial abnormal pollution control method based on dual-view core filtration as described in claim 3, characterized in that: The S2-2 local filter includes the following steps: The core set M is further sampled using the PatchCore algorithm to obtain a smaller core set. γ% of the cores are selected, and the selected core embeddings are used as cluster centers of M. Unselected members in M are assigned to the clusters corresponding to their nearest neighbors. On average, each cluster receives approximately 1 / γ% of the core embeddings. The nearest distance d between two clusters is less than the corresponding "cluster density" ρ. i and ρ j Then, these two clusters are merged into one, so that the edges are embedded into the main cluster, and the new index set is denoted as Q′. i =Q i ∪Q j The total number of new clusters is denoted as m′, and the cluster density ρ is calculated as follows: Where Q represents the core embedded index set in the current cluster, when there is only one cluster member; The above merging process is performed in only one round. The number of embeddings in each cluster is compared with the total number of the core set. Clusters that do not exceed β% of the total number of embeddings are defined as local potential anomalies. Where C l The embeddings in the corresponding initial core set M are local potential anomalies.
5. The industrial abnormal pollution control method based on dual-view core filtration as described in claim 4, characterized in that: The supplementary sampling in S3 includes the following steps: Based on the core set Z after screening r ={Z′ j |j∈C\C f } and the core set of potential anomalies that were filtered out f ={Z′ j |j∈C f }, from the remaining embedding Z fr ={Z′ i In |i∈[n]\C}, iteratively select the distance Z at the same time. f and Z r The furthest embedding: Where λ is the balance coefficient, and C represents the index of the core set element in Z′, C f The index of the core set of potential anomalies that have been filtered out in Z′.
Citation Information
Patent Citations
Active anomaly detection method for driving multi-expert mixed training by data independent subsets
CN117648656A
Image defect detection method based on double-branch inverse distillation and multi-input image
CN118521570A