Outside-distribution-based anomaly detection method and non-transient computer readable medium

By calculating the similarity between image objects and the background and combining it with a multi-geometric projection network, the problem of anomaly detection accuracy caused by background changes in the prior art is solved, and efficient anomaly detection in complex backgrounds is achieved.

CN121660957APending Publication Date: 2026-03-13INVENTEC PUDONG TECH CORPOARTION +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411273951.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-11
Publication Date
2026-03-13

AI Technical Summary

Technical Problem

Existing image anomaly detection algorithms are not robust in highly variable backgrounds and have difficulty effectively detecting anomalous samples in unbalanced backgrounds. Furthermore, the limitations of gold-plated images lead to a decline in model performance in complex backgrounds.

Method used

An out-of-distribution anomaly detection method is adopted. By calculating the similarity between image objects and the background, the image is mixed to generate background increment, and the detection model is trained by combining a multi-geometric projection network to identify out-of-distribution samples.

Benefits of technology

It improves the accuracy and robustness of anomaly detection, effectively identifies anomalous samples in multi-background environments, and reduces bias caused by data imbalance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121660957A_ABST
    Figure CN121660957A_ABST
Patent Text Reader

Abstract

The out-of-distribution-based anomaly detection method includes obtaining a training data set including a plurality of images, the images including a first image and a plurality of second images, segmenting an object and a background in each image, calculating a similarity between the object of the first image and the object of each second image, and calculating a similarity between the object of the first image and the object of each second image. Selecting candidate images of which the similarity is greater than a threshold value from the plurality of second images, mixing objects of the first image with backgrounds in the candidate images to generate a mixed image, training a detection model according to a training data set and the mixed image, executing the detection model to generate a plurality of distributed inlays according to the training data set and the mixed image, the method comprises the following steps: generating a test insert according to a test sample, calculating a plurality of distances between the distributed inserts and the test insert, and classifying the test sample as abnormal if the minimum value of the distances exceeds a preset value.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to anomaly detection in images, and in particular to an out-of-distribution anomaly detection method. Background Technology

[0002] Anomaly detection plays a crucial role in automation across various industries, identifying data points that significantly deviate from normal behavior. In sectors such as finance, cybersecurity, healthcare, and manufacturing, anomalies can signify critical events, errors, or fraudulent activities requiring attention. While initial successes have been achieved in using artificial intelligence for image anomaly detection, many unresolved challenges remain in real-world scenarios.

[0003] In manufacturing, anomaly detection plays a crucial role in ensuring functional products meet quality standards. One anomaly detection method involves visually comparing the product to a "golden image." However, this difference-based algorithm can fail when the background context of the product image varies significantly. For example, in electronics manufacturing, motherboards are composed of complex hardware components, and depending on the layout design, the same type of components may be arranged in different locations. For instance, production lines may use different lighting and / or cameras, resulting in drastically different component images. Because the component backgrounds are highly variable, using golden images for anomaly detection becomes impractical in such cases. Current image anomaly detection algorithms only work under the constraint of having a standard golden image and strongly require the data to be in a homogeneous background. This limitation necessitates separate anomaly detection for each category. Although recent technological advancements have attempted to implement multi-class models, the limitation of golden images with a uniform background has not been alleviated.

[0004] Due to the difficulty in specifying defect-free objects, the robustness of current algorithms is significantly reduced in highly variable backgrounds. Objects appearing in unbalanced backgrounds can lead to skewed distributions and produce different visual appearances. Rare backgrounds can easily confuse the model, causing it to judge the image as defective. Furthermore, in the real world, it is difficult to collect complete data on every object in every background. Summary of the Invention

[0005] In view of this, the present invention proposes an out-of-distribution anomaly detection method and a non-transitory computer-readable medium, with the aim of detecting anomalous samples in various contexts, and these samples cannot be directly detected by traditional anomaly detection methods.

[0006] An out-of-distribution anomaly detection method according to an embodiment of the present invention includes, performed by a computing device: acquiring a training dataset comprising a first image and a plurality of second images; segmenting objects and backgrounds in each image; calculating the similarity between objects in the first image and objects in each of the second images; selecting candidate images from the plurality of second images whose similarity is greater than a threshold; mixing objects in the first image with backgrounds in the candidate images to generate a mixed image; training a detection model based on the training dataset and the mixed image; executing the detection model to generate a plurality of in-distribution embeddings based on the training dataset and the mixed image, and generating a test embedding based on a test sample; calculating a plurality of distances between the in-distribution embeddings and the test embedding; and classifying the test sample as an anomaly if the minimum value of these distances exceeds a preset value.

