A method of rotation invariant multi-prototype industrial anomaly detection

CN122156889APending Publication Date: 2026-06-05SHANDONG DIEHUI INTELLIGENT TECHNOLOGY CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SHANDONG DIEHUI INTELLIGENT TECHNOLOGY CO LTD
Filing Date
2026-01-19
Publication Date
2026-06-05

AI Technical Summary

Technical Problem

In industrial manufacturing, traditional supervised learning-based defect detection methods are prone to overfitting when defect samples are scarce, while unsupervised methods suffer from contamination of normal sample sets, leading to unstable anomaly detection and difficulty in generating clear and reliable defect localization in complex backgrounds and workpiece rotation.

Method used

A rotation-invariant multi-prototype industrial anomaly detection method is adopted. By constructing foreground and background masks, extracting feature maps using a pre-trained feature extraction network, performing multi-angle rotation and mask weighted pooling, and combining a multi-expert background prototype queue and an adaptive routing mechanism, a stable anomaly heatmap is generated, and the model is optimized through multiple loss functions.

Benefits of technology

It effectively overcomes background interference and workpiece rotation changes under small sample conditions, generates stable and reliable anomaly positioning information, reduces data and computing costs, and improves detection accuracy and recall.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122156889A_ABST
    Figure CN122156889A_ABST
Patent Text Reader

Abstract

The application relates to the technical field of industrial anomaly detection, and discloses a rotation-invariant multi-prototype industrial anomaly detection method, which comprises the following steps: S1: obtaining an industrial image to be processed and a corresponding defect region frame-level label, and constructing a foreground mask and a background mask based on the frame-level label; S2: inputting the industrial image into a pre-trained feature extraction network, obtaining an initial feature map, and performing channel mapping and normalization processing on the initial feature map to obtain a normalized feature map; and S3: rotating the normalized feature map at least two different angles to obtain a feature map in each rotation direction. The rotation-invariant multi-prototype industrial anomaly detection method is based on a feature extraction network pre-trained on a large-scale data set, can make a heat map generation module converge only through a small number of training rounds, does not need to train a complex model from the beginning, and greatly reduces data demand, computing resource and training time cost.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of industrial anomaly detection technology, and in particular to a rotationally invariant multi-prototype industrial anomaly detection method. Background Technology

[0002] In the industrial manufacturing sector, automated inspection of product appearance defects is a crucial step in ensuring product quality. However, in actual production environments, this task faces numerous severe challenges: First, defect samples are typically extremely scarce and costly to collect, while defect types are complex and diverse, varying greatly in size, shape, and contrast; second, workpieces may rotate randomly on the production line, resulting in inconsistent postures; furthermore, the texture, lighting, and reflections in the background environment are complex and variable. These issues make it difficult to deploy traditional supervised learning-based defect detection methods (such as YOLO and Faster R-CNN) stably and reliably. Supervised methods heavily rely on a large amount of precisely labeled defect data, which can easily lead to overfitting when samples are scarce. Moreover, bounding box annotations cannot provide fine contours of defects, resulting in insufficient ability to locate small, blurry, or irregular defects.

[0003] On the other hand, unsupervised anomaly detection methods, which rely on "only normal samples," also have inherent flaws in real-world industrial scenarios. Since it is impossible to absolutely guarantee that the collected "normal" sample set is completely free of defects, the inclusion of minor defects can contaminate the normal feature prototype library, leading to problems such as blurred boundaries, unstable response, and frequent false anomalies in the generated anomaly heatmap, which severely reduces the confidence of the detection. Summary of the Invention

[0004] In view of the above-mentioned problems that existing methods cannot absolutely guarantee that the collected normal sample set is completely free of defects, and that the inclusion of minor defects can lead to the contamination of the normal feature prototype library, resulting in problems such as blurred boundaries, unstable response, and frequent false anomalies in the generated anomaly heatmap, which seriously reduces the confidence of detection, this invention is proposed.

[0005] Therefore, the purpose of this invention is to provide a rotation-invariant multi-prototype industrial anomaly detection method. The purpose is that the current field of industrial appearance defect detection urgently needs a technical solution that can effectively overcome background interference and workpiece rotation changes under small sample and weak supervision conditions, and generate stable and reliable anomaly location information.

