A small sample anomaly detection method based on a multi-modal large model

By fusing textual and image prompts using a multimodal large model, an anomaly heatmap is generated, which solves the problem of low anomaly detection accuracy under small sample conditions in existing technologies and achieves high-precision anomaly detection.

CN123158302APending Publication Date: 2026-11-24MAANSHAN TEACHERS COLLEGE
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611360913.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-03
Publication Date
2026-11-24

AI Technical Summary

Technical Problem

Existing technologies struggle to effectively integrate text and image prompts under small sample conditions, resulting in low anomaly detection accuracy.

Method used

By acquiring text and image prompts, a target detection model is used to generate box-shaped anomaly localization regions and extract positive and negative estimated points. Combined with a segmentation model, an anomaly heatmap is generated, achieving weighted fusion of multimodal information.

Benefits of technology

It significantly improves the accuracy and robustness of anomaly detection, especially enhancing detection precision and recall under small sample conditions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123158302A_ABST
    Figure CN123158302A_ABST
Patent Text Reader

Abstract

This invention discloses a small-sample anomaly detection method based on a multimodal large model, relating to the field of visual detection, comprising: S1, acquiring an image to be detected; S2, acquiring text prompt information and image prompt information; S3, using the box-shaped anomaly localization region as a first prompt input to the segmentation model; S4, using the positive estimated points and the negative estimated points as a second prompt input to the segmentation model; S5, fusing the text mask set, the text score set, the image mask set, and the image score set; this method, by simultaneously acquiring text prompt information and image prompt information, using a target detection model to generate box prompts and extracting positive and negative estimated points from image prompts as point prompts, and inputting them into the same segmentation model to generate masks and scores, and finally generating an anomaly heatmap through weighted fusion, significantly improves the accuracy and robustness of anomaly detection without requiring a large number of training samples.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to visual inspection technology, specifically to a method for detecting small-sample anomalies based on a multimodal large model. Background Technology

[0002] Anomaly detection aims to identify samples in data that significantly deviate from normal patterns. In the field of industrial vision, anomaly classification (determining whether an image has defects) and anomaly segmentation (locating the position of defective pixels) are two core tasks.

[0003] In recent years, the rise of basic models (such as SAM and CLIP) has provided new possibilities for zero-shot and few-shot anomaly detection. For example, WinCLIP utilizes CLIP's text-image alignment capability to achieve training-free detection; Segment AnythingModel (SAM) supports multiple cues such as points, bounding boxes, and text, and possesses powerful segmentation capabilities. However, existing methods mainly suffer from the following problems:

[0004] Most existing technologies rely on single-modal cue information: when using only text cues, the abstract and ambiguous nature of natural language makes it difficult to accurately describe complex or diverse anomalies; when using only image cues, the types of anomalies in the reference image often do not perfectly match the anomalies in the image to be detected, and a single sample cannot cover all anomaly variations. Existing schemes that simply combine the two cues lack an effective fusion mechanism, resulting in limited detection accuracy.

[0005] Therefore, how to fuse text and image prompts under small sample conditions and generate high-precision anomaly detection results is a technical problem that urgently needs to be solved. Summary of the Invention

[0006] The purpose of this invention is to provide a small-sample anomaly detection method based on a multimodal large model, in order to solve the problems in the prior art where the expressive power of single-modal prompts is limited and the multimodal prompts lack an effective fusion mechanism, resulting in low accuracy of anomaly classification and segmentation under small sample conditions.

[0007] To achieve the above objectives, the present invention provides the following technical solution:

[0008] In a first aspect, the present invention provides a method for detecting small-sample anomalies based on a multimodal large model, comprising:

[0009] S1. Obtain the image to be detected;

[0010] S2. Obtain text prompt information and image prompt information, wherein the text prompt information includes a text description for describing the anomaly category, and the image prompt information includes at least one reference anomaly image and the anomaly mask corresponding to the reference anomaly image;

[0011] S3. Using the target detection model, at least one box-shaped abnormal location region is generated on the image to be detected based on the text prompt information, and the box-shaped abnormal location region is used as the first prompt input segmentation model to generate a text mask set and a text score set.

[0012] S4. Extract at least one positive estimation point and at least one negative estimation point from the image to be detected according to the image prompt information, and input the positive estimation point and the negative estimation point as the second prompt into the segmentation model to generate an image mask set and an image score set;

[0013] S5. Merge the text mask set, the text score set, the image mask set, and the image score set to generate an anomaly heatmap.

[0014] Further, the step of extracting at least one positive estimation point and at least one negative estimation point from the image to be detected based on the image cue information includes:

