Continuous learning industrial anomaly detection method and device for edge deployment

By using a lightweight convolutional neural network and a differential augmentation knowledge distillation mechanism, combined with a product quantization method, the problem that existing technologies cannot simultaneously satisfy unsupervised learning, continuous learning, and edge deployment is solved, enabling efficient and real-time industrial anomaly detection on edge devices.

CN122046090APending Publication Date: 2026-05-15HARBIN INSTITUTE OF TECHNOLOGY (SHENZHEN) (INSTITUTE OF SCIENCE AND TECHNOLOGY INNOVATION HARBIN INSTITUTE OF TECHNOLOGY SHENZHEN) +1
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
HARBIN INSTITUTE OF TECHNOLOGY (SHENZHEN) (INSTITUTE OF SCIENCE AND TECHNOLOGY INNOVATION HARBIN INSTITUTE OF TECHNOLOGY SHENZHEN)
Filing Date
2025-12-19
Publication Date
2026-05-15

AI Technical Summary

Technical Problem

Existing industrial anomaly detection methods cannot simultaneously meet the requirements of unsupervised learning, continuous learning, and edge deployment, making them difficult to apply in real-world industrial scenarios.

Method used

A lightweight convolutional neural network is used to construct a teacher-student network architecture. Combined with a differential augmentation knowledge distillation mechanism and a product quantization method, it enables unsupervised and continuous learning and adapts to the resource limitations of edge devices.

Benefits of technology

It enables efficient and real-time industrial anomaly detection on edge devices, reduces annotation costs, adapts to dynamic changes in production data, and improves detection accuracy and model generalization ability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122046090A_ABST
    Figure CN122046090A_ABST
Patent Text Reader

Abstract

The invention discloses an edge deployment-oriented continuous learning industrial anomaly detection method and device, and the method comprises the steps: obtaining industrial normal sample data, and dividing training tasks and corresponding training sets and test sets according to classes; a teacher-student dual-network architecture is constructed, a lightweight convolutional neural network is adopted as a backbone network, dual-network front-segment parameter sharing is set, and only student network rear-segment parameters are updated; inputting samples according to a task sequence, calculating teacher-student feature matching loss based on a difference enhancement knowledge distillation mechanism, and updating student network parameters; a replay mechanism is designed, and catastrophic forgetting is avoided in combination with KNN Greedy and random sampling; compressing and replaying sample features by adopting a product quantization method; after training, test data features are extracted, and anomaly scores are calculated to realize anomaly classification and segmentation. The method can meet the requirements of unsupervised learning, continuous learning and edge deployment at the same time, gives consideration to the detection precision and the adaptability of edge equipment, and is suitable for various industrial detection scenes.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of industrial quality inspection technology, specifically relating to a continuous learning industrial anomaly detection method and device for edge deployment. Background Technology

[0002] In the field of intelligent manufacturing, industrial anomaly detection is a key link in the deep integration of computer vision and industrial applications. Its core lies in identifying industrial images containing anomalies and locating abnormal pixels. It is not only widely used in traditional industrial quality inspection but also extends to fields such as medical imaging and autonomous driving. With technological advancements, numerous industrial anomaly detection methods have emerged. However, early technologies focused primarily on improving algorithm performance and detection accuracy, paying insufficient attention to the multiple challenges in real-world scenarios. Only in recent years has research begun to explore issues such as high-noise environments, resource constraints on edge devices, and continuous learning and adaptation.

[0003] Existing industrial anomaly detection methods are categorized into two types based on the availability of labeled data: unsupervised learning and few-shot learning. Unsupervised learning methods, such as PLSTM and Dinomaly, rely on a large number of normal samples to learn deep representations. While they are highly effective, they require high sample labeling costs. Few-shot learning methods, such as InCTRL and PSAD, can alleviate the labeling pressure, but they have limitations such as performance dependence on sample quality, difficulty in identifying subtle anomalies, and high computational overhead.

[0004] However, real-world industrial scenarios present three core requirements for detection technology: first, unsupervised learning capabilities to reduce annotation costs; second, continuous learning mechanisms to adapt to the dynamic changes in data over time during production; and third, compatibility with edge devices to meet deployment needs with limited computing resources. Current technology can hardly meet all three requirements simultaneously, hindering the practical application of industrial anomaly detection technology. Developing a comprehensive solution to these problems has become an urgent need in the field. Summary of the Invention

[0005] In view of this, the purpose of this invention is to propose a continuous learning industrial anomaly detection method and apparatus for edge deployment, so as to solve or partially solve the problems mentioned in the background art.

[0006] To achieve the above objectives, in a first aspect, the present invention provides a continuous learning industrial anomaly detection method for edge deployment, comprising the following steps: Data acquisition and task division: Acquire normal sample data in industrial scenarios, divide at least one training task according to the category of the normal sample data, the sample data categories corresponding to different training tasks are different, and obtain training set and test set corresponding to the training task. Network architecture construction: Construct a dual network architecture including a teacher network and a student network. The dual network architecture uses a lightweight convolutional neural network as the feature extraction backbone network. The front-end parameters of the dual network architecture are shared, and only the back-end parameters of the student network are updated. Feature extraction and loss optimization: Normal sample data of the specified training task are input into the dual network architecture according to the task order. The teacher features output by the teacher network and the student features output by the student network are extracted respectively. The matching loss of the teacher features output by the teacher network and the student features output by the student network is calculated based on the differential enhancement knowledge distillation mechanism. The back-end parameters of the student network are updated through backpropagation. Replay mechanism design: For the current training task, a KNN Greedy sampling strategy is used to select representative samples and store them in the replay storage unit. For the historical training task, a random sampling strategy is used to extract samples from the replay storage unit. The extracted historical samples are mixed with the current task samples and then input into the dual network architecture. Feature compression processing: The sample features stored in the replay storage unit are compressed using the product quantization method, and the compressed features are decompressed during sample replay. Anomaly detection inference: After each training task, test data including normal and abnormal samples is obtained, the features of the test data in the trained student network are extracted, the anomaly score of the test data is calculated, and the test data is classified and segmented according to the preset anomaly score threshold.

[0007] As a preferred scheme for continuous learning industrial anomaly detection methods for edge deployment, the training set is represented as follows:

[0008] The test set is represented as follows:

[0009] In the formula, For the first i Training set for each training task For the first i The test set for each training task, i ≤ Γ, where Γ is the total number of training tasks, and any two distinct training tasks... and The corresponding sample data categories satisfy , i≠j .

[0010] As a preferred method for continuous learning industrial anomaly detection for edge deployment, the step of calculating the matching loss between the teacher features output by the teacher network and the student features output by the student network based on the differential enhancement knowledge distillation mechanism includes: Difference Graph Calculation and Normalization: Calculate the difference graph of the teacher network in the first... l Teacher feature map output by the layer With the student network in the l Student feature map output by layer The L2 distance, combined with the numerical stability term Normalization is performed to obtain the normalized difference map. The calculation formula is:

[0011] In the formula, B For batch size, C The number of feature channels, H , W These are the height and width of the feature map, respectively. Multiscale difference enhancement: Enhancement of normalized difference plots Perform multi-scale downsampling operations sequentially. Multi-scale upsampling operation With Sigmoid activation function Processing, through the enhancer Gain enhanced weight The calculation formula is: ; Student Feature Adaptive Augmentation: Based on Augmentation Weights Strength enhancement coefficient With the upper limit of enhanced strength Student feature map Adaptive enhancement is achieved through element-wise multiplication. With mean calculation function Enhanced student feature map The calculation formula is: ; Matching loss calculation: for teacher feature maps Compared with the enhanced student feature map Perform L2 normalization separately:

[0012] In the formula, This is the normalized teacher feature map. To enhance the student feature map after normalization, further optimization is performed on the feature hierarchy set involved in the loss calculation. L Combined with the height of the feature map H With width W Calculate L2 loss as matching loss The calculation formula is: .

[0013] As a preferred solution for continuous learning industrial anomaly detection methods for edge deployment, the steps for selecting representative samples for the current training task using the KNN Greedy sampling strategy and storing them in the replay storage unit include: Determine the feature set: Obtain the feature set of normal samples for the current training task. In the formula, For the first i The feature vector of each sample n This represents the total number of samples in the current task. Representative sample selection: from the feature set F Selected from k The target sample set consists of individual sample features. Target sample set Any two distinct eigenvectors within L2 Distance, satisfying the formula:

[0014] In the formula, This indicates the number of elements in set S; Sample storage: Select the target sample set The corresponding features are stored in the replay storage unit for subsequent replay of historical task samples.

[0015] As a preferred solution for continuous learning industrial anomaly detection methods for edge deployment, the step of compressing the sample features stored in the replay storage unit using the product quantization method includes: Batch feature extraction: Features of the samples to be compressed in the replay storage unit are extracted in batches to obtain the feature matrix. In the formula, N The total number of samples to be compressed. D For a single sample feature dimension; Unified PQ Training and Encoding: The IndexPQ module from the FAISS toolkit is used to train the feature matrix. M Perform unified PQ training to learn the optimal codebook, and use the feature matrix M Each feature vector in the matrix is ​​decomposed into m Each of the following low-dimensional sub-vectors is quantized and encoded. Tensor reshaping and storage: Tensor reshaping is performed on the quantized encoding results to decouple feature storage from compression logic, obtain compressed feature data and store it; Feature decompression: During the replay stage, the compressed feature data is read, decoded based on the optimal codebook obtained from training, and the sample features are recovered for mixed training with the current task samples.

[0016] As a preferred solution for continuous learning industrial anomaly detection methods for edge deployment, the steps of calculating anomaly scores on test data and classifying and segmenting the test data based on preset anomaly score thresholds include: Test feature extraction: Input the test data into the trained student network and extract the feature vector of the test data at a specified layer in the student network; Distance calculation: Calculate the L2 distance between the feature vector of the test data at a specified level in the student network and the feature vector of the corresponding level of the normal samples stored during training; Weighted summation: Based on the contribution of the matching loss of the specified layer during the training phase, the weight coefficients are determined, and the L2 distances of the specified layers are weighted and summed to obtain the anomaly score of the test data. Anomaly detection: An anomaly score threshold is set. When the anomaly score of the test data is higher than the anomaly score threshold, it is determined to be an abnormal sample; when the anomaly score is lower than or equal to the anomaly score threshold, it is determined to be a normal sample.

