Cooperative verification method for cross-scene zero-shot image anomaly degree

CN122967031APending Publication Date: 2026-10-23XIAN UNIV OF TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611129484.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-28
Publication Date
2026-10-23

AI Technical Summary

Technical Problem

[0004]本发明的目的是提供跨场景零样本图像异常程度的协同校验方法,解决现有方法存在异常检测精度低,易发生漏报误报的问题

Benefits of technology

[0033]本发明的有益效果是:本发明跨场景零样本图像异常程度的协同校验方法,在抑制图像边缘反光噪声的同时,保留了低对比度缺陷区域,大大提高了异常检测,避免了误报漏报。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122967031A_ABST
    Figure CN122967031A_ABST
Patent Text Reader

Abstract

The application discloses a cross-scene zero-sample image abnormality degree cooperative verification method, and steps are as follows: step 1, obtaining a spatial anomaly probability field and an initial image-level anomaly score through a to-be-detected color industrial product image; step 2, traversing the spatial anomaly probability field to obtain a maximum anomaly probability value and a minimum anomaly probability value, and calculating a dynamic adaptive segmentation threshold; step 3, according to the dynamic adaptive segmentation threshold, performing binaryzation processing on the spatial anomaly probability field to obtain a binary image, and calculating a spatial effective topology cumulative area through the binary image; step 4, calculating a final image-level anomaly score; step 5, setting execution parameters according to a scene category to which the to-be-detected color industrial product image belongs, and then executing steps 1-4 to predict the final image-level anomaly score. The method solves the problems of low anomaly detection precision and easy occurrence of missed reports and false reports of the prior art.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of industrial product image anomaly detection technology, specifically involving a collaborative verification method for the degree of anomalies in zero-sample images across different scenes. Background Technology

[0002] With the rapid development of intelligent vision and unsupervised learning image technology, image anomaly detection and localization has become an important research direction in the field of computer vision. Existing anomaly detection methods mostly rely on fully supervised deep discriminative networks, requiring massive manual annotation of specific datasets. These methods are not only time-consuming, but their detection accuracy also suffers catastrophic degradation when encountering unseen targets of unknown physical categories or unknown anomaly forms.

[0003] In recent years, large-scale pre-trained multimodal visual text models, represented by CLIP, have demonstrated powerful open-world zero-shot generalization capabilities through contrastive learning. However, these general-purpose models exhibit serious shortcomings when directly testing cross-scene tasks due to the lack of a local-global collaborative calibration module during inference. Their global visual branch is easily attracted by high-contrast singular noise points, resulting in missed detections of low-contrast continuous or multi-point diffusion anomalies. Meanwhile, their local branch, lacking neighborhood geometric constraints, is prone to discrete false positives when dealing with reflective traces on structural components, leading to a significant performance trade-off between heterogeneous datasets. Therefore, designing an adaptive calibration method that is completely decoupled from a specific dataset and allows pixel-level spatial topological features to feed back into global semantic decisions has become a challenging problem in image anomaly detection and analysis. Summary of the Invention

[0004] The purpose of this invention is to provide a collaborative verification method for the degree of anomalies in zero-sample images across different scenes, thereby solving the problems of low anomaly detection accuracy and the tendency for false negatives and missed positives in existing methods.

[0005] The technical solution adopted in this invention is a collaborative verification method for the degree of anomalies in zero-sample images across different scenes, and the steps are as follows: Step 1: Obtain the spatial anomaly probability field and initial image-level anomaly score from the image of the color industrial product to be detected; Step 2: Traverse the spatial anomaly probability field to obtain the maximum and minimum anomaly probability values, and calculate the dynamic adaptive segmentation threshold; Step 3: Based on the dynamic adaptive segmentation threshold, the spatial anomaly probability field is binarized to obtain a binary map, and the effective topological cumulative area of ​​the space is calculated through the binary map. Step 4: Calculate the final image-level anomaly score; Step 5: Set the execution parameters according to the scene category to which the color industrial product image to be detected belongs, and then execute steps 1 to 4 to predict the final image-level anomaly score.

[0006] The invention is further characterized by: The specific process of step 1 is as follows: Step 1.1, the image of the color industrial product to be inspected. Preprocessing is performed to obtain the input image. Input image The data is input into an existing zero-shot defect detection model to obtain global visual features. Local image patch features Normal text features and abnormal text features global visual features Local image patch features Normal text features and abnormal text features Normalization was performed separately to obtain the processed global visual features. Processed local image patch features Normal text features after processing and processed abnormal text features ; Step 1.2, process the local image patch features Normal text features after processing and processed abnormal text features Similarity calculations are performed, and bilinear interpolation is used to restore the resolution. Generate the original two-dimensional anomaly heat map of space. ; Step 1.3: Use a two-dimensional Gaussian convolution kernel to process the original two-dimensional spatial anomaly heatmap. Spatial neighborhood convolution denoising is performed to obtain a smooth spatial anomaly probability field. ; Step 1.4: Process the global visual features Features of processed normal text Perform cosine similarity calculation to obtain normal semantic similarity. The processed global visual features Features of processed abnormal text Cosine similarity calculation is performed to obtain abnormal semantic similarity. ; Step 1.5, normal semantic similarity Similarity to anomalous semantics Softmax normalization is performed to obtain the initial image-level anomaly score. ; Step 1.6, Calculate the initial image-level anomaly detection threshold. The initial image-level anomaly score Compared with the initial image-level anomaly detection threshold By comparing the images, a preliminary determination can be made as to whether the color industrial product images to be inspected are abnormal. like ≥ If it is, then it is judged as abnormal; if < If so, it is considered normal.

[0007] In step 1.1, the color industrial product image to be detected The size is ,in, and These represent the images of the color industrial products to be inspected. Height and width; The preprocessing process is as follows: The bilinear interpolation method is used to interpolate the color industrial product image to be detected. The size is scaled to obtain the input image. Input image The size is ,in, This refers to the input dimensions required by the existing zero-sample defect detection model.

[0008] In step 1.1, the existing zero-sample defect detection model is AnomalyCLIP.