[0015] Extract abnormal visual concepts from the reference abnormal image and the abnormal mask corresponding to the reference abnormal image, wherein the abnormal visual concept is a set of feature vectors of the abnormal region in the reference abnormal image;

[0016] Calculate the similarity between each pixel in the image to be detected and the abnormal visual concept;

[0017] The at least one pixel with the highest similarity is taken as the positive estimation point, and the at least one pixel with the lowest similarity is taken as the negative estimation point.

[0018] Furthermore, the fusion includes:

[0019] Each mask in the text mask set is multiplied by its corresponding first score to obtain the first weighted mask;

[0020] Each mask in the image mask set is multiplied by its corresponding second score to obtain the second weighted mask;

[0021] The first weighted mask and the second weighted mask are normalized pixel by pixel to generate the abnormal heatmap.

[0022] Furthermore, the segmentation model is the Segment Anything Model, and the target detection model is Grounding DINO.

[0023] Furthermore, it also includes lightweight training steps:

[0024] Obtain multi-scale versions of the image to be detected, including a first-scale image, a second-scale image, and a third-scale image, wherein the first scale, the second scale, and the third scale are different from each other;

[0025] The first-scale image, the second-scale image, and the third-scale image are respectively input into the segmentation model to generate corresponding first-scale masks, second-scale masks, and third-scale masks;

[0026] Train the first weight parameter and the second weight parameter, multiply the first scale mask by the first weight parameter, multiply the second scale mask by the second weight parameter, and multiply the third scale mask by 1 minus the first weight parameter and then minus the second weight parameter to obtain the weighted multiscale mask;

[0027] The weighted multi-scale mask is fused with the text mask set and the image mask set to generate the anomaly heatmap.

[0028] Furthermore, the loss function used in the lightweight training step is the sum of the Dice loss and the Focal loss.

[0029] Furthermore, it also includes anomaly detection steps for network time-series data:

[0030] Obtain network traffic data or transportation data as time-series data to be detected;

[0031] The time series data to be detected is subjected to feature extraction and compression using an autoencoder combined with an Informer model;

[0032] Anomaly detection is performed on the compressed features using a local outlier classifier or an isolated support vector machine classifier.

[0033] Secondly, the present invention provides a small-sample anomaly detection system based on a multimodal large model, comprising:

[0034] The image acquisition module is used to acquire the image to be detected;

[0035] The prompt acquisition module is used to acquire text prompt information and image prompt information. The text prompt information includes a text description describing the anomaly category, and the image prompt information includes at least one reference anomaly image and the anomaly mask corresponding to the reference anomaly image.

[0036] The text prompt processing module is used to generate at least one box-shaped abnormal location region on the image to be detected based on the text prompt information using the target detection model, and to use the box-shaped abnormal location region as the first prompt input segmentation model to generate a text mask set and a text score set.

[0037] An image prompting processing module is used to extract at least one positive estimation point and at least one negative estimation point from the image to be detected based on the image prompting information, and input the positive estimation point and the negative estimation point as a second prompt into the segmentation model to generate an image mask set and an image score set;

[0038] The fusion module is used to fuse the text mask set, the text score set, the image mask set, and the image score set to generate an anomaly heatmap.

[0039] Compared with existing technologies, the present invention provides a small-sample anomaly detection method based on a multimodal large model. By simultaneously acquiring textual and image prompts, it generates bounding box prompts using an object detection model and extracts positive and negative estimated points from the image prompts as point prompts. These are then input into the same segmentation model to generate masks and scores. Finally, a weighted fusion is used to generate an anomaly heatmap. This fully leverages the complementary advantages of the flexibility of textual semantics and the accuracy of image visuals, significantly improving the accuracy and robustness of anomaly detection without requiring a large number of training samples. Attached Figure Description

[0040] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this invention. For those skilled in the art, other drawings can be obtained based on these drawings.

[0041] Figure 1 A flowchart illustrating the technical route provided in the embodiments of the present invention;

[0042] Figure 2 This is a schematic diagram illustrating the multimodal cue fusion principle provided in an embodiment of the present invention;

[0043] Figure 3 This is a general framework diagram of the experimental scheme provided in the embodiments of the present invention;

[0044] Figure 4 This is a framework diagram of a lightweight training experiment scheme provided in an embodiment of the present invention;

[0045] Figure 5 This is a schematic diagram of multimodal cue mask intersection optimization provided in an embodiment of the present invention;

[0046] Figure 6 This is a schematic diagram of multimodal cue mask union optimization provided in an embodiment of the present invention;