[0017] As a preferred solution for continuous learning-based industrial anomaly detection methods for edge deployment, the following also include: A lightweight, plug-and-play ResidualECA component is introduced to perform channel attention residual enhancement on the teacher features output by the teacher network and the student features output by the student network. Specifically, this includes: Feature preprocessing: processing the raw features output by the feature extractor. It is then passed through the global average pooling function in sequence. Flattening function Processing yields a one-dimensional feature vector; Channel attention weight generation: Performing 1D convolution on a one-dimensional feature vector. With Sigmoid activation function Processing and generating channel attention weights The calculation formula is: ; Residual Feature Enhancement: Channel Attention Weights With residual coefficient residual coefficient The value range is [0,1], and the result is obtained through element-wise multiplication. For original features Perform residual enhancement to obtain enhanced features. F The calculation formula is: .

[0018] Secondly, the present invention also provides a continuous learning industrial anomaly detection device for edge deployment, comprising: The data acquisition and task division module is used to acquire normal sample data in industrial scenarios, divide at least one training task according to the category of the normal sample data, and the sample data categories corresponding to different training tasks are different, and the training set and test set corresponding to the training task are obtained. A network architecture construction module is used to construct a dual network architecture including a teacher network and a student network. The dual network architecture uses a lightweight convolutional neural network as the feature extraction backbone network. The front-end parameters of the dual network architecture are shared, and only the back-end parameters of the student network are updated. The feature extraction and loss optimization module is used to input normal sample data of the specified training task into the dual network architecture according to the task order, extract the teacher features output by the teacher network and the student features output by the student network respectively, calculate the matching loss of the teacher features output by the teacher network and the student features output by the student network based on the differential enhancement knowledge distillation mechanism, and update the back-end parameters of the student network through backpropagation. The replay storage module is used to select representative samples for the current training task using the KNN Greedy sampling strategy and store them in the replay storage unit. It also uses a random sampling strategy to extract samples from the replay storage unit for historical training tasks. The extracted historical samples are mixed with the current task samples and then input into the dual network architecture. The feature compression processing module is used to compress the sample features stored in the replay storage unit using the product quantization method, and to decompress the compressed features during sample replay. The anomaly detection inference module is used to acquire test data including normal and abnormal samples after each training task, extract the features of the test data in the trained student network, calculate the anomaly score of the test data, and perform anomaly classification and segmentation of the test data according to the preset anomaly score threshold.

[0019] As a preferred solution for a continuous learning industrial anomaly detection device for edge deployment, the training set in the data acquisition and task partitioning module is represented as follows:

[0020] The test set is represented as follows:

[0021] In the formula, For the first i Training set for each training task For the first i The test set for each training task, i ≤ Γ, where Γ is the total number of training tasks, and any two distinct training tasks... and The corresponding sample data categories satisfy , i≠j .

[0022] As a preferred solution for a continuous learning industrial anomaly detection device for edge deployment, the feature extraction and loss optimization module includes: The difference graph calculation and normalization submodule is used to calculate the difference graph of the teacher network in the first... l Teacher feature map output by the layer With the student network in the l Student feature map output by layer The L2 distance, combined with the numerical stability term Normalization is performed to obtain the normalized difference map. The calculation formula is:

[0023] In the formula, B For batch size, C The number of feature channels, H , W These are the height and width of the feature map, respectively. The multi-scale difference enhancement submodule is used to enhance the normalized difference map. Perform multi-scale downsampling operations sequentially. Multi-scale upsampling operation With Sigmoid activation function Processing, through the enhancer Gain enhanced weight The calculation formula is: ; The student feature adaptive enhancement submodule is used for enhancement weights. Strength enhancement coefficient With the upper limit of enhanced strength Student feature map Adaptive enhancement is achieved through element-wise multiplication. With mean calculation function Enhanced student feature map The calculation formula is: ; The matching loss calculation submodule is used to process the teacher feature map. Compared with the enhanced student feature map Perform L2 normalization separately:

[0024] In the formula, This is the normalized teacher feature map. To enhance the student feature map after normalization, further optimization is performed on the feature hierarchy set involved in the loss calculation. LCombined with the height of the feature map H With width W Calculate L2 loss as matching loss The calculation formula is: .

[0025] As a preferred embodiment of a continuous learning industrial anomaly detection device for edge deployment, the replay storage module includes: The feature set determination submodule is used to obtain the normal sample feature set for the current training task. In the formula, For the first i The feature vector of each sample n This represents the total number of samples in the current task. The representative sample selection submodule is used to select samples from the feature set. F Selected from k The target sample set consists of individual sample features. Target sample set Any two distinct eigenvectors within L2 Distance, satisfying the formula:

[0026] In the formula, This indicates the number of elements in set S; The sample storage submodule is used to store the selected target sample set. The corresponding features are stored in the replay storage unit for subsequent replay of historical task samples.

[0027] As a preferred embodiment of a continuous learning industrial anomaly detection device for edge deployment, the feature compression processing module includes: The batch feature extraction submodule is used to extract features from the samples to be compressed in the replay storage unit in batches, and obtain the feature matrix. In the formula, N The total number of samples to be compressed. D For a single sample feature dimension; The unified PQ training and encoding submodule is used to train the feature matrix using the IndexPQ module in the FAISS toolkit. M Perform unified PQ training to learn the optimal codebook, and use the feature matrix M Each feature vector in the matrix is ​​decomposed into m Each of the following low-dimensional sub-vectors is quantized and encoded. The tensor reshaping and storage submodule is used to reshape the quantized encoding results into tensors, thereby decoupling the feature storage and compression logic, and obtaining and storing the compressed feature data. The feature decompression submodule is used to read the compressed feature data during the replay stage, decode it based on the optimal codebook obtained through training, and recover the sample features for mixed training with the current task samples.

[0028] As a preferred embodiment of a continuous learning industrial anomaly detection device for edge deployment, the anomaly detection inference module includes: The test feature extraction submodule is used to input test data into the trained student network and extract the feature vector of the test data at a specified layer in the student network. The distance calculation submodule is used to calculate the L2 distance between the feature vector of the test data at a specified level in the student network and the feature vector of the corresponding level of the normal samples stored during the training process. The weighted summation submodule is used to determine the weight coefficients based on the contribution of the matching loss of the specified layer during the training phase, and to perform weighted summation on the L2 distance of the specified layer to obtain the anomaly score of the test data. The anomaly detection submodule is used to set an anomaly score threshold. When the anomaly score of the test data is higher than the anomaly score threshold, it is determined to be an abnormal sample; when the anomaly score is lower than or equal to the anomaly score threshold, it is determined to be a normal sample.

[0029] As a preferred solution for continuous learning industrial anomaly detection devices for edge deployment, it also includes: The feature enhancement and optimization module is used to introduce a lightweight, plug-and-play ResidualECA component to enhance the channel attention residuals of the teacher features output by the teacher network and the student features output by the student network. The feature enhancement and optimization module includes: The feature preprocessing submodule is used to process the raw features output by the feature extractor. It is then passed through the global average pooling function in sequence. Flattening function Processing yields a one-dimensional feature vector; The channel attention weight generation submodule is used to perform 1D convolution operations on one-dimensional feature vectors. With Sigmoid activation function Processing and generating channel attention weights The calculation formula is: ; The residual feature enhancement submodule is used for channel attention weight-based features. With residual coefficient residual coefficient The value range is [0,1], and the result is obtained through element-wise multiplication. For original features Perform residual enhancement to obtain enhanced features. F The calculation formula is: .

[0030] Thirdly, the present invention provides an electronic device including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the program, implements the first aspect or any possible implementation thereof, a continuous learning industrial anomaly detection method for edge deployment.

[0031] Fourthly, the present invention provides a non-transitory computer-readable storage medium storing computer instructions for causing the computer to perform steps in the edge-deployed continuous learning industrial anomaly detection method of the first aspect or any possible implementation thereof.

[0032] The beneficial effects of the technical solution provided by this invention are as follows: First, this invention breaks through the limitations of existing technologies that focus only on a single need, by integrating unsupervised learning, continuous learning, and edge deployment capabilities to create, for the first time, a continuous learning unsupervised industrial anomaly detection solution adapted to edge scenarios. It avoids high sample labeling costs through the characteristics of unsupervised learning, addresses the problem of dynamic data changes in production through a continuous learning mechanism, and adapts to the resource constraints of edge devices through a lightweight design. This overcomes the shortcomings of existing technologies that cannot simultaneously meet the three core needs of industrial scenarios, thus propelling industrial anomaly detection technology from the laboratory to practical application.

[0033] Second, multi-scale enhancement and adaptive knowledge transfer are implemented to address the differences in network characteristics between teachers and students, guiding the student network to accurately learn the key hierarchical representations of the teacher network. At the same time, the lightweight ResidualECA component is used to enhance feature modeling capabilities, ensuring that the model still has high anomaly detection accuracy under a lightweight architecture. By compressing and replaying features through product quantization, the computational and storage overhead of the model is significantly reduced, enabling the model to be deployed on resource-constrained devices such as microcontrollers and edge gateways, achieving a good balance between detection accuracy and edge deployment efficiency.

[0034] Third, a KNN Greedy sampling strategy is used to select highly representative samples for the current task, ensuring the learning quality for new tasks; efficient random sampling is used for historical tasks to reduce computational redundancy, while feature compression further controls memory usage. This mechanism ensures that the model does not forget knowledge from old tasks when learning new tasks, while avoiding the resource burden of traditional replay mechanisms, significantly improving the model's generalization ability and long-term stability in dynamic industrial scenarios, and adapting to the actual production needs of continuously introducing new industrial products.

[0035] Fourth, from an economic cost perspective, this invention reduces the manpower and time investment in sample labeling through unsupervised learning, avoids the need to purchase high-performance computing equipment through edge deployment, and reduces storage hardware costs through feature compression. From a production efficiency perspective, the model has real-time detection capabilities, which can quickly identify product anomalies and feed them back to the production system, reducing the flow of defective products and lowering rework and scrap rates. These two dimensions help industrial enterprises control quality inspection costs, improve production continuity and product qualification rates, and significantly enhance enterprise production efficiency and market competitiveness. Attached Figure Description

