Target detection method and system based on cosine perception adaptive knowledge distillation

By employing a cosine-sensing adaptive knowledge distillation method, the knowledge blind spots of student models are accurately located and differentiated collaborative distillation is performed, which solves the challenges of multi-scale target detection in existing technologies and improves the detection accuracy and robustness of lightweight target detection models.

CN122176267APending Publication Date: 2026-06-09XIAMEN UNIV OF TECH

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
XIAMEN UNIV OF TECH
Filing Date
2026-01-09
Publication Date
2026-06-09

AI Technical Summary

Technical Problem

Existing object detection methods face challenges in multi-scale object detection, object occlusion, background interference, and high computational costs. Furthermore, existing knowledge distillation methods fail to effectively distinguish between regions that the student model has mastered and those that it has not, resulting in wasted model capacity and insufficient learning of key regions.

Method used

We employ a cosine-aware adaptive knowledge distillation method, which uses an adaptive contextual cosine difference fusion module and a dynamic cosine-aware mask prediction distillation module to accurately locate the knowledge blind spots of the student model and perform differentiated collaborative distillation at the feature and prediction levels to improve knowledge transfer efficiency.

Benefits of technology

It achieves accurate difference perception and adaptive context fusion, significantly improving the multi-scale detection performance and robustness of the lightweight object detection model, especially in small object detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122176267A_ABST
    Figure CN122176267A_ABST
Patent Text Reader

Abstract

The present application relates to a kind of target detection method and system based on cosine perception adaptive knowledge distillation, the method constructs teacher-student distillation framework, and constructs the target detection network model including benchmark detector, adaptive context cosine difference fusion module, cosine perception adaptive space-channel feature distillation module and dynamic cosine perception mask prediction distillation module;Cosine difference map is calculated on the multi-scale feature layer of teacher-student model by difference fusion module;Student model is distilled by feature distillation module;Student model is distilled by prediction distillation module;Combined with feature distillation loss and prediction distillation loss, student model is jointly optimized, and the lightweight high-performance target detection model is obtained;Target detection network model is trained and used for target detection, to obtain detection result.The present application guides distillation with the cosine perception information of context, to improve the accuracy and robustness of knowledge distillation target detection method.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of target detection technology, specifically relating to a target detection method and system based on cosine perception adaptive knowledge distillation. Background Technology

[0002] Object detection, as a core task of image analysis, has significant application value in fields such as autonomous driving, intelligent video analysis, industrial quality inspection, and medical imaging. This task not only requires identifying the object category in an image but also accurately locating its spatial position (bounding box), making its technical complexity far exceed that of image classification. Currently, while convolutional neural network-based detectors have achieved breakthroughs in accuracy, the accompanying high computational cost and large number of parameters severely restrict their deployment on mobile devices and real-time systems. Simultaneously, this field still faces multiple challenges, including multi-scale object detection, object occlusion, background interference, high annotation costs, and the coupling of classification and localization tasks. Therefore, improving model efficiency and reducing resource consumption while maintaining detection performance has become one of the key research directions in object detection. Against this backdrop, knowledge distillation (KD), as an effective model compression and training strategy, has attracted widespread attention. Its core idea is to transfer knowledge learned from a high-performance "teacher model" to a lighter-weight "student model," thereby maintaining high detection accuracy while controlling inference costs.

[0003] Currently, knowledge distillation methods in object detection are mainly divided into two categories: output-level distillation and feature-level distillation. Output-level distillation directly aligns teacher and student models at the prediction level. For example, it utilizes the soft labels or regression results output by the teacher and supervises the prediction of the student model using KL divergence, cross-entropy, or L1 / L2 loss. This method also includes label assignment distillation, which borrows the teacher's sample assignment strategy to alleviate prediction conflicts between teachers and students; and prediction distillation based on confidence or region importance weighting. Feature-level distillation focuses on the representation alignment of intermediate layers. Common methods include fine-grained feature mimicry in key regions, emphasizing important spatial or channel locations through attention mechanisms, modeling the relationship matrix between features, or using prediction results to guide feature distillation weights. In addition, there are methods that design hierarchical or task-aware distillation strategies for different network layers (such as FPN) or different task branches (such as classification and regression heads).

[0004] While the aforementioned methods have improved the performance of lightweight detectors to some extent, they still have significant limitations. First, most methods employ an "indiscriminate" imitation mechanism, failing to distinguish between regions that students have already mastered and those they haven't, leading to wasted model capacity and insufficient learning of key regions—a problem known as "blind imitation." Second, while attention-based methods can identify important regions, they cannot explicitly guide students on which key locations to strengthen their learning. Furthermore, object detection heavily relies on multi-scale feature representations, and existing distillation methods often lack effective fusion of cross-level contextual information, failing to comprehensively consider both high-level semantics and low-level details, easily resulting in uneven detection performance across different scales of objects (especially small objects). Therefore, how to achieve difference-aware distillation guidance and fully integrate multi-scale contextual information has become a key challenge in improving the effectiveness of knowledge distillation. Summary of the Invention