[0047] Figure 7 A schematic diagram illustrating the optimization of the mask generated by multimodal cues on the union of the present invention, provided in an embodiment of the invention.

[0048] Figure 8 This is a schematic diagram illustrating the improvement of the multimodal cue detection algorithm compared to the single-modal algorithm provided in this embodiment of the invention. Detailed Implementation

[0049] To enable those skilled in the art to better understand the technical solution of the present invention, the present invention will be further described in detail below with reference to the accompanying drawings.

[0050] As attached Figure 1 To be continued Figure 8 As shown:

[0051] The overall method of this invention is considered an anomaly detector. It receives three inputs: the image to be detected, text prompts, and image prompts, and outputs anomaly classification results (image level) and anomaly segmentation results (pixel level). Specifically, the anomaly detector includes: processing text prompts using a grounding DINO model to generate candidate bounding boxes, and refining the text mask using a segmentation model (SAM); simultaneously, extracting visual concepts of anomalies from a reference image to generate positive and negative estimated points, which are then input into the same segmentation model to obtain an image mask; finally, fusing the two masks to generate an anomaly heatmap.

[0052] Example 1:

[0053] This invention provides a method for detecting small-sample anomalies based on a multimodal large model, the specific steps of which are as follows:

[0054] Step S1: Obtain the image to be detected.

[0055] Images of the product to be inspected, such as the surface of a bottle or cashew nut, are captured using an industrial camera at a resolution of 512×512 pixels. The images are stored in digital matrix format.

[0056] Step S2: Obtain text prompts and image prompts.

[0057] Text prompts: These are generated automatically by the user or the system, and may include general or specific phrases such as "bottle defect," "bottle breakage," or "white damaged area." In this embodiment, "damage on bottle" is used as the text prompt.

[0058] Image prompt: Select a known anomaly reference image and its corresponding ground truth mask. Anomaly areas in the reference image have been manually labeled. In this embodiment, the reference image is an image of a broken bottle; the mask shows a broken pixel value of 1 and a normal pixel value of 0.

[0059] Step S3: Generate the mask and score for the text prompt.

[0060] The text prompt "damage on bottle" is input into the Grounding DINO object detection model. GroundingDINO is an open-vocabulary object detection model based on Transformer, capable of locating corresponding objects in an image based on any text. In this embodiment, Grounding DINO generates one or more bounding boxes on the image to be detected, enclosing potentially damaged areas. Each bounding box is accompanied by a confidence score.

[0061] Each bounding box is then used as a "box cue" input to the segmentation model SAM. SAM (Segment Anything Model) consists of an image encoder, a cue encoder, and a lightweight mask decoder. SAM generates a fine-grained anomalous mask based on the box cue and outputs a corresponding mask score (representing the quality of the mask). The final result is a set of text masks. and text score set .

[0062] Step S4: Generate the mask and score for the image cue.

[0063] This step is further subdivided into the following sub-steps:

[0064] S41: Extracting Abnormal Visual Concepts C R From the reference anomalous image and its corresponding anomalous mask, a set of feature vectors for the anomalous region is extracted. Specifically, a pre-trained deep feature extraction network (such as ResNet or DINOv2) is used to extract features from the reference image, retaining only the pixel features of the anomalous region corresponding to the mask, forming an anomalous visual concept. This concept is essentially a set of multiple feature vectors representing the typical distribution of the anomalous appearance.

[0065] S42: Calculate the similarity between each pixel in the image to be detected and the abnormal visual concept. For each pixel in the image to be detected, extract its depth features (using the same network), calculate the cosine similarity between this feature and all feature vectors in the abnormal visual concept, take the maximum value as the abnormal similarity score of the pixel, and generate a similarity map.

[0066] S43: Select positive and negative estimation points. On the similarity map, find the k pixels with the highest similarity (k≥1), as positive estimation points (representing the most likely abnormal points); find the m pixels with the lowest similarity (m≥1), as negative estimation points (representing the most likely normal points). In this embodiment, k=5 and m=5.

[0067] S44: Input positive and negative estimated points as point cues into SAM. SAM's point cues support the distinction between positive (foreground) and negative (background) points. Positive estimated points indicate that the location should be segmented as anomaly, while negative estimated points indicate that the location should be segmented as normal. SAM generates an image mask set based on these point cues. and image score set .

[0068] Step S5: Generate an abnormal heatmap by merging the data.

[0069] This embodiment uses a weighted fusion scheme:

[0070] Multiply each mask in the text mask set by its corresponding score to obtain the first weighted mask: .

[0071] Similarly, we obtain the second weighted mask: .

[0072] All weighted masks are summed pixel by pixel and then normalized so that the final anomaly score of each pixel is in the range of [0,1], thus generating an anomaly heatmap H.

[0073] The formula is expressed as:

[0074] in, The maximum pixel value among all weighted masks is used to ensure normalization.

[0075] Ultimately, the anomaly heatmap H represents the detection result: higher pixel values ​​indicate a greater likelihood of an anomaly. A threshold (such as 0.5) can be set for binarization segmentation to obtain the anomaly mask.

[0076] Results: In the anomaly heatmap, the anomaly scores of regions (intersections) jointly identified by both modalities are close to the original high scores (e.g., 0.88 vs 0.92 and 0.84), while the scores of regions identified by only a single modality are significantly reduced (e.g., 0.46 vs 0.92), thereby improving the accuracy and robustness of detection.

[0077] In addition to enhancing the intersection region, the fusion method of this invention also achieves union optimization: the abnormal segmentation region in the abnormal heatmap is the result of merging the abnormal regions in each original mask (text cue mask and image cue mask). This means that as long as one modal cue can identify the abnormality, the abnormal region will be retained in the final output, thereby improving the recall rate (i.e., reducing false negatives).

[0078] Example 2:

[0079] This embodiment is basically the same as the previous embodiment, except that, in order to further improve the segmentation accuracy of multi-scale anomalies, this embodiment introduces a lightweight training step.

[0080] Placed before S5 or as a replacement for S5:

[0081] Obtain multi-scale versions of the image to be detected: obtain three scales through image pyramid downsampling, such as the original scale 512×512, half scale 256×256, and quarter scale 128×128.

[0082] Input each scale image into SAM (using the same cues, such as dot cues or box cues) to generate the corresponding scale mask: .

[0083] Train two learnable weight parameters w1 and w2, where and The weight of the third scale is then... .

[0084] By summing the masks at the three scales in a weighted manner, we obtain the weighted multi-scale mask: .

[0085] The weighted multi-scale mask is further fused with the mask sets from text prompts and image prompts (using the weighting method of Example 1) to generate the final anomaly heatmap.

[0086] During training, a small number of normal images and synthetic anomalous images (or existing labeled images) are used as the validation set. The loss function is the sum of the Dice loss and the Focal loss.

[0087]

[0088] Among them, Dice loss measures the overlap between the predicted mask and the real mask, while Focal loss handles the class imbalance problem. Since only two parameters are trained, very few samples are required (only a few dozen images), and the training speed is fast (completed within minutes).

[0089] Through this lightweight training, the model can adaptively select the most suitable scale mask, effectively segmenting both large and small anomalies.

[0090] Example 3:

[0091] This invention also provides a small-sample anomaly detection system based on a multimodal large model, comprising the following modules:

[0092] Image acquisition module: Used to acquire the image to be detected.

[0093] Prompt Acquisition Module: Used to acquire text prompts and image prompts.

[0094] Text prompt processing module: Internally integrates Grounding DINO and SAM, and executes step S3.

[0095] Image prompting processing module: It contains an abnormal visual concept extraction unit, a similarity calculation unit, a point selection unit, and SAM, and executes step S4.

[0096] Fusion module: Performs weighted multiplication and pixel-by-pixel normalization to generate anomaly heatmaps.

[0097] Experimental verification

[0098] To verify the effectiveness of this invention, the applicant has conducted experiments on two publicly available industrial anomaly detection datasets, MVTec AD and VisA. Experimental setup: one reference anomaly image was used for each class (one-shot), and comparison algorithms included WinCLIP, AnomalyDINO, and CutPaste. Evaluation metrics were image-level AUROC (anomaly classification) and pixel-level AUROC (anomaly segmentation).

[0099] Experimental results show that the multimodal cueing method of the present invention is significantly better than single-modal cueing and existing methods in anomaly segmentation tasks; the lightweight training version further improves detection accuracy.

[0100] Industrial Application Prospects

[0101] This invention can be widely applied in industrial visual quality inspection (such as electronic product appearance inspection, textile defect detection), medical image anomaly detection, and traffic monitoring anomaly detection. Because it requires no large amount of labeled data, it can significantly reduce model deployment costs and manual annotation workload, thus possessing high commercial value and widespread application potential.

[0102] The foregoing has only described certain exemplary embodiments of the present invention by way of illustration. Undoubtedly, those skilled in the art can modify the described embodiments in various ways without departing from the spirit and scope of the present invention. Therefore, the foregoing drawings and descriptions are illustrative in nature and should not be construed as limiting the scope of protection of the claims of the present invention.

