Image anomaly detection method and apparatus, device, and storage medium
By extracting and fusing features from global and local image encoders, and combining distance measurement functions and threshold judgments, the problem that a single feature extractor cannot capture local and global relationships and learn unknown categories is solved, thus improving the accuracy of image OOD anomaly detection.
Patent Information
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- PING AN TECH (SHENZHEN) CO LTD
- Filing Date
- 2025-12-24
- Publication Date
- 2026-07-23
AI Technical Summary
Existing image OOD anomaly detection methods suffer from high misjudgment rates when processing complex images. A single feature extractor cannot effectively capture the relationship between local lesions and the global background, and lacks a learning mechanism for unknown categories.
A dual-encoder architecture combining a global image encoder and a local image encoder is adopted to extract and fuse global and local features of the image. The overall deviation value is calculated by a distance measurement function and compared with a preset threshold to determine whether the image category is known or unknown.
It improves the recognition accuracy of known categories and the sensitivity to unknown categories, reduces false positives, and achieves safer and more accurate image analysis.
Smart Images

Figure CN2025145233_23072026_PF_FP_ABST
Abstract
Description
Image anomaly detection methods, devices, equipment and storage media
[0001] This application claims priority to Chinese Patent Application No. 2025100867611, filed on January 20, 2025, entitled “Image Anomaly Detection Method, Apparatus, Device and Storage Medium”, the entire contents of which are incorporated herein by reference. Technical Field
[0002] This application relates to the field of image processing technology, and in particular to an image anomaly detection method, apparatus, device, and storage medium. Background Technology
[0003] In the field of image and video analytics, especially in critical applications such as autonomous driving, security monitoring, finance, and healthcare, accurately identifying out-of-distribution (OOD) objects—samples that the detection model has never seen or struggles to classify correctly—is crucial for ensuring system security and reliability. While methods like ODIN (Outlier Detection via Input Modification) and Mahalanobis distance have improved in some aspects with the development of deep learning technology, the inventors recognized that these traditional methods still face the following challenges when processing complex images.
[0004] 1. Limitations of Single Feature Extractors: In the fintech and healthcare fields, traditional OOD (Out-of-Depth) anomaly detection methods often rely on a single feature extractor, which proves inadequate in capturing the relationship between key financial information areas or lesion areas and the overall background. For example, in lung CT scans, different types of tumors may have similar appearance characteristics, but their pathological states are drastically different. Relying solely on a fixed feature extractor to distinguish between benign nodules and malignant tumors may lead to misjudgments due to an inability to fully understand the relationship between local lesions and the overall anatomical structure.
[0005] 2. Lack of explicit learning mechanisms for unknown types of financial fraud or unknown disease types: Existing OOD anomaly detection methods are typically trained on known categories, lacking sufficient adaptability to newly emerging or unseen types of financial fraud or disease. For example, if a doctor encounters a new disease they've never seen before and inputs its X-ray into an existing automated diagnostic system, the system is likely to generate an overconfident but incorrect prediction. This is because traditional models lack learning mechanisms for unknown categories, causing them to tend to classify any object different from the training dataset into the closest known category, thus increasing the false positive rate. Another example is in autonomous driving scenarios where a newly introduced, large wild animal never before seen in the area suddenly appears on the road, such as a new species of deer with unique markings and colors, significantly different in appearance from common animals (such as deer, cattle, and sheep) included in the autonomous driving system's training dataset, potentially leading to a collision. When the cameras of autonomous vehicles capture images of this new type of deer, if this image is input into an existing animal recognition system based on traditional technology, the system is likely to make an incorrect judgment, misclassifying the new deer as a cattle, which greatly increases the potential risk of insurance claims.
[0006] Therefore, improving the accuracy of image OOD anomaly detection has become a pressing technical challenge. Summary of the Invention
[0007] This application provides an image anomaly detection method, apparatus, device, and storage medium, the purpose of which is to solve the technical problem of low accuracy in image OOD anomaly detection.
[0008] Firstly, an image anomaly detection method is provided, the method comprising:
[0009] The system receives a request to perform anomaly detection on an image to be detected, extracts global features of the image to be detected using the global image encoder of the detection model, extracts regional features of the initial region of the image to be detected using the local image encoder of the detection model, and fuses the global features and the regional features to obtain fused features.
[0010] Samples of all known categories used to train the detection model are obtained from the database. Sample features of each sample are extracted. The similarity between the fused feature and each sample feature is calculated to obtain a similarity result set between the fused feature and each known category. The maximum similarity value of the corresponding known category is selected from each similarity result set.
[0011] A distance measurement function is constructed based on each maximum similarity value. The cluster centers of all sample features in each known category are calculated on the preset spatial distribution. The distance measurement function is used to calculate the overall deviation value between the regional features and the distribution features of each cluster center on the spatial distribution.
[0012] The overall deviation value is compared with a preset threshold. Based on the comparison result, it is determined whether the initial region belongs to an unknown category or a known category, and the corresponding category label is marked to respond to the anomaly detection request.
[0013] In a second aspect, a computer device is provided, the computer device comprising:
[0014] At least one processor; and,
[0015] A memory communicatively connected to the at least one processor; wherein,
[0016] The memory stores an image anomaly detection program that can be executed by the at least one processor to perform the steps of the image anomaly detection method described above.
[0017] Thirdly, a computer-readable storage medium is provided, which stores a computer program that, when executed by a processor, implements the steps of the above-described image anomaly detection method.
[0018] Fourthly, an image anomaly detection device is provided, comprising:
[0019] The fusion module is used to receive a request to perform anomaly detection on the image to be detected, extract global features of the image to be detected using the global image encoder of the detection model, extract regional features of the initial region of the image to be detected using the local image encoder of the detection model, and fuse the global features and the regional features to obtain fused features.
[0020] The selection module is used to obtain samples of all known categories used to train the detection model from the database, extract the sample features of each sample, calculate the similarity between the fused feature and each sample feature, obtain the similarity result set between the fused feature and each known category, and select the maximum similarity value of the corresponding known category from each similarity result set.
[0021] The calculation module is used to construct a distance measurement function based on each maximum similarity value, calculate the cluster center of all sample features in each known category on the preset spatial distribution, and use the distance measurement function to calculate the overall deviation value between the distribution features of the region and the distribution features of each cluster center on the spatial distribution;
[0022] The labeling module is used to compare the overall deviation value with a preset threshold, determine whether the initial region belongs to an unknown category or a known category based on the comparison result, and label the corresponding category to respond to the anomaly detection request.
[0023] Compared to existing technologies, this application extracts both global features and regional features of the initial region from the image to be detected, and then fuses them to more accurately understand the image content. By comparing the fused features with sample features of all known categories in the database, the most similar category is found, which can provide a preliminary assessment of whether the image to be detected belongs to any known category.
[0024] A distance measurement function is constructed based on the maximum similarity value to quantify the deviation. This function determines the degree of difference between the new sample and the known category, i.e., whether the new sample might be an unknown category. The overall deviation between the initial region features of the suspected anomaly and the spatial distribution of each cluster center (representing the known category) is calculated. The overall deviation value reflects the degree to which the new sample deviates from the known category distribution and is a key indicator for determining whether a sample is an OOD (Out of Detail).
[0025] Finally, the overall deviation value is compared with a preset threshold to determine whether the area to be detected belongs to a known category or an unknown category. If the deviation value exceeds the threshold, the area is considered to be in an unknown category, indicating the possible existence of a new, unseen lesion type; otherwise, it is classified as a known category.
[0026] This application not only improves the recognition accuracy of known categories, but also enhances the sensitivity to unknown categories or abnormal situations. By integrating global and local features, quantifying similarity and deviation values, and setting reasonable thresholds for classification decisions, it ultimately achieves safer and more accurate image analysis. Attached Figure Description
[0027] Figure 1 is a schematic diagram of an application environment for an image anomaly detection method according to an embodiment of this application;
[0028] Figure 2 is a flowchart illustrating an image anomaly detection method provided in an embodiment of this application;
[0029] Figure 3 is a schematic diagram of the modules of an image anomaly detection device provided in an embodiment of this application;
[0030] Figure 4 is a structural schematic diagram of a computer device according to an embodiment of this application;
[0031] Figure 5 is another structural schematic diagram of a computer device according to one embodiment of this application.
[0032] The purpose, features, and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0033] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0034] The image anomaly detection method provided in this application embodiment can be applied in the application environment shown in Figure 1, wherein the client communicates with the server through a network. The server can receive requests to perform anomaly detection on an image to be detected. It extracts global features from the image using the global image encoder of the detection model, extracts regional features from the initial region of the image using the local image encoder of the detection model, and fuses the global and regional features to obtain a fused feature. It then retrieves samples of all known categories used to train the detection model from a database, extracts the sample features of each sample, calculates the similarity between the fused feature and each sample feature, and obtains a similarity result set between the fused feature and each known category. The server selects the maximum similarity value from each known category within the similarity result set. Based on the maximum similarity values, it constructs a distance measurement function to calculate the cluster centers of all sample features in each known category in spatial distribution. It then uses the distance measurement function to calculate the overall deviation value between the distribution features of the regional features and the distribution features of each cluster center in spatial distribution. Finally, it compares the overall deviation value with a preset threshold, determines whether the initial region belongs to an unknown or known category based on the comparison result, and labels the corresponding category to respond to the anomaly detection request. This approach not only improves the accuracy of identifying known categories but also enhances sensitivity to unknown categories or anomalies. By integrating global and local features, quantifying similarity and deviation values, and setting reasonable thresholds for classification decisions, it ultimately achieves safer and more reliable medical image analysis. The client can be, but is not limited to, various personal computers, laptops, smartphones, tablets, and portable wearable devices. The server can be implemented using a standalone server or a server cluster consisting of multiple servers. The following detailed description of specific embodiments further illustrates this application.
[0035] Referring to Figure 2, a flowchart illustrating an image anomaly detection method according to an embodiment of this application is shown. This method is executed by a device.
[0036] In this embodiment, the image anomaly detection method includes:
[0037] S1. Receive a request to perform anomaly detection on the image to be detected, extract global features of the image to be detected using the global image encoder of the detection model, extract regional features of the initial region of the image to be detected using the local image encoder of the detection model, and fuse the global features and the regional features to obtain fused features.
[0038] In this embodiment, an image to be detected uploaded by a user is received. For example, in the field of healthcare, the image to be detected is provided by a doctor or patient to check for potential lung lesions. The image to be detected is preprocessed to obtain a preprocessed image. The preprocessing includes adjusting the image size and normalizing pixel values.
[0039] For example, when an autonomous vehicle is driving on a road, its monitoring system receives an image from its onboard camera showing a novel, unusually large deer species on the road. Since this deer has never been learned by the recognition system before, its appearance is a potential anomaly, so the monitoring system receives a request to perform anomaly detection on this image. A global image encoder analyzes various elements and their relationships throughout the image to obtain global features of the image to be detected. For example, the width of the road, the distribution of surrounding trees, and the proportion of the sky in the overall image. A local image encoder focuses on the initial region where the novel deer is located, analyzing various detailed features within this region to obtain regional features. Global features (such as its presence near curves, dense surrounding vegetation, and the influence of the novel deer on the image's color tone) and local features (unique markings, large size, and special body structure) are fused to obtain fused features. A pre-trained global image encoder (such as a deep convolutional neural network like ResNet or DenseNet) is loaded, and the pre-processed image is forward-propagated. Through multiple layers of convolution and pooling operations, high-level semantic information of the image is gradually extracted to generate global features representing the entire image to be detected.
[0040] Pre-trained target detection models (such as Faster R-CNN, YOLO, etc.) are used to automatically identify the initial regions (i.e. regions of interest) in the image to be detected that may contain lesions. These initial regions may be the locations of suspected tumors or other abnormal structures.
[0041] A pre-trained local image encoder is loaded, which is specifically designed to capture local details. The cropped initial region is forward-propagated to extract feature vectors that characterize the unique properties of the region, thus obtaining the region features.
[0042] The projective linear layer of the detection model combines the acquired global and regional features to form a comprehensive fusion feature. This fusion feature can be a simple concatenation or a more complex mathematical operation, such as weighted summation or learning through additional neural network layers. The resulting fusion feature not only contains overall image information but also detailed information about specific regions of interest, thereby improving the accuracy of subsequent anomaly detection.
[0043] In this embodiment, the global context information of global features and the regional semantic information of regional features are fused using the following fusion formula:
[0044]
[0045] in, The fusion features are used to represent the image to be detected. and its initial region The comprehensive characteristics, This represents the projective linear layer following the encoder, used for feature dimensionality reduction and fusion. This represents element-wise addition, used to fuse local and global features. It is a weighting coefficient used to control the contribution ratio of local features and global features. This represents the local features of the initial region extracted by the local image encoder. This represents the global features extracted from the entire image to be detected by the global image encoder.
[0046] In one embodiment, the extraction of global features of the image to be detected using the global image encoder of the detection model includes:
[0047] The size of the image to be detected is adjusted, and the image to be detected is normalized to obtain a preprocessed image;
[0048] The global image encoder is used to sequentially perform forward propagation, feature map extraction, and feature aggregation on the preprocessed image to obtain the global features.
[0049] The image size of the image to be detected is adjusted to ensure that the input images have the same dimensions, so that the detection model can process them consistently. The pixel values of the image to be detected are normalized to make the distribution of image data more standardized, which helps to accelerate the feature extraction process and improve the performance of the detection model.
[0050] Load a pre-trained global image encoder (such as ResNet, DenseNet, etc.). The global image encoder has been fully trained on a large-scale dataset and can capture common visual features in the image to be detected.
[0051] Forward propagation of the preprocessed image includes: processing the preprocessed image through a global image encoder, progressively extracting features at different levels of the preprocessed image, and sequentially calculating the output of each layer according to the network structure until the final feature representation is obtained.
[0052] Feature map extraction includes: inputting the feature representation of the forward propagation output into the intermediate or last convolutional layer of the global image encoder, obtaining the output of the intermediate or last convolutional layer to obtain the feature map, which contains the spatial structure information of the image.
[0053] The aggregated feature processing includes applying pooling operations (such as global average pooling or max pooling) to the feature map, compressing the high-dimensional feature map into a low-dimensional feature vector, thereby obtaining the global features of the image to be detected. This low-dimensional feature vector summarizes the information of the entire image to be detected.
[0054] In one embodiment, the step of extracting region features of the initial region of the image to be detected using the local image encoder of the detection model includes:
[0055] The initial region of the image to be detected is identified using a target detection model;
[0056] The initial region is sequentially processed by the local image encoder through forward propagation, feature map extraction, and feature aggregation to obtain the region features.
[0057] The image to be detected undergoes preprocessing to obtain a preprocessed image. Preprocessing includes image resizing and pixel value normalization. A pre-trained object detection model (such as Faster R-CNN, YOLO, RetinaNet, etc.) is then used to analyze the preprocessed image. The object detection model outputs a series of bounding boxes, each identifying a potential initial region (Region of Interest (ROI)) in the preprocessed image, such as the location of a suspected tumor. The initial region contains specific details of the potential lesion.
[0058] Load a pre-trained local image encoder (which, unlike the convolutional neural network of the global image encoder, can be another convolutional neural network, such as ResNet, DenseNet, etc.), and the local image encoder focuses on extracting detailed information within a small region.
[0059] Forward propagation of the initial region includes: calculating the initial region through a local image encoder, progressively extracting different levels of features from the initial region, and calculating the output of each layer sequentially according to the network structure until the final feature representation is obtained.
[0060] Feature map extraction includes: taking the feature representation of the input local image encoder from the intermediate or last convolutional layer of the forward propagation output, obtaining the output of the intermediate or last convolutional layer to obtain the feature map, which contains information about different locations within the initial region.
[0061] Aggregation feature processing includes applying pooling operations (such as global average pooling or max pooling) to the feature map, compressing the high-dimensional feature map into a low-dimensional feature vector, thereby obtaining the local features of the initial region. This low-dimensional feature vector summarizes the information of the initial region.
[0062] The training process of the global image encoder is based on a deep learning framework and a large amount of labeled data, and is obtained as follows:
[0063] Using a pre-trained deep convolutional neural network (such as ResNet or DenseNet) on a large-scale dataset (such as ImageNet) as the initial model, the parameters of the last layer or more layers of the initial model are modified according to the specific classification task of medical images (such as lung cancer detection) to adapt to the new classification requirements.
[0064] A batch of chest X-ray images or other relevant medical imaging data were collected and labeled. The medical imaging data were divided into training set, validation set and test set.
[0065] The training set is preprocessed, such as resizing and normalizing. The initial model is then fine-tuned using the preprocessed medical image data. The weights of the last layer or some layers are updated to adapt to the predetermined task and data distribution. The model performance is evaluated periodically using the validation set. The best-performing model version is saved to obtain the trained global image encoder. The overall performance of the global image encoder is confirmed using the test set.
[0066] The training process of the local image encoder is the same as that of the global image encoder. The difference is that a batch of medical image data with lesion areas (i.e. regions of interest) on chest X-rays is collected and labeled. Similarly, the medical image data with regions of interest are divided into training set, validation set and test set.
[0067] In step S1, the traditional method's reliance on single-scale feature extraction leads to the loss of important details: for example, using only global features may fail to capture key details in local regions, or ignoring global information: using only local features may miss the overall structure and background information of the image. The detection model in this application effectively overcomes these problems by introducing a dual-encoder architecture (global and local image encoders), providing richer feature representations that include not only the overall information of the image to be detected but also detailed information about specific regions of interest, thereby improving the accuracy of subsequent anomaly detection.
[0068] S2. Obtain samples of all known categories from the database used to train the detection model, extract the sample features of each sample, calculate the similarity between the fused feature and each sample feature, obtain the similarity result set between the fused feature and each known category, and select the maximum similarity value of the corresponding known category from each similarity result set.
[0069] In this embodiment, the preset database is a database that stores the feature vectors (i.e., sample features) of all training samples for training the detection model, with each category having one or more sample features. For each known category (such as different disease types), the set of sample features for all samples under that category is retrieved from the database.
[0070] For each known category, iterate through all its sample features and calculate the similarity between the fused feature and each sample feature in each category using a preset similarity metric (such as cosine similarity, Euclidean distance, etc.). For each known category, sort all the calculated similarity results in descending order and select the maximum value as the maximum similarity value for that category.
[0071] By selecting the maximum similarity value within each known category, it's possible to determine which known category the image to be detected is most closely related to. This is a fundamental step in classification decisions, helping to identify the most likely disease type or pathological condition present in the image. For example, in lung CT scan analysis, this step can help the system determine whether a lesion is more likely to belong to pneumonia, lung cancer, or another known type of disease.
[0072] For example, in the recognition system of autonomous vehicles, the database stores a large number of samples of known animal categories, such as image samples of common animals like deer, cattle, sheep, and dogs. For each sample, the system extracts corresponding sample features. For example, for deer samples, sample features might include common deer marking patterns (such as cloverleaf patterns), body size range, antler shape and length, ear size and shape, etc.; for cattle samples, sample features include the large and robust body shape of cattle, unique coat color distribution such as black back and white belly, and the approximate shape of antlers, etc.
[0073] The previously obtained fusion features of the new deer (global features such as appearing near bends, dense surrounding vegetation, and the color tone of the picture being affected by the new deer, and local features such as unique markings, large size, and special body structure) were fused with the sample features of each known animal category in the database to calculate similarity, resulting in a set of similarity results between the fusion features and each known category (deer, cattle, dogs, etc.).
[0074] In one embodiment, selecting the maximum similarity value from the corresponding known categories in each similarity result set includes:
[0075] Iterate through the similarity result set for each known category and sort the similarity results for each known category in descending order;
[0076] Select the maximum similarity value among the known categories based on the sorting order.
[0077] For each known category (e.g., different types of lung diseases), iterate through the feature vectors (i.e., sample features) of all samples within that category. Each sample feature vector represents a feature representation of a training sample.
[0078] The similarity between the fused features and the feature vectors of each sample in each category is calculated using a preset similarity metric (such as cosine similarity, Euclidean distance, etc.). For each known category, the similarity results between all sample feature vectors and the fused features are sorted in descending order, and the maximum value is selected as the maximum similarity value for that category. This maximum similarity value reflects the degree of matching between the image to be detected and the most similar sample in that category.
[0079] In step S2, not only can the most likely disease type in the image to be detected be identified, but a quantitative index (i.e., the maximum similarity value) can also be provided for further classification decisions and anomaly detection, which improves the accuracy and reliability of detection, and is of great significance, especially in medical image analysis.
[0080] S3. Construct a distance measurement function based on each maximum similarity value, calculate the cluster center of all sample features in each known category on the preset spatial distribution, and use the distance measurement function to calculate the overall deviation value between the distribution features of the region and the distribution features of each cluster center on the spatial distribution.
[0081] In this embodiment, one of the core concepts of this application is to modify the fused features after feature extraction (i.e., calculate the overall deviation between the region features and the known categories in the corresponding spatial distribution features), ensuring that the fused features can better adapt to the learning of unknown lesion types. This avoids directly interfering with the original feature extraction process and maintains the basic performance of the detection model. It allows the detection model to make reasonable predictions when faced with unknown categories, rather than simply classifying them as the closest known category.
[0082] Existing technologies typically focus only on identifying known categories. When encountering unknown categories, they may misclassify the unknown category as the most similar known category. Even if the prediction is incorrect, the detection model may still exhibit high confidence, misleading doctors or other users. By introducing post-correction techniques and explicit learning mechanisms, and using a distance measurement function to calculate the overall deviation between region features and the distribution features of each cluster center, the uncertainty of the initial region can be accurately predicted. This effectively solves the problems existing in existing technologies and improves the detection model's ability and accuracy in identifying unknown categories.
[0083] For each known category, a distance measurement function is used to calculate the deviation between the region features of the image to be detected and the distribution features of the cluster centers of that category. The deviation values of all categories are then aggregated to obtain an overall deviation value that represents the overall difference. Aggregation processing may include taking the minimum, average, or weighted sum.
[0084] In one embodiment, constructing the distance measurement function based on each maximum similarity value includes:
[0085] Store the maximum similarity value among all known categories in a pre-defined dictionary;
[0086] The dictionary is set to have the category labels of each known category as its keys, and the dictionary is set to have the maximum similarity value of each known category as its values.
[0087] The distance measurement function is obtained by updating the dictionary settings.
[0088] The calculated maximum similarity value for each known category is stored in a pre-defined dictionary. The keys of the dictionary are the category labels of each known category, and the values are the maximum similarity values of each known category. The pre-defined dictionary is a Python dictionary object, which may initially be empty or contain some default values. As the algorithm executes, this dictionary will be gradually filled based on the calculated maximum similarity values, forming the final data source used for distance measurement.
[0089] Each known category is associated with its category label and the maximum similarity value within that category using a dictionary. This key-value pair relationship allows for quick lookup of similarity information for a specific category. By using the category label as the key, lookup operations can be performed in O(1) time complexity, meaning the maximum similarity value for a given category can be obtained almost instantaneously. This is particularly important when dealing with large-scale datasets or real-time applications.
[0090] Iterate through the dictionary, take the negative of each maximum similarity value, update the dictionary to store the transformed negative values, and obtain the distance measurement function. The distance measurement function takes the fused features of the image to be detected and the category labels of the known categories as input, and returns the corresponding negative maximum similarity value as the distance.
[0091] The distance measurement function is constructed based on the transformed negative value, as shown in the following formula:
[0092]
[0093] in, This represents the output of the distance measurement function, which is the distance metric between the image to be detected and all known categories. Indicating in the index The operation of taking the maximum value from 1 to K (i.e., the number of all known categories). This represents a similarity metric function used to calculate the similarity between two feature vectors. Similarity metrics include cosine similarity, Euclidean distance, etc. Indicates the image to be detected and its initial region The fused features are extracted and fused by the global and local encoders. It represents a process of feature extraction and fusion. Indicates the first Features of samples of known categories.
[0094] In one embodiment, calculating the overall deviation between the regional features and the distribution features of each cluster center in the spatial distribution using the distance measurement function includes:
[0095] The deviation between the distribution characteristics of each cluster center and the regional characteristics is calculated using the distance measurement function, thereby obtaining the deviation between the initial region and each known category;
[0096] A summary process is performed on all deviation values to obtain the overall deviation value. The summary process includes taking the minimum value, the average value, or the weighted sum.
[0097] Calculate the cluster centers of all sample features in each known category on a preset spatial distribution. For each known category, find a representative cluster center in its corresponding multidimensional feature space. The cluster center can best represent the common characteristics of all samples in that category.
[0098] Cluster centers can be understood as the geometric centers of a set of data points (in this example, the feature vectors of image samples belonging to the same category). Specifically, they can be calculated as follows:
[0099] Mean: If the feature space is a Euclidean space, the cluster center can be simply obtained by calculating the arithmetic mean of the coordinates of the feature vectors of all samples.
[0100] Mode: For discrete features, the cluster center is likely to be the feature combination that appears most frequently, i.e., the mode.
[0101] Centroid: Especially in clustering algorithms like k-means, the cluster center is also called the centroid, which is obtained by minimizing the sum of squared distances from all points to the center through an iterative process.
[0102] "Predefined spatial distribution" refers to a predefined feature space, where each dimension corresponds to a specific feature of the image. The calculation of "cluster centers" is to capture the central tendency of sample features within each known category, thereby providing a compact and representative point for subsequent similarity calculation and bias assessment.
[0103] By aggregating the deviation values of all categories, an overall deviation value that reflects the difference between the image to be detected and the total difference of all known categories is calculated. Appropriate aggregation methods are selected based on specific needs, including: Minimum: Selecting the minimum value among all deviation values; Average: Calculating the average of all deviation values; Weighted sum: Weighted summing of the deviation values for different categories.
[0104] The formula for calculating the deviation between each spatial distribution feature and the regional feature using the distance measurement function is as follows:
[0105]
[0106] in, It represents the mathematical expectation, which is the average value of a random variable or function. This represents a deviation measurement function under a given condition. Represents the image to be detected. This represents the identified region of interest (e.g., a lesion area). The bias metric function measures the similarity or deviation between an initial region of the image to be detected and a known category. The category labels (labels within the "in-distribution") representing known categories are used to calculate the conditional expectation. Indicates about distribution characteristics Expected value It is the distribution characteristics of cluster centers of known categories. Represents the distance measurement function. This represents the local features of the initial region cropped from the image to be detected.
[0107] In this embodiment, the distribution characteristics of known categories are obtained according to the following method. The text encoder generates text input (e.g., "a photo of {label}") using the names of categories from a known category dataset. These text inputs are processed to generate class-specific features, and the set of features forms a distribution feature (i.e., ID space) for known classes. ) .
[0108] In step S3, to address the common problem in existing technologies that tend to incorrectly classify unknown categories as the closest known category, even if the prediction is inaccurate, this application introduces a distance measurement function to quantify the difference between the image to be detected and all known categories. If the overall deviation value exceeds a preset threshold, it indicates that the sample is likely not to belong to any known category, but rather to an OOD (Out-of-Distribution) sample or an anomaly. This allows for more reasonable judgments when faced with unseen data, rather than simply classifying it into the most similar known category, thereby reducing the false alarm rate.
[0109] S4. Compare the overall deviation value with a preset threshold, determine whether the category to which the initial region belongs is an unknown category or a known category based on the comparison result, and mark the corresponding category label to respond to the anomaly detection request.
[0110] In this embodiment, one or more thresholds are set for each known category based on historical data, experimental results, or the experience of domain experts. The preset thresholds are used to determine whether the overall deviation value is within an acceptable range.
[0111] The overall deviation value is compared with a preset threshold to determine which known category best matches the image to be detected, or whether the image belongs to an unknown category. Specifically, based on the comparison results, the best matching category is used as the label for the initial region. If no match is found, the initial region is labeled as an unknown category. A response object containing category labels and other relevant information (such as confidence level, suggestions, etc.) is created to respond to the anomaly detection request.
[0112] This application will illustrate its entire process through a specific insurance claim scenario involving anomaly detection in autonomous driving:
[0113] When the autonomous vehicle monitoring system receives an anomaly detection request from an image of a new type of deer captured by an onboard camera, the global image encoder of the detection model analyzes the image to obtain global features such as roads, trees, and sky, while the local image encoder analyzes the image to obtain regional features such as the unique markings and large size of the new deer. The global and regional features are then fused into a fused feature.
[0114] Then, known animal samples (such as deer, cattle, and sheep) and their features are retrieved from the database. The similarity between the fused features and the features of each sample is calculated. If the similarity to deer is high, the maximum similarity among the known categories is taken. Next, a distance measurement function is constructed to calculate the cluster centers of the known category sample features, and the overall deviation value between the region features and the cluster centers in a preset space is calculated. Finally, the overall deviation value is compared with a threshold. If the deviation value is greater than the threshold, the initial region (new type of deer) is determined to be an unknown category and marked; if it is less than or equal to the threshold, it is a known category and marked, thus responding to anomaly detection requests. This slows down the vehicle to reduce the occurrence of insurance claims.
[0115] The entire process of this application will be explained in detail using a specific medical example (lesion detection in a lung CT scan):
[0116] The doctor uploaded a CT scan image of the patient's lungs to check for potential lung lesions (such as tumors, pneumonia, etc.).
[0117] Upon receiving the image, it is first preprocessed (resized and pixel values normalized). Then, using a pre-trained global image encoder (e.g., ResNet), high-level semantic information of the entire CT image is extracted step by step through multi-layer convolution and pooling operations to generate global features representing the entire image.
[0118] Next, a target detection model (such as Faster R-CNN) is used to automatically identify potential lesion areas, and these initial regions are cropped from the original image. Subsequently, a local image encoder is loaded to perform forward propagation on each initial region to extract the local features of that region.
[0119] Global and local features are combined to form fused features. This step ensures that the final feature representation includes both overall information and local details, improving the accuracy of subsequent analysis.
[0120] Retrieve sample features of all known disease types from a pre-defined database (e.g., different types of lung diseases, including pneumonia, lung cancer, etc.). For each known category, iterate through all its sample feature vectors and calculate the similarity between the fused feature and each sample feature in each category using a pre-defined similarity metric (e.g., cosine similarity, Euclidean distance, etc.).
[0121] For each known category, all calculated similarity results are sorted in descending order, and the maximum value is selected as the maximum similarity value for that category. This step helps determine which known category the image to be detected most likely belongs to.
[0122] A distance measurement function is constructed based on the maximum similarity value. This function takes the fused features of the image to be detected and the category labels of the known categories as inputs, and returns the corresponding negative maximum similarity value as the distance.
[0123] This distance measurement function calculates the deviation between the region features of the image to be detected and the distribution features of the cluster centers of known categories. The distribution features can be the average of the feature vectors of all samples under each category or the cluster centers. The overall difference between the initial region and all known categories is evaluated.
[0124] The calculated overall deviation value is compared with a preset threshold. If the deviation value is greater than the threshold, the initial region is considered to belong to an unknown category, suggesting the possible presence of a novel or rare lesion; otherwise, it is classified into one of the closest known categories.
[0125] Based on the assessment results, the system will assign a category label accordingly and create a response object containing the category label and other relevant information (such as confidence level, recommendations, etc.) to respond to the anomaly detection request. For example, if the detection results indicate that the lesion is most likely lung cancer, the system will mark the area in the image and provide corresponding diagnostic suggestions for the doctor's reference.
[0126] In one embodiment, determining whether the initial region belongs to an unknown or known category based on the comparison result and labeling it accordingly includes:
[0127] If the comparison result shows that the overall deviation value is greater than the preset threshold, then the initial region is determined to belong to an unknown category;
[0128] If the comparison result shows that the overall deviation value is less than or equal to a preset threshold, then the initial region is determined to belong to a known category.
[0129] The initial region is labeled with a category tag according to its category.
[0130] The overall deviation value and a preset threshold are input into a preset decision function to determine whether the initial region of the image to be tested is an unknown sample (OOD sample). The decision function formula is as follows:
[0131]
[0132] in, Describe a decision function. Represents the local features of the initial region. The category labels (labels within the "in-distribution") representing known categories are used to calculate the conditional expectation. This represents the average similarity or deviation between an initial region and all known categories, given the input data. This represents the threshold used to distinguish between known categories (ID) and unknown categories (OOD). The initial region is either a known category or an unknown category.
[0133] In step S4, the overall deviation value is used as a clear quantitative indicator, providing a clear basis for decision-making. When the deviation value exceeds the set range, the image to be detected can be marked as an unknown category, indicating the need for further professional examination. This not only improves the safety and reliability of diagnosis but also promotes the research and understanding of new or rare diseases.
[0134] In steps S1-S4, this application extracts global features and regional features of the initial region simultaneously from the image to be detected, and then fuses them to more accurately understand the image content. The fused features are compared with sample features of all known categories in the database to find the most similar category, allowing for a preliminary assessment of whether the image to be detected belongs to any known category.
[0135] A distance measurement function is constructed based on the maximum similarity value to quantify the deviation. This function determines the degree of difference between the new sample and the known category, i.e., whether the new sample might be an unknown category. The overall deviation between the initial region features of the suspected anomaly and the spatial distribution of each cluster center (representing the known category) is calculated. The overall deviation value reflects the degree to which the new sample deviates from the known category distribution and is a key indicator for determining whether a sample is an OOD (Out of Detail).
[0136] Finally, the overall deviation value is compared with a preset threshold to determine whether the area to be detected belongs to a known category or an unknown category. If the deviation value exceeds the threshold, the area is considered to be in an unknown category, indicating the possible existence of a new, unseen lesion type; otherwise, it is classified as a known category.
[0137] This application not only improves the recognition accuracy of known categories, but also enhances the sensitivity to unknown categories or abnormal situations. By integrating global and local features, quantifying similarity and deviation values, and setting reasonable thresholds for classification decisions, it ultimately achieves safer and more reliable medical image analysis, which is particularly suitable for the early detection and research of complex lesions in the health and medical field.
[0138] In one embodiment, an image anomaly detection device is provided, wherein the functions of the functional modules in the image anomaly detection device correspond one-to-one with the steps of the image anomaly detection method in the above embodiments. As shown in FIG3, the image anomaly detection device 100 may include a fusion module 110, a selection module 120, a calculation module 130, and a labeling module 140. Detailed descriptions of each functional module are as follows:
[0139] The fusion module 110 is used to receive a request to perform anomaly detection on an image to be detected, extract global features of the image to be detected using the global image encoder of the detection model, extract regional features of the initial region of the image to be detected using the local image encoder of the detection model, and fuse the global features and the regional features to obtain fused features.
[0140] The selection module 120 is used to obtain samples of all known categories used to train the detection model from the database, extract the sample features of each sample, calculate the similarity between the fused feature and each sample feature, obtain the similarity result set between the fused feature and each known category, and select the maximum similarity value of the corresponding known category from each similarity result set.
[0141] The calculation module 130 is used to construct a distance measurement function based on each maximum similarity value, calculate the cluster center of all sample features in each known category on the preset spatial distribution, and use the distance measurement function to calculate the overall deviation value between the distribution features of the region and the distribution features of each cluster center on the spatial distribution;
[0142] The labeling module 140 is used to compare the overall deviation value with a preset threshold, determine whether the category to which the initial region belongs is an unknown category or a known category based on the comparison result, and label the corresponding category to respond to the anomaly detection request.
[0143] The limitations of each module in the image anomaly detection device can be found in the limitations of each step in the image anomaly detection method described above, and will not be repeated here. Each module in the aforementioned image anomaly detection device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device in hardware form, or stored in the memory of a computer device in software form, so that the processor can call and execute the corresponding operations of each module.
[0144] In one embodiment, a computer device is provided, which can be a server, and its internal structure diagram is shown in Figure 4. The computer device includes a processor, memory, a network interface, and a database connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile and / or volatile storage media and internal memory. The non-volatile storage media stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The network interface is used to communicate with external clients via a network connection. When the computer program is executed by the processor, it implements the functions or steps of an image anomaly detection method on the server side.
[0145] In one embodiment, a computer device is provided, which can be a client, and its internal structure can be as shown in Figure 5. The computer device includes a processor, memory, network interface, display screen, and input device connected via a system bus. The processor provides computing and control capabilities. The memory includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores an operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The network interface is used to communicate with an external server via a network connection. When the computer program is executed by the processor, it implements the functions or steps of an image anomaly detection method on the client side.
[0146] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to perform the following steps:
[0147] The system receives a request to perform anomaly detection on an image to be detected, extracts global features of the image to be detected using the global image encoder of the detection model, extracts regional features of the initial region of the image to be detected using the local image encoder of the detection model, and fuses the global features and the regional features to obtain fused features.
[0148] Samples of all known categories used to train the detection model are obtained from the database. Sample features of each sample are extracted. The similarity between the fused feature and each sample feature is calculated to obtain a similarity result set between the fused feature and each known category. The maximum similarity value of the corresponding known category is selected from each similarity result set.
[0149] A distance measurement function is constructed based on each maximum similarity value. The cluster centers of all sample features in each known category are calculated on the preset spatial distribution. The distance measurement function is used to calculate the overall deviation value between the regional features and the distribution features of each cluster center on the spatial distribution.
[0150] The overall deviation value is compared with a preset threshold. Based on the comparison result, it is determined whether the initial region belongs to an unknown category or a known category, and the corresponding category label is marked to respond to the anomaly detection request.
[0151] In one embodiment, a computer-readable storage medium is provided having an image anomaly detection program stored thereon, which, when executed by a processor, performs the following steps:
[0152] The system receives a request to perform anomaly detection on an image to be detected, extracts global features of the image to be detected using the global image encoder of the detection model, extracts regional features of the initial region of the image to be detected using the local image encoder of the detection model, and fuses the global features and the regional features to obtain fused features.
[0153] Samples of all known categories used to train the detection model are obtained from the database. Sample features of each sample are extracted. The similarity between the fused feature and each sample feature is calculated to obtain a similarity result set between the fused feature and each known category. The maximum similarity value of the corresponding known category is selected from each similarity result set.
[0154] A distance measurement function is constructed based on each maximum similarity value. The cluster centers of all sample features in each known category are calculated on the preset spatial distribution. The distance measurement function is used to calculate the overall deviation value between the regional features and the distribution features of each cluster center on the spatial distribution.
[0155] The overall deviation value is compared with a preset threshold. Based on the comparison result, it is determined whether the initial region belongs to an unknown category or a known category, and the corresponding category label is marked to respond to the anomaly detection request.
[0156] It should be noted that the functions or steps that can be implemented by the computer-readable storage medium or computer device described above can be referred to the relevant descriptions on the server side and client side in the foregoing method embodiments. To avoid repetition, they will not be described one by one here.
[0157] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, which can be non-volatile or volatile. When executed, the computer program can include the processes of the embodiments of the above methods. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM) or external cache memory.
[0158] The embodiments described above are only used to illustrate the technical solutions of this application, and are not intended to limit them; if any software tools or components other than those of our company appear in the embodiments of the application, they are only used as examples and do not represent actual use.
Claims
1. An image anomaly detection method, wherein, The method includes: The system receives a request to perform anomaly detection on an image to be detected, extracts global features of the image to be detected using the global image encoder of the detection model, extracts regional features of the initial region of the image to be detected using the local image encoder of the detection model, and fuses the global features and the regional features to obtain fused features. Samples of all known categories used to train the detection model are obtained from the database. Sample features of each sample are extracted. The similarity between the fused feature and each sample feature is calculated to obtain a similarity result set between the fused feature and each known category. The maximum similarity value of the corresponding known category is selected from each similarity result set. A distance measurement function is constructed based on each maximum similarity value. The cluster centers of all sample features in each known category are calculated on the preset spatial distribution. The distance measurement function is used to calculate the overall deviation value between the regional features and the distribution features of each cluster center on the spatial distribution. The overall deviation value is compared with a preset threshold. Based on the comparison result, it is determined whether the initial region belongs to an unknown category or a known category, and the corresponding category label is marked to respond to the anomaly detection request.
2. The image anomaly detection method as described in claim 1, wherein, The step of extracting global features from the image to be detected using a global image encoder based on a preset detection model includes: The size of the image to be detected is adjusted, and the image to be detected is normalized to obtain a preprocessed image; The global image encoder is used to sequentially perform forward propagation, feature map extraction, and feature aggregation on the preprocessed image to obtain the global features.
3. The image anomaly detection method as described in claim 1, wherein, The step of extracting regional features of the initial region of the image to be detected using the local image encoder of the detection model includes: The initial region of the image to be detected is identified using a target detection model; The initial region is sequentially processed by the local image encoder through forward propagation, feature map extraction, and feature aggregation to obtain the region features.
4. The image anomaly detection method as described in claim 1, wherein, The step of selecting the maximum similarity value from the corresponding known categories in each similarity result set includes: Iterate through the similarity result set for each known category and sort the similarity results for each known category in descending order; Select the maximum similarity value among the known categories based on the sorting order.
5. The image anomaly detection method as described in claim 1, wherein, The construction of the distance measurement function based on each maximum similarity value includes: Store the maximum similarity value among all known categories in a pre-defined dictionary; The dictionary is set to have the category labels of each known category as its keys, and the dictionary is set to have the maximum similarity value of each known category as its values. The distance measurement function is obtained by updating the dictionary settings.
6. The image anomaly detection method as described in claim 1, wherein, The step of calculating the overall deviation value of the regional features and the distribution features of each cluster center in the spatial distribution using the distance measurement function includes: The deviation between the distribution characteristics of each cluster center and the regional characteristics is calculated using the distance measurement function, thereby obtaining the deviation between the initial region and each known category; A summary process is performed on all deviation values to obtain the overall deviation value. The summary process includes taking the minimum value, the average value, or the weighted sum.
7. The image anomaly detection method as described in claim 1, wherein, The step of determining the category to which the initial region belongs based on the comparison results and labeling the category includes: If the comparison result shows that the overall deviation value is greater than the preset threshold, then the initial region is determined to belong to an unknown category; If the comparison result shows that the overall deviation value is less than or equal to a preset threshold, then the initial region is determined to belong to a known category. The initial region is labeled with a category tag according to its category.
8. A computer device, wherein, The computer device includes: At least one processor; and, A memory communicatively connected to the at least one processor; wherein, The memory stores an image anomaly detection program that can be executed by the at least one processor to perform the following steps: The system receives a request to perform anomaly detection on an image to be detected, extracts global features of the image to be detected using the global image encoder of the detection model, extracts regional features of the initial region of the image to be detected using the local image encoder of the detection model, and fuses the global features and the regional features to obtain fused features. Samples of all known categories used to train the detection model are obtained from the database. Sample features of each sample are extracted. The similarity between the fused feature and each sample feature is calculated to obtain a similarity result set between the fused feature and each known category. The maximum similarity value of the corresponding known category is selected from each similarity result set. A distance measurement function is constructed based on each maximum similarity value. The cluster centers of all sample features in each known category are calculated on the preset spatial distribution. The distance measurement function is used to calculate the overall deviation value between the regional features and the distribution features of each cluster center on the spatial distribution. The overall deviation value is compared with a preset threshold. Based on the comparison result, it is determined whether the initial region belongs to an unknown category or a known category, and the corresponding category label is marked to respond to the anomaly detection request.
9. The computer device as claimed in claim 8, wherein, The step of extracting global features from the image to be detected using a global image encoder based on a preset detection model includes: The size of the image to be detected is adjusted, and the image to be detected is normalized to obtain a preprocessed image; The global image encoder is used to sequentially perform forward propagation, feature map extraction, and feature aggregation on the preprocessed image to obtain the global features.
10. The computer device as claimed in claim 8, wherein, The step of extracting regional features of the initial region of the image to be detected using the local image encoder of the detection model includes: The initial region of the image to be detected is identified using a target detection model; The initial region is sequentially processed by the local image encoder through forward propagation, feature map extraction, and feature aggregation to obtain the region features.
11. The computer device as claimed in claim 8, wherein, The step of selecting the maximum similarity value from the corresponding known categories in each similarity result set includes: Iterate through the similarity result set for each known category and sort the similarity results for each known category in descending order; Select the maximum similarity value among the known categories based on the sorting order.
12. The computer device as claimed in claim 8, wherein, The construction of the distance measurement function based on each maximum similarity value includes: Store the maximum similarity value among all known categories in a pre-defined dictionary; The dictionary is set to have the category labels of each known category as its keys, and the dictionary is set to have the maximum similarity value of each known category as its values. The distance measurement function is obtained by updating the dictionary settings.
13. The computer device as claimed in claim 8, wherein, The step of calculating the overall deviation value of the regional features and the distribution features of each cluster center in the spatial distribution using the distance measurement function includes: The deviation between the distribution characteristics of each cluster center and the regional characteristics is calculated using the distance measurement function, thereby obtaining the deviation between the initial region and each known category; A summary process is performed on all deviation values to obtain the overall deviation value. The summary process includes taking the minimum value, the average value, or the weighted sum.
14. A non-volatile computer-readable storage medium, wherein, The non-volatile computer-readable storage medium stores an image anomaly detection program, which can be executed by one or more processors to perform the following steps: The system receives a request to perform anomaly detection on an image to be detected, extracts global features of the image to be detected using the global image encoder of the detection model, extracts regional features of the initial region of the image to be detected using the local image encoder of the detection model, and fuses the global features and the regional features to obtain fused features. Samples of all known categories used to train the detection model are obtained from the database. Sample features of each sample are extracted. The similarity between the fused feature and each sample feature is calculated to obtain a similarity result set between the fused feature and each known category. The maximum similarity value of the corresponding known category is selected from each similarity result set. A distance measurement function is constructed based on each maximum similarity value. The cluster centers of all sample features in each known category are calculated on the preset spatial distribution. The distance measurement function is used to calculate the overall deviation value between the regional features and the distribution features of each cluster center on the spatial distribution. The overall deviation value is compared with a preset threshold. Based on the comparison result, it is determined whether the initial region belongs to an unknown category or a known category, and the corresponding category label is marked to respond to the anomaly detection request.
15. The non-volatile computer-readable storage medium of claim 14, wherein, The step of extracting global features from the image to be detected using a global image encoder based on a preset detection model includes: The size of the image to be detected is adjusted, and the image to be detected is normalized to obtain a preprocessed image; The global image encoder is used to sequentially perform forward propagation, feature map extraction, and feature aggregation on the preprocessed image to obtain the global features.
16. The non-volatile computer-readable storage medium of claim 14, wherein, The step of extracting regional features of the initial region of the image to be detected using the local image encoder of the detection model includes: The initial region of the image to be detected is identified using a target detection model; The initial region is sequentially processed by the local image encoder through forward propagation, feature map extraction, and feature aggregation to obtain the region features.
17. The non-volatile computer-readable storage medium of claim 14, wherein, The step of selecting the maximum similarity value from the corresponding known categories in each similarity result set includes: Iterate through the similarity result set for each known category and sort the similarity results for each known category in descending order; Select the maximum similarity value among the known categories based on the sorting order.
18. The non-volatile computer-readable storage medium of claim 14, wherein, The construction of the distance measurement function based on each maximum similarity value includes: Store the maximum similarity value among all known categories in a pre-defined dictionary; The dictionary is set to have the category labels of each known category as its keys, and the dictionary is set to have the maximum similarity value of each known category as its values. The distance measurement function is obtained by updating the dictionary settings.
19. The non-volatile computer-readable storage medium of claim 14, wherein, The step of calculating the overall deviation value of the regional features and the distribution features of each cluster center in the spatial distribution using the distance measurement function includes: The deviation between the distribution characteristics of each cluster center and the regional characteristics is calculated using the distance measurement function, thereby obtaining the deviation between the initial region and each known category; A summary process is performed on all deviation values to obtain the overall deviation value. The summary process includes taking the minimum value, the average value, or the weighted sum.
20. An image anomaly detection device, wherein, The device includes: The fusion module is used to receive a request to perform anomaly detection on the image to be detected, extract global features of the image to be detected using the global image encoder of the detection model, extract regional features of the initial region of the image to be detected using the local image encoder of the detection model, and fuse the global features and the regional features to obtain fused features. The selection module is used to obtain samples of all known categories used to train the detection model from the database, extract the sample features of each sample, calculate the similarity between the fused feature and each sample feature, obtain the similarity result set between the fused feature and each known category, and select the maximum similarity value of the corresponding known category from each similarity result set. The calculation module is used to construct a distance measurement function based on each maximum similarity value, calculate the cluster center of all sample features in each known category on the preset spatial distribution, and use the distance measurement function to calculate the overall deviation value between the distribution features of the region and the distribution features of each cluster center on the spatial distribution; The labeling module is used to compare the overall deviation value with a preset threshold, determine whether the initial region belongs to an unknown category or a known category based on the comparison result, and label the corresponding category to respond to the anomaly detection request.