[0005] The purpose of this invention is to overcome the shortcomings of the prior art and provide a target detection method and system based on cosine perception adaptive knowledge distillation. This invention uses contextual cosine perception information to guide distillation, thereby improving the accuracy and robustness of the knowledge distillation target detection method.

[0006] To achieve the above objectives, the present invention adopts the following technical solution: a target detection method based on cosine perception adaptive knowledge distillation, comprising the following steps:

[0007] 1) Constructing a teacher-student distillation framework: Select a pre-trained first object detection model as the teacher model, and a second object detection model with a lighter structure and fewer parameters as the student model; The teacher model and the student model share the same basic detection framework, but differ in the structural complexity of the backbone network and the detection head.

[0008] 2) Construct a target detection network model based on cosine-aware adaptive knowledge distillation. This model includes a baseline detector, an adaptive contextual cosine difference fusion module, a cosine-aware adaptive spatial-channel feature distillation module, and a dynamic cosine-aware mask prediction distillation module. The baseline detector comprises a backbone network, a feature pyramid (FPN), and a detection head. The adaptive contextual cosine difference fusion module calculates cosine difference maps between the teacher and student models at multi-scale feature layers. These cosine difference maps include spatial orientation differences and channel amplitude differences, and fused with contextual information from adjacent layers to generate a fused difference map. Based on this fused difference map, the student model undergoes feature distillation using the cosine-aware adaptive spatial-channel feature distillation module, calculating weighted distillation losses in both spatial and channel dimensions. The student model undergoes predictive distillation using the dynamic cosine-aware mask prediction distillation module, generating mask weights and weighting them with the prediction loss. Finally, the student model is jointly optimized by combining the feature distillation loss and the prediction distillation loss to obtain a lightweight, high-performance target detection model.

[0009] 3) Obtain the training dataset and training set annotation file, and train the object detection network model using the training dataset and training set annotation file to obtain generalizable model parameters;

[0010] 4) Use the trained object detection network model for object detection to obtain robust and robust detection results.

[0011] Furthermore, the implementation method of step 1) includes:

[0012] First, a first target detection model that has been fully trained and has a set detection accuracy is selected and fixed as the teacher model; the parameters of the teacher model are frozen during the entire distillation training process and do not participate in gradient updates. Its role is to provide supervision signals for the student model.

[0013] Then, a lighter-weight second object detection model is initialized as the student model. The student model uses the same basic detection framework as the teacher model, but the student model has a shallower backbone network and a simpler detection head structure, which results in a much lower number of parameters and computational cost than the teacher model. The student model is the model optimized and finally deployed during the distillation process. The teacher model and the student model are functionally aligned and can both output multi-scale feature maps as well as the final classification and regression prediction results.

[0014] Furthermore, the implementation method of step 2) includes:

[0015] A) The adaptive contextual cosine difference fusion module analyzes the feature map from two complementary dimensions: spatial direction difference and channel amplitude difference. The spatial direction difference is evaluated by calculating the cosine distance between normalized feature vectors to assess whether the semantic understanding of the teacher model and the student model is consistent in the same spatial location. The channel amplitude difference is calculated by calculating the difference in response intensity of different feature channels. The calculation results of the two are combined to obtain an initial cosine difference map that can comprehensively reflect the semantic and response differences. Then, a cross-layer contextual fusion mechanism is introduced to adaptively weight and fuse the abstract semantic differences from deep features with the fine-grained detail differences from shallow features to generate a fusion difference map of multi-scale contextual information.

[0016] B) The generated fusion difference map is applied to both the feature-level and prediction-level distillation paths. At the feature level, a cosine-sensing adaptive spatial-channel feature distillation module is executed, using spatial and channel weights derived from the fusion difference map to dynamically weight the feature imitation loss. At the prediction level, a dynamic cosine-sensing mask prediction distillation module is executed, converging the spatial information of the fusion difference map into a difference significance score and generating a dynamic binary mask through thresholding. This mask, combined with the confidence score predicted by the teacher model, jointly affects the prediction distillation loss. The feature distillation loss and the prediction distillation loss, combined with the standard detection loss of the object detection task itself, constitute the final multi-task joint optimization objective. The entire student model is trained end-to-end using the gradient descent algorithm, enabling the student model to not only complete the basic object detection task but also continuously correct its performance in key difference regions under the guidance of the teacher model, ultimately resulting in a lightweight, high-performance object detection model.