[0036] To more clearly illustrate the technical solutions in this invention or related technologies, the drawings used in the description of the embodiments or related technologies will be briefly introduced below. Obviously, the drawings described below are only embodiments of this invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0037] Figure 1 A schematic diagram of the technical route of the continuous learning industrial anomaly detection method for edge deployment provided in an embodiment of the present invention; Figure 2 A schematic diagram of the process of a continuous learning industrial anomaly detection method for edge deployment provided in an embodiment of the present invention; Figure 3 This is a replay strategy diagram for a continuous learning industrial anomaly detection method for edge deployment provided in an embodiment of the present invention. Figure 4 This is a component architecture diagram of ResidualECA, a continuous learning industrial anomaly detection method for edge deployment provided in an embodiment of the present invention. Figure 5 A schematic diagram of the architecture of a continuous learning industrial anomaly detection device for edge deployment provided in an embodiment of the present invention; Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation

[0038] To make the objectives, technical solutions, and advantages of the present invention clearer, the present invention will be further described in detail below with reference to specific embodiments and accompanying drawings.

[0039] It should be noted that, unless otherwise defined, the technical or scientific terms used in the embodiments of this invention should have the ordinary meaning understood by those skilled in the art to which this invention pertains. The terms "comprising" or "including," or similar words used in the embodiments of this invention, mean that the element or object preceding the word encompasses the elements or objects listed following the word and their equivalents, without excluding other elements or objects.

[0040] Industrial anomaly detection, a crucial component of smart manufacturing, is a prime example of the deep integration of computer vision and industrial applications. Its core lies in identifying industrial images containing anomalies and locating the specific pixels causing these irregularities. By employing unsupervised learning techniques, industrial anomaly detection avoids the time-consuming and costly process of collecting labeling data for pixel-level anomaly annotation. This technology not only has significant application potential in the industrial sector but also enjoys wide-ranging applications in fields such as medical imaging and autonomous vehicles.

[0041] With the development of computer vision technology, a large number of industrial anomaly detection methods have emerged. These methods mainly focus on improving algorithm performance and detection accuracy, neglecting other challenging factors. Only recently have some studies considered these other challenges. For example, SoftPatch explored real-world industrial inspection scenarios with high noise levels. By setting a noise discriminator to generate outlier scores for block-level noise cancellation before core set construction, it achieved effective denoising of data at the patch level. Paste explored the challenges of deploying visual anomaly detection methods in edge scenarios with limited computing resources and analyzed the compatibility issues between existing visual anomaly detection methods and the resource constraints of edge devices. Other methods, such as ZSCIAD, explored the challenges of industrial anomaly detection (IAD) in continuous learning (CL) scenarios. Continuous learning scenarios closely reflect the problem of input data changing over time in real-world industrial production. Because new industrial products are constantly being introduced in industrial production, quality inspection of these objects is necessary to ensure that the manufactured products are intact.

[0042] In the field of Industrial Anomaly Detection (IAD), methodologies are typically categorized into unsupervised (trained using a large number of normal samples) and few-shot methods based on the availability of labeled training data. Unsupervised methods learn robust deep representations using a large number of normal samples, serving as a baseline for identifying anomalous patterns. Representative methods include PLSTM and Dinomaly. PLSTM (Periodic Sensitive Long Short-Term Memory) predicts laser welding quality by modeling dynamic pinhole behavior. This method extracts geometric features and uses Fourier and autocorrelation analyses to capture periodic patterns, achieving effective online quality assessment. Dinomaly is a multi-class unsupervised anomaly detection framework based on a pure Transformer architecture. It requires no complex design or additional modules, relying solely on attention mechanisms and multilayer perceptrons. This framework comprises four core components: a scalable general feature backbone network, dropout-based noise injection, a naturally sparse linear attention mechanism, and a relaxed reconstruction strategy, exhibiting strong scalability and adaptability, enabling unified modeling in complex scenarios without significant performance loss. Although unsupervised methods are highly effective, they require extensive annotation work, which is both time-consuming and costly.

[0043] Among related technologies, the Few-shot method can alleviate the sample labeling problem to some extent, with InCTRL and PSAD being representative methods. InCTRL improves anomaly detection performance by integrating patch-level residual learning across multiple layers of the visual encoder and using textual cues to guide the text encoder in extracting discriminative features. However, its generalization ability decreases when faced with highly variable normal patterns, indicating limitations on more complex datasets. PSAD proposes a logical anomaly detection framework that combines component segmentation with three complementary memory banks (category histogram, component combination embedding, and local patch features). While this design improves detection performance at both the local and global levels, it also incurs higher computational overhead due to its reliance on multiple memory modules. Few-shot anomaly detection technology can quickly adapt to new domains without extensive retraining, enhancing its generalization ability in dynamic industrial scenarios. However, it also has the following limitations: detection performance is highly dependent on the quality and representativeness of a small number of samples, leading to insufficient stability; it is difficult to identify subtle or complex anomalies that are highly similar to normal data; and some methods incur high computational costs due to complex models or inference strategies, which may hinder real-time applications.

[0044] While the aforementioned studies have made significant progress in their respective directions, they mostly focus on the impact of single factors on anomaly detection performance, lacking a systematic consideration of multiple practical needs. Through research on the actual application of anomaly detection in industrial scenarios, the inventors found that this task faces multiple challenges and requirements: First, the model needs to possess unsupervised learning capabilities to reduce the high cost of annotation; second, the model should support continuous learning mechanisms to adapt to the dynamic changes in input data in industrial environments; furthermore, it needs to have efficient deployment capabilities on edge devices to meet the requirements of limited computing resources in real-world scenarios. However, through a comprehensive analysis of existing methods, no work can simultaneously meet these three requirements.

[0045] In view of this, in order to promote the practical application of industrial anomaly detection technology and make up for this key deficiency, this invention is committed to unifying unsupervised learning, continuous learning and edge deployment to explore a challenging topic that has not yet been studied in depth: to build an unsupervised industrial anomaly detection (IAD) solution that can run efficiently in edge scenarios under the continuous learning (CL) framework. In order to achieve the above research goals, this invention proposes a new scheme called the continuous learning industrial anomaly detection method for edge deployment (named EdgeCLAD): (1) Closer to actual applications. Existing anomaly detection methods usually assume that the training data is static, while in real production environments, the data is often dynamically changing. In this case, the model must adapt to the dynamically changing input data. Therefore, anomaly detection in the continuous learning scenario is closer to the actual application scenario. (2) Low computational resource consumption. Considering that most of the deployment devices in real industrial scenarios are edge devices with limited computational resources, the model should have the ability to be efficiently deployed on edge devices to meet the requirements of limited computational resources in real scenarios. (3) Reduce high labeling costs. The model needs to have unsupervised learning capabilities to reduce the high cost of sample labeling. The following are the specific details of the embodiments of the invention.

[0046] See Figure 1 , Figure 2 and Figure 3 This invention provides a continuous learning industrial anomaly detection method for edge deployment, comprising the following steps: S1. Data Acquisition and Task Division: Acquire normal sample data in industrial scenarios, and divide at least one training task according to the category of the normal sample data. The sample data categories corresponding to different training tasks are different, and training sets and test sets corresponding to the training tasks are obtained. Specifically, in step S1, firstly, collecting only normal sample data is to achieve unsupervised learning and avoid the high cost of labeling abnormal samples. In industrial scenarios, abnormal samples are scarce and labeling requires professional personnel to confirm pixel by pixel, while normal samples are easy to obtain and do not require complex labeling. Secondly, dividing training tasks into different categories is because different categories of industrial products, such as resistors and capacitors in electronic components, have significant differences in appearance and structure. The model needs to learn specific normal feature patterns for each product category to avoid cross-category data interference that leads to a decrease in detection accuracy. Finally, dividing the training set and test set accordingly is to independently and comprehensively evaluate the model's detection capability for that type of product after training for each task, while also laying a data foundation for subsequent cross-task testing.

[0047] S2. Network Architecture Construction: Construct a dual-network architecture including a teacher network and a student network. The dual-network architecture uses a lightweight convolutional neural network as the feature extraction backbone network. The front-end parameters of the dual-network architecture are shared, and only the back-end parameters of the student network are updated. Specifically, in step S2, a lightweight convolutional neural network is used as the backbone network because edge devices (such as microcontrollers and industrial edge gateways) typically have low memory and limited computing power. The lightweight network, by simplifying the number of convolutional kernels and optimizing the number of network layers, can significantly reduce memory usage and inference latency, meeting the real-time edge detection requirements. A dual-network architecture is constructed, utilizing the concept of knowledge distillation. The teacher network typically possesses stronger feature extraction capabilities and can learn more robust normal pattern features, while the student network improves accuracy by mimicking the teacher network's features. Front-end parameter sharing is set because the network's front-end extracts general features, which are common across different industrial products; sharing parameters reduces redundant computation and memory consumption. Only the student network's back-end parameters are updated because the back-end network extracts specific features. Targeted updates allow the student network to quickly adapt to the specific features of new tasks while inheriting the teacher's general features, while avoiding the impact of teacher network parameter fluctuations on the overall feature learning stability.

[0048] S3. Feature Extraction and Loss Optimization: Normal sample data of the specified training task are input into the dual network architecture according to the task order. The teacher features output by the teacher network and the student features output by the student network are extracted respectively. The matching loss of the teacher features output by the teacher network and the student features output by the student network is calculated based on the differential enhancement knowledge distillation mechanism. The back-end parameters of the student network are updated through backpropagation. Specifically, in step S3, data is input sequentially according to the task order, aligning with the "task-by-task learning" logic of continuous learning. This ensures the model first masters the normal features of the preceding task before learning the features of the new task, avoiding knowledge interference caused by data mixing between tasks. After extracting teacher and student features, the essence of calculating the matching loss is to make the features output by the student network as close as possible to the features of the teacher network. The teacher network has already learned a better representation of normal patterns, and the student network can indirectly master high-quality normal features by minimizing the difference between its features and those of the teacher. The difference-enhanced knowledge distillation (DEKD) mechanism is used instead of traditional knowledge distillation because traditional distillation simply compares the differences between teacher and student features, easily ignoring key difference regions related to anomalies. DEKD enhances the difference map at multiple scales and adaptively adjusts the knowledge transfer intensity, allowing the student network to focus on learning the teacher's features in key regions, improving its ability to perceive anomalies. Finally, the back-end parameters of the student network are updated through backpropagation because the back-end parameters correspond to task-specific features. After updating, the student network can accurately adapt to the normal features of the current task while retaining the shared general features from the previous stages, balancing learning efficiency and knowledge reuse.