[0009] In step 1.6, the initial image-level anomaly detection threshold is calculated. The process is as follows: Step S1: Construct a threshold calibration sample set, which includes several normal color industrial product images and their corresponding real category labels, and several abnormal color industrial product images and their corresponding real category labels.

[0010] Step S2: Calculate the initial image-level anomaly score for each image in the threshold calibration sample set according to steps 1.1 to 1.5, thus forming the initial image-level anomaly score set S. BASE ,Right now:

[0011] In the formula, S base,1 S represents the initial image-level anomaly score of the first image in the threshold-calibrated sample set. base,2 S represents the initial image-level anomaly score of the second image in the threshold-calibrated sample set. base,MThis represents the initial image-level anomaly score of the Mth image in the threshold calibration sample set; Step S3, for the initial image-level anomaly score set S BASE Traversing candidate thresholds When the threshold is set for the first sample... The initial image-level anomaly score of the image is greater than or equal to the candidate threshold. When the image is predicted as an anomaly, the threshold-calibrated sample set will be used to identify it as an anomaly. The initial image-level anomaly score of the image is less than the candidate threshold. When this happens, the image is predicted as normal; The expression is:

[0012] In the formula, Indicates the threshold calibration sample set of the first Image prediction results; Step S4, calibrate the sample set according to the threshold. The predicted results of each image are compared with their corresponding ground truth class labels to calculate the candidate threshold. The corresponding initial true positive rate and initial false positive rate; The expression is:

[0013]

[0014] In the formula, This represents the number of color industrial product images that were correctly predicted as anomalous in the threshold-calibrated sample set. This indicates the number of color industrial product images that are abnormal in the threshold calibration sample set and are incorrectly predicted as normal. This represents the number of normal color industrial product images in the threshold calibration sample set that were incorrectly predicted as anomalous. This indicates the number of normal color industrial product images in the threshold calibration sample set that were correctly predicted as normal. This represents the initial true rate. Indicates the initial false positive rate; Step S5, according to and Calculate candidate threshold Corresponding initial Youden index ; The expression is:

[0015] Initial Yoden Index The candidate threshold corresponding to the maximum value is determined as the initial image-level anomaly detection threshold. ; The expression is: .

[0016] The specific process of step 2 is as follows: Step 2.1, traverse the entire graph spatial anomaly probability field Obtain the current color industrial product image to be inspected. Maximum anomaly probability value and minimum anomaly probability value ; The expression is:

[0017] In the formula, Indicates the horizontal pixel coordinates. Represents the vertical pixel coordinate; Step 2.2, using the initial image-level anomaly score Calculate the spatial segmentation threshold and segmentation coefficient. ; The expression is:

[0018] In the formula, As the baseline segmentation threshold, The weighting coefficients are adjusted for feedback. Step 2.3, divide the spatial segmentation threshold into coefficients. Substitute the maximum anomaly probability value and minimum anomaly probability value Within the span, the dynamic adaptive segmentation threshold is calculated. ; The expression is: .

[0019] The specific process of step 3 is as follows: Step 3.1, utilize dynamic adaptive segmentation threshold For spatial anomaly probability fields Perform pixel-by-pixel binarization to obtain a binary map of the spatial anomaly candidate connected components. ; The expression is:

[0020] Step 3.2, for the binary image Perform connected component labeling to detect all independent topological connected components in the entire graph, and count the number of pixels inside each independent connected component. Use the number of pixels inside each independent connected component as the area of ​​each abnormal connected component. Step 3.3: Sort all the areas of abnormal connected components in descending order of size to obtain the set of connected component areas. , ,satisfy ; Step 3.4, let the maximum number of abnormal connected components selected be... K For the set of areas of connected components The front of the middle K The summation of the areas of the abnormal connected components yields the spatially effective topological cumulative area of ​​the current image. ; The expression is: .

[0021] The specific process of step 4 is as follows: Step 4.1: Accumulate area through effective spatial topology. and the set scale adjustment damping constant Calculate the nonlinear spatial cohesion index ; The expression is:

[0022] Step 4.2, Maximum anomaly probability value Nonlinear spatial cohesion index Performing a dot product yields the dynamic space feedback intensity coefficient. ; The expression is:

[0023] Step 4.3, set the upper limit of the maximum fusion mixing coefficient as follows: Calculate the optimal dynamic weighted fusion weights ; The expression is:

[0024] Step 4.4: Calculate the optimal dynamically weighted fusion weights. Compared with the initial image-level anomaly score and maximum anomaly probability value Linear weighting is performed to obtain the final image-level anomaly score. ; The expression is:

[0025] Step 4.5: Calculate the final image-level anomaly detection threshold. The final image-level anomaly score will be determined. Compared with the final image-level anomaly detection threshold By comparing the images, it is ultimately determined whether the color industrial product images to be inspected are abnormal; like ≥ If it is, then it is judged as abnormal; if < If so, it is considered normal.

[0026] In step 4.5, the final image-level anomaly detection threshold is calculated. The process is as follows: Step A: Calculate the final image-level anomaly score for each image in the threshold calibration sample set according to steps 1.1 to 4.4, thus forming the initial and final image-level anomaly score set S. FINAL ,Right now:

[0027] In the formula, S final,1 S represents the final image-level anomaly score of the first image in the threshold-calibrated sample set. final,2 S represents the final image-level anomaly score of the second image in the threshold calibration sample set. final,M This represents the final image-level anomaly score of the Mth image in the threshold calibration sample set; Step B, for the final image-level anomaly score set S FINAL Traversing candidate thresholds When the threshold is set for the first sample... The final image-level anomaly score of the images is greater than or equal to the candidate threshold. When the image is predicted as an anomaly, the threshold-calibrated sample set will be used to identify it as an anomaly. The final image-level anomaly score of the image is less than the candidate threshold. When this happens, the image is predicted as normal; The expression is:

[0028] In the formula, Indicates the threshold calibration sample set of the first Image prediction results; Step C, calibrate the sample set according to the threshold. The predicted results of each image are compared with their corresponding ground truth class labels to calculate the candidate threshold. The corresponding initial true positive rate and initial false positive rate; The expression is:

[0029]

[0030] In the formula, This represents the number of color industrial product images that were initially correctly predicted as abnormal in the threshold calibration sample set. This indicates the number of color industrial product images that were abnormal in the threshold calibration sample set but were ultimately incorrectly predicted as normal. This represents the number of normal color industrial product images in the threshold calibration sample set that were ultimately incorrectly predicted as abnormal. This indicates the number of normal color industrial product images in the threshold calibration sample set that were ultimately correctly predicted as normal. This represents the initial true rate. Indicates the initial false positive rate; Step D, according to and Calculate candidate threshold The corresponding final Youden index ; The expression is:

[0031] The final Yorkden index The candidate threshold corresponding to the maximum value is determined as the final image-level anomaly detection threshold. ; expression: .

[0032] The specific process of step 5 is as follows: The scene categories to which the color industrial product images to be inspected belong include unstructured surface scenes and structured textured surface scenes; Unstructured surface scenes represent industrial product surfaces that do not contain regular, dense traces, meshes, pads, or repetitive stepped edges; The structural textured surface scene represents the surface of industrial products containing one or more of the following: regular lines, meshes, pads, metal edges, or repeating texture structures. (1) When the color industrial product image to be detected is an unstructured surface scene, the baseline segmentation threshold is set. Set to 0.7≤ ≤0.85, the maximum number of abnormal connected components to be selected. K Set the parameter to 3, execute steps 1-4 after parameter setting, and obtain the final image-level anomaly score; (2) When the color industrial product image to be detected is a scene with a structured textured surface, the baseline segmentation threshold is set. Set to 0.85 < ≤0.95, the maximum number of abnormal connected components to be selected. K Setting it to 1, then the set of connected component areas The area of ​​the first abnormal connected component in the image is the spatially effective topological cumulative area of ​​the current image. ,and = Set threshold , ,when At that time, set the optimal dynamic weighted fusion weight. =0.0, after setting the parameters, execute steps 1 to 4 to obtain the final image-level anomaly score.

[0033] The beneficial effects of the present invention are: the collaborative verification method for the degree of anomalies in zero-sample images across scenes of the present invention, while suppressing the reflective noise at the edge of the image, preserves the low-contrast defect area, which greatly improves the anomaly detection and avoids false alarms and missed alarms. Attached Figure Description

[0034] Figure 1 These are the original images of the VisA dataset capsule samples used in Embodiment 7 of this invention; Figure 2 This is the original two-dimensional spatial anomaly heatmap of the VisA dataset capsule samples used in Embodiment 7 of the present invention; Figure 3 This is the abnormal heatmap of the VisA dataset capsule samples after two-dimensional Gaussian denoising, used in Embodiment 7 of the present invention; Figure 4 This is a binary graph of the spatial anomaly candidate connected components of the VisA dataset capsule samples used in Embodiment 7 of the present invention; Figure 5 This is a schematic diagram of all independent topological connected components of the VisA dataset capsule samples used in Embodiment 7 of the present invention; Figure 6 These are the original images of fabric samples from the DTD dataset used in Embodiment 8 of the present invention; Figure 7 This is the original two-dimensional spatial anomaly thermogram of the fabric sample from the DTD dataset used in Embodiment 8 of the present invention; Figure 8 This is an abnormal heatmap of the fabric sample from the DTD dataset used in Embodiment 8 of the present invention after two-dimensional Gaussian denoising; Figure 9 This is a binary graph of the spatial anomaly candidate connected components of the fabric samples in the DTD dataset used in Embodiment 8 of the present invention; Figure 10 This is a schematic diagram of all independent topological connected domains of the fabric sample in the DTD dataset used in Embodiment 8 of the present invention. Detailed Implementation

[0035] The present invention will now be described in detail with reference to the accompanying drawings and specific embodiments.

[0036] Example 1 The present invention provides a collaborative verification method for the anomaly degree of zero-sample images across different scenes, comprising the following steps: Step 1: Obtain the spatial anomaly probability field and initial image-level anomaly score from the image of the color industrial product to be detected; Step 2: Traverse the spatial anomaly probability field to obtain the maximum and minimum anomaly probability values, and calculate the dynamic adaptive segmentation threshold; Step 3: Based on the dynamic adaptive segmentation threshold, the spatial anomaly probability field is binarized to obtain a binary map, and the effective topological cumulative area of ​​the space is calculated through the binary map. Step 4: Calculate the final image-level anomaly score; Step 5: Set the execution parameters according to the scene category to which the color industrial product image to be detected belongs, and then execute steps 1 to 4 to predict the final image-level anomaly score.