[0006] To solve the above-mentioned technical problems, the present invention provides the following technical solution: a rotationally invariant multi-prototype industrial anomaly detection method, comprising the following steps:

[0007] S1: Obtain the industrial image to be processed and its corresponding defect region bounding box annotations, and construct a foreground mask and a background mask based on the bounding box annotations;

[0008] S2: Input the industrial image into a pre-trained feature extraction network to extract an initial feature map, and perform channel mapping and normalization on the initial feature map to obtain a normalized feature map;

[0009] S3: Rotate the normalized feature map at least two different angles to obtain feature maps in each rotation direction; use the background mask to perform mask weighted pooling on the feature maps in each rotation direction to obtain the image-level background feature vector corresponding to each direction.

[0010] S4: Match the image-level background feature vectors in each direction with the pre-stored multi-expert background prototype queue, calculate the matching degree, and select an optimal direction from all rotation directions based on the matching degree, and use the feature corresponding to the optimal direction as the rotation-invariant background feature of the current image.

[0011] S5: Match the rotation-invariant background features with the prototype mean of each expert queue in the multi-expert background prototype queue, select the most matching target expert queue through a routing mechanism, and update the rotation-invariant background features to the target expert queue using a moving average method.

[0012] S6: Calculate the similarity between the normalized feature map and the background prototype in the target expert queue in each rotation direction, and rotate the calculation result back to the original image direction and take the maximum value in each direction to obtain the abnormal response map based on the target expert queue.

[0013] S7: Merge the anomaly response maps corresponding to all expert queues to generate the final comprehensive anomaly heatmap, which is used to indicate potential defect areas in the industrial image.

[0014] As a preferred embodiment of the rotation-invariant multi-prototype industrial anomaly detection method of the present invention, in step S1, based on the difference between the original image size and the network input size, a scale mapping method that keeps the mask structure unchanged is adopted to map the foreground mask and the background mask to a coordinate space aligned with the feature map.

[0015] As a preferred embodiment of the rotation-invariant multi-prototype industrial anomaly detection method of the present invention, wherein: in S4, the multi-expert background prototype queue includes M independent queues, each queue storing K unitized background prototype vectors composed of historical image background features, where M and K are both integers greater than 1.

[0016] As a preferred embodiment of the rotationally invariant multi-prototype industrial anomaly detection method of the present invention, wherein: in step S4, the specific step of selecting the optimal direction includes:

[0017] Calculate the maximum cosine similarity between the image-level background feature vector for each rotation direction and all prototype vectors in the multi-expert background prototype queue;

[0018] The rotation direction with the highest maximum cosine similarity is selected as the optimal direction.

[0019] As a preferred embodiment of the rotationally invariant multi-prototype industrial anomaly detection method of the present invention, wherein: in step S5, the specific steps of the routing mechanism include:

[0020] Calculate the cosine similarity between the rotation-invariant background features and the prototype mean vector of each expert queue;

[0021] The routing score is obtained by normalizing the cosine similarity.

[0022] The expert queue with the highest routing score is selected as the target expert queue.

[0023] In a preferred embodiment of the rotationally invariant multi-prototype industrial anomaly detection method of the present invention, in step S6, the similarity is converted into an anomaly response using the following formula:

[0024]

[0025] If there are M expert queues in total, the final response will be:

[0026]

[0027] in, This represents the eigenvector at position (x, y) of the m-th expert under the k-th rotation, and its relationship to the prototype. Cosine similarity; This represents the maximum similarity obtained across all rotations k and all prototypes i after mapping the rotated similarity back to the original direction. This represents the abnormal response map output by the m-th expert; the lower the similarity, the higher the abnormality. This represents the final anomaly graph after multi-expert fusion.

[0028] In a preferred embodiment of the rotation-invariant multi-prototype industrial anomaly detection method of the present invention, during the model training phase, a multi-loss joint strategy is used to optimize the heatmap generation network, and the total loss function L_total is a weighted sum of multiple sub-loss terms, wherein the sub-loss terms include at least two of the following:

[0029] Background compaction loss is used to encourage background region features to cluster in the prototype space;

[0030] Foreground separation loss is used to encourage foreground region features to move away from the background prototype;

