Model efficient updating method based on incremental learning and knowledge distillation
Patent Information
- Application Number
- CN202611166807.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-03
- Publication Date
- 2026-10-23
AI Technical Summary
[0003]然而,在模型参数随新增样本调整的过程中,原有缺陷类别对应的识别特征也会受到参数变化影响,使模型内部对于历史缺陷的响应模式发生改变
[0012]1、本发明中,通过对增量更新前识别模型与增量更新后识别模型针对同一表面缺陷图像样本输出的缺陷响应位置、缺陷响应区域以及缺陷响应强度进行关联分析,构建缺陷特征迁移轨迹数据,并依据特征变化关系确定历史缺陷保持区域,使模型更新过程中能够基于缺陷响应特征变化状态识别需要保持的历史缺陷知识区域,从而降低增量学习过程中因模型参数更新导致历史缺陷特征响应变化的问题;
Smart Images

Figure CN122967093A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of model updating, and more specifically to an efficient model updating method based on incremental learning and knowledge distillation. Background Technology
[0002] As industrial manufacturing processes become increasingly automated and intelligent, machine vision-based industrial defect identification technology is widely used in product surface quality inspection. This technology typically utilizes deep learning models to extract features and classify data from acquired industrial product images, enabling automatic identification of different types of surface defects. Because industrial product types, production processes, and defect categories are constantly evolving, the identification model needs continuous updating based on new defect samples to adapt to the inspection requirements of the actual production environment.
[0003] However, as model parameters are adjusted with new samples, the identification features corresponding to the original defect categories are also affected by parameter changes, altering the model's response pattern to historical defects. Because existing update methods typically focus primarily on the accuracy of identifying new categories and lack continuous analysis of changes in historical defect responses before and after model updates, it is difficult to determine the specific reasons and areas of change in existing defect knowledge during model updates. Existing incremental update methods fail to correlate defect feature changes before and after model updates, resulting in insufficient evidence for maintaining historical defect knowledge. This has become a pressing issue that needs to be addressed in the continuous updating of current industrial defect identification models. Summary of the Invention
[0004] The purpose of this application is to provide an efficient model update method based on incremental learning and knowledge distillation. By analyzing the changing relationship between historical defect features and updated defect features during the incremental update process of the model, and combining the identification information of newly added defect categories to constrain the model parameter update process, the method can reduce the historical defect identification feature shift generated when the model introduces new defect categories, thereby improving the identification stability and update reliability of the industrial defect identification model during the continuous update process.
[0005] The objective of this application can be achieved through the following technical solution: an efficient model update method based on incremental learning and knowledge distillation, comprising the following steps:
[0006] Acquire new defect categories and their corresponding identification models before incremental update, identification models after incremental update, defect category identification data, and surface defect image samples of industrial products;
[0007] The surface defect image samples are input into the recognition model before incremental update and the recognition model after incremental update, respectively, to obtain the corresponding defect analysis data and category recognition results, and to establish a sample correspondence relationship based on the surface defect image samples;
[0008] The historical defect features and updated defect features are analyzed by the sample correspondence to generate defect feature migration trajectory data containing feature change data;
[0009] Based on the relationship between the feature change data in the defect feature migration trajectory data and the preset retention conditions, the historical defect retention area is determined;
[0010] Based on the historical defect retention area, the feature difference constraint between the historical defect features and the updated defect features is determined. Then, by using the feature difference constraint, the category identification result output by the incrementally updated identification model and the category identification data are analyzed to update the incrementally updated identification model and obtain the industrial defect identification update model.
[0011] Compared with the prior art, the beneficial effects of this application are:
[0012] 1. In this invention, by performing correlation analysis on the defect response location, defect response area, and defect response intensity output by the identification model before and after incremental update for the same surface defect image sample, defect feature migration trajectory data is constructed, and the historical defect retention area is determined based on the feature change relationship. This enables the model to identify the historical defect knowledge area that needs to be retained based on the defect response feature change state during the model update process, thereby reducing the problem of historical defect feature response changes caused by model parameter updates during incremental learning.
[0013] 2. In this invention, by utilizing the feature difference constraint between the historical defect features and the updated defect features generated in the historical defect maintenance region, and combining the category identification results corresponding to the newly added defect category with the defect category identification data to form model parameter update constraints, the parameters of the incrementally updated identification model are adjusted so that the model can adapt to the changes in the features of the newly added defect category while maintaining the existing defect category identification ability, thereby improving the stability and identification adaptability of the industrial defect identification model in the continuous incremental update process. Attached Figure Description
[0014] Figure 1 This is a flowchart illustrating the steps of the efficient model update method based on incremental learning and knowledge distillation proposed in this application. Detailed Implementation
[0015] It is readily understood that, based on the technical solution of this invention, those skilled in the art can propose various interchangeable structural methods and implementations without altering the essential spirit of the invention. Therefore, the following detailed embodiments and accompanying drawings are merely illustrative examples of the technical solution of this invention and should not be considered as the entirety of the invention or as limitations or restrictions on the technical solution of this invention.
[0016] Example 1:
[0017] In existing technologies, machine vision-based industrial defect recognition typically utilizes deep learning models to extract features and classify data from acquired industrial product images, enabling automatic identification of different types of surface defects. Because industrial product types, production processes, and defect categories are constantly evolving, the recognition model needs continuous incremental updates based on new defect samples to adapt to the inspection requirements of the actual production environment. However, as model parameters are adjusted with new samples, the recognition features corresponding to the original defect categories are also affected by parameter changes, causing a shift in the model's response pattern to historical defects. Existing update methods usually focus primarily on the accuracy of identifying new categories, lacking continuous analysis of the changes in historical defect responses before and after model updates. This makes it difficult to determine the specific reasons and areas of change in the original defect knowledge during model updates, resulting in a lack of objective basis for maintaining historical defect knowledge. This has become a critical technical problem that urgently needs improvement in the continuous updating of industrial defect recognition models.
[0018] To address the aforementioned issues, research revealed a traceable correspondence between the hidden layer response data of the same industrial product surface defect samples before and after incremental updates. By quantifying and organizing the positional shifts, regional overlaps, and intensity changes in this correspondence into defect feature migration trajectory data, the changes in historical defect knowledge during model updates can be characterized point-by-point. Furthermore, it was found that applying knowledge preservation constraints only to regions within a preset range of change in the migration trajectory data better reflects the actual local shift patterns observed in the model, compared to applying uniform constraints to all feature locations. Therefore, a feature difference constraint based on historical defect preservation regions is proposed, and this constraint is combined with the new category recognition loss to guide model parameter updates, forming an incremental update scheme that balances the ability to learn new defects with the ability to preserve historical defect knowledge.
[0019] Specifically, this solution first acquires the pre-incremental update identification model, post-incremental update identification model, defect category identification data, and industrial product surface defect image samples corresponding to the newly added defect categories. The surface defect image samples are then input into the two models respectively. A sample correspondence is established based on the sample identification, and the corresponding historical defect features and updated defect features are extracted. Subsequently, migration trajectory analysis is performed on both models to generate feature change data including location migration, regional changes, and intensity changes. This data is then compared with preset retention conditions to determine the historical defect retention area. Next, based on this area, the feature difference constraint between historical defect features and updated defect features is calculated to generate a knowledge retention constraint loss. Finally, this loss is combined with the newly added defect category identification loss to guide the parameter adjustment of the post-incremental update identification model, resulting in an updated industrial defect identification model.
[0020] Compared to existing technologies, most incremental update methods only add a historical category distillation term with uniform weight to the loss function, without distinguishing the specific regions of change in historical defect features. This can easily lead to unnecessary constraints being imposed on areas with minor changes, while insufficient constraints are applied to areas with significant changes. This solution constructs quantifiable defect feature migration trajectory data by comparing the model response data before and after the incremental update, and uses this data to delineate historical defect retention regions. This allows knowledge retention constraints to be applied differentiated according to the areas that have actually changed, balancing the learning space of newly added defect categories with the response stability of historical defect categories. This provides a traceable and quantifiable technical path for the continuous updating of industrial defect identification models.
[0021] like Figure 1 As shown, the efficient model update method based on incremental learning and knowledge distillation includes the following steps:
[0022] The process involves acquiring newly added defect categories and their corresponding pre-incremental update identification models, post-incremental update identification models, defect category label data, and surface defect image samples of industrial products. New defect categories refer to newly emerging or defined surface defect types in industrial production processes that are not covered by existing identification models and require model expansion. Examples include oxide spots on metal surfaces and new crack morphologies in ceramic products. The pre-incremental update identification model is the original model capable of identifying existing defect categories. Its parameters are fixed before the incremental update, obtained by copying and freezing the current parameters of the model to be updated, and used to provide historical defect feature references. The post-incremental update identification model is the model initially trained with the new defect samples. It has expanded its response capability to new categories, but its historical defect knowledge remains unchanged and needs verification. It is obtained by expanding the classification head on the model to be updated and training with the new samples. Defect category label data refers to the true defect category label corresponding to each surface defect image, specifically represented using one-hot encoding, used to supervise model training and evaluate identification results. Surface defect image samples of industrial products refer to product appearance images containing various surface defects acquired by image acquisition equipment on industrial production lines. Specifically, they can be high-resolution grayscale or color images acquired under specific lighting conditions, accompanied by corresponding defect category identification data.
[0023] The surface defect image samples are input into the pre-incremental update recognition model and the post-incremental update recognition model, respectively, to obtain corresponding defect analysis data and category recognition results. A sample correspondence is established based on the sample identifiers in the surface defect image samples. The sample identifier is a unique identifier assigned to each sample, which can be a sample filename or a database index ID, used to establish and trace the correspondence between samples during data processing. Defect analysis data refers to the data set reflecting the model's response characteristics to defects, extracted from a specified hidden layer after the samples are input into the model. It includes historical defect features and updated defect features, specifically containing information on three dimensions: defect response location, defect response area, and defect response intensity. Category recognition results refer to the predicted category information given by the model output layer after processing by a classification function. Specifically, it includes the historical category recognition results output by the pre-incremental update recognition model and the updated category recognition results output by the post-incremental update recognition model, determined by the category index corresponding to the highest probability in the probability distribution. The sample correspondence is a data structure that uses the sample identifier as the key to associate and store the defect analysis data and category recognition results generated by the same surface defect image sample in the two models before and after the incremental update, used for subsequent feature transfer analysis.
[0024] The historical defect features and updated defect features are analyzed by the sample correspondence to generate defect feature migration trajectory data containing feature change data. Defect feature migration trajectory data refers to a multi-dimensional change description generated by analyzing the difference in defect features of the same sample in the model before and after incremental update, including feature migration distance data, regional change data and intensity change data, which are specifically used to characterize the evolution path of defect response features in the model update process.
[0025] Based on the relationship between the feature change data in the defect feature migration trajectory data and the preset retention conditions, the historical defect retention region is determined. The historical defect retention region refers to the spatial region in the model after incremental update where the degree of change of defect features is within the preset allowable range. The feature response in this region is considered to have successfully retained the historical defect knowledge. Specifically, it is determined by comparing the feature change data with the preset retention conditions.
[0026] Based on the historical defect retention region, a feature difference constraint is determined between the historical defect features and the updated defect features. Using this feature difference constraint, the category identification results output by the incrementally updated identification model are analyzed in conjunction with the category identification data to update the incrementally updated identification model, thus obtaining an updated industrial defect identification model. The feature difference constraint refers to the difference measure between the historical defect features and the updated defect features calculated on the historical defect retention region. Specifically, it uses mean squared error as the knowledge retention constraint loss to suppress changes in historical defect features during parameter updates. The updated industrial defect identification model, after closed-loop updating and evaluation, is the final model that possesses the ability to identify new defect categories while maintaining the historical defect identification performance, specifically satisfying preset update evaluation conditions.
[0027] The core innovation of this application lies in constructing a model pair before and after incremental updates. It achieves spatial localization and measurement of feature changes through defect feature migration trajectory analysis, applies differentiated feature constraints based on the preserved regions, and jointly optimizes parameters by combining the classification loss of the newly added categories, forming a closed-loop evaluation model update architecture. Through multi-dimensional change analysis of defect response location, region, and intensity, it accurately locates regions where historical knowledge has changed, and applies constraints only to the preserved regions, reducing the incidence of indiscriminate degradation of historical knowledge in traditional incremental learning.
[0028] This application further proposes that the process of obtaining newly added defect categories and their corresponding pre-incremental update identification models, post-incremental update identification models, defect category identification data, and surface defect image samples of industrial products includes:
[0029] Obtain surface defect image samples of industrial products corresponding to the industrial defect identification model to be updated and the newly added defect categories. These surface defect image samples include images of the industrial product surface and corresponding defect category identification data. The industrial defect identification model to be updated refers to the model currently in use on the production line that already possesses the ability to identify historical defect categories; its current model parameters are denoted as... ;
[0030] After obtaining the surface defect image samples and their category identification data corresponding to the newly added defect categories, the parameters of the industrial defect identification model to be updated are adjusted using the existing gradient descent-based incremental fine-tuning method, namely:
[0031] ;
[0032] in, The adjusted incremental update identifies the model parameters; The preset learning rate is used to control the magnitude of a single parameter adjustment; Indicates the current parameter Starting with the newly added defect category sample set The gradient of the classification loss function is calculated using existing deep learning model training techniques. In this scheme, it is used to drive the industrial defect identification model to be updated to initially obtain the ability to identify new defect categories. The preservation of historical defect knowledge has not yet been considered. Therefore, the incrementally updated identification model is only used as the initial state for subsequent knowledge preservation constraint optimization, rather than the final delivery model.
[0033] The identification model before incremental update is determined based on the current model parameters of the industrial defect identification model to be updated, i.e. This operation does not change any parameters of the model; it only serves as a benchmark for subsequent comparisons. It creates a network instance with the exact same structure as the model to be updated and sets the parameters... The model is copied layer by layer to this instance, and all trainable parameters are frozen. This means that the parameter update flag for all network layers is set to non-trainable, resulting in the recognition model before the incremental update. The recognition model before the incremental update retains the complete response pattern of the previous model to historical defects, providing a benchmark for subsequent feature transfer analysis. The freezing operation is implemented through the model parameter attribute settings of the deep learning framework.
[0034] The industrial defect identification model to be updated is incrementally updated based on the surface defect image samples corresponding to the newly added defect categories and the defect category identification data to obtain the incrementally updated identification model.
[0035] Based on the model to be updated, the number of neurons in the classification head output is expanded from K (the number of existing defect categories) to K+1 (a new category is added). The weights of the new neurons are assigned using the Xavier initialization method, and the bias is initialized to 0. Training batches are constructed using surface defect image samples corresponding to the new defect category and the defect category identification data. Supervised training is performed using the cross-entropy loss function. The optimizer uses stochastic gradient descent with a learning rate of 0.001, momentum of 0.9, and a weight decay coefficient. Batch size 32, parameters obtained after training for a preset number of epochs (e.g., 30 epochs). This model is denoted as the incremental update recognition model.
[0036] This application uses the current parameters of the model to be updated as the benchmark for the identification model before incremental update, and adopts the existing incremental fine-tuning method to obtain the identification model after incremental update. This provides two comparison objects with clear parameter states and traceable change processes for the subsequent comparison of historical defect features and updated defect features. Combined with the aforementioned defect feature migration trajectory analysis and historical defect retention region determination mechanism, a correspondence is established between the parameter change process before and after model update and the response feature change process, laying a data foundation for the targeted application of subsequent knowledge retention constraints.
[0037] This application further proposes that the process of obtaining the corresponding defect analysis data and category identification results includes:
[0038] The defect analysis data includes historical defect features and updated defect features. Both historical and updated defect features include defect response location, defect response region, and defect response intensity. The defect response location refers to the coordinates of the position in the response data matrix where the activation intensity exceeds a preset response threshold. The defect response region refers to the connected region range with the location as the core and the activation intensity continuously higher than the response threshold. The defect response intensity refers to the statistical result (such as the mean) of the activation values in the region.
[0039] When the surface defect image samples are input into the pre-incremental update recognition model and the post-incremental update recognition model, respectively, the defect response data matrix output by the preset hidden layer in the pre-incremental update recognition model and the post-incremental update recognition model is obtained. ,in, , This represents the height and width of the feature map of this layer. The number of channels represents the response value at each spatial location in the matrix, reflecting the activation strength of the model for the defect features at that location. The pre-defined hidden layer refers to the intermediate feature layer in a convolutional network or visual Transformer structure that is located before the classification output layer and whose spatial resolution corresponds to the input image. Specifically, it can be the output layer of the last convolutional module or attention module.
[0040] Since the identification model before and after the incremental update uses the same network structure, the defect response data matrices output by the two models have a positional correspondence in the spatial dimension. Therefore, the matrix corresponding to the identification model before the incremental update can be denoted as the historical defect features. The matrix corresponding to the identification model after incremental update is denoted as the updated defect feature. .
[0041] Obtain the category probability distribution data of the output layer of the identification model before and after the incremental update. The category probability distribution data refers to the confidence probability of each defect category obtained after normalization of the model output layer. Its calculation method is the existing classification network output layer technology, specifically expressed as follows:
[0042] ;
[0043] in, For the first Output probability corresponding to class defect; For the output layer The original output values of each node before normalization; This represents the total number of defect categories that the model can identify.
[0044] For the category probability distribution data of the recognition model before and after the incremental update, respectively, take the category index corresponding to the highest probability, that is... The category index obtained by the identification model before the incremental update is recorded as the historical category identification result, and the category index obtained by the identification model after the incremental update is recorded as the updated category identification result. The two are collectively referred to as the category identification result, which is used to compare with the defect category identification data in the future to generate the new defect category identification loss.
[0045] This scheme reads the response data matrix of the same hidden layer of the identification model before and after incremental update, and forms historical defect features and updated defect features according to the spatial location correspondence, so that the two have a structural basis that can be compared position by position. Combined with the two comparison objects with clear model parameter states, the change process of defect response position, region and intensity can correspond to the specific model parameter adjustment process, providing original feature inputs that can be compared position by position for the subsequent generation of defect feature migration trajectory data.
[0046] This application further proposes that the process of generating feature change data includes:
[0047] The feature change data includes feature migration distance data, regional change data, and intensity change data;
[0048] The historical defect response location coordinates in the historical defect features and the updated defect response location coordinates in the updated defect features are obtained. Both the historical and updated defect response location coordinates are based on the pixel grid of the feature map containing the defect response data matrix. The location with the highest activation intensity in the corresponding defect response region is taken as the representative coordinate of that region, and the feature migration distance data is calculated. ;
[0049] Historical defects In the two-dimensional response matrix, the position of the element with the largest response intensity is searched, and its row index and column index are mapped to the original image space coordinates to obtain the coordinates of the historical defect response position. The unit is pixels. Similarly, by locating the maximum response position in the updated defect features, the coordinates of the updated defect response position are obtained. Calculate the Euclidean distance between two points as the feature transfer distance data. .
[0050] ;
[0051] in, The feature migration distance data is used to represent the degree of position shift of the identification model in response to the same surface defect area of an industrial product before and after incremental update; , These represent the x-coordinate and y-coordinate of the historical defect response location coordinates, respectively. , These represent the x-coordinate and y-coordinate of the updated defect response location coordinates, respectively.
[0052] Feature transfer distance data This reflects the degree of shift in the model's focus on the same defect after incremental updates. The smaller the value, the better the model maintains spatial awareness of the defect; The larger the value, the more the model's response to the defect has shifted, potentially indicating historical knowledge forgetting or attention shift.
[0053] This scheme quantifies the location coordinates of historical and updated defect responses using Euclidean distance, transforming two sets of feature responses that were originally difficult to compare directly into a calculable and comparable numerical index. Combined with the aforementioned positional correspondence between historical and updated defect features, the feature migration distance data can accurately reflect the degree of positional change of each defect response before and after the model update, providing a quantitative basis for the positional dimension for subsequently determining the historical defect retention area by jointly combining regional change data and intensity change data.
[0054] This application further proposes to generate defect feature migration trajectory data, including:
[0055] Obtain the range of the historical defect response region in the historical defect features and the range of the updated defect response region in the updated defect features, and determine the region overlap range;
[0056] The regional change data is calculated based on the overlapping area of the regions, and the calculation relationship is as follows:
[0057] ;
[0058] in, This indicates the change data in the region. The closer it is to 0, the higher the degree of overlap in the response coverage of the same defect before and after the model update; The closer it is to 1, the more significant the change in the coverage area of the response region. This indicates the range of the historical defect response area; This indicates the range of the updated defect response area; Indicates the number of overlapping positions between two regions; This indicates the number of locations after combining two regions.
[0059] Intensity change data is generated based on the relationship between the historical defect response intensity value and the updated defect response intensity value. The feature migration distance data, the region change data, and the intensity change data are then associated with the surface defect image samples to generate defect feature migration trajectory data.
[0060] Intensity change data The relative change in the intensity of a response activation is measured by the following relationship:
[0061] ;
[0062] in, The intensity change data is a dimensionless numerical value that reflects the degree of change in the amplitude of the model's response to the same defect area before and after the incremental update. The historical defect response intensity value is the average of the activated values within the historical defect response region. The updated defect response intensity value is calculated by taking the average of the activated values within the updated defect response region. The feature migration distance data corresponding to the same surface defect image sample is then used. Regional change data With intensity change data By associating samples according to their identifiers, the defect feature migration trajectory data corresponding to each sample can be organized. The migration trajectory data of multiple samples together constitute the historical defect response change record of this incremental update process.
[0063] This application quantifies the degree of overlap between the historical defect response area and the updated defect response area using the intersection-union comparison method, and generates intensity change data by combining the relative change relationship of response intensity, so that the change process in both the area coverage and activation intensity dimensions has a quantifiable expression. Combined with the aforementioned feature migration distance data, the change data in the three dimensions of location, region, and intensity can be associated and organized according to the same surface defect image sample to form a structurally complete defect feature migration trajectory data, providing a multi-dimensional quantitative basis for the comprehensive judgment of the historical defect retention area.
[0064] This application further proposes to define areas for preserving historical defects, including:
[0065] The feature migration distance data, the region change data, and the intensity change data in the defect feature migration trajectory data are compared with preset retention conditions, respectively.
[0066] When the following conditions are met: ; ; When the historical defect response area is defined as the historical defect retention area, the historical defect response area is determined.
[0067] in, Indicates a preset position threshold; Indicates the preset area change threshold; This indicates the preset response change threshold.
[0068] Specifically, preset position threshold Preset area change threshold and preset response change threshold All of these can be pre-defined based on the statistical distribution of feature change data during historical incremental updates, used to define the degree of positional shift, regional change, and intensity change that still fall within the acceptable range of normal model adjustments. When the feature migration distance data, regional change data, and intensity change data corresponding to a certain defect response location simultaneously meet the corresponding threshold conditions, it indicates that the response change at that location before and after the model update is within a small range, and the historical defect knowledge at that location remains relatively stable. Therefore, the historical defect response area corresponding to that location is included in the historical defect retention area as the scope of subsequent knowledge retention constraints. All three conditions must be met simultaneously to avoid misjudgments that may occur based on a single dimension, such as situations where the response location has not shifted significantly but the regional range or intensity has changed considerably.
[0069] This application sets preset thresholds for feature migration distance data, regional change data, and intensity change data, requiring all three conditions to be met simultaneously before inclusion in the historical defect retention area. This ensures that the determination of the historical defect retention area comprehensively considers changes in location, region, and intensity, reducing the potential bias caused by judging based on a single indicator. Combined with the aforementioned defect feature migration trajectory data, the division of the historical defect retention area is based on a quantitative analysis of the response changes before and after the model update, providing a clear location range basis for the targeted calculation of subsequent feature difference constraints.
[0070] This application further proposes that it also includes:
[0071] When any of the feature migration distance data, regional change data, or intensity change data exceeds the corresponding preset threshold, it indicates that the defect response at that location has changed significantly before and after the model update. If the location is directly excluded from the historical defect retention area, the historical defect knowledge at that location may lack constraints and be overwritten in subsequent updates.
[0072] Therefore, this solution will specify the historical defect response area corresponding to this location. With updated defect response area The merger will create an expanded historical defect preservation area, namely... This ensures that the location covers both the response range before and after the model update in the knowledge retention constraint calculation, avoiding the omission of some historical response locations due to regional offset.
[0073] This application determines the retention region by merging the historical and updated response regions for positions that do not meet the preset retention conditions, thus overcoming the shortcomings of simply judging the possible omission of offset regions based on the overlap range. Combined with the aforementioned threshold judgment mechanism for the historical defect retention region, the historical defect retention region has corresponding determination methods in both cases of small and large changes, improving the coverage integrity of the historical defect retention region for response positions with different degrees of change, and providing a more complete set of positions for the subsequent calculation of feature difference constraints.
[0074] This application further proposes determining the feature difference constraint between the historical defect features and the updated defect features based on the historical defect retention region, including:
[0075] Based on the historical defect retention region, a corresponding location set is determined. This corresponding location set refers to the specific spatial coordinate set determined by the historical defect retention region in the defect response data matrix. The feature difference constraint between the historical defect features and the updated defect features within the corresponding location set is calculated to generate a knowledge retention constraint loss. The calculation relationship for the knowledge retention constraint loss is as follows:
[0076] ;
[0077] in, This indicates the knowledge retention constraint loss. The smaller the value, the closer the response characteristics within the historical defect preservation region are to the model update before and after the update; This indicates the number of locations contained within the historical defect retention area. Normalize the sum of all differences so that The size of the region does not change by orders of magnitude with historical defects, making it easy to combine with other loss items; Indicates the first Does each location belong to the historical defect retention area? For position markers that take values of 0 or 1, when the first... The value is 1 when a location belongs to the historical defect retention region, and 0 otherwise. This labeling quantity reduces the knowledge retention constraint loss. The calculation is a weighted summation only within the historical defect retention area; locations outside the area are not included in the calculation of this loss. Indicates the first Historical defect characteristics corresponding to each location; Indicates the first Updated defect features corresponding to each location; Indicates the first The squared difference between the historical defect features and the updated defect features at each location is used to measure the degree of deviation of the response value at that location.
[0078] This solution introduces location markers. By limiting the calculation scope of the knowledge retention constraint loss to the set of locations corresponding to the historical defect retention region, the constraint is applied only to locations where the response change is within the retention range, avoiding excessive restrictions that may result from applying uniform constraints to all feature locations. Combined with the aforementioned process of determining the historical defect retention region, the calculation of the knowledge retention constraint loss is based on a set of locations that have been screened from multiple dimensions, providing targeted constraint terms for subsequent model parameter updates driven by the combination of the loss for identifying new defect categories.
[0079] This application further proposes that the process of updating the incrementally updated identification model to obtain the updated industrial defect identification model includes:
[0080] Obtain surface defect image samples corresponding to the newly added defect categories, and input them into the incrementally updated recognition model to obtain the category recognition results;
[0081] Based on the difference between the category identification results and the corresponding defect category identification data, a new defect category identification loss is generated;
[0082] The loss for identifying the new defect category is combined with the loss for maintaining knowledge to generate a model parameter update constraint, and the model parameters in the incrementally updated identification model are updated according to the model parameter update constraint.
[0083] Specifically, the new defect category identification loss The existing cross-entropy loss calculation method is used to measure the difference between the identification results of the recognition model for newly added defect categories after incremental updates and the actual defect category identification data. The calculation relationship is as follows:
[0084] ;
[0085] in, Identify the loss for the newly added defect category; The number of surface defect image samples used in this calculation; For the first The true label of each sample corresponding to the defect category identification data; For the incremental update of the identification model, the first The predicted probability corresponding to the true category in the class probability distribution data of each sample output. The loss for identifying new defect categories. Constraint loss with knowledge Perform weighted combinations to generate model parameter update constraints. The calculation relationship is as follows:
[0086] ;
[0087] in, A preset knowledge retention weighting coefficient is used to adjust the relative proportion between the learning ability for newly added defect categories and the ability to retain historical defect knowledge. The larger the value, the stronger the constraint on maintaining the stability of response characteristics within the region of historical defects during the model update process. (This refers to the constraint amount updated based on model parameters.) The model parameters of the identification model after incremental update are updated using gradient descent, i.e.:
[0088] ;
[0089] in, To identify model parameters after incremental updates following parameter updates. The preset learning rate.
[0090] by To optimize the objective, the gradients of the incrementally updated model parameters for all trainable parameters are calculated. Backpropagation is then performed using a gradient descent optimizer (such as stochastic gradient descent (SGD) or Adam), updating the network weights and biases layer by layer. This update process is iterative until... The training converges or reaches the preset number of training epochs. The updated model parameters are denoted as... The corresponding model is the updated incremental recognition model.
[0091] This scheme forms the model parameter update constraint by weighting and combining the loss for identifying new defect categories with the loss for knowledge retention constraints. This ensures that the model parameter update process is simultaneously constrained by the learning objective for new defect categories and the response stability objective within the historical defect retention region. Combined with the aforementioned process of determining the historical defect retention region and calculating the loss for knowledge retention constraints, the model parameter update constraint reflects both the identification requirement for new defect categories and the local retention requirement for historical defect features, providing a unified optimization objective for the incremental update process that balances both new and old defect knowledge.
[0092] This application further proposes to obtain an updated industrial defect identification model, including:
[0093] Based on the updated model parameters, the historical defect category identification results and category identification results output by the incrementally updated identification model are re-obtained, and the changes in historical defect features corresponding to the historical defect category identification results and the category identification loss corresponding to the category identification results are used as model update evaluation data.
[0094] When the model update evaluation data meets the preset model update conditions, the incremental update identification model after parameter update is determined as the industrial defect identification update model.
[0095] Specifically, after completing one round of model parameter updates, the surface defect image samples are re-input into the incrementally updated recognition model to obtain the model's classification results for historical defect categories and newly added defect categories. Then, the response features of the model at the corresponding locations in the historical defect retention areas are extracted as described above. (Historical defect feature change amount) It is used to measure the degree of deviation of the response characteristics within the historical defect preservation region before and after parameter updates, and its calculation relationship is as follows:
[0096] ;
[0097] in, After updating the parameters, the model is in the first... The response characteristics of the output at each location, To identify the model before incremental update in the 1st month Historical defect characteristics output at each location, Maintain the number of locations included in the region for historical defects. Include the variation in historical defect characteristics. Category recognition loss of the model after parameter update Together, they serve as evaluation data for model updates, and are comprehensively judged according to preset model update conditions:
[0098] ;
[0099] in, Update the overall evaluation metric for the model; , These are the preset weighting coefficients corresponding to the changes in historical defect features and the category recognition loss, respectively. ( When the preset model update evaluation threshold is reached, it indicates that the model after this round of parameter updates has met the preset requirements in both maintaining historical defect knowledge and identifying newly added defect categories, and the model is determined as the industrial defect identification and update model; when If necessary, you can return to the aforementioned model parameter update step and adjust the knowledge retention weight coefficients. After obtaining the parameters, the update process is repeated until the preset model update conditions are met.
[0100] This application uses both the changes in historical defect features and the loss from identifying new defect categories as evaluation data for model updates. It determines the final industrial defect identification update model based on the comparison between the comprehensive evaluation and a preset threshold. This ensures that the judgment of whether the model has completed the update considers both the degree of retention of historical defect knowledge and the degree of learning of new defect categories. Combined with the aforementioned process of constructing model parameter update constraints, a complete technical chain is formed, from defect feature migration trajectory analysis, determination of historical defect retention areas, calculation of knowledge retention constraint loss to model parameter updates and update effect evaluation. This provides a quantifiable and traceable technical solution for incremental updates of industrial defect identification models in scenarios with continuously added defect categories.
[0101] As a preferred embodiment, the solution of this application is specifically implemented as follows:
[0102] The company's original industrial defect recognition model could identify two types of surface defects: "scratches" and "pores". Recently, a new type of defect, "dents", has appeared on the production line. The model needs to be able to recognize dents without significantly reducing its ability to identify the original two types of defects.
[0103] Read the current model parameters of the industrial defect identification model to be updated They were identified as model parameters before incremental updates. ; Collected surface defect image samples numbered S107 (historical category: scratch) and S133 (historical category: porosity) and 120 dent defect image samples, and sorted them by learning rate. Perform incremental fine-tuning on the model to be updated, and identify the model parameters after the incremental update. .
[0104] Input sample S107 into the recognition model before and after incremental update, respectively, read the defect response data matrix output by the preset hidden layer, and determine the coordinates of the historical defect response locations. Update the defect response location coordinates Historical Defect Response Area Includes 40 locations, update defect response area It contains 36 locations, with 30 overlapping locations, resulting in a total of 46 locations after combination; historical defect response intensity values. Update the defect response intensity value .
[0105] Calculate the feature transfer distance data corresponding to S107. Regional change data Intensity change data Set a preset position threshold. Preset area change threshold Preset response change threshold All three conditions are met, therefore the historical defect response area corresponding to S107 is [defined]. This area was identified as a region where historical defects are preserved. The same method was used to calculate the results for sample S133. ,Exceed Since the preset retention conditions are not met, the historical defect response area corresponding to S133 is merged with the updated defect response area to generate the historical defect retention area corresponding to this sample.
[0106] Based on the historical defect retention region determined from all samples, calculate the knowledge retention constraint loss. ; Calculate the loss for identifying new defect categories from 120 indentation defect samples. Knowledge retention coefficients To obtain the model parameter update constraint quantity According to learning rate Perform a gradient update on the identified model parameters after the incremental update.
[0107] Recalculate the change in historical defect characteristics within the historical defect retention area. The class recognition loss of the model after parameter update Take the weighting coefficients , , obtain comprehensive evaluation score Less than the preset model update evaluation threshold The model was determined to meet the preset model update conditions, and the updated model was designated as the industrial defect identification update model. Statistical analysis showed that the model achieved a high accuracy rate in identifying dents, while the accuracy rate for identifying historical defects such as scratches and pores increased from 92.1% before the incremental update to 91.6% after. Compared to the ordinary incremental fine-tuning method without knowledge preservation constraints (where the historical category identification accuracy dropped to 86.3% in the control experiment), this model maintained a performance closer to the original level, indicating that this method has a certain quantitative control capability in preserving historical defect knowledge while incrementally learning new defect categories.
[0108] The above embodiments are only used to illustrate the technical methods of this application and are not intended to limit it. Although this application has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical methods of this application without departing from the spirit and scope of the technical methods of this application.
Claims
1. An efficient model update method based on incremental learning and knowledge distillation, characterized in that, Includes the following steps: Acquire new defect categories and their corresponding identification models before incremental update, identification models after incremental update, defect category identification data, and surface defect image samples of industrial products; The surface defect image samples are input into the recognition model before incremental update and the recognition model after incremental update, respectively, to obtain the corresponding defect analysis data and category recognition results, and to establish a sample correspondence relationship based on the surface defect image samples; The historical defect features and updated defect features are analyzed by the sample correspondence to generate defect feature migration trajectory data containing feature change data; Based on the relationship between the feature change data in the defect feature migration trajectory data and the preset retention conditions, the historical defect retention area is determined; Based on the historical defect retention area, the feature difference constraint between the historical defect features and the updated defect features is determined. Then, by using the feature difference constraint, the category identification result output by the incrementally updated identification model and the category identification data are analyzed to update the incrementally updated identification model and obtain the industrial defect identification update model.
2. The efficient model update method based on incremental learning and knowledge distillation according to claim 1, characterized in that, The process of obtaining newly added defect categories and their corresponding identification models before and after incremental updates, defect category identification data, and surface defect image samples of industrial products includes: Obtain surface defect image samples of industrial products corresponding to the industrial defect identification model to be updated and the newly added defect categories. The surface defect image samples include images of the surface of industrial products and corresponding defect category identification data. The identification model before incremental update is determined based on the current model parameters of the industrial defect identification model to be updated, and the industrial defect identification model to be updated is incrementally updated based on the surface defect image samples corresponding to the newly added defect categories and the defect category identification data to obtain the identification model after incremental update.
3. The efficient model update method based on incremental learning and knowledge distillation according to claim 1, characterized in that, The process of obtaining the corresponding defect analysis data includes: The defect analysis data includes historical defect features and updated defect features, both of which include defect response location, defect response area, and defect response intensity. When the surface defect image samples are input into the recognition model before incremental update and the recognition model after incremental update respectively, the defect response data matrix output by the preset hidden layer in the recognition model before incremental update and the recognition model after incremental update is obtained. Based on the spatial correspondence in the defect response data matrix, the defect response data matrix output by the identification model before incremental update is recorded as the historical defect feature, and the defect response data matrix output by the identification model after incremental update is recorded as the updated defect feature.
4. The efficient model update method based on incremental learning and knowledge distillation according to claim 1, characterized in that, The process of generating feature variation data includes: The feature change data includes feature migration distance data, regional change data, and intensity change data; Obtain the historical defect response location coordinates from the historical defect features and the updated defect response location coordinates from the updated defect features, and calculate the feature migration distance data. ; ; in, The feature migration distance data is used to represent the degree of position shift of the identification model in response to the same surface defect area of an industrial product before and after incremental update; , These represent the x-coordinate and y-coordinate of the historical defect response location coordinates, respectively; , These represent the x-coordinate and y-coordinate of the updated defect response location coordinates, respectively.
5. The efficient model update method based on incremental learning and knowledge distillation according to claim 4, characterized in that, Generate defect feature migration trajectory data, including: Obtain the range of the historical defect response region in the historical defect features and the range of the updated defect response region in the updated defect features, and determine the region overlap range; The regional change data is calculated based on the overlapping range of the regions, and the calculation relationship is as follows: ; in, This represents the change data in the region; This indicates the range of the historical defect response area; This indicates the range of the updated defect response area; Indicates the number of overlapping positions between two regions; This indicates the number of locations after combining two regions. Intensity change data is generated based on the relationship between the historical defect response intensity value and the updated defect response intensity value. The feature migration distance data, the region change data, and the intensity change data are then associated with the surface defect image samples to generate defect feature migration trajectory data.
6. The efficient model update method based on incremental learning and knowledge distillation according to claim 1, characterized in that, Identify areas for preserving historical defects, including: The feature migration distance data, the region change data, and the intensity change data in the defect feature migration trajectory data are compared with preset retention conditions, respectively. When the following conditions are met: ; ; When the historical defect response area is defined as the historical defect retention area, the historical defect response area is determined. in, Indicates a preset position threshold; Indicates the preset area change threshold; This indicates the preset response change threshold.
7. The efficient model update method based on incremental learning and knowledge distillation according to claim 1, characterized in that, Determining the feature difference constraint between the historical defect features and the updated defect features based on the historical defect retention region includes: Based on the historical defect retention region, a corresponding location set is determined. The feature difference constraint between the historical defect features and the updated defect features within the corresponding location set is calculated to generate a knowledge retention constraint loss. The calculation relationship for the knowledge retention constraint loss is as follows: ; in, This indicates the knowledge retention constraint loss; This indicates the number of locations contained in the historical defect retention area; Indicates the first Does each location belong to the historical defect retention area? This represents the historical defect feature corresponding to the i-th position; This represents the updated defect feature corresponding to the i-th position.
8. The efficient model update method based on incremental learning and knowledge distillation according to claim 1, characterized in that, The process of updating the incrementally updated identification model to obtain the updated industrial defect identification model includes: Obtain surface defect image samples corresponding to the newly added defect categories, and input them into the incrementally updated recognition model to obtain the category recognition results; Based on the difference between the category identification results and the corresponding defect category identification data, a new defect category identification loss is generated; The loss for identifying the new defect category is combined with the loss for maintaining knowledge to generate a model parameter update constraint, and the model parameters in the incrementally updated identification model are updated according to the model parameter update constraint.
9. The efficient model update method based on incremental learning and knowledge distillation according to claim 6, characterized in that, Also includes: When the feature migration distance data, the region change data, or the response change data do not meet the preset retention conditions, the defect response region in the historical defect feature data is combined with the defect response region in the updated defect feature data to generate a historical defect retention region.
10. The efficient model update method based on incremental learning and knowledge distillation according to claim 8, characterized in that, Obtain an updated industrial defect identification model, including: Based on the updated model parameters, the historical defect category identification results and category identification results output by the incrementally updated identification model are re-obtained, and the changes in historical defect features corresponding to the historical defect category identification results and the category identification loss corresponding to the category identification results are used as model update evaluation data. When the model update evaluation data meets the preset model update conditions, the incremental update identification model after parameter update is determined as the industrial defect identification update model.