Self-adaptive target detection method, system and equipment during online test
By employing a multi-step iterative optimization strategy involving fixed teacher consistency distillation and dynamic pseudo-label generation, the problems of unstable pseudo-label quality and high model update overhead are resolved, thereby improving the detection accuracy and stability of the model in dynamic environments and making it suitable for resource-constrained real-time deployment scenarios.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-11
- Publication Date
- 2026-03-13
AI Technical Summary
Existing adaptive object detection methods for testing suffer from unstable pseudo-label quality and high model update overhead, leading to decreased detection accuracy and stability in complex and variable testing environments. They are particularly difficult to apply effectively in resource-constrained real-time deployment scenarios.
We introduce fixed teacher consistency distillation, dynamic pseudo-label generation, and multi-step iterative optimization techniques. By combining consistency distillation loss and pseudo-label supervision loss with dynamic confidence and entropy filtering mechanisms, we optimize the student model to improve detection accuracy and stability.
It significantly improves the detection accuracy and stability of the model in dynamic environments, reduces computational and storage overhead, and achieves efficient and stable adaptive target detection in resource-constrained environments.
Smart Images

Figure CN121661331A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of computer vision and machine learning technology, and in particular to an adaptive target detection method, system and device for online testing. Background Technology
[0002] Object detection is one of the core tasks of computer vision, aiming to identify and locate specific objects in images. In practical applications, well-trained models often experience significant performance degradation due to distribution differences (i.e., domain shift) between the testing environment and the training data. Test-time adaptive techniques aim to dynamically adjust the model during the inference phase using only unlabeled test data to improve its robustness and accuracy in new environments.
[0003] However, existing test-time adaptive methods, especially those based on teacher-student network frameworks and pseudo-labels, still face key challenges. The most prominent issues are the unstable quality of pseudo-labels and the high overhead of model update mechanisms. Specifically, in complex and variable testing environments, static or simple pseudo-label selection strategies struggle to effectively filter out noise, easily leading to error accumulation. Meanwhile, while the widely adopted exponential moving average teacher model update strategy can stabilize training, its high computational and storage costs make it unsuitable for resource-constrained real-time deployment scenarios. Furthermore, small batches of test data can easily cause model statistical drift, further affecting model stability and final detection accuracy. Summary of the Invention
[0004] To address the technical problems of unstable pseudo-label quality and high model update overhead in the aforementioned adaptive testing methods, this invention provides an online adaptive target detection method, system, and device by introducing features such as fixed teacher consistency distillation, dynamic pseudo-label generation, and multi-step iterative optimization. This effectively improves the detection accuracy, stability, and deployment efficiency of the model in unknown target domains.
[0005] To achieve the above objectives, a first aspect of the present invention provides an adaptive target detection method for online testing, comprising: Obtain the input image; The input image is input into the student model to obtain the student prediction result, wherein the student model is a target detection model based on a single-shot multi-box detector architecture, and the student prediction result includes the class probability distribution and bounding box coordinates of the target in the image; The input image is input into the teacher model to obtain the teacher prediction result, wherein the teacher model is a weight copy of the student model at the beginning of the adaptation, and its weight remains fixed during the adaptation process. The teacher prediction result also includes the class probability distribution and bounding box coordinates of the target in the image. Based on the student prediction results and the teacher prediction results, the consistency distillation loss is calculated; based on the teacher prediction results, a set of pseudo-labels is generated through a dynamic pseudo-label generation process; based on the set of pseudo-labels, the pseudo-label supervision loss is calculated; based on the consistency distillation loss and the pseudo-label supervision loss, the total loss is calculated and the parameters of the student model are optimized using the total loss. The optimized student model is output as the detection result of the input image.
[0006] Furthermore, the calculation of the uniform distillation loss includes: Obtain the category probability distribution and bounding box coordinates of the prediction results for students and teachers; Based on the category probability distribution of the student and teacher prediction results, the classification consistency loss is calculated using KL divergence. Based on the bounding box coordinates of the predicted results of students and teachers, the regression consistency loss is calculated using the smoothed L1 loss function; The consistency distillation loss is obtained by weighted summing of the classification consistency loss and the regression consistency loss.
[0007] Furthermore, the dynamic pseudo-tag generation process includes: Obtain the set of prediction boxes from the teacher's prediction results, where each prediction box includes bounding box coordinates and a class probability distribution; The set of predicted boxes is filtered by confidence level, and predicted boxes with confidence levels greater than a dynamic confidence threshold are retained, wherein the dynamic confidence threshold decreases linearly with the number of iterations. Entropy filtering is applied to the predicted boxes after confidence filtering. The entropy value of each predicted box is calculated, and predicted boxes with entropy values less than the dynamic entropy threshold are retained, wherein the dynamic entropy threshold decreases linearly with the number of iterations. The predicted bounding boxes after entropy filtering are sorted by confidence level, and the top K predicted bounding boxes are retained, where K is a preset positive integer; Non-maximum suppression is performed on the retained predicted boxes to remove boxes with high overlap, resulting in the final set of pseudo-labels.
[0008] Furthermore, the calculation of the pseudo-label supervision loss includes: Obtain the bounding box coordinates and category labels from the pseudo-label set; Convert the category labels into one-hot encoded forms; Based on the class logistic values of the student's prediction results and the one-hot encoding, the classification supervision loss is calculated using the binary cross-entropy loss function; Based on the bounding box coordinates of the student prediction results and the bounding box coordinates in the pseudo-label set, the regression supervision loss is calculated using the smoothed L1 loss function. The pseudo-label supervision loss is obtained by weighted summation of the classification supervision loss and the regression supervision loss.
[0009] Furthermore, the calculation of the total loss and the optimization of the student model parameters using the total loss include: Obtain the consistency distillation loss and the pseudo-label supervision loss; The total loss is obtained by adding the pseudo-label supervision loss to the weighted consistency distillation loss. Using the total loss, the student model is optimized through multi-step iterative parameter optimization using the gradient descent algorithm, and the update magnitude is controlled by gradient clipping technique in each iteration.
[0010] Furthermore, the dynamic confidence threshold and dynamic entropy threshold in the dynamic pseudo-label generation process are adjusted with the number of iterations according to the following formula: Dynamic confidence threshold:
[0011] Dynamic entropy threshold:
[0012] in, This represents the current iteration number. This represents the total number of iterations. and These are the initial and final values of the confidence threshold, respectively. and These are the initial and final values of the entropy threshold, respectively.
[0013] A second aspect of the present invention provides an adaptive target detection system for online testing, comprising: The input module is used to acquire the input image; The student model prediction module is used to input the input image into the student model to obtain the student prediction result, wherein the student model is a target detection model based on a single-shot multi-box detector architecture, and the student prediction result includes the class probability distribution and bounding box coordinates of the target in the image; The teacher model prediction module is used to input the input image into the teacher model to obtain the teacher prediction result, wherein the teacher model is a weight copy of the student model at the beginning of the adaptation, and its weight remains fixed during the adaptation process. The teacher prediction result also includes the category probability distribution and bounding box coordinates of the target in the image. The model adaptive optimization module is used to calculate the consistency distillation loss based on the student prediction results and the teacher prediction results; generate a set of pseudo-labels through a dynamic pseudo-label generation process based on the teacher prediction results; calculate the pseudo-label supervision loss based on the pseudo-label set; calculate the total loss based on the consistency distillation loss and the pseudo-label supervision loss, and optimize the parameters of the student model using the total loss. The detection result output module is used to output the detection results of the optimized student model on the input image.
[0014] A third aspect of the present invention provides an electronic device including a memory, a processor, and a program stored in the memory and running on the processor, wherein the processor executes the program to implement the steps in the adaptive target detection method for online testing as described in the first aspect of the present invention.
[0015] A fourth aspect of the present invention provides a computer-readable storage medium having a program stored thereon that, when executed by a processor, implements the steps of the adaptive target detection method for online testing as described in the first aspect of the present invention.
[0016] A fifth aspect of the present invention provides a computer program product comprising software code, wherein the program in the software code performs the steps of the adaptive target detection method for online testing as described in the first aspect of the present invention.
[0017] Compared with existing technologies, the adaptive target detection method, system, and device for online testing provided by this invention have the following beneficial effects: (1) This invention proposes an online testing adaptive target detection method—DynSSD—which can be applied to various real-time visual scenarios such as agricultural disease detection. This invention significantly improves the adaptive performance of the model in dynamic environments by introducing a dynamic pseudo-label generation mechanism and a multi-step iterative adaptive strategy. The dynamic threshold and confidence-entropy joint screening mechanism effectively suppresses pseudo-label noise and improves the accuracy and stability of pseudo-labels. Based on this, combined with a fixed teacher consistency distillation and a small-batch multi-step update strategy, the model maintains high detection accuracy and convergence stability under different noise types (such as Gaussian noise, motion blur, and illumination perturbation). Experimental results show that this method can improve the average accuracy (mAP) of the target detection model by approximately 1%–3% compared to the unadapted baseline model without accessing source domain data (as shown in Table 2), demonstrating the practicality and reliability of this invention in real-time visual detection tasks.
[0018] (2) In response to the technical problem of unstable pseudo-label quality, this invention is based on a dynamic pseudo-label generation process. Through a dual dynamic filtering mechanism of confidence and entropy, it can select reliable predictions with high confidence and low uncertainty to generate pseudo-labels in the early stage of adaptation. As the iteration progresses, the standard is gradually relaxed to utilize more data. This mechanism effectively suppresses the introduction of noisy labels and improves the quality of pseudo-labels from the source, thereby improving the stability and detection accuracy of the model adaptation process.
[0019] (3) To address the technical problem of high model update overhead, this invention uses a fixed-weight teacher model and consistency distillation loss to provide a stable supervision signal, replacing the computationally complex exponential moving average update strategy. This not only significantly reduces computation and storage overhead, but also prevents catastrophic forgetting or excessive drift in the adaptation process by constraining the consistency between the student model output and the teacher model. Thus, it can still perform online adaptation efficiently and stably in resource-constrained environments.
[0020] (4) To address the technical problem of model drift under small batch data, this invention performs multiple iterative updates on small batch data and combines gradient clipping, so that the model can fully learn the distribution characteristics of the current test data, while avoiding training instability caused by excessive single-step updates. Thus, the model can still quickly and stably adapt to the target domain under small batch or even single image input conditions. Attached Figure Description
[0021] The accompanying drawings, which form part of this disclosure, are used to provide a further understanding of this disclosure. The illustrative embodiments of this disclosure and their descriptions are used to explain this disclosure and do not constitute an undue limitation of this disclosure.
[0022] Figure 1 This is a flowchart of the adaptive target detection method during online testing provided in Embodiment 1 of the present invention; Figure 2 This is an overall framework diagram of the adaptive target detection method during online testing provided in Embodiment 1 of the present invention; Figure 3 This is a schematic diagram of the domain generalization pest and disease detection model architecture based on self-supervised contrastive learning provided in Embodiment 1 of the present invention. Figure 4 A flowchart illustrating the analysis steps of self-supervised comparative regularization loss provided in Embodiment 1 of the present invention; Figure 5 This is a diagram of the architecture of an automatic deep learning (teacher-student adversarial, self-feedback mechanism) pest and disease detection model that resists cross-domain augmentation, as provided in Embodiment 1 of the present invention. Figure 6 This is a diagram of the training architecture of the pest and disease detection model during adaptive hybrid testing of the source domain and target domain provided in Embodiment 1 of the present invention. Figure 7 This is a diagram illustrating the application of the adaptive target detection method provided in Embodiment 1 of the present invention to the detection of fruit and vegetable diseases and pests. Figure 8 This is an architecture diagram of the online testing adaptive target detection system provided in Embodiment 2 of the present invention. Detailed Implementation
[0023] It should be noted that the following detailed descriptions are exemplary and intended to provide further illustration of the invention. Unless otherwise specified, all technical and scientific terms used in this invention have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains.
[0024] It should be noted that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the scope of exemplary embodiments according to the invention. As used herein, unless the context clearly indicates otherwise, the singular form is intended to include the plural form as well. Furthermore, it should be understood that the terms “comprising” and “having”, and any variations thereof, are intended to cover non-exclusive inclusion, for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0025] Where there is no conflict, the embodiments and features in the embodiments of the present invention can be combined with each other.
[0026] All data acquisition in this embodiment is carried out in accordance with laws and regulations and with user consent, and the data is used legally.
[0027] Terminology Explanation: 1. DynSSD: The abbreviation for the online test-time adaptive target detection method provided in this invention. Based on the SSD300 structure, it combines fixed teacher consistency distillation, dynamic pseudo-label generation and multi-step iterative optimization to achieve stable adaptation to the target domain distribution.
[0028] Example 1 like Figure 1 This embodiment provides an adaptive target detection method for online testing, including: Obtain the input image; The input image is input into the student model to obtain the student prediction result, wherein the student model is a target detection model based on a single-shot multi-box detector architecture, and the student prediction result includes the class probability distribution and bounding box coordinates of the target in the image; The input image is input into the teacher model to obtain the teacher prediction result, wherein the teacher model is a weight copy of the student model at the beginning of the adaptation, and its weight remains fixed during the adaptation process. The teacher prediction result also includes the class probability distribution and bounding box coordinates of the target in the image. Based on the student prediction results and the teacher prediction results, the consistency distillation loss is calculated; based on the teacher prediction results, a set of pseudo-labels is generated through a dynamic pseudo-label generation process; based on the set of pseudo-labels, the pseudo-label supervision loss is calculated; based on the consistency distillation loss and the pseudo-label supervision loss, the total loss is calculated and the parameters of the student model are optimized using the total loss. The optimized student model is output as the detection result of the input image.
[0029] The adaptive object detection method provided in this embodiment utilizes a fixed teacher model to provide stable prior knowledge and employs consistency distillation loss to prevent the student model from deviating excessively from the source domain. Simultaneously, it leverages the teacher model's own predictions to generate reliable supervision signals through a dynamic pseudo-label generation process, and then uses pseudo-label supervision loss to guide the student model to adapt to the target domain. The synergistic effect of these two losses enables the model to maintain stability while efficiently utilizing test data to improve performance in the target domain, effectively addressing the performance degradation problem caused by domain offset.
[0030] Specifically, the calculation of consistency distillation loss includes: Obtain the category probability distribution and bounding box coordinates of the prediction results for students and teachers; Based on the category probability distribution of the student and teacher prediction results, the classification consistency loss is calculated using KL divergence. Based on the bounding box coordinates of the predicted results of students and teachers, the regression consistency loss is calculated using the smoothed L1 loss function; The consistency distillation loss is obtained by weighted summing of the classification consistency loss and the regression consistency loss.
[0031] KL divergence is used to measure the difference in classification predictions between student and teacher models, ensuring consistency of semantic information; smoothed L1 loss is used to constrain the accuracy of bounding box localization. This consistency constraint of classification and regression branches can comprehensively align the outputs of students and teachers, providing a stable and reliable anchor point for model adaptation, and effectively avoiding deviations in model optimization direction caused by pseudo-label noise or the special characteristics of the target domain data.
[0032] Specifically, the dynamic pseudo-tag generation process includes: Obtain the set of prediction boxes from the teacher's prediction results, where each prediction box includes bounding box coordinates and a class probability distribution; The set of predicted boxes is filtered by confidence level, and predicted boxes with confidence levels greater than a dynamic confidence threshold are retained, wherein the dynamic confidence threshold decreases linearly with the number of iterations. Entropy filtering is applied to the predicted boxes after confidence filtering. The entropy value of each predicted box is calculated, and predicted boxes with entropy values less than the dynamic entropy threshold are retained, wherein the dynamic entropy threshold decreases linearly with the number of iterations. The predicted bounding boxes after entropy filtering are sorted by confidence level, and the top K predicted bounding boxes are retained, where K is a preset positive integer; Non-maximum suppression is performed on the retained predicted boxes to remove boxes with high overlap, resulting in the final set of pseudo-labels.
[0033] This embodiment provides a dynamic pseudo-label generation mechanism. Confidence filtering directly selects the predictions deemed most reliable by the model; entropy filtering further eliminates boxes with flat prediction distributions and high uncertainty. The combination of these two methods significantly improves the average quality of the candidate pseudo-label set. A dynamic threshold that decreases linearly with iteration ensures quality using strict criteria in the initial adaptive phase, gradually relaxing them later to utilize more data to promote convergence. Top-K and NMS operations ensure the diversity and spatial uniqueness of pseudo-labels. This process systematically solves the core problem of unstable pseudo-label quality.
[0034] Specifically, the calculation of the pseudo-label supervision loss includes: Obtain the bounding box coordinates and category labels from the pseudo-label set; Convert the category labels into one-hot encoded forms; Based on the class logistic values of the student's prediction results and the one-hot encoding, the classification supervision loss is calculated using the binary cross-entropy loss function; Based on the bounding box coordinates of the student prediction results and the bounding box coordinates in the pseudo-label set, the regression supervision loss is calculated using the smoothed L1 loss function. The pseudo-label supervision loss is obtained by weighted summation of the classification supervision loss and the regression supervision loss.
[0035] This embodiment transforms the generated pseudo-labels into concrete supervision signals. By converting the categories of the pseudo-labels into one-hot encodings and using binary cross-entropy loss for supervision, the student model is forced to learn reliable category features in the target domain. Simultaneously, smooth L1 loss is used for regression supervision on the bounding box coordinates of the pseudo-labels, optimizing the model's localization accuracy in the target domain. This claim effectively transforms a high-quality set of pseudo-labels into gradient signals that drive model parameter optimization, a key step in improving model performance.
[0036] Specifically, calculating the total loss and using the total loss to optimize the parameters of the student model includes: Obtain the consistency distillation loss and the pseudo-label supervision loss; The total loss is obtained by adding the pseudo-label supervision loss to the weighted consistency distillation loss. Using the total loss, the student model is optimized through multi-step iterative parameter optimization using the gradient descent algorithm, and the update magnitude is controlled by gradient clipping technique in each iteration.
[0037] This embodiment defines the final strategy for model optimization. By combining consistent distillation loss and pseudo-label supervision loss, it balances the two key objectives of model stability (not forgetting source domain knowledge) and adaptability (learning target domain features). Multi-step iterative optimization allows the model sufficient opportunities to fine-tune on the current test data, while the application of gradient pruning ensures numerical stability during training, prevents gradient explosion, and enables the entire adaptive process to proceed smoothly and convergently.
[0038] Specifically, the dynamic confidence threshold and dynamic entropy threshold in the dynamic pseudo-label generation process are adjusted with the number of iterations according to the following formula: Dynamic confidence threshold:
[0039] Dynamic entropy threshold:
[0040] in, This represents the current iteration number. This represents the total number of iterations. and These are the initial and final values of the confidence threshold, respectively. and These are the initial and final values of the entropy threshold, respectively.
[0041] This embodiment provides a specific mathematical model for dynamic threshold adjustment. The linear decreasing formula implements a simple yet effective learning strategy. In the initial adaptive phase, a higher threshold ensures that only the most reliable predictions are selected as pseudo-labels, laying the foundation for stable learning. As iterations progress, the model adapts to the target domain data to a certain extent, and the threshold is gradually lowered to introduce more diverse and challenging samples, thereby driving further learning and generalization. This dynamic adjustment mechanism ensures that the quality of pseudo-labels continues to improve.
[0042] In one specific embodiment, such as Figure 2 The present invention provides an adaptive target detection method for online testing, which is specifically applied to the typical dynamic cross-domain scenario of fruit and vegetable crop pest and disease detection, in order to solve the problem of model performance degradation caused by sudden changes in light, differences in crop varieties, evolution of growth stages and environmental occlusion.
[0043] The specific implementation steps are as follows: 1. Data Preparation and Model Initialization: A self-built dataset of 4412 images related to fruit and vegetable pests and diseases was used for source model training. This dataset covers various fruit and vegetable varieties, different growth stages, and diverse environmental conditions (such as different light levels and shading). It was divided into training, validation, and test sets in a 9:1:1 ratio, with the test set specifically designed to include cross-domain data to simulate real-world unknown target domains. A single-shot multi-frame detector was trained based on this dataset as the base student model.
[0044] 2. Online Adaptive Detection: When deploying the model to a new farmland environment (target domain) for real-time pest and disease detection, initiate an online adaptive testing process. For each captured frame or each small batch of images, perform the following operations: a. Input the image into the trained student model to obtain the initial student prediction results.
[0045] b. Input the same image into a teacher model with fixed weights (an initial copy of the student model) to obtain the teacher's prediction results as a stable reference.
[0046] c. Calculate consistency distillation loss: KL divergence and smoothed L1 loss are used to constrain the consistency between student and teacher models in pest and disease classification and lesion localization, respectively, to ensure that the model does not forget the general knowledge learned from the source domain when adapting to the new environment.
[0047] d. Dynamically Generating Pseudo-Labels: Teacher prediction results are dynamically filtered. First, using an initial high confidence threshold (e.g., 0.9) and a low entropy threshold (e.g., 0.2), only high-confidence, low-uncertainty pest and disease prediction boxes are retained. Then, during iteration, these two thresholds are linearly reduced according to a formula, gradually introducing more diverse and challenging lesion samples to enrich the supervisory signal. Finally, a high-quality pseudo-label set is obtained through Top-K filtering and non-maximum suppression.
[0048] e. Calculate pseudo-label supervision loss: Using the generated pseudo-labels, supervise the training of the student model through binary cross-entropy loss and smooth L1 loss, driving it to learn and adapt to the pest and disease feature distribution unique to the target domain.
[0049] f. Multi-step iterative optimization: The consistency distillation loss and pseudo-label supervision loss are weighted and combined into the total loss. The student model is updated in multiple steps using a gradient descent algorithm with a small learning rate. Gradient clipping is applied in each update step to ensure the stability of the optimization process.
[0050] 3. Results and Performance Improvement: After online adaptive optimization, the student model's performance in detecting pests and diseases in the current target domain environment is significantly improved. Experiments show that in scenarios with unknown target domains, this method can improve the mAP of the detection model by more than 1%–3% (as shown in Table 2), while meeting the stringent requirements of lightweight deployment (parameter count <1M) and real-time performance (≤50ms / frame), effectively overcoming the domain offset problem in dynamic environments.
[0051] This embodiment deeply integrates a general online adaptive framework with a specific agricultural pest and disease detection scenario, verifying the effectiveness, robustness, and practicality of the method in solving complex real-world cross-domain problems.
[0052] Specifically, such as Figure 3 This embodiment provides an online testing-time adaptive target detection method that offers a self-supervised contrastive learning-based domain generalization pest and disease detection model. The core objective of domain generalization is to learn domain-invariant representations from multiple source domains, enabling the model to exhibit stronger generalization ability for data in unknown domains. To this end, the model introduces a self-supervised contrastive loss, which effectively learns domain-invariant feature representations by clustering the representations of "same type" samples together while pushing the representations of "different type" samples apart. Batch self-supervised contrastive loss further standardizes this learning process, ensuring that "same type" samples are closer in the embedding space, thereby improving the model's generalization performance.
[0053] The following two dissimilarity types in the embedding space are computed: (1) personalized batch difference loss and (2) heterogeneous batch difference loss. The gradient of the conflict direction is optimized using the Stochastic Weight Averaging (SWA) technique and Inter-domain Curriculum Learning (IDCL).
[0054] (1) Personalized batch variation loss This invention employs a self-supervised contrastive regularization architecture, optimizing model performance by calculating personalized batch difference loss. To avoid performance degradation caused by domain adaptation tasks, a Class-specific Domain Perturbation Layer (CDPL) is specifically designed to effectively address potential performance degradation issues introduced by domain adaptation tasks. Given class labels... and Potential representation Calculate the loss of individualized batch variation Using by Parameterized feature generator Batch size is The difference between positive sample pairs of "same kind" latent representations is calculated using the following formula: (1) in From those with the same class label Other batches of potential representation Random selection is made from the given information. For better computational efficiency, such as... Figure 4 As shown, use the following steps to find all positive sample pairs: 1) Use the K-means clustering method to cluster the data points Data points are assigned to the same group, and the similarity between them is measured using Euclidean distance. , .
[0055] 2) For each group of the same type, perform a random rearrangement operation on the samples in the dataset to change the original order of the samples, thereby obtaining the rearranged sample sequence SHUFFLE. .
[0056] 3) According to and SHUFFLE The order forms positive sample pairs.
[0057] (2) Loss of heterogeneous batch differences Heterogeneous batch difference loss is a loss function used to handle heterogeneous batch data. It obtains cross-domain latent representations by applying latent representations to a dual-domain mixing layer, performing convex combinations of samples from different domains to regularize the mixed distribution model. This helps the model better handle multi-domain data and guides it to learn common and unique information. (Latent representation) Obtaining cross-domain latent representations of interpolation using a dual-domain hybrid layer .
[0058] (2) in, , . from Randomly selected from the middle, And they have the same class tag. By hyperparameters Control. This invention addresses the loss of heterogeneous batch variability. as follows: (3) (3) Feature and logarithmic level self-supervised contrastive loss Personalized and heterogeneous batch difference loss helps the model learn and adapt to personalized and heterogeneous batch data, accurately grasping data feature representations and obtaining more accurate classification results. Loss function as follows: (4) Among them, use Features and Controlling the strength of each term. When using a linear loss function, gradients need to be properly balanced to ensure that the network parameters converge and generate domain-invariant features useful for the original classification task. However, in the later stages of training, self-supervised contrastive loss may dominate, leading to gradient imbalance and hindering the training process. To mitigate this problem, this scheme employs two gradient stabilization techniques: 1) Stochastic Weight Averaging (SWA) Random weight averaging finds a flatter minimum in the loss space by averaging the parameters of the model derived from multiple local minima during the training process.
[0059] Given the model weight space ,in These are the training steps. (Use) c As the loop step size, the sample weight space of the random weighted average is: , (5) in, This represents the initial step in averaging random weights, resulting in the average weights. as follows: (6) 2) Inter-domain Curriculum Learning (IDCL) The course learning strategy is to gradually reveal the source domain data. First, [the strategy involves]... The source domains are arranged in a sequence ordered by the distance between the pre-trained backbone domain and each source domain. Given an ordered sequence of source domains... The entire training process is divided into Sub-stages At each stage The model uses only a subset of the source domain data, i.e. The model gradually learns more complex examples. Model loss function. Including classification loss Loss compared with self-supervision : (7) This invention alleviates the neighborhood bias problem by explicitly or implicitly extracting domain-invariant features and introduces a novel self-supervised contrastive regularization method to address the negative sample sampling problem using only positive sample pairs. Simultaneously, a class-specific domain perturbation layer is designed to ensure that the hybrid enhancement remains efficient even when using only positive sample pairs.
[0060] Specifically, such as Figure 5 This embodiment provides an online testing-based adaptive target detection method that offers an adversarial cross-domain augmentation-based automatic deep learning (teacher-student adversarial, self-feedback mechanism) pest detection model. Domain generalization aims to transfer the learning task from one or more source domains to an unknown target domain. To extract and utilize information with sufficient generalization ability, this invention proposes a teacher-student adversarial representation learning framework, including a teacher network. Student Network Classifier C And new cross-domain extender G The model advances teacher-student model learning through adversarial learning, alternating between knowledge distillation representation learning and new domain data augmentation. The former gradually updates the teacher network to obtain a domain-general representation, while the latter synthesizes a reliable data distribution outside the source domain.
[0061] Assuming the training data comes from Source domain Each domain contains a set of image and label pairs. Based on deep learning, a maximization-minimization adversarial training approach is used, alternating between two stages: domain generalization representation learning and cross-domain augmentation. The domain generalization representation learning module utilizes a strongly enhanced adaptive cross-domain augmenter. and weakly enhanced fixed amplifier Training Domain Universal Teacher Network Meanwhile, student networks By observing the synthesized cross-domain augmented data, knowledge is transferred to the teacher network. The cross-domain augmentation module learns the differences between the teacher and student encoders, gradually generating stronger style augmentations and enriching the diversity of training data distribution.
[0062] (1) Domain generalization representation learning To address the representation learning task, this invention uses multiple source domain data to train the teacher module and a single-layer classifier. First, standard cross-entropy loss is used. initialization Then the training images sampled from the source domain Input a strongly enhanced adaptive cross-domain augmenter A weakly enhanced fixed cross-domain augmenter Preserves its semantic information and generates style (or domain) perturbation enhancement. Despite cross-domain augmentation The data will be input into the student module to generate features. At the same time, the original input Input into the teacher network But to ensure Includes and With the same semantic information, the model minimizes and The differences between student modules are analyzed to ensure that the features generated by the student module are similar to those generated by the teacher network. This is achieved through difference loss. Minimum normalized features and Distance between: (8) Cross-domain augmentation features Cross-entropy loss Further enhance students' ability to classify modules, among which, This represents a single-layer classifier. This indicates the corresponding category label. In the context of the learning phase, only student networks are represented. Through the above two objectives and Update the parameters of the teacher network. and It does not update using gradients; this is called a gradient stopping strategy. Therefore, the learning rate is... At that time, The optimization can be expressed as follows: (9) Teacher network from student parameters The extracted knowledge is distilled out and updated. The update method is as follows: in (10) Among them, parameters It controls the rate at which the teacher network is updated.
[0063] (2) Cross-domain augmentation learning To encourage students to explore diverse cross-domain augmentations online, a counter-augmentation learning strategy is proposed. This involves training a new cross-domain augmenter. and freeze and At the same time, according to and The differences between the data guide the training of the student network. By maximizing these differences, a new cross-domain augmenter is trained, encouraging more augmented data to exhibit significant differences in domain information. Specifically: (11) in The boundary is determined by calculating the average value of each source domain data in a mini-batch. Secondly, the Euclidean distance between centroid pairs is averaged or adjusted as a hyperparameter. To ensure that the generated domain augmentation retains the original classification content, cross-entropy loss is incorporated. Observe augmented data With tags The matching situation is analyzed to optimize the performance of the new cross-domain augmenter and ensure the effectiveness of the model for the detection task. Therefore, the new cross-domain augmenter... The optimization can be performed as follows: (12) This invention uses single or multiple source domain data for training, and enables teachers and students to collaborate online through a teacher-student adversarial mechanism to mine data features and enhance generalization ability. It also optimizes performance by combining automatic real-time parameter adjustment with a feedback mechanism that incorporates human experience in a non-automatic manner, thereby achieving efficient and accurate detection.
[0064] Specifically, such as Figure 6 The online test-time adaptive target detection method provided in this embodiment offers a source domain and target domain adaptive hybrid test-time training pest detection model. This invention uses a trained convolutional neural network to adapt to unknown dynamic domain pest samples during the testing phase, solving the problem of the special characteristics of test samples and the domain offset between training and testing.
[0065] Representing images and their corresponding labels, a trained model is obtained during the testing phase. , For each time step t From an unknown joint distribution A batch of data points were sampled. Only unlabeled images Sampling, where It refers to the batch size.
[0066] This invention relates to model parameters Adjustments were made to enable the model to accurately predict labels using only unlabeled test data. To achieve this, an Adaptive Mixed Batch Normalization (AMBN) module was introduced, combining it with statistical transformation operations and generalized entropy minimization loss to effectively mine information from unlabeled data.
[0067] (1) Adaptive Hybrid Batch Normalization Module 1) Dynamic coefficient generation module Even without labels, the model can still obtain underlying distribution information by extracting statistical features (such as mean and variance) from the unlabeled data. This invention proposes an adaptive hybrid batch normalization module that can dynamically fuse statistical data during testing, providing more accurate statistical estimates. + (13) in, and It is a statistic estimated based on source data and batch data. It is the affine batch normalization parameter.
[0068] The model uses Euclidean distance Dynamically fusing training and testing statistics can improve adaptability and accuracy. (14) in, This represents the distance between the source statistic and the test statistic. and Each is a single image The distance between the statistic and the source statistic and the batch statistic. If Less than This indicates that the source domain and the test domain are similar, and in this case, the difference is larger. It can be used to merge statistics from more sources. This is useful when there are significant differences between the source and target statistics. and It will be very big. The ratio remains unchanged. It will be very large and cause Very small, and vice versa, the final result Obtained through average ratios.
[0069] 2) Statistical Transformation To retain mixed statistics while eliminating the side effects of source statistics, this invention improves the adaptive mixed batch normalization module, making the normalization process independent of the source statistical data. The improved normalization process is as follows: (15) (16) (17) Reinitialize the normalization parameters using the source and test statistics. and This makes the normalization process depend only on the test statistic. and It can also dynamically adjust based on the current feature map distribution. This operation is performed after batch input into the network and before fine-tuning to ensure the normalization parameters of each layer are optimized. and It can be optimized independently during fine-tuning, unaffected by training and testing modes.
[0070] (2) Minimization of generalized entropy Generalized entropy minimization framework Temperature scaling adjusts the model's output distribution. When fine-tuning networks with entropy minimization loss, it reduces the sharp distribution of high-confidence samples while softening the logistic value distribution, thereby achieving a larger loss and accelerating learning. Temperature scaling also allows the trained model to better adapt to unlabeled data during the testing phase.
[0071] (18) in, yes Temperature coefficient, setting Soften the distribution. Multiply the entropy minimization loss by This ensures the gradient magnitude is within a normal range. Because temperature scaling not only reduces the logical value to... At the same time, the gradient is reduced to its original value. Therefore, this invention demonstrates significant advantages with limited data in unknown areas and can effectively improve the accuracy of pest and disease detection for specific samples under dynamic environments.
[0072] like Figure 7 The experiment will be conducted on a self-built dataset of fruit and vegetable crop diseases and pests (4412 images). Different types of diseases will be distinguished by the border color. The dataset is divided into training set, validation set and test set in a 9:1:1 ratio. The test set contains cross-domain data (differences in plant morphology, differences in data collection conditions and differences in disease and pest morphology).
[0073] Table 1 Experimental Design Table
[0074] Table 2 shows the experimental data under different interferences.
[0075] The baseline models included SSD, CoTTA, and RoTTA. mAP (2-3% improvement over baseline) was used as the evaluation metric, and the effectiveness of each module was verified through ablation studies.
[0076] Example 2 This embodiment provides an adaptive target detection system for online testing, including: The input module is used to acquire the input image; The student model prediction module is used to input the input image into the student model to obtain the student prediction result, wherein the student model is a target detection model based on a single-shot multi-box detector architecture, and the student prediction result includes the class probability distribution and bounding box coordinates of the target in the image; The teacher model prediction module is used to input the input image into the teacher model to obtain the teacher prediction result, wherein the teacher model is a weight copy of the student model at the beginning of the adaptation, and its weight remains fixed during the adaptation process. The teacher prediction result also includes the category probability distribution and bounding box coordinates of the target in the image. The model adaptive optimization module is used to calculate the consistency distillation loss based on the student prediction results and the teacher prediction results; generate a set of pseudo-labels through a dynamic pseudo-label generation process based on the teacher prediction results; calculate the pseudo-label supervision loss based on the pseudo-label set; calculate the total loss based on the consistency distillation loss and the pseudo-label supervision loss, and optimize the parameters of the student model using the total loss. The detection result output module is used to output the detection results of the optimized student model on the input image.
[0077] Example 3 Embodiment 3 of the present invention provides an electronic device.
[0078] An electronic device includes a memory, a processor, and a program stored in the memory and running on the processor. When the processor executes the program, it implements the steps in the adaptive target detection method for online testing as described in Embodiment 1 of the present invention.
[0079] The detailed steps are the same as those of the adaptive target detection method during online testing provided in Example 1, and will not be repeated here.
[0080] Example 4 Embodiment 4 of the present invention provides a computer-readable storage medium.
[0081] A computer-readable storage medium having a program stored thereon, which, when executed by a processor, implements the steps of the adaptive target detection method during online testing as described in Embodiment 1 of the present invention.
[0082] The detailed steps are the same as those of the adaptive target detection method during online testing provided in Example 1, and will not be repeated here.
[0083] Example 5 Embodiment 5 of the present invention provides a computer program product.
[0084] A computer program product includes software code, wherein the program in the software code performs the steps of the adaptive target detection method during online testing as described in Embodiment 1 of the present invention.
[0085] The detailed steps are the same as those of the adaptive target detection method during online testing provided in Example 1, and will not be repeated here.
[0086] 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 implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code. The solutions in the embodiments of the present invention can be implemented using various computer languages, such as the object-oriented programming language Java and the interpreted scripting language JavaScript.
[0087] 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, as well as 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.
[0088] 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.
[0089] 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 1The steps of the function specified in one or more boxes.
[0090] The above description is merely a preferred embodiment of this practice and is not intended to limit the scope of this practice. Various modifications and variations can be made to this practice by those skilled in the art. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of this practice should be included within the protection scope of this practice.
Claims
1. An adaptive target detection method for online testing, characterized in that, include: Obtain the input image; The input image is input into the student model to obtain the student prediction result, wherein the student model is a target detection model based on a single-shot multi-box detector architecture, and the student prediction result includes the class probability distribution and bounding box coordinates of the target in the image; The input image is input into the teacher model to obtain the teacher prediction result, wherein the teacher model is a weight copy of the student model at the beginning of the adaptation, and its weight remains fixed during the adaptation process. The teacher prediction result also includes the class probability distribution and bounding box coordinates of the target in the image. Based on the student prediction results and the teacher prediction results, the consistency distillation loss is calculated; based on the teacher prediction results, a set of pseudo-labels is generated through a dynamic pseudo-label generation process; based on the set of pseudo-labels, the pseudo-label supervision loss is calculated; based on the consistency distillation loss and the pseudo-label supervision loss, the total loss is calculated and the parameters of the student model are optimized using the total loss. The optimized student model is output as the detection result of the input image.
2. The method as described in claim 1, characterized in that, The calculation of consistency distillation loss includes: Obtain the category probability distribution and bounding box coordinates of the prediction results for students and teachers; Based on the category probability distribution of the student and teacher prediction results, the classification consistency loss is calculated using KL divergence. Based on the bounding box coordinates of the predicted results of students and teachers, the regression consistency loss is calculated using the smoothed L1 loss function; The consistency distillation loss is obtained by weighted summing of the classification consistency loss and the regression consistency loss.
3. The method as described in claim 1, characterized in that, The dynamic pseudo-tag generation process includes: Obtain the set of prediction boxes from the teacher's prediction results, where each prediction box includes bounding box coordinates and a class probability distribution; The set of predicted boxes is filtered by confidence level, and predicted boxes with confidence levels greater than a dynamic confidence threshold are retained, wherein the dynamic confidence threshold decreases linearly with the number of iterations. Entropy filtering is applied to the predicted boxes after confidence filtering. The entropy value of each predicted box is calculated, and predicted boxes with entropy values less than the dynamic entropy threshold are retained, wherein the dynamic entropy threshold decreases linearly with the number of iterations. The predicted bounding boxes after entropy filtering are sorted by confidence level, and the top K predicted bounding boxes are retained, where K is a preset positive integer; Non-maximum suppression is performed on the retained predicted boxes to remove boxes with high overlap, resulting in the final set of pseudo-labels.
4. The method as described in claim 1, characterized in that, The calculation of the pseudo-label supervision loss includes: Obtain the bounding box coordinates and category labels from the pseudo-label set; Convert the category labels into one-hot encoded forms; Based on the class logistic values of the student's prediction results and the one-hot encoding, the classification supervision loss is calculated using the binary cross-entropy loss function; Based on the bounding box coordinates of the student prediction results and the bounding box coordinates in the pseudo-label set, the regression supervision loss is calculated using the smoothed L1 loss function. The pseudo-label supervision loss is obtained by weighted summation of the classification supervision loss and the regression supervision loss.
5. The method as described in claim 1, characterized in that, The calculation of the total loss and the optimization of the parameters of the student model using the total loss include: Obtain the consistency distillation loss and the pseudo-label supervision loss; The total loss is obtained by adding the pseudo-label supervision loss to the weighted consistency distillation loss. Using the total loss, the student model is optimized through multi-step iterative parameter optimization using the gradient descent algorithm, and the update magnitude is controlled by gradient clipping technique in each iteration.
6. The method as described in claim 3, characterized in that, The dynamic confidence threshold and dynamic entropy threshold in the dynamic pseudo-label generation process are adjusted with the number of iterations according to the following formula: Dynamic confidence threshold: Dynamic entropy threshold: in, This represents the current iteration number. This represents the total number of iterations. and These are the initial and final values of the confidence threshold, respectively. and These are the initial and final values of the entropy threshold, respectively.
7. An adaptive target detection system for online testing, characterized in that, include: The input module is used to acquire the input image; The student model prediction module is used to input the input image into the student model to obtain the student prediction result, wherein the student model is a target detection model based on a single-shot multi-box detector architecture, and the student prediction result includes the class probability distribution and bounding box coordinates of the target in the image; The teacher model prediction module is used to input the input image into the teacher model to obtain the teacher prediction result, wherein the teacher model is a weight copy of the student model at the beginning of the adaptation, and its weight remains fixed during the adaptation process. The teacher prediction result also includes the category probability distribution and bounding box coordinates of the target in the image. The model adaptive optimization module is used to calculate the consistency distillation loss based on the student prediction results and the teacher prediction results; generate a set of pseudo-labels through a dynamic pseudo-label generation process based on the teacher prediction results; calculate the pseudo-label supervision loss based on the pseudo-label set; calculate the total loss based on the consistency distillation loss and the pseudo-label supervision loss, and optimize the parameters of the student model using the total loss. The detection result output module is used to output the detection results of the optimized student model on the input image.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that, When the processor executes the program, it implements the steps of the adaptive target detection method for online testing as described in any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by the processor, the program implements the steps of the adaptive target detection method for online testing as described in any one of claims 1 to 6.
10. A computer program product, comprising software code, characterized in that, The program in the software code performs the steps of the adaptive target detection method during online testing as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Wheat scab spore detection method based on semi-supervised learning
CN116821698A
Target detection model training method, device and equipment
CN117557854A
Semi-supervised learning semantic segmentation method based on dynamic adjustment of exponential function threshold
CN117809305A
Target detection model training method, training device and electronic equipment
CN118072118A
Large building surface crack image segmentation method, system and equipment
CN120997237A