[0017] Further, in step 3), images containing targets are obtained from the COCO public dataset as the training set, and the standard annotation files provided by it are loaded; then, the data is subjected to enhanced preprocessing including standardization, random cropping, and multi-scale scaling; the gradient descent algorithm is used to iteratively update the parameters of the student model with the constructed total loss function as the optimization objective; the performance is monitored through the validation set, and finally the model weights with the best evaluation index are saved, thereby obtaining a target detection network model with strong generalization ability.

[0018] The present invention also provides a target detection system based on cosine perception adaptive knowledge distillation, including a memory, a processor, and computer program instructions stored in the memory and executable by the processor. When the processor executes the computer program instructions, it can implement the above-described method.

[0019] The present invention also provides a computer-readable storage medium having stored thereon computer program instructions that, when executed by a processor, implement the above-described method.

[0020] Compared with the prior art, the present invention has the following beneficial effects:

[0021] 1. Precise Difference Perception: This invention innovatively uses cosine similarity to measure the representational differences between teacher and student models from two complementary dimensions: spatial orientation (semantic consistency) and channel amplitude (response intensity). Compared to simple L2 distance or attention activation maps, this refined difference measurement method can more accurately locate the "knowledge blind spots" of student models.

[0022] 2. Adaptive Context Fusion: Through a designed adaptive context fusion mechanism, differential information from deep (high-level semantics) and shallow (low-level details) layers is dynamically fused, generating a fused difference map rich in multi-scale context. This enables the distillation guidance signal not only to identify "where the difference is" but also to combine "under what context the difference is," significantly alleviating the problem of imbalance in multi-scale object detection.

[0023] 3. Differentiated Collaborative Distillation: This invention proposes a "feature-prediction" dual-path collaborative distillation framework. At the feature level, differentiated imitation is performed using decoupled spatial and channel weights; at the prediction level, selective imitation is performed using dynamically generated masks. Both are guided by a fused difference map, achieving a fundamental shift from "blind imitation" to "targeted imitation," greatly improving the efficiency of knowledge transfer and the final performance of the student model. Attached Figure Description

[0024] Figure 1 This is a flowchart illustrating the implementation of the target detection method based on cosine perception adaptive knowledge distillation provided in this embodiment of the invention.

[0025] Figure 2 This is an architecture diagram of the target detection network model based on cosine perception adaptive knowledge distillation in an embodiment of the present invention. Detailed Implementation

[0026] The present invention will be further described below with reference to the accompanying drawings and embodiments.

[0027] It should be noted that the following detailed descriptions are exemplary and intended to provide further explanation of this application. 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 this application pertains.

[0028] 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 exemplary embodiments according to this application. As used herein, the singular form is intended to include the plural form as well, unless the context clearly indicates otherwise. Furthermore, it should be understood that when the terms "comprising" and / or "including" are used in this specification, they indicate the presence of features, steps, operations, devices, components, and / or combinations thereof.

[0029] like Figure 1 As shown, this embodiment provides a target detection method based on cosine perception adaptive knowledge distillation, including the following steps:

[0030] 1) Constructing a teacher-student distillation framework: Select a pre-trained, high-precision first object detection model as the teacher model, and a lighter-weight second object detection model with fewer parameters as the student model; The teacher model and the student model share the same basic detection framework, but differ in the structural complexity of the backbone network and the detection head.

[0031] 2) Construct a target detection network model based on cosine-aware adaptive knowledge distillation. This model includes a baseline detector, an adaptive contextual cosine difference fusion module, a cosine-aware adaptive spatial-channel feature distillation module, and a dynamic cosine-aware mask prediction distillation module. The baseline detector comprises a backbone network, a feature pyramid (FPN), and a detection head. The adaptive contextual cosine difference fusion module calculates the cosine difference map between the teacher model and the student model at multiple feature layers. This cosine difference map includes spatial orientation differences and channel amplitude differences, and fuses contextual information from adjacent layers to generate a fused difference map. Based on this fused difference map, the student model undergoes feature distillation using the cosine-aware adaptive spatial-channel feature distillation module, calculating weighted distillation losses in both spatial and channel dimensions. The student model undergoes predictive distillation using the dynamic cosine-aware mask prediction distillation module, generating mask weights and weighting them to the prediction loss. Finally, the student model is jointly optimized by combining the feature distillation loss and the prediction distillation loss to obtain a lightweight, high-performance target detection model.

[0032] 3) Obtain the training dataset and training set annotation file, and train the object detection network model using the training dataset and training set annotation file to obtain generalizable model parameters;

[0033] 4) Use the trained object detection network model for object detection to obtain robust and robust detection results.

[0034] Step 1) is the foundation of knowledge distillation. The implementation methods for step 1) include:

[0035] First, a well-trained object detection model with high detection accuracy is selected and fixed as the teacher model. This teacher model has a deeper backbone network (such as ResNet-101, ResNet-152, Swin-Transformer, etc.) and / or a more complex detection head, and has demonstrated excellent performance on benchmark object detection datasets (such as MS COCO). During the subsequent distillation training process, the parameters of the teacher model are frozen and it does not participate in gradient updates; its role is to provide stable, high-quality supervision signals for the student models.

[0036] Then, a lighter-weight second object detection model is initialized as the student model. The student model uses the same basic detection framework as the teacher model (such as GFL, RetinaNet, FCOS, or ATSS), but its backbone network is shallower and narrower (e.g., ResNet-50, ResNet-18, MobileNet), and its detection head structure is simpler, resulting in significantly lower parameter and computational costs compared to the teacher model. The student model is the optimized and final deployed model during the distillation process. While the teacher and student models differ in capacity, they are functionally aligned, both outputting multi-scale feature maps and final classification and regression prediction results. This provides a structural foundation for subsequent knowledge transfer at the feature and prediction layers.

[0037] Figure 2 This is an architecture diagram of the object detection network model based on cosine perception adaptive knowledge distillation in this embodiment. Figure 2 As shown, the implementation method of step 2) includes:

[0038] A) Generating key signals through adaptive contextual cosine difference fusion. This step is the foundation and guiding core of the entire method. This method designs an adaptive contextual cosine difference fusion module to accurately quantify the semantic gap between the teacher and student models in multi-level representations. This module does not simply compare the absolute values ​​of feature maps, but rather conducts an in-depth analysis of the feature maps from two complementary dimensions: spatial orientation difference and channel amplitude difference. Specifically, spatial orientation difference is assessed by calculating the cosine distance between normalized feature vectors to evaluate whether the teacher and student models have consistent semantic understanding at the same spatial location. Channel amplitude difference calculates the difference in response intensity between different feature channels. The results of both calculations are combined to obtain an initial cosine difference map that comprehensively reflects semantic and response differences. To further enhance the representational power of this difference map, a cross-layer contextual fusion mechanism is introduced, adaptively weighting and fusing the abstract semantic differences from deep features with the fine-grained detail differences from shallow features, ultimately generating a multi-scale contextual information fused difference map. This fusion difference map accurately identifies the spatial locations and feature channels where the student model differs significantly from the teacher model, providing a precise "navigation map" for subsequent distillation.

[0039] B) Dual-Path Distillation Based on Difference Maps – Co-optimization of Feature and Prediction Spaces. The generated fused difference map is applied simultaneously to two distillation paths at the feature and prediction levels, achieving comprehensive guidance combining point and surface approaches. At the feature level, a cosine-aware adaptive spatial-channel feature distillation module is executed. This module dynamically weights the traditional feature imitation loss using spatial and channel weights derived from the fused difference map. In the spatial dimension, pixels with significant differences are assigned higher weights, prompting the student model to focus on optimizing the representation of these key regions. In the channel dimension, feature channels with significant differences receive more attention to improve the channel discriminative power of the student model's overall feature map. Through this dual weighting constraint in both space and channel, the student model can efficiently and selectively imitate the teacher's feature representation, thereby rapidly improving its representational ability while preserving its own model capacity. At the prediction level, a dynamic cosine-aware mask prediction distillation module is executed. This module aggregates the spatial information of the fused difference map into a difference significance score and generates a dynamic binary mask through thresholding. This mask, combined with the confidence of the teacher model's prediction, works together to affect the prediction distillation loss. The core logic is that strong prediction imitation is only performed in areas where there is a significant difference between teacher and student predictions, and where the teacher model itself has high confidence. This mechanism effectively avoids students blindly learning from teachers' erroneous predictions or noise, ensuring high quality and reliability of predictive knowledge transfer. This method allows for joint training and optimization of the model. Feature distillation loss and prediction distillation loss are combined with the standard detection losses of the object detection task itself (such as classification loss and bounding box regression loss) to form the final multi-task joint optimization objective. The entire student model is trained end-to-end using the gradient descent algorithm, enabling the student model not only to complete basic object detection tasks but also, under the precise guidance of the teacher model, to continuously correct its performance in key difference regions, ultimately converging into a high-performance object detection model that approaches or even surpasses models of equivalent capacity in accuracy while maintaining its lightweight advantage.

[0040] In this embodiment, the specific implementation method of the adaptive context cosine difference fusion module is as follows:

[0041] In this method, cosine difference perception uses cosine similarity to measure the differences in features between teachers and students, capturing the consistency of feature vector direction in the spatial dimension and the difference in feature response intensity in the channel dimension. Through this refined difference modeling, more accurate guiding signals are provided for knowledge distillation, making distillation more targeted and efficient.

[0042] Specifically, given the same input image, we obtain lists of multi-scale feature maps output by the backbone networks of the teacher model and the student model, respectively. and ,in It is the number of layers in the FPN. It is a hierarchical index; the first The characteristic size of the layer is denoted as .