[0007] According to an embodiment of the present invention, a non-transitory computer-readable medium is used to store a plurality of instructions. These instructions, when executed by a computing device, cause a plurality of operations, including: acquiring a training dataset comprising a plurality of images, including a first image and a plurality of second images; segmenting objects and backgrounds in each image; calculating the similarity between objects in the first image and objects in each of the second images; selecting candidate images from the plurality of second images whose similarity is greater than a threshold; mixing objects in the first image with backgrounds in the candidate images to generate a mixed image; training a detection model based on the training dataset and the mixed image; executing the detection model to generate a plurality of distributed embeddings based on the training dataset and the mixed image, and generating a test embedding based on a test sample; calculating a plurality of distances between the distributed embeddings and the test embedding; and classifying the test sample as an anomaly if the minimum value of these distances exceeds a preset value.

[0008] In summary, the out-of-distribution anomaly detection method proposed in this invention can improve anomaly detection accuracy. By introducing background increment and multi-geometric projection networks, it can more effectively identify anomalous samples, achieving higher accuracy compared to traditional methods. Furthermore, the design of background increment and class weights addresses the problem of insufficient class data, reducing bias in anomaly detection caused by data imbalance.

[0009] The foregoing description of the disclosure and the following description of the embodiments are intended to demonstrate and explain the spirit and principles of the present invention, and to provide a further explanation of the scope of the patent application of the present invention. Attached Figure Description

[0010] Figure 1 This is a flowchart illustrating an out-of-distribution anomaly detection method according to an embodiment of the present invention;

[0011] Figure 2 yes Figure 1 Detailed flowchart of the first step;

[0012] Figure 3 yes Figure 1 A flowchart of the first embodiment of step one;

[0013] Figure 4 yes Figure 1 The flowchart of the second embodiment of step one.

[0014] Symbol Explanation

[0015] S1, S2, S3, S4, S5, S6, S7, S8, S9: Steps

[0016] S21, S22: Steps

[0017] S31, S32, S33, S34: Steps

[0018] S301, S302, S303, S304, S305: Steps Detailed Implementation

[0019] The following detailed description of the features and advantages of the present invention in the embodiments is sufficient to enable anyone skilled in the art to understand the technical content of the present invention and implement it accordingly. Based on the disclosure, patent claims, and drawings in this specification, anyone skilled in the art can easily understand the related objectives and advantages of the present invention. The following embodiments are further detailed in illustrating the points of view of the present invention, but are not intended to limit the scope of the present invention in any way.

[0020] The purpose of this invention is to detect defective objects in images under various backgrounds, where traditional anomaly detection methods cannot be directly applied. These background differences arise from camera translation during image capture and component orientation. Therefore, this invention transforms the anomaly detection problem with diverse backgrounds into an out-of-distribution (OOD) detection problem, aiming to relax the requirement of using standard images in anomaly detection. Defect-free images are considered in-distribution (ID) data, while defective images are considered out-of-distribution data. In this case, enhancing the background diversity of the in-distribution training data becomes crucial for establishing a robust in-distribution embedding space. Therefore, anomaly samples can be identified as out-of-distribution cases based on embedding distance comparisons.

[0021] Figure 1This is a flowchart illustrating an out-of-distribution anomaly detection method according to an embodiment of the present invention, which is suitable for execution by a computing device. In one embodiment, the computing device may be implemented using any of the following examples: a personal computer, a network server, a microcontroller (MCU), an application processor (AP), a field-programmable gate array (FPGA), an application-specific integrated circuit (ASIC), a system-on-a-chip (SOC), a deep learning accelerator, or any electronic device with similar functionality. The present invention does not limit the hardware type of the computing device.

[0022] Step S1: The computing device acquires a training dataset comprising multiple images. In one embodiment, the computing device collects a dataset of component anomalies with background variations from the output of an Automated Optical Inspection (AOI) machine. This dataset, for example, includes 29,896 images and 427 categories. Each image includes at least one target object that needs to be inspected for defects; in practice, images are manually labeled during manual motherboard inspection. In one embodiment, the dataset is divided into a training set and a test set, comprising 25,201 and 4,395 images, respectively. The images in the training set are in-distribution data and contain only defect-free target objects, while the images in the test set contain both in-distribution and out-of-distribution data.

