Target detection method and device, computer equipment and storage medium
By using the student-teacher model architecture and category multi-prototype structure in target detection, the problem of low detection accuracy in target domain data sets is solved, and the adaptability and detection accuracy of the model are improved.
Patent Information
- Application Number
- CN202411219168.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-02
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2044-09-02
AI Technical Summary
The detection accuracy of existing target detection models in target domain data sets under different equipment, weather and lighting conditions is low, mainly due to the differences between source domain and target domain data sets.
Train the student model by obtaining annotated source domain data, build the teacher model, and use the target domain data to generate pseudo labels, which are fed back to the student model for optimization. At the same time, the category multi-prototype structure is used to correct the pseudo labels and generate virtual instance features to update the teacher model. Parameters, the exponential moving average algorithm is used to optimize the model.
It improves the detection accuracy and generalization ability of the target detection model in the target domain data set, and enhances the model's adaptability to data under different conditions.
Smart Images

Figure CN118736206A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of target detection, and in particular to a target detection method, device, computer equipment, and storage medium. Background Art
[0002] For the object detection task, it is necessary to annotate each instance of each image with precise location coordinates and category information, which makes it time-consuming and laborious to annotate a complete dataset. It is a very promising method to generalize the model pre-trained on the annotated dataset (source domain dataset) to the unlabeled dataset (target domain dataset). However, since the images of the source and target domain datasets are collected under different equipment, weather, angle, lighting and other conditions, the detection accuracy of the object detection model in the target domain dataset is low. Summary of the invention
[0003] Based on this, it is necessary to provide a target detection method, device, computer equipment, and storage medium to address the above technical problems.
[0004] In a first aspect, the present application provides a target detection method. The method comprises:
[0005] Obtain annotated source domain data, unannotated target domain data, and student models;
[0006] Training a student model based on the source domain data to obtain a structure and a weight of the trained student model;
[0007] Constructing a teacher model based on the structure and weights of the trained student model;
[0008] Inputting the target domain data into the teacher model to obtain a pseudo label of the target domain data;
[0009] The pseudo labels and target domain data are input into the trained student model for training to obtain an optimized student model, the model parameters of the teacher model are updated based on the model parameters of the optimized student model, and target detection is performed based on the updated teacher model.
[0010] In one embodiment, the training of the student model based on the source domain data comprises:
[0011] Extracting instance features in the source domain data based on the student model;
[0012] For any multiple instance features in the same category, calculate the distance between the instance features;
[0013] When the distance between the instance features is less than the preset distance, the feature instances whose distance between the instance features is less than the preset distance are input into the same clustering set to form a category multi-prototype structure.
[0014] In one embodiment, the method further comprises:
[0015] The pseudo labels are modified based on the category multi-prototype structure and virtual instance features are generated.
[0016] In one embodiment, the pseudo-label is corrected in the following manner:
[0017] Extract instance features of each target instance in the image;
[0018] For each category, the spatial distance between all instance features of each category and all prototypes in each category is calculated;
[0019] The spatial distance is calculated according to the following formula:
[0020] = I k j ∙φ[dis( I k j , P k i )]< δ d ;
[0021] in represents the jth prototype in category k, represents the jth instance feature in category k, φ[∙] Represents the mapping function, when [ ∙ ] When the content is true, φ[∙]=1 ,otherwise φ[∙]=0 , Represents the distance threshold between instance features and category multi-prototypes;
[0022] The instance features that meet the distance threshold are used to predict pseudo labels.
[0023] In one embodiment, the method further comprises:
[0024] Based on the source domain data, the parameters of the feature point classification branch newly added to the student model are initialized to obtain the initialization loss function L init = ∑ k ∑ n H[ h cls Stu ( f k n ), y s ] ;
[0025] in, Represents the nth feature point in category k in a batch of features. represents the feature point classifier output of the student model, Represents the true classification label;
[0026] Generate virtual instance features based on the category multi-prototype structure, and obtain the feature consistency loss function based on the output results of the student model, the output results of the teacher model, and the virtual instance features. L consist = ∑ k ∑ n H[ h cls Stu ( f * k n ), h cls tea ( f k n )] + ∑ k ∑ n H[ h cls Stu ( f k n ), h cls tea ( f k n )] , ;
[0027] in, represents the nth feature point in category k in the virtual instance feature, represents a Gaussian distribution, represents the mean of the prototype within the i-th class of the prototype of category k, Represents the variance between feature points in a batch, represents the output of the student model, represents the output of the teacher model, represents the cross entropy loss function.
[0028] In one embodiment, updating the model parameters of the teacher model based on the optimized model parameters of the student model includes:
[0029] The model parameters of the optimized student model are obtained, and the model parameters of the teacher model are updated based on the exponential moving average algorithm.
[0030] In a second aspect, the present application further provides a target detection device, the device comprising:
[0031] An acquisition module, used to acquire source domain data with annotations, target domain data without annotations, and a student model;
[0032] A training module, used for training a student model based on the source domain data to obtain a structure and a weight of the trained student model;
[0033] Constructing a model for constructing a teacher model based on the structure and weights of the trained student model;
[0034] A generation module, used for inputting the target domain data into the teacher model to obtain a pseudo label of the target domain data;
[0035] The detection module is used to input the pseudo-label into the trained student model for training to obtain an optimized student model, update the model parameters of the teacher model based on the model parameters of the student model, and perform target detection based on the updated teacher model.
[0036] In one embodiment, the training of the student model based on the source domain data comprises:
[0037] Extracting instance features in the source domain data based on the student model;
[0038] For any multiple instance features in the same category, calculate the distance between the instance features;
[0039] When the distance between the instance features is less than the preset distance, the feature instances whose distance between the instance features is less than the preset distance are input into the same clustering set to form a category multi-prototype structure.
[0040] In one embodiment, the device further comprises:
[0041] The pseudo labels are modified based on the category multi-prototype structure and virtual instance features are generated.
[0042] In one embodiment, the pseudo-label is corrected in the following manner:
[0043] Extract instance features of each target instance in the image;
[0044] For each category, the spatial distance between all instance features of each category and all prototypes in each category is calculated;
[0045] The spatial distance is calculated according to the following formula:
[0046] = I k j ∙φ[dis( I k j , P k i )]< δ d ;
[0047] in represents the jth prototype in category k, represents the jth instance feature in category k, φ[∙] Represents the mapping function, when [ ∙ ] When the content is true, φ[∙]=1 ,otherwise φ[∙]=0 , Represents the distance threshold between instance features and category multi-prototypes;
[0048] The instance features that meet the distance threshold are used to predict pseudo labels.
[0049] In one embodiment, the device further comprises:
[0050] Based on the source domain data, the parameters of the feature point classification branch newly added to the student model are initialized to obtain the initialization loss function L init = ∑ k ∑ n H[ h cls Stu ( f k n ), y s ] ;
[0051] in, Represents the nth feature point in category k in a batch of features. represents the feature point classifier output of the student model, Represents the true classification label;
[0052] Generate virtual instance features based on the category multi-prototype structure, and obtain the feature consistency loss function based on the output results of the student model, the output results of the teacher model, and the virtual instance features. L consist = ∑ k ∑ n H[ h cls Stu ( f * k n ), h cls tea ( f k n )] + ∑ k ∑ n H[ h cls Stu ( f k n ), h cls tea ( f k n )] , ;
[0053] in, represents the nth feature point in category k in the virtual instance feature, represents a Gaussian distribution, represents the mean of the prototype within the i-th class of the prototype of category k, Represents the variance between feature points in a batch, represents the output of the student model, represents the output of the teacher model, represents the cross entropy loss function.
[0054] In one embodiment, updating the model parameters of the teacher model based on the optimized model parameters of the student model includes:
[0055] The model parameters of the optimized student model are obtained, and the model parameters of the teacher model are updated based on the exponential moving average algorithm.
[0056] In a third aspect, the present disclosure further provides a computer device, wherein the computer device comprises a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the steps of the target detection method are implemented.
[0057] In a fourth aspect, the present disclosure further provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the steps of the target detection method when executed by a processor.
[0058] In a fifth aspect, the present disclosure further provides a computer program product, wherein the computer program product comprises a computer program, and when the computer program is executed by a processor, the steps of the target detection method are implemented.
[0059] The above target detection method has at least the following beneficial effects:
[0060] The embodiment scheme provided by the present disclosure uses source domain data to train a student model in a pre-training stage, and builds a teacher model based on the student model. In the mutual learning stage, the target domain data is input into the teacher model to obtain pseudo labels, and then the student model is trained with the pseudo labels to improve the target detection capability of the model.
[0061] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0062] In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure or the conventional technology, the drawings required for use in the embodiments or the conventional technology descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present disclosure, and for ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0063] FIG1 is a diagram of an application environment of a target detection method according to an embodiment;
[0064] Figure 2 Schematic diagram of a target detection method in one embodiment;
[0065] Figure 3 A schematic diagram of generating a multi-prototype structure of a category in one embodiment;
[0066] Figure 4 is a schematic diagram of pseudo-label correction in one embodiment;
[0067] Figure 5 is a schematic diagram of a feature consistency loss process in one embodiment;
[0068] Figure 6An architectural diagram of the student model and teacher model in an embodiment;
[0069] Figure 7 is a structural block diagram of a target detection device in one embodiment;
[0070] FIG8 is a diagram showing the internal structure of a computer device in one embodiment;
[0071] FIG. 9 is a diagram showing the internal structure of a server in an embodiment. DETAILED DESCRIPTION
[0072] In order to enable ordinary persons in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings.
[0073] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present disclosure described here can be implemented in an order other than those illustrated or described here. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. On the contrary, they are only examples of devices and methods consistent with some aspects of the present disclosure as detailed in the attached claims. The terms "include", "comprise" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, product or device including a series of elements includes not only those elements, but also other elements that are not explicitly listed, or also includes elements inherent to such process, method, product or device. In the absence of more restrictions, it is not excluded that there are other identical or equivalent elements in the process, method, product or device including the elements. For example, if the words first, second, etc. are used to represent the name, they do not represent any specific order.
[0074] The disclosed embodiment provides a target detection method, which can be applied in the application environment shown in FIG. 1 . Among them, the terminal 102 communicates with the server 104 through the network. The data storage system can store the data that the server 104 needs to process. The data storage system can be integrated on the server 104, or it can be placed on the cloud or other network servers. Among them, the terminal 102 can be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, Internet of Things devices and portable wearable devices. The Internet of Things devices can be smart speakers, smart TVs, smart air conditioners, smart car-mounted devices, etc. Portable wearable devices can be smart watches, smart bracelets, head-mounted devices, etc. The server 104 can be implemented with an independent server or a server cluster consisting of multiple servers.
[0075] In some embodiments of the present disclosure, Figure 2 As shown, a target detection method is provided, and the method is applied to the server in FIG1 to process an image as an example for explanation. It can be understood that the method can be applied to the server, and can also be applied to a system including a terminal and a server, and is implemented through the interaction between the terminal and the server. In a specific embodiment, the method can include the following steps:
[0076] S202: Obtain labeled source domain data, unlabeled target domain data, and a student model.
[0077] The source domain data includes a large number of annotated images, which are usually related to the target domain data but not exactly the same. The target domain data includes unannotated images.
[0078] S204: Train a student model based on the source domain data to obtain a structure and weight of the trained student model.
[0079] S206: Construct a teacher model based on the structure and weight of the trained student model.
[0080] An initial student model is trained using source domain data to obtain the structure and weight of the trained student model. A teacher model is constructed based on the structure and weight of the trained student model. In some embodiments, the weight of the teacher model is further updated by an exponential moving average algorithm to increase its stability.
[0081] S208: Input the target domain data into the teacher model to obtain a pseudo label of the target domain data.
[0082] S210: Input the pseudo-label and target domain data into the trained student model for training to obtain an optimized student model, update the model parameters of the teacher model based on the model parameters of the optimized student model, and perform target detection based on the updated teacher model.
[0083] The target domain data is input into the teacher model, and the teacher model generates predicted labels for these data, namely pseudo labels. The target domain data and its corresponding pseudo labels are input into the trained student model again, and a new round of training allows the student model to learn from more data. The model parameters of the teacher model are updated based on the model parameters of the optimized student model. This can be a simple copy of the weights of the student model to the teacher model, or a more complex strategy, such as weighted averaging based on performance indicators.
[0084] In the initial stage, the student model is trained using labeled source domain data, and the teacher model with the same architecture is used to generate pseudo labels for the unlabeled target domain data. The student model is further trained with pseudo labels and target domain data to improve its performance on the target domain. The optimized student model is used to update the teacher model to maintain the performance of the teacher model, and target detection is performed based on the updated teacher model.
[0085] In the above target detection method, in the pre-training stage, the source domain data is used to train the student model, and the teacher model is built based on the student model. In the mutual learning stage, the target domain data is input into the teacher model to obtain pseudo labels, and then the student model is trained with the pseudo labels to improve the target detection capability of the model.
[0086] In some embodiments of the present disclosure, training the student model based on the source domain data includes:
[0087] Extracting instance features in the source domain data based on the student model;
[0088] For any multiple instance features in the same category, calculate the distance between the instance features;
[0089] When the distance between the instance features is less than the preset distance, the feature instances whose distance between the instance features is less than the preset distance are input into the same clustering set to form a category multi-prototype structure.
[0090] Figure 3 A schematic diagram of generating a multi-prototype structure of a category in one embodiment.
[0091] Using the annotated source domain data, the backbone network and the detector are used to extract instance features in the image. In order to retain the fine-grained differences within the same category, facilitate the subsequent accurate correction of pseudo labels and the semantic control of the generated virtual instance features, the following formula is used in the initialization process to cluster the instance categories according to the distance between instance features, including:
[0092] ;
[0093] in represents the jth instance feature in category k, represents the mth instance feature in category k, represents the i-th clustering set of all instance features in the k-th category that meet the screening conditions, Represents the mapping function, when When the content is true, ,otherwise , Indicates the distance threshold between features.
[0094] Secondly, to ensure the timeliness and stability of the prototype, we use the exponential moving average algorithm to continuously update the category multi-prototype structure:
[0095] ;
[0096] in represents the j-th prototype in category k, represents the jth instance feature in category k, Represents the mapping function, when When the content is true, ,otherwise , Represents the distance threshold between features and .
[0097] In some embodiments of the present disclosure, the method further includes:
[0098] The pseudo labels are modified based on the category multi-prototype structure and virtual instance features are generated.
[0099] The multi-prototype structure of a category means that there are multiple prototypes within each category. These prototypes can be representative points of subgroups within the category, such as similar objects of different colors, or paintings of different styles, etc. The multi-prototype structure of a category can help the model better understand and distinguish the diversity within the category.
[0100] The predicted labels generated by the model on the unlabeled target domain data are called pseudo-labels. Due to the imperfections of the model in the training process, the generated pseudo-labels may be wrong. The pseudo-labels can be accurately corrected through the category multi-prototype structure.
[0101] For each unlabeled target domain data, find the most similar prototype and correct the pseudo-label based on the similarity. When an unlabeled target domain data is very close to a prototype, it can be considered that the unlabeled target domain data belongs to the subcategory represented by the prototype and the pseudo-label is corrected.
[0102] In addition to correcting pseudo labels, the category multi-prototype structure can also be used to generate virtual instance features. Based on the prototype of each category, virtual instance features can be generated by interpolation, combining existing prototype features, adding noise, Gaussian distribution, etc. The generated virtual instance features are added to the existing data set to expand the data set size and improve the generalization ability of the model.
[0103] In some embodiments of the present disclosure, the pseudo-label is corrected in the following manner:
[0104] Extract instance features of each target instance in the image;
[0105] For each category, the spatial distance between all instance features of each category and all prototypes in each category is calculated;
[0106] The spatial distance is calculated according to the following formula:
[0107] ;
[0108] in represents the j-th prototype in category k, represents the jth instance feature in category k, Represents the mapping function, when When the content is true, ,otherwise , Represents the distance threshold between instance features and category multi-prototypes;
[0109] The instance features that meet the distance threshold are used to predict pseudo labels.
[0110] Figure 4 Schematic diagram of pseudo-label correction in one embodiment.
[0111] Extracting feature vectors of instance features can be done by using pre-trained convolutional neural networks such as ResNet or other feature extractors.
[0112] For each category K, calculate the spatial distance between all instance features of that category and all prototypes in that category. Spatial distance The calculation formula is as follows:
[0113] ,in, Represents the mapping function, when When the content is true, ,otherwise , Represents the distance threshold between features and .
[0114] For each category K, the distance between each prototype and the instance feature is calculated.
[0115] Each category prototype obtains multiple calculation results. If there is a spatial distance close to the category prototype, the instance feature is retained, otherwise the instance feature is deleted, that is, , retain the instance features, otherwise delete the instance features. The retained instance features will be sent to the detector for pseudo label prediction. Since the retained instance features are close enough to the category prototype, the possibility of correct classification is higher, thus generating high-quality pseudo labels.
[0116] By comparing the distance between instance features and category multi-prototypes, we can determine which instance features should be retained and further used for pseudo-label prediction, which can reduce the impact of noisy data and improve the quality of pseudo-labels.
[0117] In some embodiments of the present disclosure, the method further includes:
[0118] Based on the source domain data, the parameters of the feature point classification branch newly added to the student model are initialized to obtain the initialization loss function ;
[0119] in, Represents the nth feature point in category k in a batch of features. represents the feature point classifier output of the student model, Represents the true classification label;
[0120] Generate virtual instance features based on the category multi-prototype structure, and obtain the feature consistency loss function based on the output results of the student model, the output results of the teacher model, and the virtual instance features. , ,
[0121] in, represents the nth feature point in category k in the virtual instance feature, represents a Gaussian distribution, represents the mean of the prototype within the i-th class of the prototype of category k, Represents the variance between feature points in a batch, represents the output of the student model, represents the output of the teacher model, represents the cross entropy loss function.
[0122] Figure 5 Schematic diagram of a feature consistency loss process in one embodiment.
[0123] Object detection models, such as Faster R-CNN, are usually used to identify multiple objects and their locations in an image. The original object detection model may include multiple components such as Backbone, feature extractor, classifier, and bounding box regressor. An additional function can be added to the original object detection model, adding a feature point classification branch to identify key feature points inside the object. In the field of object detection, knowledge distillation can be used to train a smaller student model to achieve performance close to that of the teacher model while reducing the demand for computing resources. For example, there can be a large, complex Faster R-CNN model as a teacher model, and then a smaller, more efficient Faster R-CNN model can be trained as a student model.
[0124] In addition to the original classification loss and bounding box regression loss, a new loss function needs to be defined for learning the feature point classification branch, namely the initialization loss function, which is based on the prediction error of the key feature point position. ,in Represents the nth feature point in category k in a batch of features. represents the feature point classifier output of the student detection model, Represents the true classification label.
[0125] Generate virtual instance features based on multiple category prototypes to ensure the semantic consistency and diversity of the generated instance features. ,in represents the nth feature point in category k in the virtual instance feature, represents a Gaussian distribution, represents the mean of the prototype within the i-th class of the prototype of category k, Represents the variance between feature points in a batch.
[0126] In order to ensure the consistency of features, feature consistency loss can be introduced , represents the feature point classifier output of the student detection model, represents the feature point classifier output of the teacher detection model, represents the cross entropy loss function.
[0127] In the initialization phase, the source domain data is used to initialize the feature point classification branch and optimize the initialization loss function. In the training phase, the category multi-prototype is used to generate virtual instance features, and the feature consistency loss is optimized by the difference between the output of the student model and the teacher model and the virtual instance features. This can enhance the model's adaptability to data from different fields and improve the quality of pseudo labels, because the feature consistency loss ensures that the features learned by the model are not only valid in the source domain, but also maintain consistency and diversity in the target domain.
[0128] In some embodiments of the present disclosure, updating the model parameters of the teacher model based on the optimized model parameters of the student model includes:
[0129] The model parameters of the optimized student model are obtained, and the model parameters of the teacher model are updated based on the exponential moving average algorithm.
[0130] Update the weights of the teacher model using the exponential moving average algorithm (EMA):
[0131] ,
[0132] in represents the teacher model weight parameter, represents the student model weight parameter, It is a hyperparameter that controls the update speed of the teacher model weights.
[0133] The overall loss of the model can be expressed as:
[0134] ;
[0135] in, and They are the losses of the RPN (region generation network) and ROI (region of interest) branches in Faster RCNN (target detection model). is a hyperparameter to balance the total loss, and the source domain dataset is , Represent the source domain image, category, and coordinate information respectively. Let the target domain dataset be , represents the target domain image. The target domain has no annotation information, so it does not contain category and coordinate information. The detection box generated by the teacher model during training is recorded as a pseudo label as , Represents classification and coordinate information respectively.
[0136] Figure 6 This is an architectural diagram of the student model and teacher model in one embodiment.
[0137] In one embodiment of the present disclosure, the trained multi-prototype domain adaptive detection model is used for domain adaptive target detection. This specific embodiment shows the migration results of the present invention on Cityscapes to Cityscapes Foggy (semantic city landscape segmentation dataset). The source domain image is Cityscapes, which includes eight common categories such as people and cars, and is collected during the day and in good weather conditions. The target domain image is Cityscapes Foggy, which includes eight common categories such as people and cars, and is collected in foggy and bad weather conditions. The experiment uses Mean Average Precision (MAP evaluation index) to represent the average accuracy of the model detection results. It can be seen from Table 1 that the present invention has different degrees of improvement under different backbone networks, among which the performance improvement using the VGG16 backbone network is 3.8%, and the performance improvement using the ResNet50 backbone network is 3.3%. The recognition effect after the model improvement is shown in Table 1:
[0138] Table 1 Recognition effect after model improvement
[0139]
[0140] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0141] Based on the same inventive concept, the embodiment of the present disclosure also provides a target detection device for implementing the target detection method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in the target detection device embodiment provided below can refer to the limitations of the target detection method above, and will not be repeated here.
[0142] The device may include a system (including a distributed system), software (application), module, component, server, client, etc. that uses the method described in the embodiments of this specification and is combined with necessary implementation hardware. Based on the same innovative concept, the device in one or more embodiments provided in the embodiments of the present disclosure is as described in the following embodiments. Since the implementation scheme and method of the device to solve the problem are similar, the implementation of the specific device in the embodiments of this specification can refer to the implementation of the aforementioned method, and the repetitions will not be repeated. As used below, the term "unit" or "module" can be a combination of software and / or hardware that implements a predetermined function. Although the device described in the following embodiments is preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceived.
[0143] In one embodiment, Figure 7 As shown, a target detection device 700 is provided, and the device may be the aforementioned server, or a module, component, device, unit, etc. integrated in the server. The device 700 may include:
[0144] An acquisition module 702 is used to acquire source domain data with annotations, target domain data without annotations, and a student model;
[0145] A training module 704 is used to train a student model based on the source domain data to obtain a structure and a weight of the trained student model;
[0146] Constructing a model 706, for constructing a teacher model based on the structure and weights of the trained student model;
[0147] A generating module 708, configured to input the target domain data into the teacher model to obtain a pseudo label of the target domain data;
[0148] The detection module 710 is used to input the pseudo-label into the trained student model for training to obtain an optimized student model, update the model parameters of the teacher model based on the model parameters of the student model, and perform target detection based on the updated teacher model.
[0149] In one embodiment, the training of the student model based on the source domain data comprises:
[0150] The training of the student model based on the source domain data comprises:
[0151] Extracting instance features in the source domain data based on the student model;
[0152] For any multiple instance features in the same category, calculate the distance between the instance features;
[0153] When the distance between the instance features is less than the preset distance, the feature instances whose distance between the instance features is less than the preset distance are input into the same clustering set to form a category multi-prototype structure.
[0154] In one embodiment, the device further comprises:
[0155] The pseudo labels are modified based on the category multi-prototype structure and virtual instance features are generated.
[0156] In one embodiment, the pseudo-label is corrected in the following manner:
[0157] Extract instance features of each target instance in the image;
[0158] For each category, the spatial distance between all instance features of each category and all prototypes in each category is calculated;
[0159] The spatial distance is calculated according to the following formula:
[0160] ;
[0161] in represents the jth prototype in category k, represents the jth instance feature in category k, Represents the mapping function, when When the content is true, ,otherwise , Represents the distance threshold between instance features and category multi-prototypes;
[0162] The instance features that meet the distance threshold are used to predict pseudo labels.
[0163] In one embodiment, the device further comprises:
[0164] Based on the source domain data, the parameters of the feature point classification branch newly added to the student model are initialized to obtain the initialization loss function ;
[0165] in, Represents the nth feature point in category k in a batch of features. represents the feature point classifier output of the student model, Represents the true classification label;
[0166] Generate virtual instance features based on the category multi-prototype structure, and obtain the feature consistency loss function based on the output results of the student model, the output results of the teacher model, and the virtual instance features. , ,
[0167] in, represents the nth feature point in category k in the virtual instance feature, represents a Gaussian distribution, represents the mean of the prototype within the i-th class of the prototype of category k, Represents the variance between feature points in a batch, represents the output of the student model, represents the output of the teacher model, represents the cross entropy loss function.
[0168] In one embodiment, after obtaining the optimized student model, the device further includes:
[0169] The weight of the optimized student model is obtained, and the weight of the teacher model is updated based on the exponential moving average algorithm.
[0170] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0171] Each module in the above-mentioned target detection device can be implemented in whole or in part by software, hardware and a combination thereof. Each of the above-mentioned modules can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.
[0172] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be shown in FIG8. The computer device includes a processor, a memory, and a network interface connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store images. The network interface of the computer device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, a target detection method is implemented.
[0173] In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be shown in FIG9. The computer device includes a processor, a memory, a communication interface, a display screen, and an input device connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be implemented through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, a target detection method is implemented. The display screen of the computer device may be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device may be a touch layer covered on the display screen, or a key, a trackball or a touchpad provided on the housing of the computer device, or an external keyboard, touchpad or mouse, etc.
[0174] Those skilled in the art will understand that the structures shown in FIG. 8 and FIG. 9 are merely block diagrams of partial structures related to the scheme of the present disclosure, and do not constitute a limitation on the computer device to which the scheme of the present disclosure is applied. The specific computer device may include more or fewer components than those shown in the figures, or combine certain components, or have a different arrangement of components.
[0175] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the method described in any embodiment of the present disclosure is implemented.
[0176] In one embodiment, a computer program product is provided, including a computer program, which implements the method described in any embodiment of the present disclosure when executed by a processor.
[0177] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided by the present disclosure can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided by the present disclosure may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided by the present disclosure may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic unit, a data processing logic unit based on quantum computing, etc., but are not limited to this.
[0178] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0179] The above-described embodiments only express several implementation methods of the present disclosure, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present invention. It should be pointed out that, for a person of ordinary skill in the art, several modifications and improvements can be made without departing from the concept of the present disclosure, and these all belong to the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure shall be subject to the attached claims.
Claims
1. A target detection method, characterized in that: The method comprises: Obtain annotated source domain data, unannotated target domain data, and student models; Training a student model based on the source domain data to obtain a structure and a weight of the trained student model; Constructing a teacher model based on the structure and weights of the trained student model; Inputting the target domain data into the teacher model to obtain a pseudo label of the target domain data; The pseudo labels and target domain data are input into the trained student model for training to obtain an optimized student model, the model parameters of the teacher model are updated based on the model parameters of the optimized student model, and target detection is performed based on the updated teacher model.
2. The method according to claim 1, characterized in that The training of the student model based on the source domain data comprises: Extracting instance features in the source domain data based on the student model; For any multiple instance features in the same category, calculate the distance between the instance features; When the distance between the instance features is less than the preset distance, the feature instances whose distance between the instance features is less than the preset distance are input into the same clustering set to form a category multi-prototype structure.
3. The method according to claim 2, characterized in that The method further comprises: The pseudo labels are modified based on the category multi-prototype structure and virtual instance features are generated.
4. The method according to claim 3, characterized in that The pseudo-labels are corrected as follows: Extract instance features of each target instance in the image; For each category, the spatial distance between all instance features of each category and all prototypes in each category is calculated; The spatial distance is calculated according to the following formula: = ; in represents the jth prototype in category k, represents the jth instance feature in category k, Represents the mapping function, when When the content is true, ,otherwise , Represents the distance threshold between instance features and category multi-prototypes; The instance features that meet the distance threshold are used to predict pseudo labels.
5. The method according to claim 3, characterized in that: The method further comprises: Based on the source domain data, the parameters of the feature point classification branch newly added to the student model are initialized to obtain the initialization loss function ; in, Represents the nth feature point in category k in a batch of features. represents the feature point classifier output of the student model, Represents the true classification label; Generate virtual instance features based on the category multi-prototype structure, and obtain the feature consistency loss function based on the output results of the student model, the output results of the teacher model, and the virtual instance features. , ; in, represents the nth feature point in category k in the virtual instance feature, represents a Gaussian distribution, represents the mean of the prototype within the i-th class of the prototype of category k, Represents the variance between feature points in a batch, represents the output of the student model, represents the output of the teacher model, represents the cross entropy loss function.
6. The method according to claim 1, characterized in that Updating the model parameters of the teacher model based on the optimized model parameters of the student model includes: The model parameters of the optimized student model are obtained, and the model parameters of the teacher model are updated based on the exponential moving average algorithm.
7. A target detection device, characterized in that: The device comprises: An acquisition module, used to acquire source domain data with annotations, target domain data without annotations, and a student model; A training module, used for training a student model based on the source domain data to obtain a structure and a weight of the trained student model; Constructing a model for constructing a teacher model based on the structure and weights of the trained student model; A generation module, used for inputting the target domain data into the teacher model to obtain a pseudo label of the target domain data; The detection module is used to input the pseudo-label into the trained student model for training to obtain an optimized student model, update the model parameters of the teacher model based on the model parameters of the student model, and perform target detection based on the updated teacher model.
8. The device according to claim 7, characterized in that The training of the student model based on the source domain data comprises: Extracting instance features in the source domain data based on the student model; For any multiple instance features in the same category, calculate the distance between the instance features; When the distance between the instance features is less than the preset distance, the feature instances whose distance between the instance features is less than the preset distance are input into the same clustering set to form a category multi-prototype structure.
9. The device according to claim 8, characterized in that The device also includes: The pseudo labels are modified based on the category multi-prototype structure and virtual instance features are generated.
10. The device according to claim 9, characterized in that The pseudo-labels are corrected as follows: Extract instance features of each target instance in the image; For each category, the spatial distance between all instance features of each category and all prototypes in each category is calculated; The spatial distance is calculated according to the following formula: = ; in represents the j-th prototype in category k, represents the jth instance feature in category k, Represents the mapping function, when When the content is true, ,otherwise , Represents the distance threshold between instance features and category multi-prototypes; The instance features that meet the distance threshold are used to predict pseudo labels.
11. The device according to claim 10, characterized in that The device also includes: Based on the source domain data, the parameters of the feature point classification branch newly added to the student model are initialized to obtain the initialization loss function ; in, Represents the nth feature point in category k in a batch of features. represents the feature point classifier output of the student model, Represents the true classification label; Generate virtual instance features based on the category multi-prototype structure, and obtain the feature consistency loss function based on the output results of the student model, the output results of the teacher model, and the virtual instance features. , ; in, represents the nth feature point in category k in the virtual instance feature, represents a Gaussian distribution, represents the mean of the prototype within the i-th class of the prototype of category k, Represents the variance between feature points in a batch, represents the output of the student model, represents the output of the teacher model, represents the cross entropy loss function.
12. The device according to claim 7, characterized in that Updating the model parameters of the teacher model based on the optimized model parameters of the student model includes: The model parameters of the optimized student model are obtained, and the model parameters of the teacher model are updated based on the exponential moving average algorithm.
13. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
14. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
15. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Prediction model training method and device, equipment, medium and program product
CN117217293A
High-resolution remote sensing image unsupervised adaptive target detection method
CN117475295A
Passive domain adaptive target detection method and device
CN117636086A
Low-illumination face detection model construction method, device and terminal
CN118014048A
Model training method, cross-domain target detection method and electronic equipment
CN118038163A
Cited By
Pseudo tag optimization method and device, storage medium and computer equipment
CN121505389A
Pseudo-label optimization method and device, storage medium and computer device
CN121505389B
Non-intrusive load identification equipment migration performance evaluation method and system
CN121524570A
Non-intrusive load disaggregation device migration performance evaluation method and system
CN121524570B
Cross-domain target detection method and system, device, and storage medium
WO2026091816A1
