A single-stage target detection incremental learning method and device based on conflict suppression
Patent Information
- Application Number
- CN202611336402.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-31
- Publication Date
- 2026-10-27
AI Technical Summary
[0007]本发明旨在克服上述现有技术的至少一种缺陷,提供一种基于冲突抑制的单阶段目标检测增量学习方法,以解决目前工业场景检测在持续学习新类别时的旧知识遗忘、数据隐私保护及实时性维持等问题
(1)本发明提供的一种基于冲突抑制的单阶段目标检测增量学习方法和装置,对单阶段检测器中“未标注旧类被强制学习为背景”的结构性缺陷进行显式建模,通过教师模型在前向传播中在线识别潜在旧类区域,并创造性地采用对数障碍函数构建冲突抑制损失;利用对数障碍函数在边界处的无穷大惩罚特性,将错误的背景负监督信号反转为正向修正信号。在数学梯度层面阻止了新类训练对旧类特征响应的擦除,从底层机制上消除了前景-背景监督冲突,显著缓解了单阶段检测器在持续学习中的灾难性遗忘。
Smart Images

Figure CN122990427A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the technical field of vision and continuous learning, and more specifically, relates to a single-stage incremental learning method and apparatus for object detection based on conflict suppression. Background Technology
[0002] With the development of deep learning technology, object detection algorithms based on convolutional neural networks have been widely applied in industrial automation defect detection scenarios. In actual industrial production, product iteration and process upgrades continuously generate new defect categories, and the detection model needs to continuously learn the newly added categories to adapt to production needs. An ideal incremental learning model should meet the following requirements: it should not need to access the original data of the old categories, but only use the labeled data of the new categories to complete the model update, while maintaining the detection accuracy of the old categories stably, and not reducing the inference speed to adapt to the real-time requirements of online detection.
[0003] Chinese patent document CN113205142A discloses a target detection method and apparatus based on incremental learning. The method involves training a target detection network using old category sample images to obtain an original model; adding a new category detection branch for new category sample images to the output layer of the original model and initializing the parameters of the new category detection branch to obtain an incremental learning model; training the incremental learning model using new category sample images; during training, constructing a loss function using the approximation error between the output of the old category detection branch of the incremental learning model and the prediction output of the original model, and the detection error of the new category sample images in the new category detection branch of the incremental learning model, to optimize the parameters of the incremental learning model, thus obtaining a target detection model with determined parameters.
[0004] Existing deep learning-based defect detection systems still have the following problems: 1. Catastrophic Forgetting and Foreground-Background Confusion: In single-stage object detectors, unlabeled object regions are treated as background by default. During incremental learning, old class objects exist in new data but are unlabeled. These regions are incorrectly used as negative samples in training, causing the model to gradually suppress old class responses, resulting in severe catastrophic forgetting.
[0005] 2. Data privacy restrictions hinder the application of experience replay methods: Traditional experience replay methods require storing original image data of old categories, which violates the requirements for data privacy and security in industrial scenarios and is difficult to deploy in practice.
[0006] 3. Lack of structural solutions for single-stage detectors: Existing methods mostly employ knowledge distillation to mitigate forgetting, but fail to model the structural problem of "unlabeled old classes being mistakenly learned as background." Furthermore, in object detection tasks, there is still a lack of unified and effective solutions for the collaborative distillation of classification, localization, and confidence branches, as well as parameter protection mechanisms. Summary of the Invention
[0007] The present invention aims to overcome at least one of the defects of the prior art and provide a single-stage incremental learning method for object detection based on conflict suppression, so as to solve the problems of forgetting old knowledge, data privacy protection and real-time performance maintenance when continuously learning new categories in current industrial scene detection.
[0008] The detailed technical solution of this invention is as follows: A single-stage incremental learning method for object detection based on conflict suppression, the method comprising: S1: Obtain the image data to be inspected, including all old category defects, to form the original defect dataset, and conduct supervised training in the pre-built YOLOX object detection model until the model converges. Then, freeze all network parameters of the model to obtain a teacher network model with stable old category detection capability. S2: Copy all the weight parameters of the teacher network model to a student network model to be trained, then linearly expand the number of classification branch channels of the detection head of the student network model, and randomly initialize the weight parameters corresponding to the new category to obtain an initial student network model that can support the detection of both new and old categories. Simultaneously, new raw wood surface images to be inspected are collected, including: newly labeled defects and unlabeled old defects, to construct an incremental defect dataset; S3: Extract candidate regions of old categories from the teacher network model, obtain local features through region of interest alignment operation and transform them into low-dimensional feature vectors, obtain the mean vector and covariance matrix of each old category based on the low-dimensional feature vectors, construct a structured prototype and store it in the structured prototype library. S4: Train the initial student network model using an incremental defect dataset with only new categories labeled, construct a loss function based on the structured prototype as the optimization objective, and collaboratively guide the parameter update of the student network model to obtain the final student network model. S5: After training is complete, input the image of the industrial wood surface to be inspected into the final student network model, and output the defect category label, the pixel coordinates of the bounding box center point, and the defect size window information.
[0009] Furthermore, the structured prototype extraction of S3 specifically includes: S3.1 Select the P3 feature layer of the path aggregation network in the teacher network model as the feature prototype extraction layer; S3.2 Input the old category image into the teacher network model, output the detection probability of each region through the classification and regression branches, filter the old category candidate regions with high confidence, and remove the redundant regions with spatial overlap of the old category candidate regions through non-maximum suppression; S3.3 For each candidate region of the old category, perform a region of interest alignment operation on the P3 feature map output by the P3 feature layer, and reduce the dimensionality of the truncated local feature map through a global average pooling layer to transform it into a low-dimensional feature vector representing the geometric distribution of the defect texture of the old category. ; S3.4 performs statistical aggregation on multiple feature vectors of the same old defect category c to construct a vector including the mean vector. Covariance Matrix Structured Prototype : (1) , (2) in, Belongs to the old defect category The total number of high-confidence candidate regions; The sample index of the feature vector; S3.5 provides a structured prototype for all old categories. It is stored as a structured data file, i.e., a prototype library, for use in subsequent incremental training.
[0010] Furthermore, S4 specifically includes: S4.1: During the incremental training iteration, for the currently input incremental sample image, the student network model forward computes the spatial locations. Local feature vectors at [location] ; Then, the pre-stored old category is read from memory. mean vector of structured prototype , This represents the current defect category index used to calculate the smoothed prediction probability; the mean vector is calculated as follows. With the local feature vector The cosine similarity is used to obtain the prototype matching score. ; The score is used as prior knowledge to compensate the original Logits matrix of the student model's classification branch output. In this process, the final classification Logits matrix is obtained. : (4) The Softmax function is then used to calculate the final old class prediction probability, including prototype-guided predictions. : (5) in, This represents a cyclic class index used for denominator accumulation normalization; S4.2: Constructing Foreground-Background Conflict Suppression Loss ; Since the old defects are not labeled in the incremental defect dataset, according to the regression rules of the single-stage detector, these regions are used to calculate the loss for the new category. They will be forced to be monitored as background characters; To reverse this erroneous supervisory signal, the current timber image is input into the frozen teacher network model for forward computation, and the prediction result at spatial location x in the feature map is output: (6) in, Let c be the normalized probability of belonging to the old class c. Forward confidence level.
[0011] Define the set of potential old category regions The set will include positions that meet the following conditions: (7) For the old category set, A confidence threshold exists for the old target; Calculate the background probability output by the student network model at the same location x: (8) in, Represents the spatial location of the student network model The output includes defect categories guided by old class feature prototypes. The predicted probability, i.e. ; This represents the complete set of categories, including both new and old defect categories. For sets Within the region, a logarithmic barrier function is introduced to construct a foreground-background conflict suppression loss. : (9) This is the overflow prevention constant; S4.3: Constructing Teacher-Student Distillation Loss ; The current timber image is simultaneously input into both the teacher and student models. Three-way joint distillation is performed within the foreground region FG, which the teacher model predicts as a defect, to avoid background noise interference. (10) First, perform branch distillation: calculate the smoothed L1 loss of the bounding box regression parameter vectors output by the student and teacher models. The positioning manifolds of both are constrained to be consistent; (11) Only in the region predicted as the foreground by the teacher model Calculations should be performed to avoid background noise interference; among which, For the student model at the feature map location The predicted bounding box regression parameter vector; Teacher models in the same position The output of the regression parameter vector; Secondly, perform classification branch distillation: extract the original classification Logits vectors from the decoupling head output of the teacher and student models. and The KL divergence loss was calculated after softening at temperature T. This forces the student model to inherit the teacher model's knowledge about the similarity distribution between old defect categories: (12) Only in the region predicted as the foreground by the teacher model Calculations are performed to avoid background noise interference. Among these, Teacher model in position The original classification Logits vector output at the point; Student model in position The output includes a classification Logits vector guided by the old class feature prototype; The distillation temperature. Kullback-Leibler divergence is used to measure the difference between two probability distributions. This is a gradient compensation factor used to compensate for the softened gradient scale to an order of magnitude comparable to the hard label loss during backpropagation. For the Softmax function; Then, location-based confidence distillation: calculate the binary cross-entropy loss of the foreground confidence scores of the student and teacher model outputs. This constrains both to have the same activation intensity for the defect region; (13) in, , The student model and the teacher model are located at the following positions respectively. The output is the foreground confidence score; BCE is the binary cross-entropy loss, used for binary classification supervision.
[0012] S4.4: Prototype playback; During the training of the student model, for each input image, high-confidence old category candidate regions predicted by the teacher model with a confidence level greater than a preset threshold are used. For these regions, the corresponding local feature vectors are extracted from the feature map of the student model using the RoIAlign operation, denoted as... Prototype constraint loss ( )as follows: (14) The first term is the characteristic mean square error. This brings students' characteristics closer to the old category center.
[0013] The second term is the KL divergence regularization term, which constrains the distribution of student features to be consistent with the stored distribution of the old classes. This is achieved by minimizing... This forces the features extracted by the student model to be aligned with the discreteness of the teacher model in the manifold space, thereby effectively maintaining the decision boundary shape of the old category and preventing the old category recall rate from decreasing due to feature collapse or excessive discretization.
[0014] In the formula middle, This represents the old category in the teacher model (or historical statistics). The characteristics follow a Gaussian distribution; This represents the feature vector currently extracted by the student model. Mean, in identity matrix An assumed Gaussian distribution is constructed for the covariance matrix; This is the distribution constraint balance factor.
[0015] By minimizing this loss, the mean squared error of the first feature brings the current feature closer to the pre-stored old class center. The second term, the KL divergence regularization term, constrains the Gaussian distribution shape of the student characteristics and the stored old class statistical distribution. Maintain consistency.
[0016] S4.5: Parameter subspace isolation: During the backpropagation computation phase, the classification convolutional layer weight matrix in the decoupled detection head of the student model is explicitly decomposed into the old class parameter subspace. and new class parameter subspace : (15) During the backpropagation phase of incremental training: Set the gradient to zero. This is a normal update.
[0017] S4.6: Total Loss Calculation and Parameter Update; Jointly calculate the total loss function Backpropagation is performed based on this total loss, and the gradient descent algorithm is used to dynamically update the student model except for... For all other network physical parameters, complete a single iteration of optimization, and repeat the iteration until the end.
[0018] In summary, the constructed total loss function is: (3) in, For new category detection loss, new category loss It consists of three parts: classification loss for the new category, position regression loss, and prospect confidence loss, which are inherent losses and can be obtained directly; For teacher-student distillation losses; The structured prototype constraint loss; To mitigate loss due to foreground-background conflict; These are all hyperparameters, set according to the training situation.
[0019] S5: Reasoning Stage; After incremental training is completed, the image of the industrial wood surface to be inspected is input into the updated student network model. Without increasing hardware computational overhead, the student network model performs a single-stage forward computation using the updated full parameters, and simultaneously outputs the category labels, bounding box center pixel coordinates, and defect size window information for both the old and new defect categories.
[0020] In another aspect of the invention, a single-stage incremental learning device for target detection based on conflict suppression is provided, the device comprising: At least one processor; and The memory stores instructions that, when executed by the at least one processor, cause the at least one processor to perform a single-stage incremental learning method for object detection based on conflict suppression as described above.
[0021] In another aspect of the invention, a computer-readable storage medium is also provided, which stores executable instructions that, when executed, cause the machine to perform a conflict-suppression-based single-stage incremental learning method for object detection as described above.
[0022] Compared with the prior art, the beneficial effects of the present invention are as follows: (1) The present invention provides a single-stage object detection incremental learning method and apparatus based on conflict suppression, which explicitly models the structural defect of "unlabeled old classes being forced to learn as background" in single-stage detectors. It identifies potential old class regions online during forward propagation using a teacher model and creatively employs a logarithmic barrier function to construct a conflict suppression loss. Utilizing the infinite penalty characteristic of the logarithmic barrier function at the boundary, it reverses the erroneous background negative supervision signal into a positive correction signal. This prevents the erasure of old class feature responses by new class training at the mathematical gradient level, eliminating foreground-background supervision conflict from the underlying mechanism and significantly alleviating the catastrophic forgetting of single-stage detectors during continuous learning.
[0023] (2) The present invention provides a single-stage incremental learning method and apparatus for target detection based on conflict suppression. It uses a structured prototype including mean and covariance to replace the original image data for knowledge playback. Since it only needs to store low-dimensional statistics representing the distribution of old-class defect features, namely the mean vector and covariance matrix, its storage space is reduced by several orders of magnitude compared with traditional experience playback (saving the original image). This not only completely avoids the privacy and security control risks of industrial core data in physical terms, but also greatly reduces the consumption of storage resources of edge computing devices by industrial online detection systems and improves the deployment flexibility of the system.
[0024] (3) The present invention provides a single-stage incremental learning method and device for target detection based on conflict suppression, which constructs a three-level all-round protection system of "output layer distillation + feature layer prototype constraint + parameter layer spatial isolation" from the perspective of the entire network architecture: First, at the output layer level: a dual joint distillation of class log odds and confidence scores is adopted to ensure that the student model maximizes the inheritance of the macroscopic detection output performance of the teacher model. Second, at the feature layer level: a structured prototype constraint loss based on the P3 feature layer is used to forcibly constrain the feature manifold distribution extracted by the student model to prevent collapse and maintain the morphological stability of the old defect feature boundary. Third, at the parameter layer level: by explicitly setting the gradient of the old class parameter subspace to zero in the weight matrix of the decoupled detection head classification convolutional layer, the classification decision channel of the old class is locked from the backpropagation mechanism of computer hardware parameter update, thus constructing a physical blockage. This three-level system works in multiple dimensions to coordinate soft logical constraints (loss function) and hard physical isolation (gradient deadlock), perfectly resolving the inherent conflict between rapid convergence of new classes and performance preservation of old classes. Attached Figure Description
[0025] Figure 1 This is the flowchart of incremental learning knowledge distillation described in this invention.
[0026] Figure 2 This is a schematic diagram of the foreground-background conflict suppression mechanism in Embodiment 1 of the present invention.
[0027] Figure 3 is a schematic diagram of the structured prototype mechanism in Embodiment 1 of the present invention.
[0028] Figure 4 is a schematic diagram of the prototype-participatory classification mechanism in Embodiment 1 of the present invention. Detailed Description of the Embodiments
[0029] The present invention will be further described below with reference to the accompanying drawings and embodiments.
[0030] It should be noted that the following detailed description is exemplary and aims to provide further explanation of the present invention. Unless otherwise specified, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which the present invention pertains.
[0031] It is to be noted that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the exemplary embodiments according to the present invention. As used herein, unless the context clearly dictates otherwise, the singular forms are also intended to include the plural forms. Furthermore, it should be understood that when the terms "comprise" and / or "comprising" are used in this specification, they specify the presence of stated features, steps, operations, devices, components, and / or combinations thereof.
[0032] The embodiments of the present invention and the features in the embodiments may be combined with each other on a non-conflicting basis.
[0033] Embodiment 1 Refer Figure 1 , the present embodiment provides a single-stage object detection incremental learning method based on conflict suppression, and the method comprises: S1: Teacher model training and freezing.
[0034] First, industrial image acquisition equipment (for example, a high-resolution camera) is used to acquire to-be-inspected image data including all defects of old categories to form an original defect dataset, where the defects of old categories are, for example, dead knots, live knots, burrs and the like on the wood surface.
[0035] Then, the original defect dataset is input into a pre-constructed YOLOX object detection model for supervised training until the model converges; Subsequently, all network parameters of the model are frozen to serve as a teacher network model, and at this time, the model has the capability of stably identifying the image features of the defects of the old categories.
[0036] S2: Student model initialization and expansion.
[0037] Copy all weight parameters of the teacher network model to a student network model to be trained; for the newly added wood defect categories (such as newly appearing decay and wormhole defects), linearly expand the number of classification channels in the decoupled detection head of the student network model, and randomly initialize the weight parameters corresponding to the new categories, thereby constructing an initial student network model that can simultaneously accommodate feature mappings of the old and new categories.
[0038] Next, new raw wood surface image data to be inspected is collected, focusing on collecting and labeling wood surface data containing two new types of defects: decay and wormholes. It is important to note that the new raw wood surface image data will inevitably include previously learned defect categories (dead knots, live knots, burrs, etc.), but these do not need to be re-labeled. Only the new defect categories need to be labeled to construct an incremental defect dataset.
[0039] S3: Structured prototype extraction and storage; In this embodiment, the structured prototype extraction and storage are as follows: Figure 3 As shown, firstly, the teacher network model is used to extract candidate regions of old categories. Local features are obtained through region of interest alignment and transformed into low-dimensional feature vectors. Based on the low-dimensional feature vectors, the mean vector and covariance matrix of each old category are obtained, and a structured prototype is constructed. Subsequently, during incremental training, the student network model utilizes the structured prototype to participate in classification prediction, thereby enabling the replay of old category knowledge.
[0040] The extraction and storage of the structured prototype is an offline process, using only old class data, specifically including: S3.1 Feature layer selection; The P3 feature layer of the path aggregation network (PANet) in the teacher network model is taken as the physical feature prototype extraction medium to carry high-resolution defect geometry and texture information. The Path Aggregation Network (PANet) is the neck network of YOLOX, which performs bidirectional fusion of multi-scale features output by the backbone network to ultimately output multi-level feature maps of different resolutions. The P3 feature layer is one of the multi-level feature maps output by PANet. Here, the P3 feature map output by PANet in the trained teacher model is used as the unified feature source for subsequent extraction of local features of old categories and construction of feature prototypes. The path aggregation network outputs three layers of feature maps with different resolutions. The P3 layer outputs the highest resolution feature maps, which retain the richest spatial geometric information and detailed textures. Furthermore, due to the high resolution of the P3 layer, when performing Region of Interest Alignment (RoI Align) operations on it, more accurate spatial localization and smaller pixel alignment errors can be obtained for local feature vectors. This avoids the loss of defective spatial structure information caused by the small feature map size (severe downsampling) in deeper layers (such as the P5 layer).
[0041] S3.2 Candidate region generation; Input old class labeled data: Input the image including all old class labeled data into the teacher network model, and use the selected feature layer to perform feature extraction by the teacher model.
[0042] Candidate region selection: The defect probability of each region is calculated through its classification and regression branches, and candidate regions of each old category with high confidence are selected. The high confidence screening + non-maximum suppression (NMS) algorithm is used to eliminate spatially overlapping redundant regions.
[0043] 3.3 Feature extraction; ROI Alignment and Feature Extraction: For the selected candidate regions of old-class defects, a Region of Interest (RoI Align) operation is performed on the P3 feature map. The truncated local feature map is then dimensionality-reduced through a global average pooling layer, transforming it into a low-dimensional feature vector representing the geometric distribution of the texture of old-class defects. .
[0044] 3.4 Prototype Building; Statistical aggregation as a structured prototype: Statistical aggregation is performed on multiple feature vectors of the same old defect category c to construct a structure including a mean vector. (Center) and covariance matrix (Distribution shape) structured prototype : (1) , (2) in, Belongs to the old defect category The total number of high-confidence candidate regions; The sample index is the feature vector.
[0045] 3.5 Prototype storage; Store structured prototypes: Store structured prototypes of all old categories The data is stored as a structured data file, i.e., a prototype library (the original images are not saved), for subsequent incremental training.
[0046] S4: Incremental training; In the incremental training phase, an incremental defect dataset is input. In this dataset, images are manually labeled only for new defect categories (such as decay and insect holes), while existing defects (such as dead nodes and live nodes) are left unlabeled. Then, an initial student network model is trained using this newly labeled incremental defect dataset. A loss function is constructed based on a structured prototype as the optimization objective, collaboratively guiding the parameter updates of the student network model to obtain the final student network model. Use the total loss function to collaboratively guide parameter updates for student network models: (3) Loss detection for the new category; For teacher-student distillation losses; The structured prototype constraint loss; To mitigate loss due to foreground-background conflict; These are all hyperparameters, set according to the training situation.
[0047] Furthermore, S4 specifically includes: S4.1: Prototype-based participatory classification mechanism, belonging to the training / reasoning phase, such as... Figure 4 As shown.
[0048] Local feature extraction: During incremental training iterations, for the currently input incremental sample image, the student network model (P3 feature layer) performs forward computation to obtain the spatial locations. Local feature vectors at [location] ; Calculate the similarity with each old class prototype: Then, read the pre-stored old categories from memory, i.e., the prototype library. mean vector Calculate its relationship with the local feature vector. The cosine similarity is used to obtain the prototype matching score. That is, the score vector s: (16) in, Represents the spatial location coordinates (or grid cell index) on the feature map of the current input image; Weighted Compensation to Classification Logits: The prototype matching score (weighted) s is used as prior knowledge to compensate the original Logits matrix output by the classification branch of the student model. In this process, the final classification Logits matrix is obtained. : (4) Among them, the compensation for the new category K is 0; Softmax outputs the final probability: The final probability of the old class prediction, including prototype guidance, is calculated using the Softmax function. : (5) in: This indicates the current defect category number in the current calculation of the smooth prediction probability; This represents the cyclic category index (or traversal category number) used for denominator accumulation and normalization.
[0049] S4.2 Foreground-Background Conflict Suppression – Solving the Problem of Misjudgment Due to Unlabeled Classes (Constructing Foreground-Background Conflict Suppression Loss) ),like Figure 2 As shown.
[0050] Since the old defects are not labeled in the incremental defect dataset, according to the regression rules of the single-stage detector, these regions are used to calculate the loss for the new category. They will be forced to be supervised as “background (negative sample)”.
[0051] To reverse this erroneous supervisory signal, the current wood image (incremental training data (new class only)) is input into the frozen teacher network model (frozen gradient) for forward computation, and the prediction result at position x is the old class response result: (6) in, Let c be the normalized probability of belonging to the old class c. Forward confidence level.
[0052] Define the set of potential old category regions The set will include positions that meet the following conditions: (7) Note: For the old category set; For the old target, a confidence threshold exists; in the industrial wood defect detection scenario, [the threshold is taken]. =0.80, to ensure the purity of pseudo-label generation and avoid misclassifying difficult-to-distinguish backgrounds as old targets.
[0053] Simultaneously, the background probability output by the student network model (with normal gradient updates) at the same position x is calculated, which represents the response results of the new and old classes: (8) in: Represents the spatial location of the student network model The output includes defect categories guided by old class feature prototypes. The predicted probability, i.e. ; This represents the complete set of categories, including both new and old defect categories, i.e., the full category space. .
[0054] For sets Within the region, a logarithmic barrier function is introduced to construct a foreground-background conflict suppression loss. : (9) Preferred overflow prevention constant = To prevent overflow of tiny numbers.
[0055] The physical mechanism means that when a student network model is influenced by new, unlabeled rules, it tends to predict the unlabeled old defect area as background (i.e., When the log term approaches negative infinity, it leads to... .
[0056] Compared to traditional methods: incremental training data (only new classes are labeled) - network forward propagation and output prediction - unlabeled old class regions are forced to participate in training as background - loss of old class region detection ability, resulting in catastrophic forgetting. This invention generates a large penalty gradient at this time, which physically prevents the model from erasing the old defect feature response channels, forcibly retains the feature response of the region, thereby eliminating the conflict between foreground and background supervision signals.
[0057] S4.3: Constructing Teacher-Student Distillation Loss ; The current timber image is simultaneously input into both the teacher and student models. Three-way joint distillation is performed within the foreground region FG, which the teacher model predicts as a defect, to avoid background noise interference. (10) First, perform branch distillation: calculate the bounding box regression parameter vectors output by the student and teacher models ( Smoothing L1 loss The positioning manifolds of both are constrained to be consistent; (11) Only in the region predicted as the foreground by the teacher model Calculations should be performed to avoid background noise interference; among which, For the student model at the feature map location The predicted bounding box regression parameter vector; Teacher models in the same position The output regression parameter vector (format is the same as the student's); For YOLOX, That is, the offset relative to the anchor point (or grid center) and the logarithmic scaling of width and height. This represents the center point coordinates of the predicted target bounding box, with horizontal and vertical offsets relative to the top-left vertex of the current feature map grid cell. This represents the width and height of the predicted target bounding box, scaled logarithmically relative to a preset baseline scale (or grid size).
[0058] Secondly, classification branch distillation: extracting the original classification Logits vectors from the decoupling head output of the teacher and student models. and The KL divergence loss was calculated after softening at temperature T. This forces student models to inherit the teacher model's knowledge about the similarity distribution between old defect categories (such as the physical similarity between "cracks" and "scratches"). (12) Only in the region predicted as the foreground by the teacher model Calculations are performed to avoid background noise interference. Among these, Teacher model in position The output is the original classification Logits vector (scores without Softmax, dimension is the number of categories); Student model in position The output includes a classification Logits vector guided by the old class feature prototype (scores without Softmax, with the dimension being the number of classes). The Softmax function is defined as follows: (17) in, This is the Logits vector. Here, the input to Softmax is the temperature-dependent input. Scaled Logits: . The distillation temperature is used to soften the class probability distribution, allowing the teacher model output to include more information about inter-class similarity (e.g., the similarity in features between "crack" and "scratch"), thereby guiding the student model to learn a smoother decision boundary. Kullback-Leibler divergence measures the difference between two probability distributions. This loss forces the class distribution of the student model's output to approximate the smooth distribution of the teacher model. This is a gradient compensation factor, the value of which is related to the distillation temperature. The squares are consistent (i.e.) ), used to compensate the softened gradient scale to an order of magnitude comparable to the hard label loss during backpropagation; Then, positional confidence distillation: calculate the binary cross-entropy loss of the foreground confidence score (ObjectnessScore) of the student and teacher model outputs. This constrains both to have the same activation intensity for the defect region; (13) in, , : These represent the student model and the teacher model in terms of location. The output foreground confidence score (Objectness Score), with a numerical range of... , which represents the probability that the location contains the target.
[0059] BCE: Binary Cross Entropy Loss, used for binary classification supervision.
[0060] The student model is constrained to activate the same intensity of the foreground / background regions as the teacher model.
[0061] S4.4: Prototype Replay (Constructing Prototype Constraint Loss) ); During the training of the student model, for each input image, the teacher model predicts high-confidence candidate regions for the old class. For these regions, the RoI Align operation is used to extract the corresponding local feature vectors from the feature map of the student model, denoted as . Constructing prototype constraint loss as follows: (14) The first item: feature mean squared error, which narrows the distance between student features and the old category center.
[0062] The second term, the KL divergence regularization term, constrains the distribution of student features to match the stored distribution of the old classes. This is achieved by minimizing... This forces the features extracted by the student model to be aligned with the discreteness of the teacher model in the manifold space, thereby effectively maintaining the decision boundary shape of the old category and preventing the old category recall rate from decreasing due to feature collapse or excessive discretization.
[0063] In the formula middle, This represents the old category in the teacher model (or historical statistics). The characteristics are governed by a Gaussian distribution. This represents the feature vector currently extracted by the student model. Mean, in identity matrix An assumed Gaussian distribution is constructed for the covariance matrix (an auxiliary distribution used to calculate the KL divergence). Let be the distribution constraint balance factor, and take . .
[0064] By minimizing this loss, the mean squared error of the first feature brings the current feature closer to the pre-stored old class center. The second term, the KL divergence regularization term, constrains the Gaussian distribution shape of the student characteristics and the stored old class statistical distribution. Maintain consistency. At the physical level, the old-class defect features extracted by the student model are forced to not collapse or become over-discrete in the manifold space, thus preserving the decision boundary shape of the old defects.
[0065] S4.5: Parameter subspace isolation: During the backpropagation computation phase, the classification convolutional layer weight matrix in the decoupled detection head of the student model is explicitly decomposed into the old class parameter subspace. and new class parameter subspace : (15) During the backpropagation phase of incremental training: Set the gradient to zero (or multiply it by a very small learning rate factor). Only very minor adjustments are allowed to protect the decision boundaries of the old categories. This is a normal update.
[0066] Backbone feature extraction layer: Although updated, it is affected by... and Strong constraints maintain the characteristic manifold structure.
[0067] S4.6: Total Loss Calculation and Parameter Update; Jointly calculate the total loss function Backpropagation is performed based on this total loss, and the gradient descent algorithm is used to dynamically update the student model except for... The remaining network physical parameters, excluding those specified, are optimized in a single iteration.
[0068] Total loss function: (3) in: For new category detection loss, new category loss It consists of three parts: classification loss for the new category, position regression loss, and prospect confidence loss, which are inherent losses and can be obtained directly; For teacher-student distillation losses; The structured prototype constraint loss; To mitigate loss due to foreground-background conflict; These are all hyperparameters, set according to the training situation.
[0069] S5: Reasoning Stage; After incremental training is completed, the images of the industrial wood surface to be inspected are input into the updated student network model. The student network model performs single-stage forward computation using the updated full parameters without increasing additional hardware computational overhead, and outputs category labels, bounding box center point pixel coordinates, and defect size window information for the old category defects (dead knots, live knots, pith) and the new category defects (decay, wormholes).
[0070] Example 2 This embodiment provides an apparatus for implementing a single-stage incremental learning method for target detection based on conflict suppression, the apparatus comprising: At least one processor; and The memory stores instructions that, when executed by the at least one processor, cause the at least one processor to perform a single-stage incremental learning method for object detection based on conflict suppression as described above.
[0071] In this embodiment, the device can be an electronic device, which may include, but is not limited to: personal computer, server computer, workstation, desktop computer, laptop computer, notebook computer, mobile computing device, smartphone, tablet computer, cellular phone, personal digital assistant (PDA), handheld device, messaging device, wearable computing device, consumer electronic device, etc.
[0072] Example 3 This embodiment also provides a machine-readable storage medium storing executable instructions that, when executed, cause the machine to perform a single-stage incremental learning method for object detection based on conflict suppression as described above.
[0073] Specifically, a system or apparatus equipped with a readable storage medium may be provided, on which software program code implementing the functions of any of the embodiments described above is stored, and the computer or processor of the system or apparatus can read and execute the instructions stored in the readable storage medium.
[0074] In this case, the program code read from the readable medium itself can perform the functions of any of the above embodiments, and therefore the machine-readable code and the readable storage medium storing the machine-readable code constitute a part of this specification.
[0075] Examples of readable storage media include floppy disks, hard disks, magneto-optical disks, optical disks (such as CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD-RW), magnetic tapes, non-volatile memory cards, and ROMs. Alternatively, program code can be downloaded from a server computer or the cloud via a communication network.
[0076] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0077] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0078] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0079] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0080] Obviously, the above embodiments of the present invention are merely examples for clearly illustrating the technical solutions of the present invention, and are not intended to limit the specific implementation of the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the claims of the present invention should be included within the protection scope of the claims of the present invention.
Claims
1. A single-stage incremental learning method for target detection based on conflict suppression, characterized in that, The method includes: S1: Train and freeze the teacher network model. Using a target detection dataset labeled with all old categories, supervise the training of the pre-set single-stage target detection model until convergence, freeze all network parameters of the model, and use it as the teacher network model. S2: Copy all weight parameters of the teacher network model to the student network model to be trained; linearly expand the number of classification branch channels of the detection head of the student network model, randomly initialize the weight parameters corresponding to the newly added categories, and obtain the initial student network model; S3: Extract candidate regions of old categories from the teacher network model, obtain local features through region of interest alignment operation and transform them into low-dimensional feature vectors, obtain the mean vector and covariance matrix of each old category based on the low-dimensional feature vectors, construct a structured prototype and store it in the structured prototype library. S4: Train the initial student network model using an incremental defect dataset with only new categories labeled, construct a loss function based on the structured prototype as the optimization objective, and collaboratively guide the parameter update of the student network model to obtain the final student network model. S5: After training is complete, input the image of the industrial wood surface to be inspected into the final student network model, and output the defect category label, the pixel coordinates of the bounding box center point, and the defect size window information.
2. The single-stage incremental learning method for target detection based on conflict suppression according to claim 1, characterized in that, The structured prototype extraction specifically includes: S3.1 Select the P3 feature layer of the path aggregation network in the teacher network model as the feature prototype extraction layer; S3.2 Input the old category image into the teacher network model, output the detection probability of each region through the classification and regression branches, filter the old category candidate regions with high confidence, and remove the redundant regions with spatial overlap of the old category candidate regions through non-maximum suppression; S3.3 For each candidate region of the old category, perform a region of interest alignment operation on the P3 feature map output by the P3 feature layer, and reduce the dimensionality of the truncated local feature map through a global average pooling layer to transform it into a low-dimensional feature vector representing the geometric distribution of the defect texture of the old category. ; S3.4 performs statistical aggregation on multiple feature vectors of the same old defect category c to construct a vector including the mean vector. Covariance Matrix Structured Prototype : (1) , (2) in, Belongs to the old defect category The total number of high-confidence candidate regions. This indicates the current defect category number in the current calculation of the smooth prediction probability; The sample index of the feature vector; S3.5 provides a structured prototype for all old categories. It is stored as a structured data file, i.e., a prototype library.
3. The single-stage incremental learning method for target detection based on conflict suppression according to claim 1, characterized in that, The specific construction of the loss function as the optimization objective is as follows: Total loss function for: (3) in, For new category detection loss, new category loss It consists of three parts: classification loss for the new category, position regression loss, and prospect confidence loss, which are inherent losses and can be obtained directly; For teacher-student distillation losses; The structured prototype constraint loss; To mitigate loss due to foreground-background conflict; These are all hyperparameters, set according to the training situation.
4. The single-stage incremental learning method for target detection based on conflict suppression according to claim 1, characterized in that, The specific construction of the total loss function includes: S4.1: For the currently input incremental sample image, the student network model performs forward computation to obtain each spatial location. Local feature vectors at [location] ; Then, the pre-stored old category is read from memory. mean vector of structured prototype Then, by calculating the mean vector With the local feature vector The cosine similarity is used to obtain the prototype matching score. ; The score is used as prior knowledge to compensate the original Logits matrix of the student model's classification branch output. In this process, the final classification Logits matrix is obtained. : (4) The final old class prediction probability, including prototype guidance, is calculated using the Softmax function. : (5) in, This represents a cyclic class index used for denominator accumulation normalization; S4.2: Input the current wood image into the frozen teacher network model for forward computation, and output the prediction result at spatial location x in the feature map: (6) in, Let c be the normalized probability of belonging to the old class c. Define the foreground confidence; then, define the set of potential old class regions. The set will include positions that meet the following conditions: (7) in, For the old category set, A confidence threshold exists for the old target; Simultaneously, calculate the background probability output by the student network model at the same location x: (8) in, Represents the spatial location of the student network model The output includes defect categories guided by old class feature prototypes. The predicted probability, i.e. ; This represents the complete set of categories, including both new and old defect categories. For sets Within the region, a logarithmic barrier function is introduced to construct a foreground-background conflict suppression loss. : (9) This is the overflow prevention constant; S4.3: Input the current wood image into both the teacher and student models simultaneously. Perform three-way joint distillation within the foreground region FG, which the teacher model predicts as a defect, and construct the teacher-student distillation loss. : (10) First, perform branch distillation: calculate the smoothed L1 loss of the bounding box regression parameter vectors output by the student and teacher models. : (11) in, For the student model at the feature map location The predicted bounding box regression parameter vector; Teacher models in the same position The output of the regression parameter vector; Secondly, perform classification branch distillation: extract the original classification Logits vectors from the decoupling head output of the teacher and student models. and The KL divergence loss was calculated after softening at temperature T. : (12) in, Teacher model in position The original classification Logits vector output at the point; Student model in position The output includes a classification Logits vector guided by the old class feature prototype; The distillation temperature. Kullback-Leibler divergence; This is the gradient compensation factor; For the Softmax function; Then, location-based confidence distillation: calculate the binary cross-entropy loss of the foreground confidence scores of the student and teacher model outputs. : (13) in, , The student model and the teacher model are located at the following positions respectively. The output is the foreground confidence score; BCE is the binary cross-entropy loss, used for binary classification supervision; S4.4: During the student model training process, for each input image, high-confidence old category candidate regions predicted by the teacher model with a confidence level greater than a preset threshold are used. For these regions, the corresponding local feature vectors are extracted from the feature map of the student model using the RoIAlign operation, denoted as... Constructing prototype constraint loss as follows: (14) Among them, the first item The characteristic mean square error; the second term For KL divergence regularization, This is the distribution constraint balance factor; Represents the old category in the teacher model The characteristics follow a Gaussian distribution; This represents the feature vector currently extracted by the student model. Mean, in identity matrix An assumed Gaussian distribution is constructed for the covariance matrix; S4.5: During the backpropagation computation phase, the classification convolutional layer weight matrix in the decoupled detection head of the student model is explicitly decomposed into the old class parameter subspace. and new class parameter subspace : (15) During the backpropagation phase of incremental training: Set the gradient to zero. This is a normal update; S4.6: Jointly calculate the total loss function Backpropagation is performed based on this total loss, and the gradient descent algorithm is used to dynamically update the student model except for... For all other network physical parameters, complete a single iteration of optimization, and repeat the iteration until the end.
5. The single-stage incremental learning method for target detection based on conflict suppression according to claim 1, characterized in that, and Only in the region predicted as the foreground by the teacher model calculate.
6. A single-stage incremental learning device for target detection based on conflict suppression, used to implement the method as described in any one of claims 1-5, characterized in that, The device includes: processor; A memory on which computer programs that can run on the processor are stored; The computer program, when executed by the processor, implements the steps of a single-stage incremental learning method for object detection based on conflict suppression.
7. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Target detection method and device based on incremental learning
CN113205142A