[0043] First, the directional differences at each spatial location are measured to assess the inconsistency in direction between the teacher's and student's feature vectors; the teacher's and student's feature vectors are first analyzed... Normalize, then calculate each spatial location The cosine similarity is converted into a difference measure:

[0044]

[0045]

[0046] in, It is a tiny constant used to prevent division by zero. and These are normalized teacher characteristics and student characteristics, respectively. for Norm calculation notation; The range of values ​​for the differences between student and teacher characteristics in spatial direction is: l, c, h, and w represent the number of layers, channels, height, and width of the FPN, respectively.

[0047] Secondly, the differences in channel amplitude between teacher and student characteristics are measured:

[0048]

[0049] in, These represent the number of samples, the number of channels in the feature map, its height, and its number of layers, respectively.

[0050] Finally, the spatial orientation difference and channel amplitude difference are fused to obtain the cosine difference map of this layer:

[0051]

[0052] in, To account for the differences in channel amplitudes between teacher and student characteristics, Calculate the element-wise absolute values ​​for teacher and student characteristics. A graph showing the cosine difference between teachers and students. and This is a hyperparameter.

[0053] Specifically, we first conduct a detailed contextual missing assessment of the current layer features. This involves introducing local differences from the upper layer to supplement high-level semantic cues, and introducing global differences from the lower layer to restore low-level spatial consistency. Considering the lack of upper-level and lower-level differences between the top and bottom layers, we treat the local enhancements of the top layer as "upper-level differences" and the global enhancements of the bottom layer as "lower-level differences," and then fuse them. The fused differences possess both high-level semantic discriminative power and low-level localization details, enabling more precise identification of key locations and channels that need enhancement, thereby mitigating the problem of blind imitation and reducing scale bias.

[0054] For the initial difference map of each layer, for the current layer The difference maps of adjacent layers are upsampled / downsampled to the same spatial size as the current difference layer using bilinear interpolation. Thus obtain and As shown below:

[0055]

[0056]

[0057] in, and upper layer respectively and lower level Layer size alignment Difference diagram after layer.

[0058] To assess the lack of contextual information in the current difference layer, a lightweight weight generation network is used to assign proportional weights to detailed and global contextual information in the current difference layer, followed by dynamic fusion. First, channel compression and feature extraction are performed on the current difference layer to obtain a difference map with contextual information. Secondly, a multilayer perceptron is used. right The proportional weighting of prediction context information:

[0059]

[0060]

[0061] in, for Difference map after convolution compression This indicates the weight proportion from the upper-level detailed feature map. This indicates the weight proportion from the lower-level global feature map.

[0062] Finally, contextual information is fused between the current difference layer and its upper and lower difference layers; thus obtaining a fused difference graph dominated by the current layer's differences and incorporating contextual information, i.e.:

[0063]

[0064] in, A fusion difference graph that incorporates contextual information; This is the difference graph for the current layer, with a weight ratio of 2, which represents the context fusion dominated by the current layer.

[0065] Because the top level of the FPN pyramid lacks adjacent upper levels and the bottom level lacks adjacent lower levels, a difference diagram between upper and lower levels is missing. For the top level difference diagram... By extracting high-frequency detail information and fusing it with the original difference map, a detail-enhanced difference map is obtained as... Difference diagram, i.e. For the underlying difference map A global enhanced difference map is obtained by extracting low-frequency global information and fusing it with the original difference map. Difference diagram, i.e. .

[0066] The specific implementation method of the cosine sensing adaptive spatial-channel feature distillation module is as follows:

[0067] Based on context-fused cosine difference maps, this method further decouples them into spatial difference maps and channel difference maps to more finely characterize feature differences across different dimensions. Then, distillation strategies are designed for both spatial and channel dimensions, and the corresponding spatial distillation losses and channel distillation losses are calculated. This approach can achieve fine-grained modeling of local differences while maintaining global guidance, thereby improving the learning performance of student networks in terms of spatial distribution and channel representation.

[0068] Introducing a fusion difference graph Distillation as attention-guided features. Specifically, for The spatial weight map is obtained by averaging along the channel dimension; for The spatial weight map is obtained by averaging along the spatial dimension.

[0069]

[0070]

[0071] in, This is a spatial weighting map that reflects the importance of each spatial location; This is a channel weighting graph, reflecting the importance of each channel.

[0072] By weighting the spatial and channel weight maps separately in the feature distillation loss, we achieve targeted distillation in both the spatial and channel dimensions simultaneously. To this end, we define the spatial distillation loss and the channel distillation loss as follows:

[0073]

[0074]

[0075] in, and These represent feature maps for students and teachers, respectively. To calculate the square Norm, and These represent spatial and channel distillation losses, respectively.

