An industrial image anomaly detection and segmentation method

By combining reinforcement learning and cross-modal alignment techniques with format reward and focus reward mechanisms, high precision and efficiency of industrial image anomaly detection and segmentation are achieved, solving the problems of insufficient precision and generalization ability in existing industrial detection technologies and providing a high-precision industrial quality inspection solution.

CN120912993BActive Publication Date: 2026-02-17CHINA JILIANG UNIV +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511430204.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-10-09
Publication Date
2026-02-17
Estimated Expiration
2045-10-09

AI Technical Summary

Technical Problem

Existing industrial image anomaly detection methods have limited generalization ability in complex industrial scenarios, lack cross-modal information utilization, and suffer from low segmentation accuracy and high sample annotation costs under weak supervision, making it difficult to meet the accuracy requirements of industrial detection.

Method used

We employ a reinforcement learning-based and cross-modal alignment approach, using the GRPO algorithm to fine-tune a large multimodal model, combined with format reward and focus reward mechanisms, to achieve hierarchical semantic fusion of image and text features, and utilize dynamic cue tokens for pixel-level anomaly segmentation.

Benefits of technology

It improves the accuracy of anomaly detection and the refinement of segmentation results under weak supervision, solves the problems of sample imbalance and weak supervision learning, and provides a high-precision industrial quality inspection solution.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120912993B_ABST
    Figure CN120912993B_ABST
Patent Text Reader

Abstract

The application discloses an industrial image anomaly detection and segmentation method based on reinforcement learning and cross-modal alignment, and specific steps are as follows: S1, a multi-modal large model based on reinforcement learning fine-tuning is established; S2, an image to be queried and a prompt text are input into the trained multi-modal large model based on reinforcement learning fine-tuning, an inference text and an answer of whether there is an anomaly are output, and if the answer is that there is an anomaly, step S3 is entered; S3, the image to be queried and the inference text obtained in step S2 are input into a cross-modal image-text alignment module, and hierarchical image-text features are generated; and S4, the image to be queried is input into an image segmentation module, and meanwhile, the image-text features obtained in step S3 are mapped into dynamic prompt tokens through a full connection layer and input into a segmentation decoder to generate a pixel-level anomaly segmentation result. The application improves the accuracy of anomaly detection and the fine degree of segmentation results.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application belongs to the technical field of computers, and particularly relates to an industrial image anomaly detection and segmentation method based on reinforcement learning and cross-modal alignment. BACKGROUND

[0002] In the manufacturing and quality detection fields, image anomaly detection technology is crucial for ensuring product quality and production efficiency. However, existing methods still face many challenges in practical applications. Traditional anomaly detection is mainly based on manually designed features or supervised learning models, which not only require a large amount of labeled data, but also have limited generalization ability in complex industrial scenarios. Due to the scarcity of industrial defect samples and the high cost of labeling, model training is easily affected by the class imbalance problem, resulting in insufficient detection performance for abnormal samples. In addition, existing technologies are mostly limited to a single visual modality, lacking effective utilization of cross-modal information such as text prompts, making it difficult to achieve explainable anomaly reasoning.

[0003] In recent years, the development of multi-modal large models has provided new possibilities for combining visual and linguistic information, but their application in industrial scenarios still has room for optimization. For example, how to use reinforcement learning to fine-tune strategies to improve the model's ability to judge anomalies without masks, and how to achieve more accurate fusion of text and image features through cross-modal alignment, are problems that need to be solved. At the same time, in the absence of pixel-level labeling, existing weakly supervised segmentation methods often generate rough abnormal regions, making it difficult to meet the strict requirements of industrial detection for precision. Therefore, developing an anomaly detection method that can integrate multi-modal information, adapt to weak supervision conditions, and have high-precision segmentation capability is of great significance for promoting industrial intelligent detection. SUMMARY