[0031] Total variational regularization loss is used to facilitate the smoothing of anomalous heatmaps;

[0032] Rotation consistency loss is used to constrain the model to produce a consistent response to rotations;

[0033] The bounding box contrast constraint loss is used to constrain the location of high-response regions in the heatmap based on the bounding box constraints.

[0034] Structure-sensitive suppression loss is used to suppress pseudo-abnormal responses caused by reflectivity or strong textures;

[0035] Difficult background mining loss is used to automatically mine and suppress areas in the background that are easily misjudged as abnormal.

[0036] As a preferred embodiment of the rotationally invariant multi-prototype industrial anomaly detection method of the present invention, the frame contrast constraint loss is achieved by constructing a foreground core region and an outer frame neighborhood ring, and constraining the average anomaly response of the foreground core region to be higher than the average anomaly response of the outer frame neighborhood ring.

[0037] Compared with the prior art, the present invention has at least the following beneficial effects:

[0038] 1. This invention is based on a feature extraction network pre-trained on a large-scale dataset. The heatmap generation module can converge with only a few training epochs, eliminating the need to train a complex model from scratch. This greatly reduces the data requirements, computing resources, and training time costs. At the same time, it innovatively utilizes existing bounding box annotation information, treating the area outside the bounding box as a high-confidence normal background. Only this part of the background features is used to construct and update the prototype queue. This mechanism fundamentally avoids the "prototype pollution" problem caused by defective features mixing into the normal feature library, ensuring the purity and stability of the background representation.

[0039] 2. This invention utilizes multi-angle rotation feature maps, direction normalization selection, and comparison with the rotated prototype to make the algorithm insensitive to changes in the workpiece's posture (rotation). Regardless of how the workpiece rotates, the generated abnormal heatmap maintains a consistent response, significantly improving its practicality and reliability in automated production lines.

[0040] 3. By introducing a multi-expert prototype queue structure and an adaptive routing mechanism, this invention can establish multiple independent background distribution subspaces for different working conditions, materials, and background textures. The system can automatically select the most matching background expert for each image, effectively solving the problem that a single prototype library is difficult to cover complex multimodal background distributions and enhancing the model's adaptability in changing environments.

[0041] 4. This invention utilizes a combination of loss functions, including foreground separation and background compactness constraints, heatmap smoothing constraints, rotational consistency constraints, box contrast constraints, structure sensitivity suppression loss, and difficult background mining loss, to jointly optimize the heatmap. This effectively suppresses pseudo-anomaly responses caused by complex textures, specular reflections, etc., resulting in more concentrated defect areas and clearer boundaries in the generated heatmap.

[0042] 5. The abnormal heat map generated by this invention can be used as strong prior information and seamlessly integrated into downstream target detection or segmentation networks to enhance defect region features and suppress background noise, thereby effectively improving the accuracy and recall of the overall detection model when defect samples are scarce. Attached Figure Description

[0043] Figure 1 This is a schematic diagram of the overall framework of the rotationally invariant multi-prototype industrial anomaly detection method of the present invention;

[0044] Figure 2 This is the first original diagram of the rotationally invariant multi-prototype industrial anomaly detection method of the present invention;

[0045] Figure 3 This is the first anomaly thermal diagram of the rotationally invariant multi-prototype industrial anomaly detection method of the present invention;

[0046] Figure 4 This is a diagram showing the location of the first significant anomaly in the rotationally invariant multi-prototype industrial anomaly detection method of the present invention.

[0047] Figure 5 This is the first original image superimposed with the anomaly response image in the rotation-invariant multi-prototype industrial anomaly detection method of the present invention;

[0048] Figure 6 This is the second original diagram of the rotationally invariant multi-prototype industrial anomaly detection method of the present invention;

[0049] Figure 7 This is the second anomaly thermogram of the rotationally invariant multi-prototype industrial anomaly detection method of the present invention;

[0050] Figure 8 This is a diagram showing the location of the second significant anomaly in the rotationally invariant multi-prototype industrial anomaly detection method of the present invention.

[0051] Figure 9This is the second original image superimposed with the anomaly response image in the rotation-invariant multi-prototype industrial anomaly detection method of the present invention. Detailed Implementation

[0052] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings.

[0053] Example

[0054] (a) Constructing a mask based on the bounding box