[0049] S4. Replay Mechanism Design: For the current training task, a KNN Greedy sampling strategy is used to select representative samples and store them in the replay storage unit. For the historical training task, a random sampling strategy is used to extract samples from the replay storage unit. The extracted historical samples are mixed with the current task samples and then input into the dual network architecture. Specifically, in step S4, the replay storage unit serves to preserve key knowledge from old tasks. By training with a mixture of historical and current samples, the model "reviews" knowledge from old tasks while learning new ones, achieving coexistence of new and old knowledge. KNN Greedy sampling is used for the current task because it is in the training phase, requiring the selection of the most representative samples (i.e., samples that cover the normal feature distribution of the current task) to be stored in the storage unit. KNN Greedy maximizes the L2 distance between samples, ensuring high sample diversity and low redundancy, efficiently representing the normal feature patterns of the current task and avoiding the waste of edge device memory by storing a large number of duplicate samples. Random sampling is used for historical tasks because they have already been trained, and the samples stored in their storage units are already representative. Random sampling can cover the feature distribution of old tasks while avoiding the high computational overhead of repeatedly performing KNN Greedy sampling. The essence of mixed sample training is joint optimization. In one training session, the model simultaneously learns new features of the current task and features already learned from old tasks, updating parameters synchronously through gradient descent to achieve a balanced memorization of new and old knowledge.

[0050] S5. Feature compression processing: The sample features stored in the replay storage unit are compressed using the product quantization method, and the compressed features are decompressed during sample replay. Specifically, in step S5, the number of continuous learning tasks in industrial scenarios may reach dozens. Directly storing the original sample features would quickly exhaust the limited memory of edge devices. The advantage of the Product Quantization (PQ) method lies in its efficient dimensionality reduction. It decomposes high-dimensional feature vectors into multiple low-dimensional sub-vectors, independently quantizes and encodes each sub-vector, and represents each sub-vector with a small number of bits, significantly reducing the feature storage capacity. Batch processing and the FAISS IndexPQ module can be used. Batch processing can improve compression efficiency and avoid frequent I / O operations for sample-by-sample compression. The IndexPQ module of the FAISS toolkit can generate the optimal codebook by learning the data distribution, ensuring low distortion of compressed features and retaining the key information of the original features after decompression, without affecting the model's "review" effect on old task knowledge.

[0051] S6. Anomaly Detection Inference: After each training task, acquire test data including normal and abnormal samples, extract features of the test data in the trained student network, calculate the anomaly score of the test data, and classify and segment the test data according to the preset anomaly score threshold.

[0052] Specifically, in step S6, the student network is selected for inference because it is a lightweight architecture with fast inference speed and low resource consumption, making it suitable for real-time detection needs of edge devices. The teacher network, on the other hand, is only used for knowledge transfer during the training phase and does not participate in inference to save resources. After extracting test data features, calculating the anomaly score essentially involves "comparing the differences between normal and test features." The model has mastered the normal feature patterns of the current task through training. If the test sample is a normal sample, its features differ little from normal features; if it is an anomaly sample, its defective areas will cause significant differences between its features and normal features. A weighted summation of L2 distance is used to calculate the anomaly score because features at different network levels have different sensitivities to anomalies. For example, features at later layers correspond to product-specific structures and are more sensitive to subtle defects. By determining the weights based on the contribution of the matching loss during the training phase, the differences at sensitive layers can account for a higher proportion in the anomaly score, improving detection accuracy. An anomaly score threshold is set to convert continuous anomaly scores into discrete classification results. The threshold needs to be adjusted according to the specific industrial scenario. For example, a higher threshold is set for high-precision detection scenarios to reduce missed detections, and a lower threshold is set for high-speed scenarios to reduce false detections. Anomaly segmentation is achieved by locating pixel regions with large differences in features to accurately label the defect location.

[0053] In this embodiment, in step S1, the training set is represented as:

[0054] The test set is represented as follows:

[0055] In the formula, For the first i Training set for each training task For the first i The test set for each training task, i ≤ Γ, where Γ is the total number of training tasks, and any two distinct training tasks... and The corresponding sample data categories satisfy , i≠ j .

[0056] Specifically, both the training and test sets are used in a union format. Because tasks are introduced progressively in continuous learning, the model needs to add the training / test set of the new task to the overall dataset after training for each task, facilitating subsequent cross-task testing. Clearly define the scope of the current tasks to avoid exceeding the preset total number of tasks and causing data corruption. (Emphasis) , i≠j Mathematical constraints ensure that data categories are mutually exclusive between tasks, preventing data from different product categories from being mixed into the same task and causing the normal feature patterns learned by the model to become blurred.

[0057] In this embodiment, step S3, which calculates the matching loss between the teacher features output by the teacher network and the student features output by the student network based on the differential enhancement knowledge distillation mechanism, includes: S31. Difference Map Calculation and Normalization: Calculate the difference map of the teacher network in the... l Teacher feature map output by the layer With the student network in the l Student feature map output by layer The L2 distance, combined with the numerical stability term Normalization is performed to obtain the normalized difference map. The calculation formula is:

[0058] In the formula, B For batch size, C The number of feature channels, H , W These represent the height and width of the feature map, respectively; first, select the... l The difference calculation is performed on the layer feature maps. Different layers of features correspond to information with different levels of abstraction, and the difference needs to be calculated layer by layer to accurately capture the feature matching situation at each layer. Feature map dimension The definition clarifies the composition of features: B (Batch size) determines the number of samples to be computed at one time, adapting to the parallel computing capabilities of edge devices; C(Number of channels) corresponds to the dimension of the feature (such as color, texture channels); H , W The spatial resolution of the corresponding feature map ensures that the difference calculation can pinpoint specific pixel regions. The L2 distance is calculated because it effectively measures the overall difference between two feature vectors; a larger value indicates a greater mismatch between teacher and student features. A numerical stability term is introduced. ε To avoid denominators of 0 and prevent overflow of calculation results due to excessively small denominators, normalization compresses the difference map values ​​to the [0, 1] interval, eliminating the influence of differences in feature scales at different levels. This allows subsequent multi-scale enhancements to be performed at a unified scale, improving processing consistency.

[0059] S32. Multi-scale difference enhancement: Enhancement of normalized difference maps Perform multi-scale downsampling operations sequentially. Multi-scale upsampling operation With Sigmoid activation function Processing, through the enhancer Gain enhanced weight The calculation formula is: Multi-scale downsampling captures global difference patterns. Downsampling expands the receptive field, allowing the model to perceive a wider range of feature differences and avoiding being limited to small differences caused by local noise. Multi-scale upsampling maps global difference patterns back to the original feature map resolution, ensuring that the enhancement weights are accurately aligned with the original feature map, achieving pixel-level difference enhancement. The Sigmoid activation function compresses the enhancement result to the [0, 1] interval, and the output enhancement weights... This can be understood as a "difference importance coefficient," where a value close to 1 indicates that the difference in that region is more important for anomaly detection, and a value close to 0 indicates that the difference in that region is irrelevant noise. This is achieved through an enhancer. By integrating multi-scale operations and activation functions, an end-to-end difference enhancement process is formed, which can automatically identify key difference regions without manual intervention and improve the model's sensitivity to subtle anomalies.