[0004] To solve the above problems, the application provides an industrial image anomaly detection and segmentation method based on reinforcement learning and cross-modal alignment, which can solve the problems of high labeling cost of industrial defect samples, insufficient fusion of multi-modal information, and low segmentation precision under weak supervision conditions in the prior art.

[0005] The technical solution adopted by the application is as follows:

[0006] An industrial image anomaly detection and segmentation method based on reinforcement learning and cross-modal alignment, the specific steps of which are as follows:

[0007] Step S1, establishing a multi-modal large model based on reinforcement learning fine-tuning;

[0008] Step S2, inputting the image to be queried and the prompt text into the trained multi-modal large model based on reinforcement learning fine-tuning, outputting the reasoning text and the answer to whether there is an anomaly, and if the answer is that there is an anomaly, entering step S3;

[0009] Step S3, input the image to be queried and the reasoning text obtained in step S2 into the cross-modal image-text alignment module to generate hierarchical image-text features;

[0010] Step S4, input the image to be queried into the image segmentation module, and input the image-text features obtained in step S3 into the segmentation decoder by mapping through a fully connected layer to generate a pixel-level anomaly segmentation result.

[0011] Further, the training steps of the multi-modal large model based on reinforcement learning fine-tuning in step S1 are as follows:

[0012] Step S1.1, obtain an industrial image dataset and automatically generate corresponding prompt texts to form an image-text training set;

[0013] Step S1.2, load a pre-trained multi-modal large model Qwen2-VL 7B;

[0014] Step S1.3, input the image-text training set in step S1.1 into the multi-modal large model as training input, and fine-tune the multi-modal large model using the GRPO algorithm for reinforcement learning;

[0015] Step S1.4, input the image-text for testing into the fine-tuned multi-modal large model to output reasoning text and an answer to whether it is abnormal, and evaluate the performance of the multi-modal large model.

[0016] Further, the specific steps of reinforcement learning fine-tuning in step S1.3 include:

[0017] Step S1.3.1, reward mechanism: use format reward to force the model to generate structured output, and use focus reward to guide the model to focus on difficult-to-classify samples and encourage the model to prioritize learning abnormal patterns;

[0018] The expression of the format reward is as follows:

[0019] ;

[0020] The calculation method of the focus reward is as follows:

[0021] ;

[0022] wherein, represents the prediction probability of the model for the correct class; represents an adjustment factor that controls the overall reward intensity; represents a focus parameter that improves the attention to low confidence samples; represents the importance weight of the key abnormal area, i.e., the proportion of the abnormal area;

[0023] Step S1.3.2, advantage function normalization: standardize the reward of each group of samples, and calculate the advantage value of each sample :

[0024] ;

[0025] wherein, represents the total reward of the current sample, respectively represent the mean and standard deviation of the current group of sample rewards, represents a small constant to prevent division by zero;

[0026] Step S1.3.3, policy update: optimize the model based on the advantage function using the policy gradient method, and introduce the KL divergence term as regularization to keep the policy stable, the update formula is as follows:

[0027] ;

[0028] wherein, represents the current policy, represents the policy of the previous step, represents the KL divergence between the policies, represents the learning rate, represents the adjustment coefficient of the KL term.

[0029] Further, the indicators for evaluating the performance of the model in step S1.4 include:

[0030] Accuracy: measures the correctness of the overall prediction of the model, defined as follows:

[0031] ;

[0032] wherein, respectively represent true positive, true negative, false positive and false negative;

[0033] Macro F1 score F1-macro: calculate the F1 score for each class separately and take the average, which pays more attention to the overall performance of each class in the case of class imbalance, defined as follows:

[0034] ;

[0035] wherein, N represents the number of classes, represents the F1 score of the i-th class, and the F1 score is the harmonic mean of precision and recall.

[0036] Further, the specific steps of the cross-modal image-text alignment module in step S3 to generate hierarchical image-text features are as follows:

[0037] Step S3.1, after the image passes through the pre-trained CLIP image encoder, four levels of feature representations are extracted, representing different levels of information of the image respectively: wherein, is the image global classification feature, is the local segmentation feature;