[0055] Before training a defect detection network, most networks require drawing rectangular boxes to annotate defect areas using annotation software. Therefore, this invention constructs foreground and background masks based on the rectangular box annotations. The defect areas annotated within the rectangles are the foreground, and the areas outside the rectangles are the background. Specifically, let the image region be... The given annotation box area is The functions for constructing the foreground and background masks are as follows:

[0056] (1)

[0057] (2)

[0058] in, Indicates foreground mask, This represents the background mask.

[0059] At the same time, the original resolution of the image and the fixed size of the network input are also taken into account. Due to differences, a scale mapping method that preserves the mask structure is adopted, ensuring strict alignment between the mask and the feature space. Let the image size be... The mapping formula is defined as follows:

[0060] (3)

[0061] This mapping method ensures that the mask maintains its binary nature and contour consistency during scaling, allowing subsequent feature pooling, region similarity calculation, and box-aware constraints to be performed in a unified coordinate system.

[0062] (II) Feature map generation of the pre-trained feature extraction network ResNet50

[0063] After obtaining the input image and its corresponding foreground and background masks, the image is fed into a pre-trained ResNet50 feature extraction network to obtain deep feature maps for anomaly modeling. This network has been pre-trained on large-scale data, thus possessing good image feature extraction capabilities. Specifically, let the input image be... The image is input into ResNet50 for forward inference to obtain intermediate feature maps. .

[0064] (4)

[0065] Then use Convolution maps all channels to a predefined feature dimension C, and then normalizes the data along the channel dimension to obtain the final feature map.

[0066] (5)

[0067] Where C represents the number of channels, we set C to 384 in this implementation. , This represents the spatial dimensions after network downsampling. This feature map contains information about the workpiece texture, edges, and local structure, serving as the foundational data source for subsequent background prototype construction, rotation-invariant similarity calculation, and anomaly heatmap generation.

[0068] (III) Rotation-invariant feature processing and orientation normalization

[0069] Since the workpiece's posture in a specific scenario may involve rotation at arbitrary angles, we perform four rotations on the feature map to eliminate posture sensitivity:

[0070] (6)

[0071] In industrial scenarios, defects on the workpiece occupy only a small portion of the foreground region, while the background region remains relatively stable. To utilize only the statistics of the background region, we compare each rotated feature map with the background mask. Perform mask-weighted pooling:

[0072] (7)

[0073] in, Let be the feature vector of the rotated feature at position (x, y); ; As a stable term, Let be the k-th candidate background feature vector. Through this pooling, the background region is compressed into an image-level background feature vector. Finally, this feature vector is normalized to ensure that the background prototype library can stably store statistical information from different images.

[0074] (8)

[0075] Previously, we constructed feature maps in four directions. To correspond with images of different rotation directions, we adopted a direction selection strategy to choose the rotation direction most similar to the background prototype library as the main background direction of the image. First, we established the background prototype library...

[0076]

[0077] in, This represents the unitized background prototype vector obtained from historical image background statistics.

[0078] Calculate the maximum similarity between each rotation direction vector and all background prototypes:

[0079] (9)

[0080] in, Indicates cosine similarity; This reflects the degree to which the background features in direction k fit the known background pattern. The optimal direction is ultimately selected as:

[0081] (10)

[0082] Finally, the optimal orientation feature is selected as the background feature that remains rotation-invariant for the current image:

[0083] (11)

[0084] in, The selected optimal direction Background features.

[0085] (iv) Construction of multi-expert prototype queues and adaptive routing mechanism

[0086] After completing the rotation alignment, we adopt a multi-expert background prototype queue structure to model the multimodal background distribution under different working conditions, materials, and background textures, thus solving the problem that the background patterns are diverse in industrial environments and a single prototype library cannot fully cover them.

[0087] First, we construct a multi-expert background prototype queue, with M being the number of background prototypes. In this implementation, we choose M=4 to construct the queue.

[0088] (12)

[0089] in, Let M be the Mth expert queue, and each queue has a length of K, storing K normalized background features. Let the queues... The current set of valid prototypes is:

[0090] (13)

[0091] These prototypes all come from the background areas of historical images, reflecting the statistical stability of the background.