[0076] The final characteristic distillation loss is obtained by adding the spatial characteristic distillation loss and the channel distillation loss. :

[0077] .

[0078] The specific implementation method of the dynamic cosine sensing mask prediction distillation module is as follows:

[0079] In traditional output distillation, student models typically mimic the teacher's prediction distribution in an equal manner. This approach fails to highlight areas where there are significant differences between teacher and student predictions, leading to ineffective imitation and wasted learning resources. To address this, we propose the Dynamic Cosine-Aware Masked Predictive Distillation (DCPD) method. This method generates corresponding mask weights using the context-fused cosine difference map obtained earlier, and applies a difference-driven weighting to the predictive distillation loss. This loss adaptively emphasizes the categories and spatial locations where there are significant differences between teacher and student predictions, thereby avoiding over-constraint on already consistent regions and improving students' representation and discrimination abilities in key regions.

[0080] Specifically, we use a fusion difference graph based on fusion context information. Calculate the spatial difference score, and then generate a binary mask, i.e.:

[0081]

[0082]

[0083] in, for Spatial difference score, For the score threshold, ( Normalize the values ​​to for The mask at the location.

[0084] Then, the difference mask containing the above information is weighted and applied to the predictive distillation, as follows:

[0085]

[0086] in, To predict distillation losses, and Teacher model and student model respectively The prediction results at the location, Here is the formula for calculating divergence loss.

[0087] The optimization objective of the student model consists of the original detection loss and the distillation loss; the original detection loss... Ensure that the student model has basic target recognition and localization capabilities, including classification loss. and regression loss Two core components:

[0088]

[0089] The total loss function of this method Represented as:

[0090]

[0091] in, It is the original detection loss. Characteristic distillation loss, To predict distillation losses; and This is a hyperparameter.

[0092] In step 3), images containing targets are obtained from the COCO public dataset as the training set, and the standard annotation file provided (such as a COCO format JSON file containing bounding box coordinates and class labels) is loaded. Then, the data undergoes enhanced preprocessing such as standardization, random cropping, and multi-scale scaling. The gradient descent algorithm is used to iteratively update the parameters of the student model with the aforementioned total loss function as the optimization objective. The performance is monitored through the validation set, and finally, the model weights with the best evaluation metrics are saved, thereby obtaining a target detection network model with strong generalization ability.

[0093] To comprehensively verify the effectiveness and robustness of the proposed method (CACKD) in object detection tasks, we conducted systematic comparative experiments on the MS COCO dataset. Specifically, based on the MMDetection framework, under a unified training strategy and experimental settings, we fairly compared our method (CACKD) with several representative object detection knowledge distillation methods, and embedded them into the GFL detection framework for evaluation. CACKD uses only logit distillation, while CACKD(feature) uses a combination of feature distillation and logit distillation. Simultaneously, mainstream single-stage detectors such as GFL, ATSS, RetinaNet, and FCOS were selected as teacher and student model combinations to verify the universality of CACKD across different detection architectures. Experimental results are primarily evaluated using standard average precision (AP) metrics, including overall detection performance (AP), AP_50 and AP_75 at different IoU thresholds, and AP_s, AP_m, and AP_l for small, medium, and large targets. The comparative results show that, under the same teacher-student configuration, CACKD outperforms existing mainstream distillation methods in both overall AP and multi-scale target detection metrics, especially in small target detection performance, which fully verifies the effectiveness of the proposed method in improving the detection accuracy of the student model.

[0094] Table 1. Comparison of the CACKD method proposed in this patent with recent knowledge distillation-based target detection methods on the COCO dataset.

[0095]

[0096] This embodiment also provides a target detection system based on cosine perception adaptive knowledge distillation, including a memory, a processor, and computer program instructions stored in the memory and executable by the processor. When the processor executes the computer program instructions, it can implement the above-described method.

[0097] This embodiment also provides a computer-readable storage medium storing computer program instructions that, when executed by a processor, implement the above-described method.

[0098] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application 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.) containing computer-usable program code.

[0099] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. 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... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0100] 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.

[0101] 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.

[0102] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention in any other way. Any person skilled in the art may make changes or modifications to the above-disclosed technical content to create equivalent embodiments. However, any simple modifications, equivalent changes, and modifications made to the above embodiments based on the technical essence of the present invention without departing from the scope of the present invention shall still fall within the protection scope of the present invention.

Claims