[0037] Example 2 Based on Example 1, the specific process of step 1 is as follows: Step 1.1, the image of the color industrial product to be inspected. Preprocessing is performed to obtain the input image. Input image The data is input into an existing zero-shot defect detection model to obtain global visual features. Local image patch features Normal text features and abnormal text features global visual features Local image patch features Normal text features and abnormal text features Normalization was performed separately to obtain the processed global visual features. Processed local image patch features Normal text features after processing and processed abnormal text features ; Among them, the color industrial product images to be inspected The size is ,in, and These represent the images of the color industrial products to be inspected. Height and width; The preprocessing process is as follows: The bilinear interpolation method is used to interpolate the color industrial product image to be detected. The size is scaled to obtain the input image. Input image The size is ,in, The input dimensions are those required for existing zero-sample defect detection models; The existing zero-shot defect detection model is AnomalyCLIP. AnomalyCLIP can detect and segment anomalies in industrial product images without training samples in the target dataset. AnomalyCLIP includes a visual encoder, a text encoder, and an object-independent cue learning module. The visual encoder is used to extract global visual features and local image patch features of the image to be inspected; the text encoder is used to extract text features corresponding to normal and abnormal semantics; the object-independent cue learning module is used to generate normal and abnormal state cuees that are independent of the specific category of the target to be inspected. Global visual features Obtained through the visual encoder in AnomalyCLIP, i.e., the input image. The input is fed into the visual encoder in AnomalyCLIP, and the output is global visual features. ; The expression is: (1) In the formula, Represents the dimension of visual features; Local image patch features This is obtained by extracting the outputs of one or more selected intermediate layers from the visual encoder and arranging these outputs according to their spatial positions. The expression is: (2) In the formula, Represents the dimension of visual features. Indicates the number of selected intermediate layers; Normal text features Normal state prompts generated by the object-independent prompting learning module The text encoder in AnomalyCLIP outputs the normal state prompts generated by the object-independent prompting learning module. Input the text encoder from AnomalyCLIP and output normal text features. ; Abnormal text features The exception status prompts generated by the object-independent prompt learning module The text encoder in AnomalyCLIP outputs the exception status message generated by the object-independent hint learning module. Input the text encoder from AnomalyCLIP and output normal text features. ; The expression is: (3) In the formula, This refers to the text encoder in AnomalyCLIP; Step 1.2, process the local image patch features Normal text features after processing and processed abnormal text features Similarity calculations are performed, and bilinear interpolation is used to restore the resolution. Generate the original two-dimensional anomaly heat map of space. ; The expression is: (4) In the formula, This represents the original two-dimensional anomaly heat map of space; This represents the cosine similarity between the features of each local image patch and the features of the abnormal text. This represents the cosine similarity between the features of each local image patch and the features of normal text. This indicates that bilinear interpolation is used to restore the image block-level anomaly response to the original image size. ; Step 1.3: Use a two-dimensional Gaussian convolution kernel to process the original two-dimensional spatial anomaly heatmap. Spatial neighborhood convolution denoising is performed to obtain a smooth spatial anomaly probability field. ; The expression is: (5) In the formula, Indicates the horizontal pixel coordinates. Represents the vertical pixel coordinate; For a two-dimensional Gaussian filter operator, the scaling factor of the Gaussian filter is... Based on experience, the preferred value is... ; Step 1.4: Process the global visual features Features of processed normal text Perform cosine similarity calculation to obtain normal semantic similarity. The processed global visual features Features of processed abnormal text Cosine similarity calculation is performed to obtain abnormal semantic similarity. ; The expression is: (6) (7) In the formula, This is the temperature regulation coefficient; Step 1.5, normal semantic similarity Similarity to anomalous semantics Softmax normalization is performed to obtain the initial image-level anomaly score. ; The expression is: (8) In the formula, The value ranges from 0 to 1, and the larger the value, the higher the probability that the image under inspection is abnormal. Step 1.6, Calculate the initial image-level anomaly detection threshold. The initial image-level anomaly score Compared with the initial image-level anomaly detection threshold By comparing the images, a preliminary determination can be made as to whether the color industrial product images to be inspected are abnormal. like ≥ If it is, then it is judged as abnormal; if < If so, it is considered normal; Among them, the initial image-level anomaly detection threshold is calculated. The process is as follows: Step S1: Construct a threshold calibration sample set. The threshold calibration sample set includes several normal color industrial product images and their corresponding real category labels, and several abnormal color industrial product images and their corresponding real category labels. The color industrial product images in the threshold calibration sample set are images of the same industrial products as the color industrial product images to be detected. Let the threshold calibration sample set be: (9) In the formula, Indicates the threshold calibration sample set of the first Image Indicates the first Amplitude thresholding determines the true class label of the image. This represents a normal color industrial product image. Colored industrial product images indicating anomalies. This indicates the number of images in the threshold calibration sample set; Step S2: Calculate the initial image-level anomaly score for each image in the threshold calibration sample set according to steps 1.1 to 1.5, thus forming the initial image-level anomaly score set S. BASE ,Right now: (10) In the formula, Sbase,1 represents the initial image-level anomaly score of the first image in the threshold calibration sample set, Sbase,2 represents the initial image-level anomaly score of the second image in the threshold calibration sample set, and Sbase,M represents the initial image-level anomaly score of the Mth image in the threshold calibration sample set. Step S3, for the initial image-level anomaly score set S BASE Traversing candidate thresholds When the threshold is set for the first sample... The initial image-level anomaly score of the image is greater than or equal to the candidate threshold. When the image is predicted as an anomaly, the threshold-calibrated sample set will be used to identify it as an anomaly. The initial image-level anomaly score of the image is less than the candidate threshold. When this happens, the image is predicted as normal; The expression is: (11) In the formula, Indicates the threshold calibration sample set of the first Image prediction results; Step S4, calibrate the sample set according to the threshold. The predicted results of each image are compared with their corresponding ground truth class labels to calculate the candidate threshold. The corresponding initial true positive rate and initial false positive rate; The expression is: (12) (13) In the formula, This represents the number of color industrial product images that were correctly predicted as anomalous in the threshold-calibrated sample set. This indicates the number of color industrial product images that are abnormal in the threshold calibration sample set and are incorrectly predicted as normal. This represents the number of normal color industrial product images in the threshold calibration sample set that were incorrectly predicted as anomalous. This indicates the number of normal color industrial product images in the threshold calibration sample set that were correctly predicted as normal. This represents the initial true rate. Indicates the initial false positive rate; Step S5, according to and Calculate candidate threshold Corresponding initial Youden index ; The expression is: (14) Initial Yoden Index The candidate threshold corresponding to the maximum value is determined as the initial image-level anomaly detection threshold. ; The expression is: (15).

[0038] Example 3 Based on Example 2, the specific process of step 2 is as follows: Step 2.1, traverse the entire graph spatial anomaly probability field Obtain the current color industrial product image to be inspected. Maximum anomaly probability value and minimum anomaly probability value ; The expression is: (16) In the formula, Indicates the horizontal pixel coordinates. Represents the vertical pixel coordinate; Step 2.2, using the initial image-level anomaly score Calculate the spatial segmentation threshold and segmentation coefficient. ; The expression is: (17) In the formula, As the baseline segmentation threshold, The weighting coefficients are adjusted for feedback. Step 2.3, divide the spatial segmentation threshold into coefficients. Substitute the maximum anomaly probability value and minimum anomaly probability value Within the span, the dynamic adaptive segmentation threshold is calculated. ; The expression is: (18).