[0092] For the current image, its rotation-normalized background feature vector is: Then, calculate the similarity between each vector and the average vector of each queue prototype. Let the queue be... The prototype mean is :

[0093] (14)

[0094] Calculate the route score after normalization And select the most similar expert queue :

[0095] (15)

[0096] (16)

[0097] in, The expert queue is the best match for the current image background. In this way, each image is routed to the most suitable background subspace, avoiding all background samples from being mixed into the same feature library and interfering with each other.

[0098] To update the expert queue, we employed an exponential moving average (EMA) mechanism. The rotation-normalized background features of the current image are also considered. Added to queue In China, updates are made via EMA:

[0099] (17)

[0100] in, The EMA weight is set to 0.9 here. Through this update method, the expert queue gradually forms a stable and well-distributed multi-background subspace, providing a more robust reference for subsequent anomaly measurement.

[0101] (v) Generation of rotationally invariant anomaly heatmaps based on a multi-expert prototype library

[0102] After completing background direction normalization and expert routing, this invention generates an anomaly heatmap independently for each expert queue and merges them to obtain the final anomaly response.

[0103] 1. Calculation of rotation-invariant anomaly maps under a single expert prototype: For feature maps We use the following steps to generate an exception response:

[0104] (1) Normalize the feature map to obtain the normalized feature map. :

[0105] (18)

[0106] (2) Rotate in four directions and compare with expert prototypes. First, use equation (6) to rotate the feature map, flatten it and calculate the comparison with the expert prototype library. Similarity:

[0107] (19)

[0108] (3) Rotate the similarity back to its original direction and take the maximum value:

[0109] (20)

[0110] Finally, the similarity score is converted into an anomaly response:

[0111] (twenty one)

[0112] If there are M expert queues in total, the final response will be:

[0113] (twenty two)

[0114] in, This represents the eigenvector at position (x, y) of the m-th expert under the k-th rotation, and its relationship to the prototype. Cosine similarity; This represents the maximum similarity obtained across all rotations k and all prototypes i after mapping the rotated similarity back to the original direction. This represents the abnormal response map output by the m-th expert; the lower the similarity, the higher the abnormality. This represents the final anomaly graph after multi-expert fusion.

[0115] (vi) Training of anomaly heatmaps based on multi-loss joint optimization

[0116] To better distinguish between abnormal and normal background features, we used a set of complementary loss functions. The aim was to enable the model to learn anomaly response distributions that are characterized by "compact background, separable foreground, smooth edges, and contours that conform to bounding box information," thereby obtaining stable and reliable anomaly heatmaps even with very few samples.

[0117] 1. Foreground Separation and Background Tight Constraint

[0118] To ensure that background features are more concentrated in the prototype space, while keeping the defect region (within the bounding box) far from the normal background in the feature space, we adopt a dual constraint of maximizing background similarity and minimizing foreground similarity:

[0119] (twenty three)

[0120] (twenty four)

[0121] in, and These represent background compactness loss and foreground separation loss, respectively. To separate the foreground area from the background area, a sufficient distance is maintained between them.

[0122] 2. Smoothing of abnormal heatmaps

[0123] To avoid excessive dispersion or noise in the heatmap, TV regularization is employed. The TV regularization loss function is represented as follows:

[0124] (25)

[0125] 3. Rotational Consistency Constraint

[0126] Industrial parts often undergo random rotation. To ensure the model responds consistently to rotation during inference, we introduce a lightweight rotation consistency term loss function. :

[0127] (26)

[0128] 4. Box-based contrast constraints

[0129] In order to extract sufficient anomaly features during training by constraining the location of regions with high thermal values ​​based on the bounding boxes, a box-based contrastive constraint loss was constructed:

[0130] (27)

[0131] in, The core foreground region is obtained by shrinking it from the foreground mask through morphological erosion, preserving the most core and stable area within the bounding box and reducing edge errors.

[0132] (28)

[0133] The outer-bound neighborhood ring is obtained by dilating the background mask and then mutually excluding it from the foreground core region:

[0134] (29)

[0135] in, The background mask is obtained through morphological dilation.

[0136] Meanwhile, to further improve the quality of the area within the frame, a combined BCE and Dice supervision was introduced:

[0137] (30)

[0138] (31)