[0023] Step S2: The computing device segments the objects and background in each image. All images in the training dataset... They are all divided into objects and background, forming a collection of objects. and a background set In one embodiment, step S2 is implemented as follows: Figure 2 As shown, Figure 2 yes Figure 1 Detailed flowchart of step S2. Step S21: The computing device assigns a reference point to each image, such as the center of the image. Step S22: The computing device executes an arbitrary segmentation model (SAM) to output a mask containing this reference point. The arbitrary segmentation model is used to segment foreground objects from the background.

[0024] Step S3: The computing device calculates the similarity between the objects in the first image and the objects in each of the second images. For each training image, after acquiring the segmented objects, a background candidate set is retrieved by restricting the visual appearance of the objects to be consistent. This invention proposes three embodiments to calculate the similarity between masks output by arbitrary segmentation models. Figure 3 and Figure 4 These are flowcharts of the first and second embodiments of step S3, respectively.

[0025] First, let me explain the following custom terms: "First Image" refers to any image in the training dataset, and "Second Image" refers to any image in the training dataset other than the first image. "First / Second Mask" refers to the mask output after step S2 for the first / second image, and the mask is used to select objects in the image.

[0026] The first embodiment of similarity calculation uses the shape of the mask as a comparison benchmark. For detailed procedures, please refer to [link / reference needed]. Figure 3 Step S31: The computing device performs downsampling and overlap operations on the first mask and each of the second masks. Step S32: The computing device obtains the reference area of ​​the larger area among the first mask and each of the second masks. Step S33: The computing device calculates the overlapping area and the non-overlapping area of ​​the first mask and each of the second masks. Step S34: The similarity is calculated based on the overlapping area, the non-overlapping area, and the reference area.

[0027] Overall, the processing unit downsamples the masks while preserving their aspect ratio to maintain the shape of the objects. For each pair of masks (first mask and second mask), the processing unit overlaps them using the smallest common area. A larger overlap indicates higher similarity between the two objects. Considering cases of significant shape differences, non-overlapping areas are subtracted from the overlapping areas. The normalized difference is the similarity score between the two object masks. Given a mask image with dimensions... Its binary mask can be represented as a set of tuples. , where t is a preset binarization decision value. In one embodiment, t=200.

[0028] Given two masks Ma and Mb, the similarity based on overlap is calculated as follows:

[0029] ;

[0030] in, , ,and .

[0031] The second embodiment of similarity calculation is an extension of the first embodiment. If the number of masks is large, the computational cost of the first embodiment may be high. To avoid calculating the similarity between all masks, the range of potentially similar masks can be pre-narrowed by calculating the mask area. Figure 4 As shown, the procedure before step S31 further includes:

[0032] Step S301: The computing device calculates an area range based on the first area of ​​the first mask and a ratio value. In one embodiment, the ratio value... The area range is defined as the range consisting of 5% above and below the first area.

[0033] In step S302, the computing device calculates the multiple second areas of the multiple second masks.

[0034] In step S303, the computing device selects multiple candidate masks from multiple second masks, with the selection criterion being that these second areas are located within an area range.

[0035] In step S304, the computing device calculates multiple difference values ​​between each candidate mask and the first mask. In one embodiment, the difference values ​​are the absolute values ​​of the area difference. In another embodiment, the difference values ​​are the absolute values ​​of the pixel number difference.

[0036] In step S305, the processing unit sorts these difference values ​​and retains the N candidate masks with the smallest difference values. Then it continues... Figure 3 The process involves calculating the similarity between these N candidate masks and the first mask.

[0037] The third embodiment of similarity calculation uses cosine similarity. Calculating cosine similarity does not require high computational costs and is suitable for large sets of masks. First, an adjustment operation is performed to make the first mask and each second mask have the same size (dimensions, length and width). After the adjustment operation is complete, the cosine similarity matrix between the first mask and each second mask is calculated. As described in step S3, A and B represent the one-dimensional vector forms of the first and second masks, respectively.