[0038] Step S3.2, the inference text is constructed into a learnable hierarchical text representation, each layer of text is composed of a set of learnable embedded word vectors, containing semantic guide words, and the text features are also generated in four levels, respectively ;

[0039] Step S3.3, using the image feature and the corresponding text feature to do hierarchical alignment:

[0040] ;

[0041] wherein, respectively represent normal and abnormal text features, and the cosine similarity is used to construct the hierarchical contrast learning target, h represents the level, and t represents the text feature.

[0042] Further, step S3 also includes step S3.4, weighting and fusing the matching results of each layer, and adjusting the contribution of each layer through dynamic weight to obtain the final image-text alignment score:

[0043] ;

[0044] wherein, is the learnable attention weight, which dynamically adjusts the contribution of each layer.

[0045] Further, the image segmentation module in step S4 is realized by weakly supervised training, and the specific steps are as follows:

[0046] Step S4.1, adopt pre-trained Vision Transformer to extract image features, and simultaneously receive image-text features;

[0047] Step S4.2, encode the image-text feature into a dynamic prompt token as input through the prompt encoder, and input it into the mask decoder together with the image feature to perform pixel-level segmentation inference of the abnormal area.

[0048] Further, the mask decoder in step S4.2 adopts a two-level Transformer decoding structure, which realizes the interaction between the image and the prompt feature through the cross-attention mechanism, and finally outputs the foreground probability map, which specifically includes:

[0049] First layer attention: dynamic prompt token as query, image embedding as key and value;

[0050] Second layer attention: image embedding as query, prompt token as key and value;

[0051] Normalization and residual: the output of each layer of attention is transmitted to the next layer after layer normalization and residual connection.

[0052] Further, the pixel-level segmentation inference of the abnormal area in step S4.2 adopts a multi-scale prediction mechanism, specifically as follows:

[0053] (1) 32x32 grid points are sampled on the complete image to generate initial candidate regions, and 16x16 and 8x8 dense sampling are performed on 2x2 and 4x4 local cropped regions respectively, after eliminating redundant proposals by non-maximum suppression, the highest confidence prediction result is selected;

[0054] (2) After connected domain filtering, hole filling and stability verification processing, an accurate pixel-level abnormal segmentation image is output.

[0055] Compared with the prior art, the present application has the following advantages: by combining reinforcement learning strategy with cross-modal feature alignment technology, and simultaneously fine-tuning the multi-modal large model by using the GRPO algorithm, a double incentive mechanism including format reward and focus reward is constructed, effectively solving the problems of sample imbalance and weak supervision learning in industrial scenes. In addition, the cross-modal image-text alignment module is used to realize hierarchical semantic fusion of image and text features, and the weak supervision segmentation mechanism based on dynamic prompt token breaks through the limitation of traditional methods in pixel-level positioning accuracy. This technical route of combining reinforcement learning optimization, multi-level cross-modal understanding and adaptive segmentation simultaneously improves the accuracy of anomaly detection and the refinement degree of segmentation results under the condition of only relying on image-level weak labels, providing a new intelligent solution for industrial quality inspection. BRIEF DESCRIPTION OF DRAWINGS

[0056] Figure 1 is the overall framework flowchart of the present application.

[0057] Figure 2 is a cross-modal image-text alignment module structure diagram of the present application.

[0058] Figure 3 is an image segmentation module structure diagram of the present application.

[0059] Figure 4 is a structure diagram of the image segmentation module decoder of the present application. DETAILED DESCRIPTION

[0060] The application will be further described in conjunction with specific embodiments, but the application is not limited to these specific embodiments. Those skilled in the art should realize that the application encompasses all alternatives, improvements and equivalents within the scope of the claims.

[0061] With reference to Figures 1-4 The embodiment provides an industrial image anomaly detection and segmentation method based on reinforcement learning and cross-modal alignment, and specific steps are as follows:

[0062] Step S1, a multi-modal large model based on reinforcement learning (GRPO) fine-tuning is established;