[0039] Example 4 Based on Example 3, the specific process of step 3 is as follows: Step 3.1, utilize dynamic adaptive segmentation threshold For spatial anomaly probability fields Perform pixel-by-pixel binarization to obtain a binary map of the spatial anomaly candidate connected components. ; The expression is: (19) Step 3.2, for the binary image Perform connected component labeling to detect all independent topological connected components in the entire graph, and count the number of pixels inside each independent connected component. Use the number of pixels inside each independent connected component as the area of ​​each abnormal connected component. Step 3.3: Sort all the areas of abnormal connected components in descending order of size to obtain the set of connected component areas. , ,satisfy ; Step 3.4, let the maximum number of abnormal connected components selected be... K For the set of areas of connected components The front of the middle K The summation of the areas of the abnormal connected components yields the spatially effective topological cumulative area of ​​the current image. ; The expression is: (20).

[0040] Example 5 Based on Example 4, the specific process of step 4 is as follows: Step 4.1: Accumulate area through effective spatial topology. and the set scale adjustment damping constant Calculate the nonlinear spatial cohesion index ; The expression is: (twenty one) In the formula, the scale-adjusted damping constant is... The preferred value is 100.0; Step 4.2, Maximum anomaly probability value Nonlinear spatial cohesion index Performing a dot product yields the dynamic space feedback intensity coefficient. ; The expression is: (twenty two) Step 4.3, set the upper limit of the maximum fusion mixing coefficient as follows: Calculate the optimal dynamic weighted fusion weights ; The expression is: (twenty three) In the formula, the upper limit of the fusion mixing coefficient is... The preferred value is 0.25; Step 4.4: Calculate the optimal dynamically weighted fusion weights. Compared with the initial image-level anomaly score and maximum anomaly probability value Linear weighting is performed to obtain the final image-level anomaly score. ; The expression is: (twenty four) Step 4.5: Calculate the final image-level anomaly detection threshold. The final image-level anomaly score will be determined. Compared with the final image-level anomaly detection threshold By comparing the images, it is ultimately determined whether the color industrial product images to be inspected are abnormal; like ≥ If it is, then it is judged as abnormal; if < If so, it is considered normal; Among them, the final image-level anomaly detection threshold is calculated. The process is as follows: Step A: Calculate the final image-level anomaly score for each image in the threshold calibration sample set according to steps 1.1 to 4.4, forming the initial final image-level anomaly score set SFINAL, i.e.: (25) In the formula, Sfinal,1 represents the final image-level anomaly score of the first image in the threshold calibration sample set, Sfinal,2 represents the final image-level anomaly score of the second image in the threshold calibration sample set, and Sfinal,M represents the final image-level anomaly score of the Mth image in the threshold calibration sample set. Step B, for the final image-level anomaly score set S FINAL Traversing candidate thresholds When the threshold is set for the first sample... The final image-level anomaly score of the images is greater than or equal to the candidate threshold. When the image is predicted as an anomaly, the threshold-calibrated sample set will be used to identify it as an anomaly. The final image-level anomaly score of the image is less than the candidate threshold. When this happens, the image is predicted as normal; The expression is: (26) In the formula, Indicates the threshold calibration sample set of the first Image prediction results; Step C, calibrate the sample set according to the threshold. The predicted results of each image are compared with their corresponding ground truth class labels to calculate the candidate threshold. The corresponding initial true positive rate and initial false positive rate; The expression is: (27) (28) In the formula, This represents the number of color industrial product images that were initially correctly predicted as abnormal in the threshold calibration sample set. This indicates the number of color industrial product images that were abnormal in the threshold calibration sample set but were ultimately incorrectly predicted as normal. This represents the number of normal color industrial product images in the threshold calibration sample set that were ultimately incorrectly predicted as abnormal. This indicates the number of normal color industrial product images in the threshold calibration sample set that were ultimately correctly predicted as normal. This represents the initial true rate. Indicates the initial false positive rate; Step D, according to and Calculate candidate threshold The corresponding final Youden index ; The expression is: (29) The final Yorkden index The candidate threshold corresponding to the maximum value is determined as the final image-level anomaly detection threshold. ; expression: (30).