Claims

1. A method for detecting small-sample anomalies based on a multimodal large model, characterized in that, include: S1. Obtain the image to be detected; S2. Obtain text prompt information and image prompt information, wherein the text prompt information includes a text description for describing the anomaly category, and the image prompt information includes at least one reference anomaly image and the anomaly mask corresponding to the reference anomaly image; S3. Using the target detection model, at least one box-shaped abnormal location region is generated on the image to be detected based on the text prompt information, and the box-shaped abnormal location region is used as the first prompt input segmentation model to generate a text mask set and a text score set. S4. Extract at least one positive estimation point and at least one negative estimation point from the image to be detected according to the image prompt information, and input the positive estimation point and the negative estimation point as the second prompt into the segmentation model to generate an image mask set and an image score set; S5. Merge the text mask set, the text score set, the image mask set, and the image score set to generate an anomaly heatmap.

2. The method for detecting small-sample anomalies based on a multimodal large model according to claim 1, characterized in that, The step of extracting at least one positive estimation point and at least one negative estimation point from the image to be detected based on the image prompt information includes: Extract abnormal visual concepts from the reference abnormal image and the abnormal mask corresponding to the reference abnormal image, wherein the abnormal visual concept is a set of feature vectors of the abnormal region in the reference abnormal image; Calculate the similarity between each pixel in the image to be detected and the abnormal visual concept; The at least one pixel with the highest similarity is taken as the positive estimation point, and the at least one pixel with the lowest similarity is taken as the negative estimation point.

3. The method for detecting small-sample anomalies based on a multimodal large model according to claim 1, characterized in that, The fusion includes: Each mask in the text mask set is multiplied by its corresponding first score to obtain the first weighted mask; Each mask in the image mask set is multiplied by its corresponding second score to obtain the second weighted mask; The first weighted mask and the second weighted mask are normalized pixel by pixel to generate the abnormal heatmap.

4. The method for detecting small-sample anomalies based on a multimodal large model according to claim 1, characterized in that, The segmentation model is the Segment Anything Model, and the target detection model is Grounding DINO.

5. The method for detecting small-sample anomalies based on a multimodal large model according to claim 1, characterized in that, It also includes lightweight training steps: Obtain multi-scale versions of the image to be detected, including a first-scale image, a second-scale image, and a third-scale image, wherein the first scale, the second scale, and the third scale are different from each other; The first-scale image, the second-scale image, and the third-scale image are respectively input into the segmentation model to generate corresponding first-scale masks, second-scale masks, and third-scale masks; Train the first weight parameter and the second weight parameter, multiply the first scale mask by the first weight parameter, multiply the second scale mask by the second weight parameter, and multiply the third scale mask by 1 minus the first weight parameter and then minus the second weight parameter to obtain the weighted multiscale mask; The weighted multi-scale mask is fused with the text mask set and the image mask set to generate the anomaly heatmap.

6. The method for detecting small-sample anomalies based on a multimodal large model according to claim 5, characterized in that, The loss function used in the lightweight training step is the sum of the Dice loss and the Focal loss.

7. The method for detecting small-sample anomalies based on a multimodal large model according to claim 1, characterized in that, It also includes anomaly detection steps for network time-series data: Obtain network traffic data or transportation data as time-series data to be detected; The time series data to be detected is subjected to feature extraction and compression using an autoencoder combined with an Informer model; Anomaly detection is performed on the compressed features using a local outlier classifier or an isolated support vector machine classifier.

8. A small-sample anomaly detection system based on a multimodal large model, characterized in that, include: The image acquisition module is used to acquire the image to be detected; The prompt acquisition module is used to acquire text prompt information and image prompt information. The text prompt information includes a text description describing the anomaly category, and the image prompt information includes at least one reference anomaly image and the anomaly mask corresponding to the reference anomaly image. The text prompt processing module is used to generate at least one box-shaped abnormal location region on the image to be detected based on the text prompt information using the target detection model, and to use the box-shaped abnormal location region as the first prompt input segmentation model to generate a text mask set and a text score set. An image prompting processing module is used to extract at least one positive estimation point and at least one negative estimation point from the image to be detected based on the image prompting information, and input the positive estimation point and the negative estimation point as a second prompt into the segmentation model to generate an image mask set and an image score set; The fusion module is used to fuse the text mask set, the text score set, the image mask set, and the image score set to generate an anomaly heatmap.