1. A target detection method based on cosine perception adaptive knowledge distillation, characterized in that, Includes the following steps: 1) Constructing a teacher-student distillation framework: Select a pre-trained first object detection model as the teacher model, and a second object detection model with a lighter structure and fewer parameters as the student model; The teacher model and the student model share the same basic detection framework, but differ in the structural complexity of the backbone network and the detection head. 2) Construct a target detection network model based on cosine-aware adaptive knowledge distillation. This model includes a baseline detector, an adaptive contextual cosine difference fusion module, a cosine-aware adaptive spatial-channel feature distillation module, and a dynamic cosine-aware mask prediction distillation module. The baseline detector comprises a backbone network, a feature pyramid (FPN), and a detection head. The adaptive contextual cosine difference fusion module calculates cosine difference maps between the teacher and student models at multi-scale feature layers. These cosine difference maps include spatial orientation differences and channel amplitude differences, and fused with contextual information from adjacent layers to generate a fused difference map. Based on this fused difference map, the student model undergoes feature distillation using the cosine-aware adaptive spatial-channel feature distillation module, calculating weighted distillation losses in both spatial and channel dimensions. The student model undergoes predictive distillation using the dynamic cosine-aware mask prediction distillation module, generating mask weights and weighting them with the prediction loss. Finally, the student model is jointly optimized by combining the feature distillation loss and the prediction distillation loss to obtain a lightweight, high-performance target detection model. 3) Obtain the training dataset and training set annotation file, and train the object detection network model using the training dataset and training set annotation file to obtain generalizable model parameters; 4) Use the trained object detection network model for object detection to obtain detection results.

2. The target detection method based on cosine perception adaptive knowledge distillation according to claim 1, characterized in that, The implementation methods for step 1) include: First, a first target detection model that has been fully trained and has a set detection accuracy is selected and fixed as the teacher model; the parameters of the teacher model are frozen during the entire distillation training process and do not participate in gradient updates. Its role is to provide supervision signals for the student model. Then, a lighter-weight second object detection model is initialized as the student model. The student model uses the same basic detection framework as the teacher model, but the student model has a shallower backbone network and a simpler detection head structure, which results in a much lower number of parameters and computational cost than the teacher model. The student model is the model optimized and finally deployed during the distillation process. The teacher model and the student model are functionally aligned and can both output multi-scale feature maps as well as the final classification and regression prediction results.

3. The target detection method based on cosine perception adaptive knowledge distillation according to claim 1, characterized in that, Step 2) can be implemented by: A) The adaptive contextual cosine difference fusion module analyzes the feature map from two complementary dimensions: spatial direction difference and channel amplitude difference. The spatial direction difference is evaluated by calculating the cosine distance between normalized feature vectors to assess whether the semantic understanding of the teacher model and the student model is consistent in the same spatial location. The channel amplitude difference is calculated by calculating the difference in response intensity of different feature channels. The calculation results of the two are combined to obtain an initial cosine difference map that can comprehensively reflect the semantic and response differences. Then, a cross-layer contextual fusion mechanism is introduced to adaptively weight and fuse the abstract semantic differences from deep features with the fine-grained detail differences from shallow features to generate a fusion difference map of multi-scale contextual information. B) The generated fusion difference map is applied to both the feature-level and prediction-level distillation paths. At the feature level, a cosine-sensing adaptive spatial-channel feature distillation module is executed, using spatial and channel weights derived from the fusion difference map to dynamically weight the feature imitation loss. At the prediction level, a dynamic cosine-sensing mask prediction distillation module is executed, converging the spatial information of the fusion difference map into a difference significance score and generating a dynamic binary mask through thresholding. This mask, combined with the confidence score predicted by the teacher model, jointly affects the prediction distillation loss. The feature distillation loss and the prediction distillation loss, combined with the standard detection loss of the object detection task itself, constitute the final multi-task joint optimization objective. The entire student model is trained end-to-end using the gradient descent algorithm, enabling the student model to not only complete the basic object detection task but also continuously correct its performance in key difference regions under the guidance of the teacher model, ultimately resulting in a lightweight, high-performance object detection model.