[0063] The training steps of the multi-modal large model based on reinforcement learning fine-tuning are as follows:

[0064] Step S1.1, an industrial image dataset is obtained, and corresponding prompt text is automatically generated to form an image-text training set;

[0065] The industrial image dataset of the embodiment covers multiple industrial object categories and mixed complex scene categories. It contains 27 different image categories, including 15 common industrial products and 12 complex actual scenes. Among all the samples, the defect images account for about 17.7% of the total data, among which the defect sample proportion of the industrial object category is 23.8%, and the defect sample proportion of the complex scene category is 11.1%. All images come from the original dataset, only image-level labels (normal / defect) are used, and no pixel-level mask information is relied on. In addition, a corresponding text prompt is automatically generated for each image, a unified prompt template is constructed in combination with the object name, and is used to guide the model to perform image understanding and anomaly discrimination. Text prompt: example: "This is a picture containing [object name]". Please analyze the picture and judge whether the object has defects.

[0066] Step S1.2, a pre-trained multi-modal large model Qwen2-VL 7B is loaded; the embodiment adopts LoRA (Low-Rank Adaptation) and only fine-tunes part of the weights.

[0067] Step S1.3, the image-text training set in step S1.1 is input into the multi-modal large model as training, and the multi-modal large model is fine-tuned by reinforcement learning using the GRPO algorithm; the GRPO (Group Relative Policy Optimization) is a reinforcement learning algorithm based on group normalization and KL divergence regularization, which is used to optimize the inference strategy of the model.

[0068] The specific steps of reinforcement learning fine-tuning include:

[0069] Step S1.3.1, reward mechanism: generate structured output by adopting the format reward forcing model, focus on difficult-to-classify samples by adopting the focus reward guiding model, and encourage the model to preferentially learn abnormal patterns; guide the model to output structured and interpretable results, and alleviate the class imbalance problem commonly seen in industrial image data.

[0070] The expression of the format reward is as follows:

[0071] ;

[0072] The calculation method of the focus reward is as follows:

[0073] ;

[0074] wherein, represents the prediction probability of the model for the correct class; represents an adjustment factor that controls the overall reward intensity; represents a focus parameter that improves the attention to low-confidence samples; represents the importance weight of the key abnormal region, i.e., the proportion of the abnormal region;

[0075] The format reward and the focus reward cooperatively optimize the model from two dimensions of output specification and classification accuracy, respectively. <think>and <answer>The label) to ensure that the results are resolvable and provide reliability for industrial deployment; the focal reward addresses the data imbalance problem by dynamically weighting (such as focusing on difficult samples and defect areas) to improve the sensitivity to rare defects. The association between the two is that the format reward establishes the output framework, and the focal reward refines the content quality within this framework, and finally realizes "performance maximization under the rules" through the GRPO strategy.

[0076] Step S1.3.2, advantage function normalization: standardize the reward of each group of samples, and calculate the advantage value of each sample :

[0077] ;

[0078] wherein, represents the total reward of the current sample, respectively represent the mean and standard deviation of the current group of sample rewards, represents a small constant to prevent division by zero;

[0079] The correct format is a prerequisite for the focal reward to take effect, but the value of the focal reward is not directly added to the format reward. The format reward (Format Reward) and the focal reward (Focal Reward) are combined and take effect under the following conditions: (1) if the output format is incorrect → reward = 0 (format reward is 0, focal reward is not calculated); (2) if the format is correct → calculate the focal reward and take it as .

[0080] This step ensures that the model focuses on samples with relatively better or worse performance, effectively avoiding the problem of numerical instability during training.

[0081] Step S1.3.3, policy update: based on the advantage function, use the policy gradient method to optimize the model, and introduce the KL divergence term as regularization to keep the policy stable, the update formula is as follows:

[0082] ;

[0083] wherein, represents the current policy, represents the policy of the previous step, represents the KL divergence between the policies, represents the learning rate, represents the adjustment coefficient of the KL term.