[0139] in, yes and The average fusion is used to provide weak supervision, making the heatmap more concentrated and stable in the area within the box; A is the abnormal heatmap obtained earlier.

[0140] 5. Structure-sensitive suppression for suppressing reflective / strong texture noise.

[0141] Industrial metal surfaces often exhibit pseudo-anomalies such as highlights and textured structures. Suppression terms are constructed using brightness gradients and reflectivity analysis.

[0142] (32)

[0143] in, Sobel gradient information is used to suppress non-defect structures.

[0144] 6. Self-discovery of challenging backgrounds

[0145] Automatically identify the most "anomaly-like" parts (high-response background pixels) from the background region and align their feature vectors closer to the background direction to reduce false positives.

[0146] (33)

[0147] This represents the difficult background features automatically selected from difficult backgrounds. It selects a number of pixels with the largest abnormal response A(x,y) from the background pixels. These pixels are very easy to be misjudged as defects and are defined as difficult backgrounds. The background prototype for the final orientation of the current image.

[0148] 7. Total Losses

[0149] The final total loss is defined as the weighted sum of all constraints:

[0150] (34)

[0151] in, arrive The weights are set to 1, 2, 0.05, 0.1, 0.5, 0.2, 0.2, 1 respectively in this implementation.

[0152] (vii) Reasoning Stage

[0153] During the inference phase, the feature extraction network weights obtained in the training phase and the multi-expert background prototype library are used as priors. For the image to be detected, size normalization is first performed using the same preprocessing procedure as in the training phase, and then input into the backbone network to obtain feature maps. Subsequently, the feature maps are compared with the similarity of each expert prototype library in four directions: 0° / 90° / 180° / 270°. Anomaly maps for each expert are generated using the rotation-invariant response construction method consistent with the training phase. The minimum value is then taken in the expert dimension to obtain the final anomaly heatmap. Finally, the anomaly heatmap is upsampled back to the original image resolution, and gating suppression is performed by combining edge and highlight information, thereby obtaining a more stable defect response result with fewer artifacts, which can be used to assist in subsequent target detection or defect determination.

[0154] (1) By utilizing pre-trained features, defect heatmaps can be generated quickly without a large number of training rounds.

[0155] This invention is based on a pre-trained feature extraction network, which can achieve stable defect localization capabilities with a small number of iterations, without the need to train a complex model from scratch. Compared with traditional unsupervised methods, this invention does not rely on a large number of normal samples to learn the background prototype; compared with supervised detection, it also does not require a large number of defect samples, significantly reducing the actual deployment cost.

[0156] (2) Use box-level supervision to build a "pure background prototype library" to avoid prototype pollution problems of unsupervised methods;

[0157] The biggest drawback of traditional unsupervised methods is that defective samples mixed into normal data can corrupt the normal feature library. This invention accurately distinguishes foreground and background through box-level annotation, constructing a background prototype queue using only the regions outside the boxes. This effectively prevents defective features from entering the normal library, ensuring the prototype library remains stable and pure, and significantly improving the reliability of anomaly heatmaps.

[0158] (3) Rotation-invariant feature modeling significantly enhances robustness to changes in workpiece posture.

[0159] Achieve end-to-end rotation-invariant anomaly detection mechanism. Regardless of changes in the workpiece rotation angle, the thermal map output maintains a consistent response, significantly improving repeatability and stability in actual production lines.

[0160] (4) Multi-expert prototype queue structure

[0161] Adaptive modeling for different working conditions, materials, and background textures effectively overcomes the limitations of traditional single prototype libraries that cannot cover diverse background distributions. Through an expert routing mechanism, this method can automatically select the most matching background sub-library, thereby obtaining more stable background priors in complex and frequently changing industrial scenarios, ensuring consistency and reliability of anomaly heatmaps across multiple workpiece types and background modes.

[0162] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention, and all such modifications or substitutions should be covered within the scope of the claims of the present invention.

Claims

