Model training method and device, target detection method and device and electronic equipment
By combining pre-training of non-target domain datasets and pseudo-label generation with multi-batch training, the accuracy problem of target detection models in the absence of high-quality labeled data is solved, and high-precision target detection is achieved.
Patent Information
- Application Number
- CN202510770591.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-10
- Publication Date
- 2025-09-23
AI Technical Summary
The target detection neural network model trained by existing technology has low detection accuracy for targets, especially in the absence of high-quality labeled data, and cannot accurately detect targets.
By using the non-target domain training dataset to pre-train the to-be-trained model, generating pseudo labels, and combining it with the multi-batch training method, the target domain training dataset is constructed, and the model is gradually optimized to improve the detection accuracy.
In the absence of high-quality labeled data, the model's target detection accuracy is significantly improved, especially in pathology testing and small-batch industrial production, increasing the pathology recognition accuracy by 20% to 40%.
Smart Images

Figure CN120689594A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of neural network models, and in particular to a model training method, a target detection method, a device and an electronic device. Background Art
[0002] With the continuous development of neural network technology, neural network models have been widely used in various fields.
[0003] In target detection fields, such as medical image recognition, industrial inspection, and other object recognition fields, it is often necessary to obtain a large amount of high-quality annotated data from related fields, especially bounding box and category annotations. However, in practical applications, the cost of obtaining annotated data is high. In particular, in specific fields or scenarios, it is often impossible to obtain effective high-quality annotated data, resulting in the inability of trained target detection neural network models to accurately detect targets. For example, in the field of liver lesion recognition, when training a liver lesion recognition model, it is necessary to obtain a large number of liver CT images annotated with the location, size, and type of liver lesions, but these CT images are difficult to obtain in large quantities. For another example, in small-batch industrial production, product quality testing requires a large number of images annotated with product quality, but the production volume is small and cannot be obtained in large quantities. All of these situations will significantly reduce the recognition accuracy of the target detection model.
[0004] This shows that the target detection neural network model trained by existing technologies has low detection accuracy for targets. Summary of the Invention
[0005] In view of this, it is necessary to provide a model training method, target detection method, device and electronic equipment to solve the problem that the target detection neural network model trained by the existing technology has low detection accuracy for target objects.
[0006] In order to solve the above problems, in a first aspect, the present invention provides a model training method, comprising: Obtain a non-target domain training dataset and target domain data, and use the non-target domain training dataset to train the transferable features of the to-be-trained model to obtain a pre-trained model; The target domain data is processed using a pre-trained model to obtain pseudo labels for each target domain data, and a target domain training dataset is generated based on the target domain data and pseudo labels. The target domain training dataset is used to perform multi-batch training on the pre-trained model to obtain a trained model.
[0007] In one possible embodiment of the present invention, a non-target domain training dataset is used to train transferable features of a to-be-trained model to obtain a pre-trained model, including: A non-target domain training data set is used to train the feature extraction ability, feature dimensionality reduction ability, and feature classification ability of the training model to obtain a pre-trained feature extractor, bottleneck layer, and classifier. The feature extractor is used to extract data features, the bottleneck layer is used to reduce the dimensionality of data features to obtain reduced dimensionality data features, and the classifier is used to classify the reduced dimensionality data features.
[0008] In one possible implementation of the present invention, a pre-trained model is used to process target domain data to obtain pseudo labels for each target domain data, including: Use the pre-trained model to process the target domain data and determine the probability of the category to which the target domain data belongs; The categories with probabilities greater than the preset probability threshold are used as pseudo labels for the target domain data.
[0009] In one possible implementation of the present invention, generating a target domain training dataset based on each target domain data and pseudo labels includes: Combine the pseudo labels corresponding to the target domain data with the target domain data to generate target domain pseudo label data; The target domain pseudo-labeled data is mixed with the target domain real-labeled data to generate the target domain training dataset.
[0010] In a possible implementation of the present invention, after generating a target domain training dataset based on each target domain data and pseudo labels, the following steps are included: Construct the loss function of the model to be trained. The loss function is:
[0011]
[0012] in, L is the cross entropy loss function, For the i The true labels of the target domain data, For the i Pseudo labels of target domain data, N is the number of target domain data, for KL Divergence loss function, is the target distribution of the target domain, is the target distribution of the non-target domain.
[0013] In one possible embodiment of the present invention, a pre-trained model is trained in multiple batches using a target domain training dataset to obtain a trained model, including: Divide the target domain training data set into multiple target domain training data subsets; The pre-trained model is trained for multiple rounds using multiple target domain training data subsets to obtain a trained model. After each round of training is completed, a preset number of target domain training data from the previous round of target domain training data subset is added to the next round of target domain training data subset.
[0014] In a possible implementation of the present invention, when a preset number of target domain training data in a previous round of target domain training data subset is added to a next round of target domain training data subset, the value of the preset number is gradually reduced.
[0015] In a second aspect, the present invention further provides a target detection method for detecting a target to be detected using a target detection model trained based on the model training method described in any of the above embodiments.
[0016] In a third aspect, an embodiment of the present invention further provides a model training device, comprising: The model pre-training module is used to obtain a non-target domain training dataset and target domain data, and use the non-target domain training dataset to train the transferable features of the to-be-trained model to obtain a pre-trained model; A target domain training dataset generation module is used to process the target domain data using a pre-trained model to obtain pseudo labels for each target domain data, and generate a target domain training dataset based on each target domain data and pseudo labels; The multi-batch training module is used to perform multi-batch training on the pre-trained model using the target domain training dataset to obtain a trained model.
[0017] In a fourth aspect, an embodiment of the present invention further provides an electronic device, comprising a memory and a processor, wherein: Memory, used to store programs; A processor, coupled to the memory, is used to execute the program stored in the memory to implement the steps in the model training method of any of the above embodiments.
[0018] The beneficial effects of the present invention are as follows: the model training method provided by the present invention trains the transferable features of the to-be-trained model using a non-target domain training dataset to obtain a pre-trained model, pre-trains the to-be-trained model using an easily available non-target domain training dataset to obtain a pre-trained model including transferable features, then uses the pre-trained model to process the target domain data to obtain pseudo labels for each target domain data, and generates a target domain training dataset based on the pseudo labels and the target domain data, labels the target domain data using the pre-trained model to obtain a large amount of high-quality target domain training dataset, then uses the target domain training dataset to perform multiple batches of training on the pre-trained model to obtain a trained model, thereby ensuring the quality of model training. The present invention does not require manual labeling of a large amount of data, but can obtain a large amount of labeled data through pseudo-labeling, and iteratively trains the model using the large amount of labeled data to ensure model training accuracy, thereby improving model quality. In particular, in the field of target detection, high-precision model training can still be achieved when there is no large amount of high-quality labeled data, thereby improving the accuracy of the model for target detection. By training the model with labeled non-target domain data, tasks such as recognition and classification of unlabeled target domain data can be achieved. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0020] Figure 1 A flowchart of a model training method provided by an embodiment of the present invention; Figure 2 A schematic diagram of a flow chart of a pseudo-label generation method provided by an embodiment of the present invention; Figure 3 A flowchart of a method for generating a target domain training dataset provided by an embodiment of the present invention; Figure 4 A schematic diagram of a multi-batch training method according to an embodiment of the present invention; Figure 5 A schematic structural diagram of a model training device provided by an embodiment of the present invention; Figure 6 A schematic structural diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0021] The preferred embodiments of the present invention will be described in detail below with reference to the accompanying drawings, wherein the accompanying drawings constitute a part of the present invention and are used together with the embodiments of the present invention to illustrate the principles of the present invention, but are not used to limit the scope of the present invention.
[0022] The terms "first," "second," and so on, used in the embodiments of the present invention are for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Therefore, technical features designated as "first" or "second" may explicitly or implicitly include at least one such feature.
[0023] References herein to "embodiments" mean that a particular feature, structure, or characteristic described in connection with the embodiments may be included in at least one embodiment of the present invention. The appearance of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor does it constitute a separate or alternative embodiment that is mutually exclusive of other embodiments. It is understood, both explicitly and implicitly, by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0024] A specific embodiment of the present invention, as Figure 1 As shown, a model training method is disclosed, comprising: S101, obtaining a non-target domain training dataset and target domain data, and using the non-target domain training dataset to train transferable features of a to-be-trained model to obtain a pre-trained model.
[0025] In an embodiment of the present invention, a model training method is provided for training a neural network model. The trained neural network model can be applied to target detection and recognition in target fields, such as medical imaging inspection models, industrial inspection models, and other target object detection models. When training the target detection model, it is necessary to obtain a large amount of high-quality annotated data to construct a training set and a test set. For example, for target detection models in the medical field, such as pathology detection models, it is necessary to obtain a large number of pathology images containing pathology, which are annotated with data such as the location, size, and type of the pathology. This is generally achieved through manual annotation. Due to the particularity of pathology, it may be impossible to obtain a large number of pathology images, resulting in insufficient data in the dataset and test set, which in turn leads to poor training results of the pathology detection model and the inability of the pathology detection model to accurately identify the location, size, or type of the pathology when identifying the pathology images. Alternatively, for small-batch industrial production, it is necessary to test product quality and obtain a large number of images annotated with product quality. However, due to the small number of products produced, it is impossible to obtain a large number of images, resulting in low product quality detection accuracy of the target detection model trained based on product images. In an embodiment of the present invention, the non-target domain training dataset is an easily accessible dataset that can be obtained from a public dataset, such as data from other fields, including but not limited to vehicle images, pedestrian images, animal images, etc. These datasets are suitable for training the initial model, and data diversity can ensure that the data covers a variety of scenarios, target forms, and distribution characteristics. In an embodiment of the present invention, the transferable features of the model to be trained refer to model features that can be transferred between different fields. When training the transferable features of the model to be trained, the easily accessible non-target domain training dataset can be used for training to obtain a pre-trained model containing the training results of the transferable features, thereby laying the foundation for subsequent further training of the model to be trained.
[0026] Optionally, the non-target domain training data in the non-target domain training dataset can be preprocessed. For example, for image data, the image can be adjusted to a statistical resolution to adapt to the input size of the model. Alternatively, simple data augmentation can be performed on the dataset, and data augmentation operations can be randomly applied during the training process to improve the robustness of the model, including horizontal flipping, random rotation, scaling, random cropping, etc. Furthermore, the data can be divided into training set, validation set, and test set, with a commonly used ratio of 8:1:1. The training set is used for parameter optimization of the model and must contain as diverse samples as possible; the validation set is used for intermediate evaluation of the model to check whether the model is overfitting or underfitting. The test set is used for final model performance evaluation, and samples must not participate in model training or validation.
[0027] S102: Process the target domain data using a pre-trained model to obtain pseudo labels for each target domain data, and generate a target domain training dataset based on each target domain data and the pseudo labels.
[0028] In an embodiment of the present invention, target domain data refers to data in a target domain that needs to be processed by a model, such as the pathological image of the pathological detection model in the aforementioned embodiment. The target domain data only includes data without corresponding labels, and model training cannot be performed. For example, a pathological image only contains images of pathology, and the image does not mark the location, size, and category of the pathology. By processing the target domain data with a pre-trained model, pseudo labels for each target domain data can be obtained. Pseudo labels refer to the labeled data obtained by identifying the target domain image with the pre-trained model after pre-training in the aforementioned steps. For example, for pathological images, a pre-trained model can be used to identify the pathological image, and labeled data such as the size, location, and type of the pathology in the pathological image can be obtained. By combining these labeled data with the pathological image, the target domain training data in the target domain training dataset can be obtained.
[0029] S103, using the target domain training dataset to perform multiple batches of training on the pre-trained model to obtain a trained model.
[0030] In an embodiment of the present invention, after obtaining a target domain training dataset containing a large amount of high-quality target domain training data, the target domain training dataset is used to perform multi-batch training on the pre-trained model to obtain a trained model. The specific training process is described in detail later in the present invention.
[0031] The model training method provided by the present invention trains the transferable features of the to-be-trained model using a non-target domain training dataset to obtain a pre-trained model. The to-be-trained model is pre-trained using an easily accessible non-target domain training dataset to obtain a pre-trained model including transferable features. The pre-trained model is then used to process the target domain data to obtain pseudo labels for each target domain data, and a target domain training dataset is generated based on the pseudo labels and the target domain data. The target domain data is labeled using the pre-trained model to obtain a large amount of high-quality target domain training dataset. The pre-trained model is then trained in multiple batches using the target domain training dataset to obtain a trained model, thereby ensuring the quality of model training. The present invention does not require manual labeling of a large amount of data. A large amount of labeled data can be obtained by pseudo-labeling, and the model is iteratively trained using the large amount of labeled data to ensure model training accuracy and improve model quality. In particular, in the field of target detection, high-precision model training can still be achieved when a large amount of high-quality labeled data is not available, thereby improving the model's accuracy in target detection. It has been verified that the pathology recognition model trained by the model training method provided by the embodiment of the present invention has an accuracy rate of 20% to 40% higher than that of the prior art in pathology recognition in pathology images.
[0032] In some possible embodiments of the present invention, a non-target domain training dataset is used to train transferable features of a to-be-trained model to obtain a pre-trained model, including: A non-target domain training data set is used to train the feature extraction ability, feature dimensionality reduction ability, and feature classification ability of the training model to obtain a pre-trained feature extractor, bottleneck layer, and classifier. The feature extractor is used to extract data features, the bottleneck layer is used to reduce the dimensionality of data features to obtain reduced dimensionality data features, and the classifier is used to classify the reduced dimensionality data features.
[0033] In this embodiment of the present invention, to train transferable features for a pre-trained model, it is necessary to first select an appropriate pre-trained model. For example, in the image recognition field, a ResNet50 network can be selected. Using the deep learning framework PyTorch, the model can be loaded and trained on datasets such as office-home. Pre-trained models typically employ a large-scale training strategy, requiring appropriate optimization and hyperparameter selection. Adam is selected as the optimizer, and Exponential Decay is used for learning rate scheduling. The ReLU activation function is first used to prevent vanishing or exploding gradients. The bottleneck layer reduces the dimensionality of image features to a fixed value to preemptively adapt to subsequent dynamic datasets. The classifier outputs class probabilities for the fully connected layer or the classifier with weight normalization. The advantage of the classifier is that it decouples the weight modulus and direction, improving robustness against domain shift. It can also prevent overfitting of the classifier. Using a label-smoothed cross-entropy strategy can prevent overconfidence in the generated pre-trained model. Images in the dataset are subjected to feature extraction, a bottleneck layer, and classification to obtain the desired dimensionality. The pre-trained model is then evaluated and tested, with the best-performing feature extractor, bottleneck layer, and classifier retained.
[0034] The embodiment of the present invention pre-trains the to-be-trained model using a non-target domain training data set, thereby training the transferable features of the model and retaining the transferable features of the model, thereby facilitating subsequent model training.
[0035] In some possible embodiments of the present invention, Figure 2 As shown in the figure, the pre-trained model is used to process the target domain data to obtain pseudo labels for each target domain data, including: S201, using a pre-trained model to process the target domain data to determine the probability of the category to which the target domain data belongs; S202: The category with a probability greater than a preset probability threshold is used as a pseudo label for the target domain data.
[0036] In the embodiment of the present invention, pseudo labels refer to labels that are not manually labeled, and their 100% accuracy cannot be guaranteed. By pseudo-labeling the target domain data through the pre-training model, a large number of target domain training data sets can be obtained. Pseudo labels play a dual role of knowledge transfer and self-enhancement in transfer learning, utilizing a large amount of unlabeled data to reduce the need for manual labeling.
[0037] In an embodiment of the present invention, for each target domain data, a pre-trained model is used to identify the target domain data to obtain the probability of the category to which the target domain data may belong, and then the category with a probability greater than a preset probability threshold is used as a pseudo-label for the target domain data. For example, when the probability that a certain target domain data belongs to category A is greater than 70%, A can be used as the pseudo-label for the target domain data. The specific probability threshold setting can be selected according to actual conditions.
[0038] The embodiment of the present invention labels the target domain data through a pre-trained model, and can more accurately determine the pseudo labels of the target domain data.
[0039] In some possible embodiments of the present invention, Figure 3 As shown in Figure 2, a target domain training dataset is generated based on each target domain data and pseudo labels, including: S301, combining the pseudo labels corresponding to the target domain data with the target domain data to generate target domain pseudo label data; S032: Mix the target domain pseudo-label data with the target domain real-label data to generate a target domain training dataset.
[0040] In an embodiment of the present invention, after determining the pseudo labels for each target domain data item, the pseudo labels are combined with the target domain data to generate target domain pseudo-label data. Optionally, manually labeled target domain real label data can be obtained, and then the target domain pseudo-label data is mixed with the target domain real label data to generate a target domain training dataset. Optionally, the target domain real label data is manually labeled data in the target domain, and the mixing ratio of the target domain real label data and the target domain pseudo-label data can be determined based on actual conditions.
[0041] The embodiment of the present invention can obtain a more accurate target domain training data set by mixing target domain pseudo-label data with target domain real-label data.
[0042] In some possible embodiments of the present invention, after generating a target domain training dataset based on each target domain data and pseudo labels, the following steps are included: Construct the loss function of the model to be trained. The loss function is:
[0043]
[0044] in, L is the cross entropy loss function, For the i The true labels of the target domain data, For the i Pseudo labels of target domain data, N is the number of target domain data, for KL Divergence loss function, is the target distribution of the target domain, is the target distribution of the non-target domain.
[0045] In an embodiment of the present invention, after the prediction result is obtained through forward propagation, the next step is to calculate the loss, measure the gap between the model output and the true label, and then calculate the gradient through the chain rule through back propagation, and use gradient descent to update the model parameters, calculate the gradient of the loss function for the parameter weights and bias of each layer, and use KL divergence loss in transfer learning for model compression or cross-domain adaptation. The current model is used to generate pseudo labels for the unlabeled data in the newly added categories, and the pseudo labels are used as part of the training data and added to the model optimization to improve the utilization rate of the unlabeled data.
[0046] In some possible embodiments of the present invention, Figure 4 As shown in the figure, the pre-trained model is trained in multiple batches using the target domain training dataset to obtain a trained model, including: S401, dividing the target domain training data set into multiple target domain training data subsets; S402, using multiple target domain training data subsets to perform multiple rounds of training on the pre-trained model to obtain a trained model, wherein after each round of training is completed, a preset number of target domain training data in the previous round of target domain training data subset is added to the next round of target domain training data subset.
[0047] In an embodiment of the present invention, when multi-batch training is performed on a pre-trained model using a target domain training dataset, the target domain training dataset can be first divided into multiple target domain training data subsets. Multi-batch training is a step-by-step optimization strategy that divides the dataset into multiple small batches and gradually feeds them into the model for training. Compared to global training, which feeds the entire dataset all at once, multi-batch training offers significant advantages in terms of computing resource management, model generalization, and optimization efficiency. Furthermore, to enhance the memory of old target domain data, samples from the previous round of target domain data are added to a mixed training set when training a new round of target domain data to preserve the memory of old data. By regularly updating the stored samples, the most easily forgotten or representative samples are prioritized, thereby improving the long-term stability of the model. To prevent the model from adapting to new data due to excessive replay, the replay sample ratio is gradually reduced as training progresses, allowing the model to focus more on the current target domain data. Combined with multi-batch training, generalization is improved. During training, the dataset is divided into multiple small batches, each containing a certain number of samples. These batches are gradually fed into the model for training, loss calculation, and parameter update. After the entire training cycle is complete, the next round of training begins until convergence conditions are met. Multi-batch training can reduce memory overhead, improve computational efficiency, and is suitable for training large datasets. Compared to single-sample stochastic gradient descent, multi-batch training reduces gradient fluctuations, improves optimization stability, and reduces overfitting to specific data subsets. In transfer learning tasks, multi-batch training can be used to gradually adapt to new domain data and improve the adaptability of the target domain. Combined with memory replay, catastrophic forgetting is reduced. When training new categories, some samples from old categories are retained and mixed with the new category data for training. Through memory replay technology, the risk of forgetting old tasks is reduced, allowing the model to maintain its grasp of old knowledge while adapting to new knowledge.
[0048] By combining multi-batch training with experience replay, the present invention effectively improves the model's adaptability to target domain data in transfer learning while mitigating catastrophic forgetting. By rationally adjusting the replay ratio, optimizing the pseudo-labeling strategy, and dynamically adjusting the batch size, the model's generalization and training stability can be further enhanced.
[0049] In some possible embodiments of the present invention, when a preset number of target domain training data in a previous round of target domain training data subset is added to a next round of target domain training data subset, the value of the preset number is gradually reduced.
[0050] In an embodiment of the present invention, when adding a preset number of target domain training data from the previous round of target domain training data subset to the next round of target domain training data subset, it is necessary to determine the confidence of each pseudo-label in the previous round of training, and the target domain training data with higher pseudo-label confidence can be added to the next round of target domain training data subset, such as when the confidence is greater than 80%, wherein the number of target domain training data with higher pseudo-label confidence can be 10% of the target domain training data subset. Of course, the confidence threshold or the number of target domain training data subsets can be determined according to actual conditions, and the present invention does not impose any restrictions on this. Furthermore, in the process of training the model, a dynamic replay strategy is adopted, giving more replay samples at the beginning of training, and gradually reducing the replay ratio as the training progresses, so that the model can better balance the learning of new and old knowledge, avoid over-reliance on historical data, and affect the ability to learn new tasks.
[0051] Embodiments of the present invention utilize an experience replay mechanism to store some historical samples and mix them with old data during training. This allows the model to retain its memory of previous tasks while learning new knowledge, effectively mitigating catastrophic forgetting and improving the model's long-term stability. They also adapt to changes in target domain data and improve generalization capabilities. Traditional transfer learning methods can suffer from small sample sizes or dynamic changes in the target domain data distribution, making it difficult for the model to stably adapt to new data. This present invention utilizes a dynamic replay mechanism to periodically update stored samples during training, prioritizing the most representative or easily forgotten samples. This allows the model to continuously adapt to changes in the target domain data distribution and improves generalization capabilities in long-term task environments. In combination with multi-batch training, compared to training with a complete dataset at once, this present invention employs a multi-batch training strategy to gradually optimize the model. This, combined with experience replay, reduces computing resource consumption and makes the training process more stable. In each training round, part of the data batch consists of current target domain data, while part contains historically stored samples. This allows the model to simultaneously address both new and old tasks, improving training efficiency. Gradually adjust the replay ratio to prevent new task learning from being hindered. During continuous learning, if the proportion of replay data is too high, the model may focus too much on old tasks and fail to effectively learn new tasks.
[0052] The present invention also provides a target detection method for detecting a target to be detected using a target detection model trained based on the model training method in any of the above embodiments.
[0053] The target detection model trained by the model training method provided by the present invention, combined with a pseudo-label strategy, stores not only real label samples in the experience replay mechanism, but also high-confidence pseudo-label samples, allowing the model to use unlabeled data for continuous learning, further improving its adaptability to the target domain. It is applicable to a variety of application scenarios and improves the practicality of transfer learning. The replay mechanism of the present invention, combined with multi-batch training, can be widely applied to various transfer learning tasks, such as computer vision (target detection, image classification), natural language processing (cross-domain text classification, machine translation), reinforcement learning (robot control, autonomous driving), etc. Compared with traditional transfer learning methods, this solution can more effectively cope with long-term tasks, dynamic changes in data, and cross-domain adaptability problems, and has greater practical value.
[0054] In order to better implement the model training method in the embodiment of the present invention, based on the model training method, correspondingly, Figure 5 As shown, an embodiment of the present invention further provides a model training device, and the model training device 500 includes: The model pre-training module 501 is used to obtain a non-target domain training data set and target domain data, and use the non-target domain training data set to train the transferable features of the to-be-trained model to obtain a pre-trained model; A target domain training data set generation module 502 is configured to process the target domain data using a pre-trained model to obtain pseudo labels for each target domain data, and generate a target domain training data set based on each target domain data and the pseudo labels; The multi-batch training module 503 is used to perform multi-batch training on the pre-trained model using the target domain training dataset to obtain a trained model.
[0055] The model training device 500 provided in the above embodiment can implement the technical solution described in the above model training method embodiment. The specific implementation principles of the above modules or units can refer to the corresponding contents in the above model training method embodiment, which will not be repeated here.
[0056] like Figure 6 As shown, the present invention also provides an electronic device 600. The electronic device 600 includes a processor 601, a memory 602 and a display 603. Figure 6 Only some of the components of the electronic device 600 are shown, but it should be understood that implementation of all of the shown components is not required, and more or fewer components may be implemented instead.
[0057] In some embodiments, the processor 601 can be a central processing unit (CPU), a microprocessor, or other data processing chip, used to run the program code stored in the memory 602 or process data, such as the model training method in the present invention.
[0058] In some embodiments, processor 601 may be a single server or a server group. The server group may be centralized or distributed. In some embodiments, processor 601 may be local or remote. In some embodiments, processor 601 may be implemented on a cloud platform. In some embodiments, the cloud platform may include a private cloud, a public cloud, a hybrid cloud, a community cloud, a distributed cloud, an internal cloud, multiple clouds, or any combination thereof.
[0059] In some embodiments, the memory 602 may be an internal storage unit of the electronic device 600, such as a hard disk or memory of the electronic device 600. In other embodiments, the memory 602 may also be an external storage device of the electronic device 600, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the electronic device 600.
[0060] Furthermore, the memory 602 may include both an internal storage unit of the electronic device 600 and an external storage device. The memory 602 is used to store application software installed in the electronic device 600 and various data.
[0061] In some embodiments, the display 603 can be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, or an OLED (Organic Light-Emitting Diode) touchscreen. The display 603 is used to display information about the electronic device 600 and to display a visual user interface. Components 601-603 of the electronic device 600 communicate with each other via a system bus.
[0062] In some embodiments, when the processor 601 executes the model training program in the memory 602, the following steps may be implemented: Obtain a non-target domain training dataset and target domain data, and use the non-target domain training dataset to train the transferable features of the to-be-trained model to obtain a pre-trained model; The target domain data is processed using a pre-trained model to obtain pseudo labels for each target domain data, and a target domain training dataset is generated based on the target domain data and pseudo labels. The target domain training dataset is used to perform multi-batch training on the pre-trained model to obtain a trained model.
[0063] It should be understood that when the processor 601 executes the model training program in the memory 602, in addition to the above functions, it can also implement other functions. For details, please refer to the description of the corresponding method embodiment above.
[0064] The above description is only a preferred specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by any technician familiar with this technical field within the technical scope disclosed by the present invention should be covered by the scope of protection of the present invention.
Claims
1. A model training method, characterized in that: include: Obtaining a non-target domain training dataset and target domain data, and using the non-target domain training dataset to train transferable features of a to-be-trained model to obtain a pre-trained model; Processing the target domain data using the pre-training model to obtain pseudo labels for each target domain data, and generating a target domain training dataset based on each target domain data and the pseudo labels; The pre-trained model is trained in multiple batches using the target domain training dataset to obtain a trained model.
2. The model training method according to claim 1, characterized in that The method of using the non-target domain training data set to train the transferable features of the to-be-trained model to obtain a pre-trained model includes: The non-target domain training data set is used to train the feature extraction ability, feature dimensionality reduction ability and feature classification ability of the training model to obtain a pre-trained feature extractor, bottleneck layer and classifier, wherein the feature extractor is used to extract data features, the bottleneck layer is used to reduce the dimensionality of the data features to obtain reduced dimensionality data features, and the classifier is used to classify the reduced dimensionality data features.
3. The model training method according to claim 1, characterized in that The process of processing the target domain data using the pre-trained model to obtain pseudo labels for each target domain data includes: Processing the target domain data using the pre-trained model to determine the probability of the category to which the target domain data belongs; The category with the probability greater than the preset probability threshold is used as the pseudo label of the target domain data.
4. The model training method according to claim 3, characterized in that The generating of a target domain training data set based on the target domain data and the pseudo labels includes: Combining the pseudo label corresponding to the target domain data with the target domain data to generate target domain pseudo label data; The target domain pseudo-label data is mixed with the target domain real-label data to generate a target domain training dataset.
5. The model training method according to claim 1, characterized in that After generating the target domain training data set based on the target domain data and the pseudo labels, the method includes: Construct a loss function for the model to be trained, where the loss function is: in, L is the cross entropy loss function, For the i The true labels of the target domain data, For the i Pseudo labels of target domain data, N is the number of target domain data, for KL Divergence loss function, is the target distribution of the target domain, is the target distribution of the non-target domain.
6. The model training method according to claim 1, characterized in that The method of performing multiple batch training on the pre-trained model using the target domain training dataset to obtain a trained model includes: dividing the target domain training data set into a plurality of target domain training data subsets; The pre-trained model is trained for multiple rounds using the multiple target domain training data subsets to obtain a trained model, wherein after each round of training is completed, a preset number of target domain training data in the previous round of target domain training data subsets are added to the next round of target domain training data subsets.
7. The model training method according to claim 6, characterized in that When adding a preset number of target domain training data in the previous round of target domain training data subset to the next round of target domain training data subset, the value of the preset number is gradually reduced.
8. A target detection method, characterized in that: Used to detect a target to be detected using a target detection model trained based on the model training method described in any one of claims 1 to 7.
9. A model training device, characterized in that: include: A model pre-training module is used to obtain a non-target domain training data set and target domain data, and use the non-target domain training data set to train the transferable features of the to-be-trained model to obtain a pre-trained model; a target domain training data set generation module, configured to process the target domain data using the pre-training model to obtain pseudo labels for each target domain data, and generate a target domain training data set based on each target domain data and the pseudo labels; The multi-batch training module is used to perform multi-batch training on the pre-trained model using the target domain training dataset to obtain a trained model.
10. An electronic device, characterized in that: comprising a memory and a processor, wherein, The memory is used to store programs; The processor is coupled to the memory and is used to execute the program stored in the memory to implement the steps in the model training method described in any one of claims 1 to 7.