[0038] In step S4, the computing device selects a candidate image from multiple second images whose similarity is greater than a threshold. The present invention does not limit the value of the threshold. In one embodiment, to avoid generating redundant mixed images, if the object includes multiple categories, the candidate image will exclude the first category to which the object in the first image belongs.

[0039] In step S5, the computing device blends the objects of the first image with the background of the candidate image to generate a blended image. In one embodiment, the computing device uses Poisson blending P to smooth the boundary between the objects of the first image and the background of the candidate image. This method introduces fewer imperfections into the appearance of the image.

[0040] Steps S1 to S5 follow the context augmentation method proposed in this invention. For imbalanced object categories, this method can increase the variability of a few objects. The weight w of the k-th category... k It can be done To obtain, where N k This represents the number of images in the k-th category. Then, it is standardized using the total category weights. For example, a weight threshold value w can be set. th As a parameter, and in the weight w k Greater than the weight threshold value w th Further increments are made to one or more categories. The total number of increments is determined by a parameter γ, which represents the proportion of increments; for example, γ=1 represents an increase of 100% in the number of samples. It is worth noting that background increments can still be applied to the category with the majority of samples, because the diversity of the background is usually greater than that of the sample space.

[0041] Step S6: The computing device trains a detection model based on the training dataset and the mixed images. In one embodiment, the detection model is a Multi-Geometry Projection (MGP) network, comprising multiple branches. The detection model uses a backbone network combined with dual-stream geometric projection to capture different latent structures in the data. Each geometric stream is defined by a specific loss function for joint optimization. In one embodiment, these branches include hypersphere manifolds and hyperbolic manifolds, which are Riemannian manifolds with positive and negative curvatures, respectively. Curvature serves as an indicator of deviation from Euclidean space.

[0042] Hyperspherical manifolds include compactness and disparity loss functions, which ensure that samples from different classes are kept at a sufficient distance and group the data samples onto a hypersphere.

[0043] In one embodiment, the computing device uses CIDER (Y. Ming, Y. Sun, O. Dia and Y. Li, “How to Explore Hyperspherical Embeddings for Out-of-Distribution Detection?” in ICLR, 2023) to optimize the compactness and disparity loss functions of the hyperspherical manifold, where the unit vector Belongs to the k-th category, category prototype τ is a temperature parameter. Embedded z s The probability of being assigned to the kth category is:

[0044] ;

[0045] The compactness loss can be derived by taking the negative log-likelihood. It forces each sample to be close to the prototype of its class:

[0046] ;

[0047] Loss of difference This encourages larger angular intervals between category prototypes:

[0048] ;

[0049] in It is an indicator function, defined as .

[0050] The loss function of the hyperspherical branch can be expressed as: These two loss functions together shape the clustering on the hypersphere. For normal data, they achieve intra-class compactness and inter-class diversity. Therefore, outlier data is less likely to be located in the space near the normal prototype.

[0051] Hyperbolic manifold: A hyperbolic space that deviates from Euclidean space and has a constant negative curvature is usually represented by a Poincaré sphere. To describe this, by defining a manifold Equipped with Riemannian metric in It is a curvature The conformal factor,

[0052] It is an Euclidean metric tensor. Operations on manifolds rely on the Mobius gyrovector space, including Möbius addition. scalar multiplication ,in and It is a vector. It is a scalar.

[0053] ;

[0054] ;

[0055] Two points and The geometric distance between them can be expressed in the following form:

[0056] ;

[0057] When curvature When the distance converges to This is directly proportional to the case of Euclidean distance.

[0058] An exponential map maps a vector to a tangent space on a Poincaré sphere. In one embodiment, the computing device uses a backbone network to generate embedded vectors. Using exponential mapping This vector is converted into a hyperbolic embedding. The processing unit then obtains the hyperbolic average of multiple hyperbolic embeddings using the Einstein midpoint. The processing unit can then extract the embeddings from the Poincaré sphere. Projected onto the Klein model And use Klein coordinates to calculate a simpler average form:

[0059] ;

[0060] in This is the Lorentz factor. After obtaining the average embedding in Klein coordinates, the computational device transforms the space back into a Poincaré sphere:

[0061] ;

[0062] Using the available operations in hyperbolic space, the computational device projects the latent embedding with the hyperbolic head onto the Poincaré sphere to obtain the embedding. Using from The generated increment set To form a complete set This incremental set It was generated by combining a background increment method with standard increment methods (including overall image cropping, flipping, and color dithering). For Positive samples Other incremental samples By comparing the results, the supervised contrastive loss is calculated, as follows:

[0063] ;

[0064] The final loss function used to optimize ID classification accuracy It is a hyperspherical loss function Hyperbolic loss function and the cross entropy loss function Combinations: Curvature parameters It is usually considered a hyperparameter, and in one embodiment, it is estimated using the Gromov product mentioned in the following literature. Value of: V. Khrulkov, L. Mirvakhabova, E. Ustinova, I. Oseledets and V. Lempitsky, “Hyperbolic image embeddings,” in CVPR, 2020.

[0065] To maintain learning stability, one embodiment employs feature clipping. Experiments have shown that this technique contributes to better convergence and avoids gradient vanishing in complex manifold learning. (Euclidean space sample points) Being truncated becomes a cutting feature ,in It is the effective radius of the Poincaré sphere. This process regulates points that are too close to the sphere's boundary.

[0066] Please refer to Figure 1 Step S7: Execute the detection model to generate multiple distributed embeddings based on multiple images and mixed images, and generate a test embedding based on a test sample. Step S8: Calculate multiple distances between these distributed embeddings and the test embedding. Step S9: When the minimum value among these distances exceeds a preset value, classify the test sample as an anomaly.

[0067] For anomaly detection, the objective of this invention is to identify anomaly A from normal data N. Input data Input into the detection model To predict labels ,in Anomaly detection environment due to background changes, originating from edge distribution. Information It includes different backgrounds, object sizes, and positions. Therefore, traditional anomaly detection methods based on gold-imagery are not applicable.

[0068] Steps S7 to S9 rely on out-of-distribution detection settings to distribute normal data. Data is considered as in-distribution data, and outlier data distribution is also considered as outlier data. This is considered out-of-distribution data. Only in-distribution data will be used during training. and its labels During the testing phase, we will observe the distribution of normal test data and data from anomalies. Out-of-distribution data. In this way, out-of-distribution detection algorithms can be used based on the normal data distribution. Anomaly detection is performed by comparing the sample with a test sample, without using golden images. This transformed anomaly detection method differs from the original out-of-distribution algorithm, which distinguishes between in-distribution and out-of-distribution samples based on predicted categories. For example, Include Each category, and Including except In Any category other than the specified category forms a disjoint set of categories. In one embodiment, the normal data distribution... and abnormal data distribution They all contain multiple categories.

[0069] In step S6, the detection model Use from edge distribution In-distribution data extracted from Training is performed, and multiple distributed in-embeddings are generated in step S7. The objective of this invention is to detect anomalous data distributions during inference. Abnormal samples. In steps S8 and S9, the estimator used for out-of-distribution detection. Based on the scoring function and preset values Implementation:

[0070] ;

[0071] The standard steps for out-of-distribution detection are as follows: First, train the detection model 𝑓 using in-distribution data and freeze the model parameters (step S6); second, input the test samples into the frozen model (step S7); and third, calculate the out-of-distribution score and use a preset value. Identify abnormal samples (steps S8 and S9).

[0072] In one embodiment, the computing device extracts the output of the penultimate layer of the detection model as a sample in step S7. L2 normalized embedding To distinguish between out-of-distribution samples and in-distribution samples, the computing device calculates the in-distribution embedding for each sample in step S8. With test embedding The embedding distance between them is used to determine the reference embedding. Then, the out-of-distribution score is calculated based on the L2 distance. estimator Comparison of out-of-distribution scores Compared with preset value To achieve anomaly detection.

[0073] An embodiment of the present invention provides a non-transitory computer-readable medium for storing multiple instructions. These instructions, when executed by a computing device, cause multiple operations. These operations correspond to the steps of an out-of-distribution anomaly detection method according to an embodiment of the present invention, including: acquiring a training dataset comprising multiple images, including a first image and multiple second images; segmenting objects and backgrounds in each image; calculating the similarity between objects in the first image and objects in each second image; selecting candidate images from the multiple second images whose similarity is greater than a threshold; mixing objects in the first image with backgrounds in the candidate images to generate a mixed image; training a detection model based on the training dataset and the mixed image; executing the detection model to generate multiple in-distribution embeddings based on the training dataset and the mixed image, and generating a test embedding based on a test sample; calculating multiple distances between these in-distribution embeddings and the test embedding; and classifying the test sample as an anomaly if the minimum value of these distances exceeds a preset value.