[0060] S33. Student Feature Adaptive Enhancement: Based on Enhancement Weights Strength enhancement coefficient With the upper limit of enhanced strength Student feature map Adaptive enhancement is achieved through element-wise multiplication. With mean calculation function Enhanced student feature map The calculation formula is: ; Enhance weight Differences in characteristics between teachers and students ( ) perform element-wise multiplication to identify key difference regions ( The feature correction magnitude is larger for values ​​that are large, and for irrelevant regions ( Smaller values ​​result in smaller correction amplitudes, enabling on-demand enhancement. An enhancement intensity coefficient ρ is introduced to globally adjust the enhancement level; a larger ρ value leads to a more significant enhancement effect, but an excessively large value may cause student characteristics to deviate from the normal pattern. Conversely, a smaller ρ value results in a weaker enhancement effect, which may not be able to compensate for differences in teacher and student characteristics. An upper limit for enhancement intensity is set. ,pass Limiting the maximum enhancement amplitude prevents excessive local regional differences from distorting student features after enhancement, thus ensuring the stability of the enhancement process. Mean calculation function. Its function is to dynamically adjust the enhancement intensity based on the overall difference level of the current level. If the overall difference is large, the enhancement amplitude will be appropriately reduced; if the overall difference is small, the enhancement amplitude will be appropriately increased, thus achieving adaptive adjustment across levels.

[0061] S34. Matching Loss Calculation: Calculate the teacher feature map. Compared with the enhanced student feature map Perform L2 normalization separately:

[0062] In the formula, This is the normalized teacher feature map. To enhance the student feature map after normalization, further optimization is performed on the feature hierarchy set involved in the loss calculation. L Combined with the height of the feature map H With width W Calculate L2 loss as matching loss The calculation formula is: ; Specifically, L2 normalization is first performed to eliminate the influence of differences in feature vector magnitudes. If the feature magnitude of teachers is much larger than that of students, directly calculating the L2 loss will be dominated by the magnitude and cannot truly reflect the differences in feature direction. After normalization, the feature magnitudes are all 1, and the loss is determined only by the differences in feature direction, which is more in line with the goal of learning feature patterns. The set L of feature levels participating in the loss calculation is limited because different levels contribute differently to anomaly detection. The specific features extracted in later levels are more correlated with product defects, and their matching loss has a greater impact on model accuracy. Focusing on key levels can reduce noise interference from irrelevant levels and improve training efficiency. This is combined with the feature map width and height. H , W Calculate the loss and normalize the loss value. (This refers to feature maps at different levels.) H , W Different, divide by 2 HW This ensures that the contribution of losses at different levels remains consistent, preventing a particular level from being negatively impacted. H , WA large loss value leads to an excessively high proportion of losses; it's crucial to ensure that losses across all key levels guide parameter updates in a balanced manner. The final matching loss... It is the sum of the losses at each level. Through backpropagation, the loss is transformed into the update gradient of the parameters of the student network in the later stages, so that the student network gradually approaches the feature pattern of the teacher network at key levels, thereby improving the ability to distinguish between normal and abnormal samples.

[0063] In this embodiment, step S4, which involves selecting representative samples for the current training task using the KNN Greedy sampling strategy and storing them in the replay storage unit, includes: S41. Determine the feature set: Obtain the feature set of normal samples for the current training task. In the formula, For the first i The feature vector of each sample n This represents the total number of samples in the current task. Specifically, selecting sample features instead of original samples is because features have already undergone dimensionality compression and information extraction. Storing features can significantly reduce the memory footprint of replay storage units, adapting to the resource constraints of edge devices. Feature set Features encompassing all normal samples for the current task are included to ensure that sampling covers the complete feature distribution of the task and avoids insufficient representativeness due to missing data. Definition For feature vectors, n Given the total number of samples, the sampling algorithm can quantify the differences between samples through vector operations, providing a mathematical basis for selecting representative samples.

[0064] S42. Representative Sample Selection: From Feature Set F Selected from k The target sample set consists of individual sample features. Target sample set Any two distinct eigenvectors within L2 Distance, satisfying the formula:

[0065] In the formula, This indicates the number of elements in set S; Specifically, in the formula, " "and" The combination of "" is essentially in all possible k a sample subset S Find a subset in This maximizes the minimum L2 distance between any two samples within the subset. This selection method effectively avoids selecting similar samples, allowing... The samples are evenly distributed in the feature space to cover the normal feature distribution of the current task to the greatest extent. For example, if the normal sample features of the current task are distributed in a circle, KNN Greedy sampling will select the samples that are farthest from the center of the circle. k The goal is to store samples that, rather than those concentrated near the center, represent key information about the entire distribution. Control storage overhead. Since the device has limited memory, it's necessary to pre-determine storage requirements based on the available memory. k Values ​​should be set to avoid sampling too many samples, which could lead to memory overflow; at the same time k The value needs to be large enough to ensure representativeness and avoid the model not fully remembering the old task knowledge when replaying training because the sample size is too small to cover the feature distribution.

[0066] S43. Sample Storage: Store the selected target sample set. The corresponding features are stored in the replay storage unit for subsequent replay of historical task samples; Specifically, storing the target sample set Instead of using original samples, storing features reduces memory usage and the number of feature extraction steps during subsequent replays. Replays can directly use stored features without needing to re-input the original samples to the network for feature extraction, significantly reducing computational overhead on edge devices and meeting real-time detection requirements. The replay storage unit uses task partitioning management, facilitating rapid location of historical task feature data during subsequent random sampling and avoiding sampling confusion caused by mixing features from different tasks. Stored features must be associated with task identifiers to ensure that subsequent replays clearly identify the historical task to which the sample belongs, allowing the model to clearly understand which task's knowledge it is "reviewing" during mixed training and avoiding knowledge confusion.

[0067] In this embodiment, step S5, which involves compressing the sample features stored in the replay storage unit using a product quantization method, includes: S51. Batch Feature Extraction: Extract features from the samples to be compressed in the replay storage unit in batches to obtain the feature matrix. In the formula, N The total number of samples to be compressed. D For a single sample feature dimension; Specifically, using batch extraction instead of sample-by-sample extraction reduces the number of I / O interactions in storage units. Furthermore, subsequent PQ training and encoding support batch operations, significantly improving processing speed. Feature matrix The definition will N one sample D The dimensional features are integrated into a matrix form, facilitating subsequent quantization processing based on matrix operations. Matrix operations can be accelerated in hardware, offering higher efficiency compared to sample-by-sample vector operations. N (Total number of samples to be compressed) and D(Feature dimension) is used to determine the key parameters for PQ quantization, ensure the mathematical rationality of the quantization process, and avoid compression failure due to parameter mismatch.

[0068] S52, Unified PQ Training and Encoding: The IndexPQ module in the FAISS toolkit is used to train and encode the feature matrix. Perform unified PQ training to learn the optimal codebook, and use the feature matrix Each feature vector in the model is decomposed into m low-dimensional sub-vectors, and each sub-vector is quantized and encoded. Specifically, the essence of unified PQ training is learning the data distribution. The IndexPQ module uses the K-means clustering algorithm to cluster each sub-vector dimension of all feature vectors to be compressed, generating a dictionary containing multiple cluster centers, with each cluster center corresponding to an encoding. High-dimensional feature vectors are decomposed into m low-dimensional sub-vectors because direct quantization of high-dimensional vectors easily leads to severe distortion, while quantization of low-dimensional sub-vectors better preserves local feature information and reduces distortion. Each sub-vector is independently quantized and encoded, mapping each sub-vector to its nearest cluster center encoding. Ultimately, each high-dimensional feature vector only needs to store m encodings, significantly reducing storage compared to the original feature vector and effectively saving memory on edge devices.

[0069] S53. Tensor Reshaping and Storage: Tensor reshaping is performed on the quantized encoding results to decouple feature storage from compression logic, obtain compressed feature data and store it. Specifically, the quantized encoding result is typically a two-dimensional matrix. Tensor reshaping can convert it into a format suitable for storage units, while making the storage structure independent of specific compression parameters, thus decoupling storage and compression logic. If compression parameters are adjusted subsequently, only the compression logic needs to be modified, without adjusting the storage structure, reducing module maintenance costs. When storing compressed feature data, the corresponding codebook information must be stored synchronously to ensure that features can be recovered based on the same codebook during subsequent decompression, avoiding decompression failure due to codebook loss. A compact storage format is adopted to further reduce storage overhead and avoid wasting memory due to storage format redundancy.

[0070] S54. Feature decompression: During the replay stage, the compressed feature data is read, and the data is decoded based on the optimal codebook obtained from training to recover the sample features for mixed training with the current task samples. Specifically, when reading compressed data, the corresponding codebook information must first be obtained. Then, decoding is performed according to the sub-vector-cluster center mapping, mapping the encoding of each sub-vector back to its corresponding cluster center vector. Finally, the m low-dimensional sub-vectors are concatenated into a complete D-dimensional feature vector, completing the decompression. The decoding process must ensure parameter consistency with the encoding process; otherwise, the recovered features will differ significantly from the original features, affecting the model's "review" effect on old task knowledge. The decompressed features need to undergo consistency verification, calculating the L2 distance between the recovered features and the original features to ensure the error is within a preset range. This avoids feature distortion due to hardware failure or data corruption, ensuring the reliability of historical feature data used during replay training. The recovered features are directly used for hybrid training without needing to be extracted again through the network, significantly reducing the computational latency of edge devices and meeting the needs of real-time review in continuous learning.

[0071] In this embodiment, step S6, which involves calculating the anomaly score of the test data and classifying and segmenting the test data according to a preset anomaly score threshold, includes: S61. Test Feature Extraction: Input the test data into the trained student network and extract the feature vector of the test data at a specified layer of the student network. Specifically, a student network is chosen over a teacher network for feature extraction because the student network has a lightweight architecture, fast inference speed, and low memory consumption, meeting the real-time detection needs of edge devices. The teacher network, on the other hand, is only used for knowledge transfer during the training phase and does not participate in inference to save resources. The designated layer is usually a later layer of the student network because later layers extract product-specific features, which have a stronger correlation with anomalies and can more accurately reflect the degree of anomalies in the test data compared to the general features extracted earlier layers. Feature vectors are extracted instead of feature maps because vector form is easier to calculate L2 distance later, and feature vectors have already undergone spatial dimensionality compression, reducing the amount of data required for subsequent calculations and improving detection efficiency.

[0072] S62. Distance Calculation: Calculate the L2 distance between the feature vector of the test data at a specified level in the student network and the feature vector of the corresponding level of the normal samples stored during the training process. Specifically, choosing L2 distance as the difference metric effectively reflects the overall degree of difference between two vectors. If the test sample is a normal sample, its feature vector has a smaller L2 distance compared to normal feature vectors; if it is an abnormal sample, defective regions will cause the feature vector to deviate from the normal pattern, resulting in a larger L2 distance. Calculating the feature distance at the corresponding level is crucial because features at different levels have different meanings. Comparing only the corresponding level avoids meaningless calculations of cross-level feature differences, improving the accuracy of difference quantification. The normal sample features stored during training are usually from the target sample set. The features are highly representative and can cover the normal feature distribution. Using them to calculate the distance can ensure the reliability of the difference measure and avoid misjudgment caused by improper selection of normal feature samples.

[0073] S63. Weighted summation: Based on the contribution of the matching loss of the specified level during the training phase, the weight coefficients are determined, and the L2 distance of the specified level is weighted and summed to obtain the anomaly score of the test data. Specifically, the contribution of a specified level's matching loss refers to the proportion of that level's matching loss in the total matching loss during training. A higher contribution indicates that the features of that level are more important for the model to learn normal patterns, and the corresponding L2 distance has greater reference value for anomaly detection. For example, if the matching loss contribution of a certain level in the later stages is 30% (the highest total contribution), then it should be assigned a higher weight (e.g., 0.3) to ensure that the L2 distance of that level accounts for a higher proportion of the anomaly score, thus ensuring that anomalies can be effectively identified. Weighted summation, rather than simple averaging, avoids the accuracy loss caused by all levels contributing equally. Assigning the same weight to earlier levels with low contribution and later levels with high contribution will dilute the anomaly indication effect of later levels, making the model insensitive to subtle anomalies. The anomaly score typically ranges from [0, +∞), with a larger value indicating a greater difference between the test data and the normal pattern, and a higher anomaly probability.

[0074] S64. Anomaly detection: Set an anomaly score threshold. When the anomaly score of the test data is higher than the anomaly score threshold, it is determined to be an abnormal sample; when the anomaly score is lower than or equal to the anomaly score threshold, it is determined to be a normal sample. Specifically, the anomaly score threshold needs to be determined through validation set tuning. After model training, a validation set containing both normal and anomaly samples is used to test the detection performance under different thresholds, and the threshold with the best overall performance is selected as the final judgment criterion. For example, in the scenario of electronic component inspection, if it is necessary to prioritize avoiding missed detections (missed detections will lead to unqualified products entering the market), a lower threshold is set, such as allowing the recall rate to reach above 99%; if it is necessary to prioritize avoiding false detections, a higher threshold is set, such as allowing the accuracy rate to reach above 99%. The implementation logic of anomaly segmentation is based on pixel-level feature differences. When calculating feature distance, if the spatial dimension of the feature map is preserved, an anomaly heatmap can be generated through pixel-level L2 distance. Areas with values ​​higher than the threshold in the heatmap are the anomaly segmentation results, achieving accurate location of defects and providing a specific basis for subsequent production adjustments.

[0075] See Figure 4 In one possible embodiment, it further includes: A lightweight, plug-and-play ResidualECA component is introduced to perform channel attention residual enhancement on the teacher features output by the teacher network and the student features output by the student network. Specifically, this includes: Feature preprocessing: processing the raw features output by the feature extractor. The vectors are processed sequentially by the global average pooling function AvgPool(·) and the flattening function Flatten(·) to obtain a one-dimensional feature vector. Specifically, original features Including spatial and channel dimensions, the global average pooling function AvgPool(·) calculates the spatial mean of each channel, separating features from... B×C×H×W Compress to B×C×1×1 This eliminates redundant information in the spatial dimension while preserving the global statistical characteristics of each channel. The flatten function Flatten(·) will... B×C×1 ×1 The features are further converted into B×C The one-dimensional feature vector provides a suitable input format for subsequent 1D convolution operations. 1D convolution excels at processing sequential data and has lower computational complexity than 2D convolution, meeting the lightweight requirements of edge devices. The preprocessing process does not change the number of channels C, ensuring that the subsequently generated attention weights correspond one-to-one with the channels of the original features, achieving accurate channel-level enhancement.

[0076] Channel attention weight generation: 1D convolution operation Conv1d(·) and Sigmoid activation function on a one-dimensional feature vector. Processing and generating channel attention weights The calculation formula is: The 1D convolution operation Conv1d(·) models the dependencies between channels. By setting an appropriate kernel size, the weight calculation of each channel references the information of its neighboring channels, avoiding the isolated calculation of the importance of a single channel and improving the rationality of the weights. For example, in industrial images, the "edge" channel and the "texture" channel are strongly correlated. 1D convolution can capture this correlation, allowing the weights of the two channels to influence each other, which is more in line with the semantic association of actual features. The Sigmoid activation function compresses the convolution output to the [0, 1] interval, generating channel attention weights. This can be understood as a "channel importance coefficient," where a value close to 1 indicates that the channel is more important for anomaly detection, and a value close to 0 indicates that the channel contains redundant information. The end-to-end design of the formula ensures that the attention weights can be dynamically optimized during model training, eliminating the need for manual weight setting and improving the module's adaptability.

[0077] Residual Feature Enhancement: Channel Attention Weights The residual coefficient α (within the range of [0, 1]) is used to multiply the original features element-wise. Residual enhancement is performed to obtain the enhanced feature F, and the calculation formula is as follows: ; Specifically, This indicates that the original features are weighted at the channel level, with important channels ( The characteristics of large values ​​are preserved or even enhanced, and redundant channels ( Features with small values ​​are suppressed, thereby highlighting key features related to anomaly detection (such as channel features corresponding to product defects) and reducing interference from irrelevant information such as background noise. The calculation focuses on the difference between the weighted features and the original features, reflecting the extent to which channel attention adjusts the original features; a residual coefficient is introduced. α (Values ​​[0, 1]) allow for flexible control of the reinforcement strength. α The higher the value, the greater the enhancement, making it suitable for scenarios with high noise levels and unclear key features. α A smaller value results in a smaller enhancement, suitable for scenarios with clear features and low noise, avoiding the disruption of the original feature's normal pattern due to excessive enhancement. The adjusted difference is then connected to the original feature via residual linking. The two features are combined to form the original features and the enhanced features F, which retain the basic information of the original features while incorporating the optimization effect of channel attention, making the enhanced features more suitable for anomaly detection requirements. This lightweight design does not significantly increase the computational and memory overhead of the model, can adapt to the deployment constraints of edge devices, and effectively improves the feature representation capability.

[0078] The application scenarios of this invention are as follows: Scenario 1: Quality Inspection in the Manufacturing of Electronic Components In the mass production of electronic components, real-time detection of component appearance defects (such as pin deformation, surface scratches, and package damage) is required. In such scenarios, production lines are typically equipped with industrial cameras and edge gateways, requiring the detection system to operate with low latency on resource-constrained edge devices. Simultaneously, as component models iterate, detection tasks need to be dynamically added, and the model must possess continuous learning capabilities to adapt to the normal feature patterns of new component categories. Furthermore, abnormal samples are scarce and labeling is costly, necessitating unsupervised learning capabilities that rely solely on normal samples for training.

[0079] This invention can be deployed via a lightweight MCUNet backbone network adapted to edge gateways, receiving component images transmitted from industrial cameras in real time on the production line; it stores representative normal features of historical component models through a replay mechanism, and mixes historical samples with current samples for training when adding new models, avoiding the model forgetting the detection capabilities of old models; relying on the characteristics of unsupervised learning, training can be completed using only normal samples of new models, without the need to label abnormal samples, greatly reducing the labeling cost for enterprises, ensuring that the defect detection accuracy of each batch of components is stable at over 99%, and preventing unqualified products from flowing into the downstream assembly stage.

[0080] Scenario 2: Defect screening in automotive parts processing: In the manufacturing process of automotive parts, defects such as surface cracks, dimensional deviations, and incomplete welds need to be detected. These detection devices are often deployed on microcontrollers or industrial edge terminals near the production line (where computing resources are limited). The core requirements for this scenario include: first, the need to adapt to the dynamic detection of multiple types of parts, such as alternating production of engine blocks and transmission housings on the same production line, requiring the model to continuously learn the normal characteristics of different parts; second, the need for real-time feedback of detection results to the production line control system to adjust processing parameters promptly; and third, the need for models with strong feature representation capabilities to distinguish noise from real defects, given that part surfaces are susceptible to interference from oil stains and metal debris (high-noise scenarios).

[0081] This invention enhances the learning of key defect features by the teacher-student network through the DEKD (Differential Knowledge Distillation) mechanism, and effectively suppresses noise interference such as oil stains and debris by combining the channel attention enhancement of the ResidualECA component, thereby improving the robustness of defect identification. The OneShotPQ product quantization method is used to compress the feature data of the replay storage unit, adapting to the limited memory of the MCU. When switching part types on the production line, the model quickly learns the normal mode of the new part through continuous learning, and at the same time avoids forgetting the detection capability of old parts by replaying historical samples, ensuring that the detection latency is controlled within 50ms, meeting the real-time adjustment needs of the production line.

[0082] Scenario 3: Defect Monitoring in Textile Fabric Production Process In the continuous production of textile fabrics (such as cotton, synthetic fiber, and knitted fabrics), it is necessary to detect defects such as broken yarns, skipped stitches, and stains on the fabric surface online. The detection equipment is typically an edge detection device with integrated cameras, deployed at the winding end of the fabric production line. It needs to achieve real-time defect location and classification while the fabric is moving at high speed. The characteristics of this scenario include: first, a wide variety of fabrics, such as switching from plain weave to twill, with detection tasks dynamically increasing with fabric type, requiring continuous model learning; second, defects are often subtle features, such as broken yarns only 0.1-0.2mm wide, requiring the model to have high-precision feature extraction capabilities; and third, edge detection devices have limited memory and computing power, making it impossible to run large detection models.

[0083] This invention employs a lightweight dual-network architecture, updating only the back-end parameters of the student network to reduce computational overhead and ensure an image detection rate of 20-30 frames per second on the edge detection device, matching high-speed fabric movement scenarios. A KNNGreedy sampling strategy is used to select representative features of normal fabric samples, maximizing the L2 distance between samples to cover the complete distribution of fabric texture. These features are stored in a OneShotPQ compressed replay storage unit, enabling rapid continuous learning when switching fabric types. In the anomaly detection inference stage, the weighted L2 distance between test data and normal features is calculated to accurately locate the pixel positions of subtle defects, generating a defect heatmap that is fed back to the production system, achieving real-time interception of fabric defects and reducing the mass production of defective fabrics. It should be noted that the method of this embodiment can be executed by a single device, such as a computer or server. This method can also be applied to distributed scenarios, where multiple devices cooperate to complete the task. In this distributed scenario, one of the multiple devices may execute only one or more steps of the method in this embodiment of the invention. These multiple devices will interact with each other to complete the continuous learning industrial anomaly detection method for edge deployment.

[0084] It should be noted that the above description describes some embodiments of the present invention. In some cases, the described actions or steps can be performed in a different order than that shown in the above embodiments and the desired result can still be achieved. Furthermore, the processes depicted in the accompanying drawings do not necessarily require a specific or sequential order to achieve the desired result. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0085] See Figure 5 Based on the same inventive concept, and corresponding to the methods of any of the above embodiments, this embodiment of the invention also provides a continuous learning industrial anomaly detection device for edge deployment, comprising: The data acquisition and task division module 100 is used to acquire normal sample data in an industrial scenario, divide at least one training task according to the category of the normal sample data, and the sample data categories corresponding to different training tasks are different, and the training set and test set corresponding to the training task are obtained. The network architecture construction module 200 is used to construct a dual network architecture including a teacher network and a student network. The dual network architecture uses a lightweight convolutional neural network as the feature extraction backbone network. The front-end parameters of the dual network architecture are shared, and only the back-end parameters of the student network are updated. The feature extraction and loss optimization module 300 is used to input normal sample data of the specified training task into the dual network architecture according to the task order, extract the teacher features output by the teacher network and the student features output by the student network respectively, calculate the matching loss of the teacher features output by the teacher network and the student features output by the student network based on the differential enhancement knowledge distillation mechanism, and update the back-end parameters of the student network through backpropagation. The replay storage module 400 is used to select representative samples for the current training task using the KNN Greedy sampling strategy and store them in the replay storage unit, and to extract samples from the replay storage unit for the historical training task using a random sampling strategy. The extracted historical samples are mixed with the current task samples and then input into the dual network architecture. The feature compression processing module 500 is used to compress the sample features stored in the replay storage unit using the product quantization method, and to decompress the compressed features during sample replay. The anomaly detection inference module 600 is used to acquire test data including normal samples and abnormal samples after each training task, extract the features of the test data in the trained student network, calculate the anomaly score of the test data, and perform anomaly classification and anomaly segmentation of the test data according to the preset anomaly score threshold.

[0086] In this embodiment, the training set in the data acquisition and task partitioning module 100 is represented as follows:

[0087] The test set is represented as follows:

[0088] In the formula, For the first i Training set for each training task For the first i The test set for each training task, i ≤ Γ, where Γ is the total number of training tasks, and any two distinct training tasks... and The corresponding sample data categories satisfy , i≠ j .

[0089] In this embodiment, the feature extraction and loss optimization module 300 includes: The difference graph calculation and normalization submodule 301 is used to calculate the difference graph of the teacher network in the first... l Teacher feature map output by the layer With the student network in the l Student feature map output by layer The L2 distance, combined with the numerical stability term Normalization is performed to obtain the normalized difference map. The calculation formula is:

[0090] In the formula, B For batch size, C The number of feature channels, H , W These are the height and width of the feature map, respectively. Multi-scale difference enhancement submodule 302 is used to enhance the normalized difference map. Perform multi-scale downsampling operations sequentially. Multi-scale upsampling operation With Sigmoid activation function Processing, through the enhancer Gain enhanced weight The calculation formula is: ; Student feature adaptive enhancement submodule 303, used for enhancement weights Strength enhancement coefficient With the upper limit of enhanced strength Student feature map Adaptive enhancement is achieved through element-wise multiplication. With mean calculation function Enhanced student feature map The calculation formula is: ; Matching loss calculation submodule 304 is used for teacher feature maps Compared with the enhanced student feature map Perform L2 normalization separately:

[0091] In the formula, This is the normalized teacher feature map. To enhance the student feature map after normalization, further optimization is performed on the feature hierarchy set involved in the loss calculation. L Combined with the height of the feature map H With width W Calculate L2 loss as matching loss The calculation formula is: .

[0092] In this embodiment, the replay storage module 400 includes: The feature set determination submodule 401 is used to obtain the normal sample feature set for the current training task. In the formula, For the first iThe feature vector of each sample n This represents the total number of samples in the current task. Representative sample selection submodule 402 is used to select samples from the feature set. F Selected from k The target sample set consists of individual sample features. Target sample set Any two distinct eigenvectors within L2 Distance, satisfying the formula:

[0093] In the formula, This indicates the number of elements in set S; Sample storage submodule 403 is used to store the selected target sample set The corresponding features are stored in the replay storage unit for subsequent replay of historical task samples.

[0094] In this embodiment, the feature compression processing module 500 includes: Batch feature extraction submodule 501 is used to extract features from the samples to be compressed in the replay storage unit in batches to obtain feature matrices. In the formula, N The total number of samples to be compressed. D For a single sample feature dimension; Unified PQ training and encoding submodule 502 is used to train the feature matrix using the IndexPQ module in the FAISS toolkit. M Perform unified PQ training to learn the optimal codebook, and use the feature matrix M Each feature vector in the matrix is ​​decomposed into m Each of the following low-dimensional sub-vectors is quantized and encoded. Tensor reshaping and storage submodule 503 is used to reshape the quantized encoding result into a tensor, thereby decoupling the feature storage and compression logic, and obtaining and storing the compressed feature data. The feature decompression submodule 504 is used to read the compressed feature data during the replay stage, decode it based on the optimal codebook obtained through training, and recover the sample features for mixed training with the current task samples.

[0095] In this embodiment, the anomaly detection inference module 600 includes: The test feature extraction submodule 601 is used to input test data into the trained student network and extract the feature vector of the test data at a specified level in the student network. The distance calculation submodule 602 is used to calculate the L2 distance between the feature vector of the test data at a specified level of the student network and the feature vector of the corresponding level of the normal samples stored during the training process. The weighted summation submodule 603 is used to determine the weight coefficients based on the matching loss contribution of the specified level during the training phase, and to perform weighted summation on the L2 distance of the specified level to obtain the anomaly score of the test data. The anomaly determination submodule 604 is used to set an anomaly score threshold. When the anomaly score of the test data is higher than the anomaly score threshold, it is determined to be an abnormal sample; when the anomaly score is lower than or equal to the anomaly score threshold, it is determined to be a normal sample.

[0096] This embodiment also includes: The feature enhancement and optimization module 700 is used to introduce a lightweight, plug-and-play ResidualECA component to enhance the channel attention residuals of the teacher features output by the teacher network and the student features output by the student network. The feature enhancement and optimization module 700 includes: Feature preprocessing submodule 701 is used to process the raw features output by the feature extractor. It is then passed through the global average pooling function in sequence. Flattening function Processing yields a one-dimensional feature vector; Channel attention weight generation submodule 702 is used to perform 1D convolution operations on one-dimensional feature vectors. With Sigmoid activation function Processing and generating channel attention weights The calculation formula is: ; Residual feature enhancement submodule 703 is used for channel attention weight-based features. With residual coefficient residual coefficient The value range is [0,1], and the result is obtained through element-wise multiplication. For original features Perform residual enhancement to obtain enhanced features. F The calculation formula is: .

[0097] The system described in the above embodiments is used to implement a corresponding edge-deployed continuous learning industrial anomaly detection method in any of the foregoing embodiments, and has the beneficial effects of the corresponding method embodiments, which will not be repeated here.

[0098] Based on the same inventive concept, corresponding to the methods of any of the above embodiments, the present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, it implements the edge-deployable continuous learning industrial anomaly detection method described in any of the above embodiments.

[0099] Figure 6 This embodiment illustrates a more specific hardware structure of an electronic device, which may include a processor 810, a memory 820, an input / output interface 830, a communication interface 840, and a bus 850. The processor 810, memory 820, input / output interface 830, and communication interface 840 are interconnected internally via the bus 850.

[0100] The processor 810 can be implemented using a general-purpose CPU (Central Processing Unit), microprocessor, application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this specification.

[0101] The memory 820 can be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory), static storage device, dynamic storage device, etc. The memory 820 can store the operating system and other applications. When the technical solutions provided in the embodiments of this specification are implemented by software or firmware, the relevant program code is stored in the memory 820 and is called and executed by the processor 810.

[0102] The input / output interface 830 is used to connect input / output modules to enable information input and output. Input / output modules can be configured as components within the device (not shown in the figure) or externally connected to the device to provide corresponding functions. Input devices may include keyboards, mice, touchscreens, microphones, various sensors, etc., while output devices may include displays, speakers, vibrators, indicator lights, etc.

[0103] The communication interface 840 is used to connect the communication module (not shown in the figure) to enable communication between this device and other devices. The communication module can communicate via wired means (such as USB, Ethernet cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.).

[0104] Bus 850 includes a pathway for transmitting information between various components of the device, such as processor 810, memory 820, input / output interface 830, and communication interface 840.

[0105] It should be noted that although the above-described device only shows the processor 810, memory 820, input / output interface 830, communication interface 840, and bus 850, in specific implementations, the device may also include other components necessary for normal operation. Furthermore, those skilled in the art will understand that the above-described device may only include the components necessary for implementing the embodiments of this specification, and not necessarily all the components shown in the figures.

[0106] The electronic devices described above are used to implement a corresponding edge-deployed continuous learning industrial anomaly detection method in any of the foregoing embodiments, and have the beneficial effects of the corresponding method embodiments, which will not be repeated here.

[0107] Based on the same inventive concept, corresponding to the methods of any of the above embodiments, the present invention also provides a non-transitory computer-readable storage medium storing computer instructions for causing the computer to execute a continuous learning industrial anomaly detection method for edge deployment as described in any of the above embodiments.

[0108] The computer-readable medium of this embodiment includes permanent and non-permanent, removable and non-removable media, and information storage can be implemented by any method or technology. Information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transfer medium that can be used to store information accessible by a computing device.

[0109] The computer instructions stored in the storage medium of the above embodiments are used to cause the computer to execute a continuous learning industrial anomaly detection method for edge deployment as described in any of the above embodiments, and have the beneficial effects of the corresponding method embodiments, which will not be repeated here.

[0110] Those skilled in the art should understand that the discussion of any of the above embodiments is merely exemplary and is not intended to imply that the scope of the invention is limited to these examples; within the framework of the invention, the technical features of the above embodiments or different embodiments can also be combined, the steps can be implemented in any order, and there are many other variations of the different aspects of the embodiments of the invention as described above, which are not provided in detail for the sake of brevity.

[0111] Additionally, to simplify the description and discussion, and to avoid obscuring the embodiments of the invention, the well-known power / ground connections to integrated circuit (IC) chips and other components may or may not be shown in the provided drawings. Furthermore, the apparatus may be shown in block diagram form to avoid obscuring the embodiments of the invention, and this also takes into account the fact that the details of implementation of these block diagram apparatuses are highly dependent on the platform on which the embodiments of the invention will be implemented (i.e., these details should be fully understood by those skilled in the art). While specific details (e.g., circuits) have been set forth to describe exemplary embodiments of the invention, it will be apparent to those skilled in the art that the embodiments of the invention may be implemented without these specific details or with variations thereof. Therefore, these descriptions should be considered illustrative rather than restrictive.

[0112] Although the invention has been described in conjunction with specific embodiments thereof, many substitutions, modifications, and variations of these embodiments will be apparent to those skilled in the art from the foregoing description. For example, other memory architectures (e.g., dynamic RAMDRAM) may be used with the embodiments discussed.

[0113] The embodiments of this invention are intended to cover all such substitutions, modifications, and variations falling within the scope of the claims. Therefore, any omissions, modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the embodiments of this invention should be included within the scope of protection of this invention.

Claims

1. A continuous learning industrial anomaly detection method for edge deployment, characterized in that, Includes the following steps: Obtain normal sample data in an industrial setting, and divide at least one training task according to the category of the normal sample data. The sample data categories corresponding to different training tasks are different, and training sets and test sets corresponding to the training tasks are obtained. A dual-network architecture comprising a teacher network and a student network is constructed. The dual-network architecture uses a lightweight convolutional neural network as the backbone network for feature extraction. The front-end parameters of the dual-network architecture are shared, and only the back-end parameters of the student network are updated. Normal sample data of the specified training task are input into the dual network architecture according to the task order. The teacher features output by the teacher network and the student features output by the student network are extracted respectively. The matching loss of the teacher features output by the teacher network and the student features output by the student network is calculated based on the differential enhancement knowledge distillation mechanism. The back-end parameters of the student network are updated through backpropagation. For the current training task, a KNN Greedy sampling strategy is used to select representative samples and store them in the replay storage unit. For historical training tasks, a random sampling strategy is used to extract samples from the replay storage unit. The extracted historical samples are mixed with the current task samples and then input into the dual network architecture. The sample features stored in the replay storage unit are compressed using the product quantization method, and the compressed features are decompressed during sample replay. After each training task, test data including normal and abnormal samples is obtained, the features of the test data in the trained student network are extracted, the abnormal score of the test data is calculated, and the test data is classified and segmented according to the preset abnormal score threshold.

2. The continuous learning industrial anomaly detection method for edge deployment according to claim 1, characterized in that, The training set is represented as follows: ; The test set is represented as follows: ; In the formula, For the first i Training set for each training task For the first i The test set for each training task, i ≤ Γ, where Γ is the total number of training tasks, and any two distinct training tasks... and The corresponding sample data categories satisfy , i≠j .

3. The continuous learning industrial anomaly detection method for edge deployment according to claim 1, characterized in that, The steps for calculating the matching loss between the teacher features output by the teacher network and the student features output by the student network based on the differential enhancement knowledge distillation mechanism include: Calculate the teacher network in the first... l Teacher feature map output by the layer With the student network in the l Student feature map output by layer The L2 distance, combined with the numerical stability term Normalization is performed to obtain the normalized difference map. The calculation formula is: ; In the formula, B For batch size, C The number of feature channels, H , W These are the height and width of the feature map, respectively. Normalized difference plot Perform multi-scale downsampling operations sequentially. Multi-scale upsampling operation With Sigmoid activation function Processing, through the enhancer Gain enhanced weight The calculation formula is: ; Based on enhanced weights Strength enhancement coefficient With the upper limit of enhanced strength Student feature map Adaptive enhancement is achieved through element-wise multiplication. With mean calculation function Enhanced student feature map The calculation formula is: ; Teacher feature map Compared with the enhanced student feature map Perform L2 normalization separately: ; In the formula, This is the normalized teacher feature map. To enhance the student feature map after normalization, further optimization is performed on the feature hierarchy set involved in the loss calculation. L Combined with the height of the feature map H With width W Calculate L2 loss as matching loss The calculation formula is: .

4. The continuous learning industrial anomaly detection method for edge deployment according to claim 1, characterized in that, The steps for selecting representative samples for the current training task using the KNN Greedy sampling strategy and storing them in the replay storage unit include: Obtain the normal sample feature set for the current training task. In the formula, For the first i The feature vector of each sample n This represents the total number of samples in the current task. From feature set F Selected from k The target sample set consists of individual sample features. Target sample set Any two distinct eigenvectors within L2 Distance, satisfying the formula: ; In the formula, This indicates the number of elements in set S; Selected target sample set The corresponding features are stored in the replay storage unit for subsequent replay of historical task samples.

5. The continuous learning industrial anomaly detection method for edge deployment according to claim 1, characterized in that, The steps of compressing the sample features stored in the replay storage unit using the product quantization method include: The features of the samples to be compressed in the playback storage unit are extracted in batches to obtain the feature matrix. In the formula, N The total number of samples to be compressed. D For a single sample feature dimension; The feature matrix was processed using the IndexPQ module in the FAISS toolkit. M Perform unified PQ training to learn the optimal codebook, and use the feature matrix M Each feature vector in the matrix is ​​decomposed into m Each of the following low-dimensional sub-vectors is quantized and encoded. Tensor reshaping is performed on the quantized encoding results to decouple feature storage from compression logic, thereby obtaining and storing compressed feature data; During the replay phase, the compressed feature data is read, decoded based on the optimal codebook obtained through training, and the recovered sample features are used for mixed training with the current task samples.

6. The continuous learning industrial anomaly detection method for edge deployment according to claim 1, characterized in that, The steps for calculating the anomaly score of the test data and classifying and segmenting the test data according to a preset anomaly score threshold include: Input the test data into the trained student network and extract the feature vector of the test data at a specified layer of the student network. Calculate the L2 distance between the feature vector of the test data at a specified level in the student network and the feature vector of the corresponding level of the normal samples stored during training; The weight coefficients are determined based on the contribution of the matching loss of the specified level during the training phase. The L2 distances of the specified levels are weighted and summed to obtain the anomaly score of the test data. An abnormal score threshold is set. When the abnormal score of the test data is higher than the abnormal score threshold, it is determined to be an abnormal sample; when the abnormal score is lower than or equal to the abnormal score threshold, it is determined to be a normal sample.

7. The continuous learning industrial anomaly detection method for edge deployment according to claim 1, characterized in that, Also includes: A lightweight, plug-and-play ResidualECA component is introduced to perform channel attention residual enhancement on the teacher features output by the teacher network and the student features output by the student network. Specifically, this includes: For the raw features output by the feature extractor It is then passed through the global average pooling function in sequence. Flattening function Processing yields a one-dimensional feature vector; Perform 1D convolution operation on a one-dimensional feature vector With Sigmoid activation function Processing and generating channel attention weights The calculation formula is: ; Channel attention weights With residual coefficient residual coefficient The value range is [0,1], and the result is obtained through element-wise multiplication. For original features Perform residual enhancement to obtain enhanced features. F The calculation formula is: .

8. A continuous learning industrial anomaly detection device for edge deployment, characterized in that, include: The data acquisition and task division module is used to acquire normal sample data in industrial scenarios, divide at least one training task according to the category of the normal sample data, and the sample data categories corresponding to different training tasks are different, and the training set and test set corresponding to the training task are obtained. A network architecture construction module is used to construct a dual network architecture including a teacher network and a student network. The dual network architecture uses a lightweight convolutional neural network as the feature extraction backbone network. The front-end parameters of the dual network architecture are shared, and only the back-end parameters of the student network are updated. The feature extraction and loss optimization module is used to input normal sample data of the specified training task into the dual network architecture according to the task order, extract the teacher features output by the teacher network and the student features output by the student network respectively, calculate the matching loss of the teacher features output by the teacher network and the student features output by the student network based on the differential enhancement knowledge distillation mechanism, and update the back-end parameters of the student network through backpropagation. The replay storage module is used to select representative samples for the current training task using the KNN Greedy sampling strategy and store them in the replay storage unit. It also uses a random sampling strategy to extract samples from the replay storage unit for historical training tasks. The extracted historical samples are mixed with the current task samples and then input into the dual network architecture. The feature compression processing module is used to compress the sample features stored in the replay storage unit using the product quantization method, and to decompress the compressed features during sample replay. The anomaly detection inference module is used to acquire test data including normal and abnormal samples after each training task, extract the features of the test data in the trained student network, calculate the anomaly score of the test data, and perform anomaly classification and segmentation of the test data according to the preset anomaly score threshold.

9. A continuous learning industrial anomaly detection device for edge deployment according to claim 8, characterized in that, In the data acquisition and task partitioning module, the training set is represented as follows: ; The test set is represented as follows: ; In the formula, For the first i Training set for each training task For the first i The test set for each training task, i ≤ Γ, where Γ is the total number of training tasks, and any two distinct training tasks... and The corresponding sample data categories satisfy , i≠j ; The feature extraction and loss optimization module includes: The difference graph calculation and normalization submodule is used to calculate the difference graph of the teacher network in the first... l Teacher feature map output by the layer With the student network in the l Student feature map output by layer The L2 distance, combined with the numerical stability term Normalization is performed to obtain the normalized difference map. The calculation formula is: ; In the formula, B For batch size, C The number of feature channels, H , W These are the height and width of the feature map, respectively. The multi-scale difference enhancement submodule is used to enhance the normalized difference map. Perform multi-scale downsampling operations sequentially. Multi-scale upsampling operation With Sigmoid activation function Processing, through the enhancer Gain enhanced weight The calculation formula is: ; The student feature adaptive enhancement submodule is used for enhancement weights. Strength enhancement coefficient With the upper limit of enhanced strength Student feature map Adaptive enhancement is achieved through element-wise multiplication. With mean calculation function Enhanced student feature map The calculation formula is: ; The matching loss calculation submodule is used to process the teacher feature map. Compared with the enhanced student feature map Perform L2 normalization separately: ; In the formula, This is the normalized teacher feature map. To enhance the student feature map after normalization, further optimization is performed on the feature hierarchy set involved in the loss calculation. L Combined with the height of the feature map H With width W Calculate L2 loss as matching loss The calculation formula is: ; The replay storage module includes: The feature set determination submodule is used to obtain the normal sample feature set for the current training task. In the formula, For the first i The feature vector of each sample n This represents the total number of samples in the current task. The representative sample selection submodule is used to select samples from the feature set. F Selected from k The target sample set consists of individual sample features. Target sample set Any two distinct eigenvectors within L2 Distance, satisfying the formula: ; In the formula, This indicates the number of elements in set S; The sample storage submodule is used to store the selected target sample set. The corresponding features are stored in the replay storage unit for subsequent replay of historical task samples; The feature compression processing module includes: The batch feature extraction submodule is used to extract features from the samples to be compressed in the replay storage unit in batches, and obtain the feature matrix. In the formula, N The total number of samples to be compressed. D For a single sample feature dimension; The unified PQ training and encoding submodule is used to train the feature matrix using the IndexPQ module in the FAISS toolkit. M Perform unified PQ training to learn the optimal codebook, and use the feature matrix M Each feature vector in the matrix is ​​decomposed into m Each of the following low-dimensional sub-vectors is quantized and encoded. The tensor reshaping and storage submodule is used to reshape the quantized encoding results into tensors, thereby decoupling the feature storage and compression logic, and obtaining and storing the compressed feature data. The feature decompression submodule is used to read the compressed feature data during the replay stage, decode it based on the optimal codebook obtained through training, and recover the sample features for mixed training with the current task samples. The anomaly detection inference module includes: The test feature extraction submodule is used to input test data into the trained student network and extract the feature vector of the test data at a specified layer in the student network. The distance calculation submodule is used to calculate the L2 distance between the feature vector of the test data at a specified level in the student network and the feature vector of the corresponding level of the normal samples stored during the training process. The weighted summation submodule is used to determine the weight coefficients based on the contribution of the matching loss of the specified layer during the training phase, and to perform weighted summation on the L2 distance of the specified layer to obtain the anomaly score of the test data. The anomaly detection submodule is used to set an anomaly score threshold. When the anomaly score of the test data is higher than the anomaly score threshold, it is determined to be an abnormal sample; when the anomaly score is lower than or equal to the anomaly score threshold, it is determined to be a normal sample.

10. A continuous learning industrial anomaly detection device for edge deployment according to claim 8, characterized in that, Also includes: The feature enhancement and optimization module is used to introduce a lightweight, plug-and-play ResidualECA component to enhance the channel attention residuals of the teacher features output by the teacher network and the student features output by the student network. The feature enhancement and optimization module includes: The feature preprocessing submodule is used to process the raw features output by the feature extractor. It is then passed through the global average pooling function in sequence. Flattening function Processing yields a one-dimensional feature vector; The channel attention weight generation submodule is used to perform 1D convolution operations on one-dimensional feature vectors. With Sigmoid activation function Processing and generating channel attention weights The calculation formula is: ; The residual feature enhancement submodule is used for channel attention weight-based features. With residual coefficient residual coefficient The value range is [0,1], and the result is obtained through element-wise multiplication. For original features Perform residual enhancement to obtain enhanced features. F The calculation formula is: .