[0041] Example 6 Based on Example 5, the specific process of step 5 is as follows: the scene category to which the color industrial product image to be detected belongs includes unstructured surface scene and structured textured surface scene; Unstructured surface scenes represent industrial product surfaces that do not contain regular, dense traces, meshes, pads, or repetitive stepped edges; The structural textured surface scene represents the surface of industrial products containing one or more of the following: regular lines, meshes, pads, metal edges, or repeating texture structures. (1) When the color industrial product image to be detected is an unstructured surface scene, the baseline segmentation threshold is set. Set to 0.7≤ ≤0.85, the maximum number of abnormal connected components to be selected. K Set the value to 3 to retain more candidate pixels for anomalies and their corresponding connected components. After setting the parameters, execute steps 1 to 4 to obtain the final image-level anomaly score. (2) When the color industrial product image to be detected is a scene with a structured textured surface, the baseline segmentation threshold is set. Set to 0.85 < ≤0.95, used to intercept discrete edge reflection noise, and to select the maximum number of abnormal connected components. K Setting it to 1, then the set of connected component areas The area of ​​the first abnormal connected component in the image is the spatially effective topological cumulative area of ​​the current image. ,and = Set threshold , ( (Value is 15); when At that time, it was considered that the spatial scale of local abnormal responses was too small, and the optimal dynamic weighted fusion weight was set. =0.0, to avoid discrete local responses with excessively small areas from participating in image-level anomaly score calibration; when At that time, the optimal dynamic weighted fusion weight is calculated according to equation (16); After setting the parameters, proceed with steps 1-4 to obtain the final image-level anomaly score.

[0042] Example 7 This example demonstrates anomaly detection for images in the VisA dataset capsules. Figure 1 As shown, the capsule surface does not contain regular dense traces, meshes, pads, or repeating stepped edges; therefore, the capsule belongs to an unstructured surface scene, and thus is set to... With a value of 0.85 and K of 3, steps 1-4 are executed to obtain the final image-level anomaly score. The capsule's normal sample material has a reflective surface, specifically: Step 1: Obtain the spatial anomaly probability field and initial image-level anomaly score from the image of the color industrial product to be detected; The specific process is as follows: Step 1.1: Preprocess the images of the capsules to be detected to obtain the input image. Input image Input into an existing AnomalyCLIP to obtain global visual features. Local image patch features Normal text features and abnormal text features global visual features Local image patch features Normal text features and abnormal text features Normalization was performed separately to obtain the processed global visual features. Processed local image patch features Normal text features after processing and processed abnormal text features ; The size of the image of the capsules to be detected is ; Step 1.2, process the local image patch features Normal text features after processing and processed abnormal text features Similarity calculations are performed, and bilinear interpolation is used to restore the resolution. Generate the original two-dimensional anomaly heat map of space. ,like Figure 2 As shown; Step 1.3: Use a two-dimensional Gaussian convolution kernel to process the original two-dimensional spatial anomaly heatmap. Spatial neighborhood convolution denoising is performed to obtain a smooth spatial anomaly probability field. ,like Figure 3 As shown; Step 1.4: Process the global visual features Features of processed normal text Perform cosine similarity calculation to obtain normal semantic similarity. , The value is 0.4360, representing the processed global visual features. Features of processed abnormal text Cosine similarity calculation is performed to obtain abnormal semantic similarity. , It is 0.7698; Step 1.5, normal semantic similarity Similarity to anomalous semantics Softmax normalization is performed to obtain the initial image-level anomaly score. , It is 0.5827.

[0043] Step 1.6, Initial Image-Level Anomaly Detection Threshold The initial image-level anomaly score Compared with the initial image-level anomaly detection threshold In comparison, because Therefore, the normal capsule sample was initially determined to be abnormal, which is a false positive test result; Step 2: Traverse the spatial anomaly probability field to obtain the maximum and minimum anomaly probability values, and calculate the dynamic adaptive segmentation threshold; The specific process is as follows: Step 2.1, traverse the entire graph spatial anomaly probability field Obtain the current color industrial product image to be inspected. Maximum anomaly probability value ( (0.4023) and minimum anomaly probability value ( (0.0026) The expression is:

[0044] In the formula, Indicates the horizontal pixel coordinates. Represents the vertical pixel coordinate; Step 2.2, using the initial image-level anomaly score Calculate the spatial segmentation threshold and segmentation coefficient. , It is 0.7917; The expression is:

[0045] In the formula, As the baseline segmentation threshold, It is 0.85. To adjust the weighting coefficients for feedback, It is 0.1; Step 2.3, divide the spatial segmentation threshold into coefficients. Substitute the maximum anomaly probability value and minimum anomaly probability value Within the span, the dynamic adaptive segmentation threshold is calculated. , It is 0.3190; The expression is: ; Step 3: Based on the dynamic adaptive segmentation threshold, the spatial anomaly probability field is binarized to obtain a binary map, and the effective topological cumulative area of ​​the space is calculated through the binary map. The specific process is as follows: Step 3.1, utilize dynamic adaptive segmentation threshold For spatial anomaly probability fields Perform pixel-by-pixel binarization to obtain a binary map of the spatial anomaly candidate connected components. ,like Figure 4 As shown; The expression is:

[0046] Step 3.2, for the binary image Perform connected component labeling to detect all independent topologically connected components in the entire graph, such as... Figure 5As shown, the number of pixels inside each independent connected component is counted, and the number of pixels inside each independent connected component is used as the area of ​​each abnormal connected component. Then the area of ​​the abnormal connected component is [108, 57, 45, 31, 21, 19]. Step 3.3: Sort all the areas of abnormal connected components in descending order of size to obtain the set of connected component areas. ( (281), ={108, 57, 45, 31, 21, 19}; Step 3.4: Set the maximum number of abnormal connected components to be selected to 3, and then consider the set of connected component areas. The effective topological cumulative area of ​​the current image is obtained by summing the areas of the first three abnormal connected components. , It is 210; The expression is: ; Step 4: Calculate the final image-level anomaly score; The specific process is as follows: Step 4.1: Accumulate area through effective spatial topology. and the set scale adjustment damping constant ( (with a value of 100.0), calculate the nonlinear spatial condensation index. , It is 0.8775; The expression is:

[0047] Step 4.2, Maximum anomaly probability value Nonlinear spatial cohesion index Performing a dot product yields the dynamic space feedback intensity coefficient. , It is 0.3530; The expression is:

[0048] Step 4.3, set the upper limit of the maximum fusion mixing coefficient as follows: ( (0.25), calculate the optimal dynamic weighted fusion weight. , It is 0.0882; The expression is:

[0049] Step 4.4: Calculate the optimal dynamically weighted fusion weights. Compared with the initial image-level anomaly score and maximum anomaly probability value Linear weighting is performed to obtain the final image-level anomaly score. , It is 0.5668; The expression is:

[0050] Step 4.5, final image-level anomaly detection threshold =0.5728, the final image-level anomaly score Compared with the final image-level anomaly detection threshold In comparison, because If the result is negative, the capsule sample is ultimately determined to be normal, representing a true negative test result. This demonstrates that, under the corresponding image-level anomaly detection thresholds before and after calibration, this method corrects the sample from a false positive to a true negative result, reducing false alarms caused by high gloss reflection from the capsule surface.

[0051] Example 8 This embodiment performs anomaly detection on the fabric (Woven_127) image from the DTD dataset. For example... Figure 6 As shown, this normal sample, due to its surface containing a mesh, belongs to a structured texture surface scene, and therefore is set... With a value of 0.95 and K = 1, step 1 is executed, and the generated original two-dimensional spatial anomaly heat map is as follows. Figure 7 As shown, the obtained smooth spatial anomaly probability field is as follows: Figure 8 As shown, the initial image-level anomaly score is obtained. The initial image-level anomaly detection threshold is 0.6745. ,because =0.6745 < If the abnormal fabric sample is normal, it is considered a negative test result; proceed to step 2, where the maximum abnormal probability value is... The value is 0.9862. Continuing with step 3, the resulting binary graph of the spatial anomaly candidate connected components is shown below. Figure 9 As shown, all independent topologically connected components are as follows: Figure 10 As shown, continue with step 4 to obtain the nonlinear spatial cohesion index. The final image-level anomaly score is 0.9793. The final image-level anomaly detection threshold is 0.7498. ,because =0.7498> Therefore, the sample was ultimately identified as an anomaly. This demonstrates that, under the respective image-level anomaly detection thresholds before and after calibration, this method corrects the sample from a false negative to a true positive, thereby suppressing false negatives caused by complex and repetitive textures.

Claims

1. A collaborative verification method for anomaly degree of zero-sample images across scenes, characterized in that, The steps are as follows: Step 1: Obtain the spatial anomaly probability field and initial image-level anomaly score from the image of the color industrial product to be detected; Step 2: Traverse the spatial anomaly probability field to obtain the maximum and minimum anomaly probability values, and calculate the dynamic adaptive segmentation threshold; Step 3: Based on the dynamic adaptive segmentation threshold, the spatial anomaly probability field is binarized to obtain a binary map, and the effective topological cumulative area of ​​the space is calculated through the binary map. Step 4: Calculate the final image-level anomaly score; Step 5: Set the execution parameters according to the scene category to which the color industrial product image to be detected belongs, and then execute steps 1 to 4 to predict the final image-level anomaly score.

2. The collaborative verification method for cross-scene zero-sample image anomaly degree according to claim 1, characterized in that, The specific process of step 1 is as follows: Step 1.1, the image of the color industrial product to be inspected. Preprocessing is performed to obtain the input image. Input image The data is input into an existing zero-shot defect detection model to obtain global visual features. Local image patch features Normal text features and abnormal text features global visual features Local image patch features Normal text features and abnormal text features Normalization was performed separately to obtain the processed global visual features. Processed local image patch features Normal text features after processing and processed abnormal text features ; Step 1.2, process the local image patch features Normal text features after processing and processed abnormal text features Similarity calculations are performed, and bilinear interpolation is used to restore the resolution. Generate the original two-dimensional anomaly heat map of space. ; Step 1.3: Use a two-dimensional Gaussian convolution kernel to process the original two-dimensional spatial anomaly heatmap. Spatial neighborhood convolution denoising is performed to obtain a smooth spatial anomaly probability field. ; Step 1.4: Process the global visual features Features of processed normal text Perform cosine similarity calculation to obtain normal semantic similarity. The processed global visual features Features of processed abnormal text Cosine similarity calculation is performed to obtain abnormal semantic similarity. ; Step 1.5, normal semantic similarity Similarity to anomalous semantics Softmax normalization is performed to obtain the initial image-level anomaly score. ; Step 1.6, Calculate the initial image-level anomaly detection threshold. The initial image-level anomaly score Compared with the initial image-level anomaly detection threshold By comparing the images, a preliminary determination can be made as to whether the color industrial product images to be inspected are abnormal. like ≥ If it is, then it is judged as abnormal; if < If so, it is considered normal.

3. The collaborative verification method for cross-scene zero-sample image anomaly degree according to claim 2, characterized in that, In step 1.1, the color industrial product image to be detected The size is ,in, and These represent the images of the color industrial products to be inspected. Height and width; The preprocessing process is as follows: The bilinear interpolation method is used to interpolate the color industrial product image to be detected. The size is scaled to obtain the input image. Input image The size is ,in, This refers to the input dimensions required by the existing zero-sample defect detection model.

4. The collaborative verification method for anomaly degree of zero-sample images across scenes according to claim 2, characterized in that, In step 1.1, the existing zero-sample defect detection model is AnomalyCLIP.

5. The collaborative verification method for anomaly degree of zero-sample images across scenes according to claim 2, characterized in that, In step 1.6, the initial image-level anomaly detection threshold is calculated. The process is as follows: Step S1: Construct a threshold calibration sample set, which includes several normal color industrial product images and their corresponding real category labels, and several abnormal color industrial product images and their corresponding real category labels. Step S2: Calculate the initial image-level anomaly score for each image in the threshold calibration sample set according to steps 1.1 to 1.5, thus forming the initial image-level anomaly score set S. BASE ,Right now: In the formula, S base,1 S represents the initial image-level anomaly score of the first image in the threshold-calibrated sample set. base,2 S represents the initial image-level anomaly score of the second image in the threshold-calibrated sample set. base,M This represents the initial image-level anomaly score of the Mth image in the threshold calibration sample set; Step S3, for the initial image-level anomaly score set S BASE Traversing candidate thresholds When the threshold is set for the first sample... The initial image-level anomaly score of the image is greater than or equal to the candidate threshold. When the image is predicted as an anomaly, the threshold-calibrated sample set will be used to identify it as an anomaly. The initial image-level anomaly score of the image is less than the candidate threshold. When this happens, the image is predicted as normal; The expression is: In the formula, Indicates the threshold calibration sample set of the first Image prediction results; Step S4, calibrate the sample set according to the threshold. The predicted results of each image are compared with their corresponding ground truth class labels to calculate the candidate threshold. The corresponding initial true positive rate and initial false positive rate; The expression is: In the formula, This represents the number of color industrial product images that were correctly predicted as anomalous in the threshold-calibrated sample set. This indicates the number of color industrial product images that are abnormal in the threshold calibration sample set and are incorrectly predicted as normal. This represents the number of normal color industrial product images in the threshold calibration sample set that were incorrectly predicted as anomalous. This indicates the number of normal color industrial product images in the threshold calibration sample set that were correctly predicted as normal. This represents the initial true rate. Indicates the initial false positive rate; Step S5, according to and Calculate candidate threshold Corresponding initial Youden index ; The expression is: Initial Yoden Index The candidate threshold corresponding to the maximum value is determined as the initial image-level anomaly detection threshold. ; The expression is: 。 6. The collaborative verification method for anomaly degree of zero-sample images across scenes according to claim 2, characterized in that, The specific process of step 2 is as follows: Step 2.1, traverse the entire graph spatial anomaly probability field Obtain the current color industrial product image to be inspected. Maximum anomaly probability value and minimum anomaly probability value ; The expression is: In the formula, Indicates the horizontal pixel coordinates. Represents the vertical pixel coordinate; Step 2.2, using the initial image-level anomaly score Calculate the spatial segmentation threshold and segmentation coefficient. ; The expression is: In the formula, As the baseline segmentation threshold, The weighting coefficients are adjusted for feedback. Step 2.3, divide the spatial segmentation threshold into coefficients. Substitute the maximum anomaly probability value and minimum anomaly probability value Within the span, the dynamic adaptive segmentation threshold is calculated. ; The expression is: 。 7. The collaborative verification method for anomaly degree of zero-sample images across scenes according to claim 6, characterized in that, The specific process of step 3 is as follows: Step 3.1, utilize dynamic adaptive segmentation threshold For spatial anomaly probability fields Perform pixel-by-pixel binarization to obtain a binary map of the spatial anomaly candidate connected components. ; The expression is: Step 3.2, for the binary image Perform connected component labeling to detect all independent topological connected components in the entire graph, and count the number of pixels inside each independent connected component. Use the number of pixels inside each independent connected component as the area of ​​each abnormal connected component. Step 3.3: Sort all the areas of abnormal connected components in descending order of size to obtain the set of connected component areas. , ,satisfy ; Step 3.4, let the maximum number of abnormal connected components selected be... K For the set of areas of connected components The front of the middle K The summation of the areas of the abnormal connected components yields the spatially effective topological cumulative area of ​​the current image. ; The expression is: 。 8. The collaborative verification method for anomaly degree of zero-sample images across scenes according to claim 7, characterized in that, The specific process of step 4 is as follows: Step 4.1: Accumulate area through effective spatial topology. and the set scale adjustment damping constant Calculate the nonlinear spatial cohesion index ; The expression is: Step 4.2, Maximum anomaly probability value Nonlinear spatial cohesion index Performing a dot product yields the dynamic space feedback intensity coefficient. ; The expression is: Step 4.3, set the upper limit of the maximum fusion mixing coefficient as follows: Calculate the optimal dynamic weighted fusion weights ; The expression is: Step 4.4: Calculate the optimal dynamically weighted fusion weights. Compared with the initial image-level anomaly score and maximum anomaly probability value Linear weighting is performed to obtain the final image-level anomaly score. ; The expression is: Step 4.5: Calculate the final image-level anomaly detection threshold. The final image-level anomaly score will be determined. Compared with the final image-level anomaly detection threshold By comparing the images, it is ultimately determined whether the color industrial product images to be inspected are abnormal; like ≥ If it is, then it is judged as abnormal; if < If so, it is considered normal.

9. The collaborative verification method for cross-scene zero-sample image anomaly degree according to claim 8, characterized in that, In step 4.5, the final image-level anomaly detection threshold is calculated. The process is as follows: Step A: Calculate the final image-level anomaly score for each image in the threshold calibration sample set according to steps 1.1 to 4.4, forming the initial final image-level anomaly score set SFINAL, i.e.: In the formula, Sfinal,1 represents the final image-level anomaly score of the first image in the threshold calibration sample set, Sfinal,2 represents the final image-level anomaly score of the second image in the threshold calibration sample set, and Sfinal,M represents the final image-level anomaly score of the Mth image in the threshold calibration sample set. Step B, for the final image-level anomaly score set S FINAL Traversing candidate thresholds When the threshold is set for the first sample... The final image-level anomaly score of the images is greater than or equal to the candidate threshold. When the image is predicted as an anomaly, the threshold-calibrated sample set will be used to identify it as an anomaly. The final image-level anomaly score of the image is less than the candidate threshold. When this happens, the image is predicted as normal; The expression is: In the formula, Indicates the threshold calibration sample set of the first Image prediction results; Step C, calibrate the sample set according to the threshold. The predicted results of each image are compared with their corresponding ground truth class labels to calculate the candidate threshold. The corresponding initial true positive rate and initial false positive rate; The expression is: In the formula, This represents the number of color industrial product images that were initially correctly predicted as abnormal in the threshold calibration sample set. This indicates the number of color industrial product images that were abnormal in the threshold calibration sample set but were ultimately incorrectly predicted as normal. This represents the number of normal color industrial product images in the threshold calibration sample set that were ultimately incorrectly predicted as abnormal. This indicates the number of normal color industrial product images in the threshold calibration sample set that were ultimately correctly predicted as normal. This represents the initial true rate. Indicates the initial false positive rate; Step D, according to and Calculate candidate threshold The corresponding final Youden index ; The expression is: The final Yorkden index The candidate threshold corresponding to the maximum value is determined as the final image-level anomaly detection threshold. ; expression: 。 10. The collaborative verification method for anomaly degree of zero-sample images across scenes according to claim 8, characterized in that, The specific process of step 5 is as follows: The scene categories to which the color industrial product images to be inspected belong include unstructured surface scenes and structured textured surface scenes; Unstructured surface scenes represent industrial product surfaces that do not contain regular, dense traces, meshes, pads, or repetitive stepped edges; The structural textured surface scene represents the surface of industrial products containing one or more of the following: regular lines, meshes, pads, metal edges, or repeating texture structures. (1) When the color industrial product image to be detected is an unstructured surface scene, the baseline segmentation threshold is set. Set to 0.7≤ ≤0.85, the maximum number of abnormal connected components to be selected. K Set the parameter to 3, execute steps 1-4 after parameter setting, and obtain the final image-level anomaly score; (2) When the color industrial product image to be detected is a scene with a structured textured surface, the baseline segmentation threshold is set. Set to 0.85 < ≤0.95, the maximum number of abnormal connected components to be selected. K Setting it to 1, then the set of connected component areas The area of ​​the first abnormal connected component in the image is the spatially effective topological cumulative area of ​​the current image. ,and = Set threshold , ,when At that time, set the optimal dynamic weighted fusion weight. =0.0, after setting the parameters, execute steps 1 to 4 to obtain the final image-level anomaly score.