[0084] Through this updated strategy, the model can continuously optimize its anomaly judgment ability and reasoning accuracy while ensuring the stability of the output.

[0085] Step S1.4, input the image-text for testing into the fine-tuned multi-modal large model, output the inference text and the answer of whether it is abnormal, and evaluate the performance of the multi-modal large model. Write the inference process in <analysis process>< / answer> < / think> The final answer is written in the <answer> tag.

[0086] The indicators for evaluating the performance of the model in step S1.4 include:

[0087] Accuracy: measures the correctness of the overall prediction of the model, defined as follows:

[0088] ;

[0089] wherein, respectively represent true positive, true negative, false positive, and false negative;

[0090] Macro-averaged F1 score F1-macro: calculates the F1 score for each class separately and then takes the average, which pays more attention to the overall performance of each class in the case of class imbalance, defined as follows:

[0091] ;

[0092] wherein, N represents the number of classes, represents the F1 score of the i-th class, and the F1 score is the harmonic mean of precision and recall.

[0093] Step S2, input the image to be queried and the prompt text into the trained multi-modal large model based on reinforcement learning fine-tuning, output the reasoning text and the answer whether there is an anomaly, if the answer is that there is an anomaly, enter step S3;

[0094] Step S3, input the image to be queried and the reasoning text obtained in step S2 into the cross-modal image-text alignment module to generate hierarchical image-text features;

[0095] The specific steps of the cross-modal image-text alignment module generating hierarchical image-text features are as follows:

[0096] Step S3.1, after the image passes through the pre-trained CLIP image encoder, four levels of feature representations (bottom, middle, high, and semantic) are extracted, representing different levels of information of the image: , wherein, is the image global classification feature, is the local segmentation feature;

[0097] Step S3.2, construct a learnable hierarchical text representation for the reasoning text to reduce the semantic difference between the image and the text at different levels. Each layer of text is composed of a group of learnable embedded word vectors, including semantic guide words such as [level], [good] indicating normal, and [damage] indicating abnormal. The text features are also generated according to four levels, respectively , as the input of the text encoder;

[0098] Step S3.3, use the image features and the corresponding text features to do hierarchical alignment, wherein is the feature representation processed by the text encoder in step S3.2;

[0099] ;

[0100] wherein, respectively represent normal and abnormal text features, and cosine similarity is used to construct the hierarchical contrast learning target, h represents the level, and t represents the text feature.

[0101] Step S3.4, weight the matching results of each layer and adaptively adjust the contribution of each layer through dynamic weights to obtain the final image-text alignment score:

[0102] ;

[0103] wherein, is a learnable attention weight that dynamically adjusts the contribution of each layer.

[0104] Hierarchical feature fusion: alignment scores are used to weight the fusion of image and text feature matching results at different levels. (2) Dynamic weight adjustment: through attention mechanism, the weight coefficients of each level are dynamically learned, so that the model can adaptively emphasize important levels according to task requirements (for example, industrial data may rely more on local details, while medical data needs global semantics).

[0105] Adjustment method: the weight coefficients are calculated by multi-layer perception and Softmax function. During training, these weights are optimized through back propagation to minimize the total loss.

[0106] Step S4, the image to be queried is input to the image segmentation module, and the image-text features obtained in step S3 are mapped to dynamic prompt tokens through a fully connected layer and input to the segmentation decoder to generate pixel-level anomaly segmentation results.

[0107] The image segmentation module is realized through weakly supervised training, and the specific steps are as follows:

[0108] Step S4.1, image features are extracted based on pre-trained Vision Transformer (ViT), while receiving image-text features;

[0109] Step S4.2, the image-text features are encoded into dynamic prompt tokens by the prompt encoder as input joint image features to the mask decoder for pixel-level segmentation inference of abnormal areas.

[0110] The mask decoder adopts a two-level Transformer decoding structure, which realizes the interaction between image and prompt features through cross-attention mechanism, and finally outputs the foreground probability map, which includes:

[0111] First attention: dynamic prompt tokens are used as queries (Query), and image embeddings are used as keys (Key) and values (Value);

[0112] Second attention: image embeddings are used as queries, and prompt tokens are used as keys and values;

[0113] Normalization and residual: the output of each attention is normalized by layer normalization (LayerNorm) and residual connection before being passed to the next layer.

[0114] Among them, the pixel-level segmentation inference of the abnormal area adopts a multi-scale prediction mechanism, which is as follows:

[0115] (1) On the complete image, 32x32 grid points are used for sampling to generate initial candidate regions, and 2x2 and 4x4 local cropped regions are respectively densely sampled by 16x16 and 8x8, after eliminating redundant proposals by non-maximum suppression (threshold 0.7), the highest confidence prediction result is selected;

[0116] (2) After connected component filtering (remove fragments with area <100 pixels), hole filling (fill gaps with area <100 pixels) and stability verification (double threshold 0.4 / 0.6 binaryzation IoU >=0.95) processing, the accurate pixel-level anomaly segmentation image is output.

[0117] The application combines reinforcement learning strategy and cross-modal feature alignment technology, simultaneously fine-tunes multi-modal large model by using GRPO algorithm, constructs a double incentive mechanism containing format reward and focus reward, effectively solves the problems of sample imbalance and weakly supervised learning in industrial scene. In addition, the cross-modal image-text alignment module realizes the hierarchical semantic fusion of image and text features, and the weakly supervised segmentation mechanism based on dynamic prompt token breaks through the limitation of traditional method in pixel-level positioning accuracy. This technical route of fusing reinforcement learning optimization, multi-level cross-modal understanding and adaptive segmentation simultaneously improves the accuracy of anomaly detection and the refinement degree of segmentation result under the condition of only relying on image-level weak label, providing a new intelligent solution for industrial quality inspection.

Claims

1. An industrial image anomaly detection and segmentation method, comprising the following specific steps: Step S1, establishing a multi-modal large model based on reinforcement learning fine-tuning; The training steps of the multi-modal large model based on reinforcement learning fine-tuning are as follows: Step S1.1, obtaining an industrial image dataset, and automatically generating corresponding prompt text to form an image-text training set; Step S1.2, loading a pre-trained multi-modal large model Qwen2-VL 7B; Step S1.3, inputting the image-text training set in step S1.1 into the multi-modal large model as training input, and performing reinforcement learning fine-tuning on the multi-modal large model by using the GRPO algorithm; The specific steps of reinforcement learning fine-tuning include: Step S1.3.1, reward mechanism: using format reward to force the model to generate structured output, and using focus reward to guide the model to focus on difficult-to-classify samples and encourage the model to preferentially learn abnormal patterns; The expression of the format reward is as follows: ; The calculation method of the focus reward is as follows: ; wherein, denotes the prediction probability of the model for the correct class; denotes the adjustment factor, controlling the overall reward intensity; Step S1.3.3, strategy update: using the policy gradient method based on the advantage function to optimize the model, and introducing the KL divergence term as regularization to keep the strategy stable, and the update formula is as follows: denotes the focus parameter, enhancing the attention to low-confidence samples; denotes the importance weight of the key abnormal region, i.e., the abnormal region proportion; Step S1.3.2, advantage function normalization: standardize the rewards for each set of samples, compute the advantage value for each sample : ; wherein, represents the total reward of the current sample, , respectively represent the mean and standard deviation of the current group sample reward, represents a small constant to prevent division by zero; Step S1.4, inputting the image-text for testing into the multi-modal large model fine-tuned, outputting the inference text and the answer whether there is an anomaly, and evaluating the performance of the multi-modal large model; ; wherein, denotes the current policy, denotes the policy of the previous step, denotes the KL divergence between the policies, denotes the learning rate, denotes the adjustment coefficient of the KL term; Step S2, inputting the image to be queried and the prompt text into the multi-modal large model based on reinforcement learning fine-tuning, outputting the inference text and the answer whether there is an anomaly, and if the answer is that there is an anomaly, entering step S3; Step S3, inputting the image to be queried and the inference text obtained in step S2 into the cross-modal image-text alignment module to generate hierarchical image-text features; Step S4, inputting the image to be queried into the image segmentation module, and inputting the image-text features obtained in step S3 into the segmentation decoder through a fully connected layer to map them into dynamic prompt tokens, and generating pixel-level anomaly segmentation results. The indicators for evaluating the performance of the model in step S1.4 include:

2. The industrial image anomaly detection and segmentation method of claim 1, wherein: Accuracy: measures the correctness of the overall prediction of the model, defined as follows: Macro-averaged F1 score F1-macro: calculates the F1 score for each class separately and takes the average, which is more concerned about the overall performance of each class in the case of class imbalance, defined as follows: ; wherein, , , , true positive, true negative, false positive, and false negative, respectively. The specific steps of the cross-modal image-text alignment module generating hierarchical image-text features in step S3 are as follows: ; wherein, represents the number of classes, represents the first class F1 score, which is the harmonic mean of precision and recall.

3. The industrial image anomaly detection and segmentation method of claim 1, wherein: Step S3 also includes S3.4, weighting and fusing the matching results of each layer, and adaptively adjusting the contribution of each layer through dynamic weights to obtain the final image-text alignment score: Step S3.1, after the image passes through the pre-trained CLIP image encoder, four levels of feature representations are extracted, representing different levels of information of the image respectively: wherein, is the image global classification feature, is the local segmentation feature; Step S3.2, constructing a learnable hierarchical text representation for the inference text, each layer of the text consisting of a set of learnable embedding word vectors, including semantic guiding words, text features are also generated according to four levels, respectively ; Step S3.3, using image layer features and corresponding text features Do hierarchical alignment: ; wherein, , respectively represent normal and abnormal text features, and the cosine similarity is used to construct the hierarchical contrast learning objective, h represents the i-th level, and t represents the text feature.

4. The industrial image anomaly detection and segmentation method of claim 3, wherein: The image segmentation module in step S4 is realized through weakly supervised training, and the specific steps are as follows: ; wherein, are learnable attention weights that dynamically adjust the contribution of each layer.

5. The industrial image anomaly detection and segmentation method of claim 1, wherein: Step S4.1, using a pre-trained Vision Transformer to extract image features, while receiving image-text features; Step S4.2, encoding the image-text features into dynamic prompt tokens as input through a prompt encoder, and inputting them into a mask decoder together with the image features to perform pixel-level segmentation inference of abnormal areas. The mask decoder in step S4.2 adopts a two-level Transformer decoding structure, realizes the interaction between the image and the prompt features through a cross-attention mechanism, and finally outputs a foreground probability map, which specifically includes:

6. The industrial image anomaly detection and segmentation method of claim 5, wherein: ​ First layer attention: dynamic prompt token as query, image embedding as key and value; Second layer attention: image embedding as query, prompt token as key and value; Normalization and residual: the output of each layer of attention is transmitted to the next layer after layer normalization and residual connection.

7. The industrial image anomaly detection and segmentation method of claim 5, wherein: The pixel-level segmentation inference of the abnormal area in step S4.2 adopts a multi-scale prediction mechanism, which is as follows: (1) On the complete image, 32x32 grid points are sampled to generate initial candidate regions, and 2x2 and 4x4 local cropped regions are respectively densely sampled at 16x16 and 8x8. After eliminating redundant proposals through non-maximum suppression, the highest confidence prediction result is selected; (2) After connected component filtering, hole filling and stability verification processing, an accurate pixel-level abnormal segmentation image is output.

Citation Information

Patent Citations

  • Heat supply system pipe network anomaly detection method based on multi-mode AI large model

    CN120430214A

  • Less-sample industrial anomaly detection method based on CLIP anomaly generation and text prompt

    CN120526219A