[0074] In the above operation, segmenting objects and background in each image includes the following steps: specifying a reference point in the plurality of images; and performing an arbitrary segmentation model to output a first mask and a plurality of second masks containing the reference point, wherein the first mask corresponds to an object in the first image, and one of the plurality of second masks corresponds to an object in one of the plurality of second images.

[0075] In the above operation, calculating the similarity between objects in the first image and objects in the second image includes the following steps: performing downsampling and overlapping operations on the first mask and each second mask, obtaining the reference area of ​​the larger area among the first mask and each second mask, calculating the overlapping area and non-overlapping area of ​​the first mask and each second mask, and calculating the similarity based on the overlapping area, non-overlapping area and reference area.

[0076] To verify the out-of-distribution anomaly detection method proposed in this invention, three common out-of-distribution detection metrics are used, which are also image-level anomaly detection metrics: first, the false positive rate (FPR) when the true positive rate is equal to 95%; second, the area under the ROC curve (AUC), where ROC is an abbreviation for Receiver operating characteristic; and third, the area under the precision and recall curves (AUPR).

[0077] Table 1

[0078]

[0079] Table 1 uses the AOI dataset mentioned earlier to evaluate anomaly detection under changing background conditions. The out-of-distribution anomaly detection method proposed in this invention is also known as the Context-Augmented Embedding Learning (CAEL) framework. Table 1 compares two embedding-based methods, CIDER and MGP, as network learning methods. Considering data imbalance, Table 1 also investigates the performance of various incremental and reweighting methods; for example, CIDER-reweight uses the class weights mentioned earlier. The sample loss is reweighted. The second row of Table 1 lists the masking methods, including overlapping, random overlapping, and the background increment method proposed in this invention. The overlapping strategy directly overlays the mask onto the image, thus forcing the model to focus on the image pattern on the object. The random overlapping strategy randomly selects masks with different confidence values ​​from any segmentation model output for overlapping.

[0080] As shown in Table 1, CAEL combined with CIDER and MGP networks achieved improvements in all three metrics. Specifically, the CAEL-CIDER framework achieved an FPR of 50.24%, an AUC of 97.46%, and an AUPR of 84.86% in anomaly detection. CAEL-MGP, with an FPR of 42.36%, surpassed other methods. The advantages of CAEL are evident when using both CIDER and MMEL networks. CAEL-CIDER, compared to CIDER, improved AUPR by 17.59%, AUC by 5.19%, and FPR by 26.97%, demonstrating the advantages of background enhancement.

[0081] Table 2

[0082]

[0083] Table 2 shows the anomaly detection results under different data distributions, evaluating the categories with different sample sizes using CAEL-MGP. Table 2 displays the top 100, 80, and 60 main categories with the most samples, and the bottom 100 categories with the fewest samples. Specifically, the categories are sorted according to their sample size, and the top 100, top 80, and top 60 categories are selected. Selecting fewer categories means each category contains more samples in the training dataset. Conversely, the bottom 300 categories are selected to represent categories with fewer samples.

[0084] Overall, the CAEL framework includes object and background segmentation during the training phase for background increment. Based on the segmented objects in the entire training dataset, the computing device can search for other objects with similar shapes and sizes for each specified object in the dataset. Therefore, each object in the image is associated with another similar object that may be located in a different background. The computing device obtains the background of these found similar objects to increment the specified object and generates a new image through Poisson mixing. The new image increments the training data and diversifies the background of each object in the dataset. In some embodiments, the computing device further performs standard data increments, including random flipping, cropping, and adding color dithering, to improve the robustness of training.

[0085] In summary, the out-of-distribution anomaly detection method proposed in this invention can improve anomaly detection accuracy. By introducing background increment and multi-geometric projection networks, it can more effectively identify anomalous samples, achieving higher accuracy compared to traditional methods. Furthermore, the design of background increment and class weights addresses the problem of insufficient class data, reducing bias in anomaly detection caused by data imbalance.

[0086] While the present invention has been disclosed above with reference to the foregoing embodiments, it is not intended to limit the invention. Any modifications and refinements made without departing from the spirit and scope of the invention are within the scope of patent protection of the present invention. For details regarding the scope of protection defined in the present invention, please refer to the appended claims.