4. The target detection method based on cosine perception adaptive knowledge distillation according to claim 3, characterized in that, The implementation method of the adaptive context cosine difference fusion module is as follows: Given the same input image, obtain the multi-scale feature map lists output by the backbone networks of the teacher model and the student model, respectively. and ,in It is the number of layers in the FPN. It is a hierarchical index; the first The characteristic size of the layer is denoted as , These represent the number of samples and the number of channels, height, and layers of the feature map, respectively. First, the directional differences at each spatial location are measured to assess the inconsistency in direction between the teacher's and student's feature vectors; the teacher's and student's feature vectors are first analyzed... Normalize, then calculate each spatial location The cosine similarity is converted into a difference measure: in, It is a tiny constant used to prevent division by zero. and These are normalized teacher characteristics and student characteristics, respectively. for Norm calculation notation; The range of values ​​for the differences between student and teacher characteristics in spatial direction is: l, c, h, and w represent the number of layers, channels, height, and width of the FPN, respectively. Secondly, the differences in channel amplitude between teacher and student characteristics are measured: Finally, the spatial orientation difference and channel amplitude difference are fused to obtain the cosine difference map of this layer: in, To account for the differences in channel amplitudes between teacher and student characteristics, Calculate the element-wise absolute values ​​for teacher and student characteristics. A graph showing the cosine difference between teachers and students. and For hyperparameters; Specifically, the current layer features are first evaluated for contextual missingness, that is, local differences are introduced from the upper layer to supplement high-level semantic cues, and global differences are introduced from the lower layer to restore low-level spatial consistency; the local enhancements of the top layer are used as upper-level differences, and the global enhancements of the bottom layer are used as lower-level differences, and thus they are fused. For the initial difference map of each layer, for the current layer The difference maps of adjacent layers are upsampled / downsampled to the same spatial size as the current difference layer using bilinear interpolation. Thus obtain and As shown below: in, and upper layer respectively and lower level Layer size alignment Difference diagram after layer; To assess the lack of contextual information in the current difference layer, a lightweight weight generation network is used to assign proportional weights to detailed and global contextual information in the current difference layer, followed by dynamic fusion. First, channel compression and feature extraction are performed on the current difference layer to obtain a difference map with contextual information. Secondly, a multilayer perceptron is used. right The proportional weighting of prediction context information: in, for Difference map after convolution compression This indicates the weight proportion from the upper-level detailed feature map. This indicates the weight proportions from the lower-level global feature map; Finally, contextual information is fused between the current difference layer and its upper and lower difference layers; thus obtaining a fused difference graph dominated by the current layer's differences and incorporating contextual information, i.e.: in, A fusion difference graph that incorporates contextual information; This is the difference graph for the current layer; For the top-level difference chart By extracting high-frequency detail information and fusing it with the original difference map, a detail-enhanced difference map is obtained as... Difference diagram For the underlying difference map A global enhanced difference map is obtained by extracting low-frequency global information and fusing it with the original difference map. Difference diagram .

5. The target detection method based on cosine perception adaptive knowledge distillation according to claim 3, characterized in that, The implementation method of the cosine sensing adaptive spatial-channel feature distillation module is as follows: Based on the context-fused cosine difference graph, it is further decoupled into a spatial difference graph and a channel difference graph; then, distillation strategies are designed in the spatial dimension and the channel dimension respectively, and the corresponding spatial distillation loss and channel distillation loss are calculated. Introducing a fusion difference graph Distillation as attention-guided features; specifically, for The spatial weight map is obtained by averaging along the channel dimension; for The spatial weight map is obtained by averaging along the spatial dimension. in, This is a spatial weighting map that reflects the importance of each spatial location; This is a channel weighting graph, reflecting the importance of each channel; In the feature distillation loss, spatial and channel weight maps are weighted separately to achieve selective distillation in both spatial and channel dimensions. The spatial distillation loss and channel distillation loss are defined as follows: in, and These represent feature maps for students and teachers, respectively. To calculate the square Norm, and These are the spatial and channel distillation losses, respectively. The final characteristic distillation loss is obtained by adding the spatial characteristic distillation loss and the channel distillation loss. : 。 6. The target detection method based on cosine perception adaptive knowledge distillation according to claim 3, characterized in that, The implementation method of the dynamic cosine sensing mask prediction distillation module is as follows: Fusion difference graph based on fusion context information Calculate the spatial difference score, and then generate a binary mask, i.e.: in, for Spatial difference score, For the score threshold, ( Normalize the values ​​to for The mask at the location; Then, the difference mask containing the above information is weighted and applied to the predictive distillation, as follows: in, To predict distillation losses, and Teacher model and student model respectively The prediction results at the location, Here is the formula for calculating divergence loss; The optimization objective of the student model consists of the original detection loss and the distillation loss; the original detection loss... Includes classification loss and regression loss : Total loss function Represented as: in, It is the original detection loss. Characteristic distillation loss, To predict distillation losses; and This is a hyperparameter.

7. The target detection method based on cosine perception adaptive knowledge distillation according to claim 1, characterized in that, In step 3), images containing targets are obtained from the COCO public dataset as the training set, and the standard annotation files provided are loaded. Then, the data is subjected to enhanced preprocessing including standardization, random cropping, and multi-scale scaling. The gradient descent algorithm is used to iteratively update the parameters of the student model with the constructed total loss function as the optimization objective. The performance is monitored through the validation set, and finally the model weights with the best evaluation index are saved to obtain a target detection network model with strong generalization ability.

8. A target detection system based on cosine sensing adaptive knowledge distillation, characterized in that, It includes a memory, a processor, and computer program instructions stored in the memory and executable by the processor, wherein when the processor executes the computer program instructions, it can implement the method as described in any one of claims 1-7.

9. A computer-readable storage medium having computer program instructions stored thereon, characterized in that, When the computer program instructions are executed by a processor, the method described in any one of claims 1-7 is implemented.