1. A method for detecting rotationally invariant multi-prototype industrial anomalies, characterized in that, Includes the following steps: S1: Obtain the industrial image to be processed and its corresponding defect region bounding box annotations, and construct a foreground mask and a background mask based on the bounding box annotations; S2: Input the industrial image into a pre-trained feature extraction network to extract an initial feature map, and perform channel mapping and normalization on the initial feature map to obtain a normalized feature map; S3: Rotate the normalized feature map at least two different angles to obtain feature maps in each rotation direction; use the background mask to perform mask weighted pooling on the feature maps in each rotation direction to obtain the image-level background feature vector corresponding to each direction. S4: Match the image-level background feature vectors in each direction with the pre-stored multi-expert background prototype queue, calculate the matching degree, and select an optimal direction from all rotation directions based on the matching degree, and use the feature corresponding to the optimal direction as the rotation-invariant background feature of the current image. S5: Match the rotation-invariant background features with the prototype mean of each expert queue in the multi-expert background prototype queue, select the most matching target expert queue through a routing mechanism, and update the rotation-invariant background features to the target expert queue using a moving average method. S6: Calculate the similarity between the normalized feature map and the background prototype in the target expert queue in each rotation direction, and rotate the calculation result back to the original image direction and take the maximum value in each direction to obtain the abnormal response map based on the target expert queue. S7: Merge the anomaly response maps corresponding to all expert queues to generate the final comprehensive anomaly heatmap, which is used to indicate potential defect areas in the industrial image.

2. The rotationally invariant multi-prototype industrial anomaly detection method according to claim 1, characterized in that: In step S1, based on the difference between the original image size and the network input size, a scale mapping method that keeps the mask structure unchanged is used to map the foreground mask and the background mask to a coordinate space aligned with the feature map.

3. The rotationally invariant multi-prototype industrial anomaly detection method according to claim 2, characterized in that: In step S4, the multi-expert background prototype queue includes M independent queues, each queue storing K unitized background prototype vectors composed of historical image background features, where M and K are both integers greater than 1.

4. The rotationally invariant multi-prototype industrial anomaly detection method according to claim 3, characterized in that: In step S4, the specific steps for selecting the optimal direction include: Calculate the maximum cosine similarity between the image-level background feature vector for each rotation direction and all prototype vectors in the multi-expert background prototype queue; The rotation direction with the highest maximum cosine similarity is selected as the optimal direction.

5. The rotationally invariant multi-prototype industrial anomaly detection method according to claim 4, characterized in that: In step S5, the specific steps of the routing mechanism include: Calculate the cosine similarity between the rotation-invariant background features and the prototype mean vector of each expert queue; The routing score is obtained by normalizing the cosine similarity. The expert queue with the highest routing score is selected as the target expert queue.

6. The rotationally invariant multi-prototype industrial anomaly detection method according to claim 5, characterized in that: In step S6, similarity is converted into anomaly response using the following formula: , If there are M expert queues in total, the final response will be: , in, This represents the eigenvector at position (x, y) of the m-th expert under the k-th rotation, and its relationship to the prototype. Cosine similarity; This represents the maximum similarity obtained across all rotations k and all prototypes i after mapping the rotated similarity back to the original direction. This represents the abnormal response map output by the m-th expert; the lower the similarity, the higher the abnormality. This represents the final anomaly graph after multi-expert fusion.

7. The rotationally invariant multi-prototype industrial anomaly detection method according to claim 1, characterized in that: During the model training phase, a multi-loss joint strategy is used to optimize the heatmap generation network. The total loss function L_total is a weighted sum of multiple sub-loss terms, which include at least two of the following: Background compaction loss is used to encourage background region features to cluster in the prototype space; Foreground separation loss is used to encourage foreground region features to move away from the background prototype; Total variational regularization loss is used to facilitate the smoothing of anomalous heatmaps; Rotation consistency loss is used to constrain the model to produce a consistent response to rotations; The bounding box contrast constraint loss is used to constrain the location of high-response regions in the heatmap based on the bounding box constraints. Structure-sensitive suppression loss is used to suppress pseudo-abnormal responses caused by reflections or strong textures; Difficult background mining loss is used to automatically mine and suppress areas in the background that are easily misjudged as abnormal.

8. The rotationally invariant multi-prototype industrial anomaly detection method according to claim 1, characterized in that: The frame contrast constraint loss is achieved by constructing a foreground core region and an outer frame neighborhood ring, and constraining the average anomalous response of the foreground core region to be higher than the average anomalous response of the outer frame neighborhood ring.