Claims

1. An out-of-distribution anomaly detection method, characterized in that, Including execution by a computing device: Obtain a training dataset comprising multiple images, including a first image and multiple second images; Segment the objects and background in each of these images; Calculate the similarity between the object in the first image and the object in each of the second images; Select a candidate image from these second images whose similarity is greater than a threshold; The object in the first image is blended with the background in the candidate image to produce a blended image; The detection model is trained based on the training dataset and the mixed image. The detection model is executed to generate multiple distributional embeddings based on the images and the mixed images, and a test embedding is generated based on a test sample. Calculate multiple distances between these distributed embeddings and the test embedding; When the minimum value among these distances exceeds a preset value, the test sample is classified as an anomaly.

2. The out-of-distribution anomaly detection method according to claim 1, characterized in that, The object and background in each of the segments of these images include: Specify a reference point in these images; and Execute the Segment Anything Model to output a first mask and a plurality of second masks containing the reference point, wherein the first mask corresponds to the object in the first image, and one of the second masks corresponds to the object in one of the second images.

3. The out-of-distribution anomaly detection method according to claim 2, characterized in that, The calculation of the similarity between the object in the first image and the object in the second image includes: Perform downsampling and overlap operations on each of the first mask and the second masks; Obtain the reference area of ​​the larger of the first mask and each of the second masks; Calculate the overlapping area and non-overlapping area of ​​each of the first mask and the second masks; and The similarity is calculated based on the area of ​​the overlapping region, the area of ​​the non-overlapping region, and the reference area.

4. The out-of-distribution anomaly detection method according to claim 3, characterized in that, Before performing the overlap operation on each of the first mask and the second masks, it further includes: Calculate an area range based on the first area of ​​the first mask and a ratio value; Calculate the multiple second areas of these second masks; Multiple candidate masks are selected from these second masks based on a condition, wherein the condition is that the areas of these second masks are within the area range; Calculate multiple difference values ​​between each of the candidate masks and the first mask; and Sort the difference values ​​and retain the N candidate masks with the smallest difference values.

5. The out-of-distribution anomaly detection method according to claim 2, characterized in that, The calculation of the similarity between the object in the first image and the object in the second image includes: Perform an adjustment operation to make each of the first mask and the second masks the same size; and After the adjustment operation, the cosine similarity between the first mask and each of the second masks is calculated as the similarity.

6. The out-of-distribution anomaly detection method according to claim 1, characterized in that, The process of mixing the object in the first image and the background in the candidate image to generate the mixed image includes: using Poisson blending to smooth the boundary between the object and the background in the first image.

7. The out-of-distribution anomaly detection method according to claim 1, characterized in that, The detection model includes hyperspherical manifold branches and hyperbolic manifold branches.

8. A non-transitory computer-readable medium, characterized in that, This is used to store multiple instructions that, when executed by a computing device, cause multiple operations, including: Obtain a training dataset comprising multiple images, including a first image and multiple second images; Segment the objects and background in each of these images; Calculate the similarity between the object in the first image and the object in each of the second images; Select a candidate image from these second images whose similarity is greater than a threshold; The object in the first image is blended with the background in the candidate image to produce a blended image; The detection model is trained based on the training dataset and the mixed image. The detection model is executed to generate multiple distributional embeddings based on the images and the mixed images, and a test embedding is generated based on a test sample. Calculate multiple distances between these distributed embeddings and the test embedding; When the minimum value among these distances exceeds a preset value, the test sample is classified as an anomaly.

9. The non-transitory computer-readable medium according to claim 8, characterized in that, The object and background in each of the segments of these images include: Specify a reference point in these images; and Execute the Segment Anything Model to output a first mask and a plurality of second masks containing the reference point, wherein the first mask corresponds to the object in the first image, and one of the second masks corresponds to the object in one of the second images.

10. The non-transitory computer-readable medium according to claim 9, characterized in that, The calculation of the similarity between the object in the first image and the object in the second image includes: Perform downsampling and overlap operations on each of the first mask and the second masks; Obtain the reference area of ​​the larger of the first mask and each of the second masks; Calculate the overlapping area and non-overlapping area of ​​each of the first mask and the second masks; and The similarity is calculated based on the area of ​​the overlapping region, the area of ​​the non-overlapping region, and the reference area.