Target detection model training method and device, readable storage medium and electronic equipment
By constructing a joint training dataset and using the feature similarity and domain labels of the source and target domain datasets to guide the loss function, the problem of poor adaptability of the target detection model to new scenes is solved, and the model can be efficiently adapted to new scenes.
Patent Information
- Application Number
- CN202510638485.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-16
- Publication Date
- 2025-09-23
AI Technical Summary
During the iterative update process, existing target detection models face the problem of difficulty in controlling the quality of annotations when new scene data flows back or new demand supplementary data is added, resulting in the existence of noisy labels and reducing the model's adaptability to new scenarios.
Construct a joint training dataset, use the source domain and target domain datasets, and train the model through feature similarity loss function, domain label guidance loss function and target detection loss function to improve the model's adaptability to new scenarios.
By constructing a joint training dataset, the target detection model is guided to adapt to the noisy labels in new scenes, thereby improving the model's adaptability to new scenes.
Smart Images

Figure CN120689696A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of target detection technology, and in particular relates to a target detection model training method, device, computer-readable storage medium and electronic device. Background Art
[0002] The application of artificial intelligence (AI) technology in obstacle detection tasks for sweepers has garnered widespread attention in recent years. Object detection algorithms, as a key branch of computer vision, provide strong technical support for intelligent navigation and obstacle avoidance capabilities in sweepers. Using cameras or laser sensors, sweepers can perceive their surroundings, identify and avoid obstacles, and thus ensure efficient and safe cleaning. To ensure efficient object detection in sweepers, the object detection model must be trained using large-scale datasets. Each image frame in these datasets typically requires annotation of the obstacle's location and category.
[0003] However, in real-world applications, during the iterative update of the robot vacuum's object detection model, the return of new scene data or supplementary data based on new requirements often faces the challenge of ensuring labeling quality. Especially in dynamically changing environments, the data labeling process can introduce noisy labels such as mislabeling, missing labels, and misclassification. The presence of these noisy labels often reduces training effectiveness, resulting in poor adaptability of the trained object detection model to new scenarios. Summary of the Invention
[0004] In view of this, the embodiments of the present application provide a target detection model training method, device, computer-readable storage medium and electronic device to solve the problem that the trained target detection model has poor adaptability to new scenarios in the existing target detection model training method.
[0005] A first aspect of an embodiment of the present application provides a method for training a target detection model, which may include:
[0006] Acquire a source domain dataset; wherein the source domain dataset is a dataset collected and labeled in the first scenario;
[0007] Training a preset artificial intelligence model based on the source domain dataset to obtain a trained first object detection model;
[0008] Acquire a target domain dataset; wherein the target domain dataset is a dataset collected and labeled in a second scenario different from the first scenario;
[0009] Constructing a joint training dataset based on the source domain dataset and the target domain dataset;
[0010] The first target detection model is trained based on the joint training data set to obtain a trained second target detection model.
[0011] In a specific implementation of the first aspect, the training the first object detection model based on the joint training dataset to obtain the trained second object detection model may include:
[0012] Determining a feature similarity loss function for model training; wherein the feature similarity loss function is a loss function for minimizing the feature distance between samples in the source domain dataset and minimizing the feature distance between samples in the target domain dataset;
[0013] Determining a domain label guided loss function for model training; wherein the domain label guided loss function is a loss function used to distinguish sample features of the source domain dataset and the target domain dataset;
[0014] Determine the target detection loss function for model training;
[0015] Determining a joint loss function for model training based on the target detection loss function, the feature similarity loss function, and the domain label guidance loss function;
[0016] Based on the joint training data set and the joint loss function, the first target detection model is trained to obtain a trained second target detection model.
[0017] In a specific implementation of the first aspect, determining the feature similarity loss function for model training may include:
[0018] Determining feature distances between samples in the source domain dataset;
[0019] Determining feature distances between samples in the target domain dataset;
[0020] A feature similarity loss function for model training is determined based on the feature distances between samples in the source domain dataset and the feature distances between samples in the target domain dataset.
[0021] In a specific implementation of the first aspect, determining a feature similarity loss function for model training based on feature distances between samples in the source domain dataset and feature distances between samples in the target domain dataset may include:
[0022] Based on a preset weighting factor, a weighted sum is performed on the feature distances between samples in the source domain dataset and the feature distances between samples in the target domain dataset to obtain a feature similarity loss function for model training.
[0023] In a specific implementation of the first aspect, determining the domain label guided loss function for model training may include:
[0024] Determine a first domain label and a second domain label of a sample in the joint training dataset; wherein the first domain label is a true domain label, and the second domain label is a domain label output by the model;
[0025] A domain label guided loss function for model training is determined according to the first domain label and the second domain label.
[0026] In a specific implementation of the first aspect, determining a joint loss function for model training based on the object detection loss function, the feature similarity loss function, and the domain label guidance loss function may include:
[0027] Weighting the target detection loss function according to a preset target detection weighting factor to obtain the weighted target detection loss function;
[0028] Weighting the feature similarity loss function according to a preset feature similarity weighting factor to obtain the weighted feature similarity loss function;
[0029] weighting the domain label guided loss function according to a preset domain label guided weighting factor to obtain the weighted domain label guided loss function;
[0030] The weighted object detection loss function, the weighted feature similarity loss function, and the weighted domain label guidance loss function are summed to obtain a joint loss function for model training.
[0031] In a specific implementation of the first aspect, after training the first object detection model based on the joint training dataset to obtain a trained second object detection model, the method may further include:
[0032] Obtain the image to be detected;
[0033] Use the second target detection model to perform target detection on the image to be detected to obtain a target detection result of the image to be detected.
[0034] A second aspect of the embodiments of the present application provides a target detection model training device, which may include:
[0035] A source domain dataset acquisition module, configured to acquire a source domain dataset; wherein the source domain dataset is a dataset collected and labeled in the first scenario;
[0036] A first target detection model training module is used to train a preset artificial intelligence model based on the source domain dataset to obtain a trained first target detection model;
[0037] a target domain dataset acquisition module, configured to acquire a target domain dataset; wherein the target domain dataset is a dataset collected and labeled in a second scenario different from the first scenario;
[0038] A joint training dataset construction module, configured to construct a joint training dataset based on the source domain dataset and the target domain dataset;
[0039] The second target detection model training module is used to train the first target detection model based on the joint training data set to obtain a trained second target detection model.
[0040] In a specific implementation of the second aspect, the second object detection model training module may include:
[0041] A feature similarity loss function determination submodule, configured to determine a feature similarity loss function for model training; wherein the feature similarity loss function is a loss function for minimizing the feature distance between samples in the source domain dataset and minimizing the feature distance between samples in the target domain dataset;
[0042] A domain label guided loss function determination submodule, configured to determine a domain label guided loss function for model training; wherein the domain label guided loss function is a loss function for distinguishing sample features of the source domain dataset and the target domain dataset;
[0043] The target detection loss function determination submodule is used to determine the target detection loss function for model training;
[0044] a joint loss function determination submodule, configured to determine a joint loss function for model training based on the target detection loss function, the feature similarity loss function, and the domain label guidance loss function;
[0045] The model training submodule is used to train the first target detection model based on the joint training data set and the joint loss function to obtain a trained second target detection model.
[0046] In a specific implementation of the second aspect, the feature similarity loss function determination submodule may include:
[0047] A first feature distance determining unit, configured to determine a feature distance between samples in the source domain dataset;
[0048] a second feature distance determining unit, configured to determine the feature distance between samples in the target domain dataset;
[0049] The feature similarity loss function determining unit is used to determine a feature similarity loss function for model training based on the feature distances between samples in the source domain dataset and the feature distances between samples in the target domain dataset.
[0050] In a specific implementation of the second aspect, the feature similarity loss function determination unit can be specifically used to: based on a preset weighting factor, perform weighted summation on the feature distances between samples in the source domain dataset and the feature distances between samples in the target domain dataset to obtain a feature similarity loss function for model training.
[0051] In a specific implementation of the second aspect, the domain label guided loss function determination submodule can be specifically used to: determine a first domain label and a second domain label of a sample in the joint training dataset; wherein the first domain label is a true domain label, and the second domain label is a domain label output by the model; and determine a domain label guided loss function for model training based on the first domain label and the second domain label.
[0052] In a specific implementation of the second aspect, the joint loss function determination submodule can be specifically used to: weight the target detection loss function according to a preset target detection weighting factor to obtain the weighted target detection loss function; weight the feature similarity loss function according to a preset feature similarity weighting factor to obtain the weighted feature similarity loss function; weight the domain label guided loss function according to a preset domain label guided weighting factor to obtain the weighted domain label guided loss function; and sum the weighted target detection loss function, the weighted feature similarity loss function, and the weighted domain label guided loss function to obtain a joint loss function for model training.
[0053] In a specific implementation of the second aspect, the target detection model training device may further include:
[0054] The target detection module is used to obtain an image to be detected; use the second target detection model to perform target detection on the image to be detected, and obtain a target detection result of the image to be detected.
[0055] A third aspect of an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the steps of any of the above-mentioned target detection model training methods.
[0056] The fourth aspect of an embodiment of the present application provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of any one of the above-mentioned target detection model training methods when executing the computer program.
[0057] A fifth aspect of an embodiment of the present application provides a computer program product, which, when executed on an electronic device, enables the electronic device to execute the steps of any one of the above-mentioned target detection model training methods.
[0058] Compared with the prior art, the embodiments of the present application have the following beneficial effects: the embodiments of the present application obtain a source domain dataset; wherein, the source domain dataset is a dataset collected and labeled in a first scenario; a preset artificial intelligence model is trained based on the source domain dataset to obtain a trained first target detection model; a target domain dataset is obtained; wherein, the target domain dataset is a dataset collected and labeled in a second scenario different from the first scenario; a joint training dataset is constructed based on the source domain dataset and the target domain dataset; the first target detection model is trained based on the joint training dataset to obtain a trained second target detection model. Through the embodiments of the present application, a joint training dataset can be constructed based on the dataset of the existing scenario (i.e., the first scenario) and the dataset of the new scenario (i.e., the second scenario) to train the target detection model, thereby guiding the target detection model to adapt to the noise labels in the new scenario and improving the adaptability of the trained target detection model to the new scenario. BRIEF DESCRIPTION OF THE DRAWINGS
[0059] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the embodiments or descriptions of the prior art. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0060] Figure 1 This is a flow chart of an embodiment of a target detection model training method in an embodiment of the present application;
[0061] Figure 2 Output diagram of target detection model for input image;
[0062] Figure 3 is a schematic flowchart of training a first object detection model based on a joint training dataset;
[0063] Figure 4 This is a structural diagram of an embodiment of a target detection model training device in an embodiment of the present application;
[0064] Figure 5 This is a schematic block diagram of an electronic device in an embodiment of the present application. DETAILED DESCRIPTION
[0065] In order to make the purpose, features, and advantages of the invention of this application more obvious and easy to understand, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the embodiments described below are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0066] It will be understood that when used in this specification and the appended claims, the term "comprising" indicates the presence of described features, integers, steps, operations, elements and / or components, but does not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof.
[0067] It should also be understood that the terms used in this specification are for the purpose of describing specific embodiments only and are not intended to limit the present application. As used in this specification and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms unless the context clearly indicates otherwise.
[0068] It should be further understood that the term "and / or" used in this specification and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
[0069] As used in this specification and the appended claims, the term "if" can be interpreted as "when" or "upon" or "in response to determining" or "in response to detecting," depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "upon determination" or "in response to determining" or "upon detection of [described condition or event]" or "in response to detecting [described condition or event]," depending on the context.
[0070] In addition, in the description of the present application, the terms "first", "second", "third", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.
[0071] The application of artificial intelligence (AI) technology in obstacle detection tasks for sweepers has garnered widespread attention in recent years. Object detection algorithms, as a key branch of computer vision, provide strong technical support for intelligent navigation and obstacle avoidance capabilities in sweepers. Using cameras or laser sensors, sweepers can perceive their surroundings, identify and avoid obstacles, and thus ensure efficient and safe cleaning. To ensure efficient object detection in sweepers, the object detection model must be trained using large-scale datasets. Each image frame in these datasets typically requires annotation of the obstacle's location and category.
[0072] However, in real-world applications, during the iterative update of the robot vacuum's object detection model, the return of new scene data or supplementary data based on new requirements often faces the challenge of ensuring labeling quality. Especially in dynamically changing environments, the data labeling process can introduce noisy labels such as mislabeling, missing labels, and misclassification. The presence of these noisy labels often reduces training effectiveness, resulting in poor adaptability of the trained object detection model to new scenarios.
[0073] In view of this, the embodiments of the present application provide a target detection model training method, device, computer-readable storage medium and electronic device to solve the problem that the trained target detection model has poor adaptability to new scenarios in the existing target detection model training method.
[0074] In an embodiment of the present application, a joint training dataset can be constructed based on the dataset of the existing scene and the dataset of the new scene to train the target detection model, thereby guiding the target detection model to adapt to the noise labels in the new scene and improving the adaptability of the trained target detection model to the new scene.
[0075] The execution subject of the embodiment of the present application can be an electronic device, which may include but is not limited to mobile phones, tablet computers, desktop computers, notebooks, PDAs, sweepers, robots, and servers. It should be noted that the electronic device for model training and the electronic device for target detection can be the same electronic device or different electronic devices. That is, the model training can be performed in one electronic device, and then the trained model can be deployed to another electronic device for target detection.
[0076] See also Figure 1 In one embodiment of the present application, a method for training a target detection model may include:
[0077] Step S101: Acquire a source domain dataset.
[0078] The source domain dataset (denoted as source) is a dataset collected and labeled in the first scenario. The first scenario can be a known stable scenario, so the label quality of the samples in the source domain dataset is relatively high.
[0079] Step S102: Train the preset artificial intelligence model based on the source domain dataset to obtain a trained first target detection model.
[0080] Among them, the model structure of the artificial intelligence model can be flexibly set according to actual conditions, and may include but is not limited to YOLO, EfficientDet, RetinaNet or other model structures, which is not specifically limited in the embodiments of this application.
[0081] In the embodiment of the present application, the artificial intelligence model can be trained based on the source domain data set to obtain the trained first target detection model. Figure 2 As shown, the first target detection model can perform target detection on the input image and output the predicted box and the corresponding category and confidence information.
[0082] Step S103: Acquire the target domain dataset.
[0083] The target domain dataset (denoted as target) is a dataset collected and labeled in a second scenario, which is different from the first scenario. The second scenario can be an unknown new usage scenario. Therefore, the label quality of the samples in the target domain dataset cannot be fully controlled and may contain noisy labels such as mislabeling, missing labels, and misclassification.
[0084] Step S104: construct a joint training dataset based on the source domain dataset and the target domain dataset.
[0085] In the embodiment of the present application, the source domain dataset and the target domain dataset can be combined to construct a joint training dataset. In the subsequent model training process, the input data received by the model may come from the source domain dataset or the target domain dataset.
[0086] Step S105: Train the first target detection model based on the joint training data set to obtain a trained second target detection model.
[0087] like Figure 3 As shown, step S105 may specifically include the following steps:
[0088] Step S1051: Determine a feature similarity loss function for model training.
[0089] The feature similarity loss function is a loss function used to minimize the feature distance between samples in the source domain dataset and minimize the feature distance between samples in the target domain dataset.
[0090] In each batch of model training, the feature distances between samples in the source domain dataset and the feature distances between samples in the target domain dataset can be determined respectively.
[0091] Specifically, for any two samples in the source domain dataset (denoted as x i and x j ), we can extract features from it through the feature extraction network (denoted as f) in the model to obtain the sample x i The image feature f(x i ) and sample x j The image feature f(x j ), the image feature f(x i ) and image features f(x j ) to calculate the feature distance, we can get the sample x i and sample x j The characteristic distance D(f(x i ),f(x j )). The distance calculation function may adopt any distance calculation function in the prior art according to actual circumstances, including but not limited to a cosine distance calculation function, a Euclidean distance calculation function, and the like, and is not specifically limited in this embodiment of the present application. By traversing any two samples in the source domain dataset in this manner, the characteristic distances between each pair of samples in the source domain dataset can be obtained, and the sum of these distances can be calculated. The result is the characteristic distance between the samples in the source domain dataset.
[0092] Similarly, for any two samples in the target domain dataset (denoted as x m and x n ), the feature extraction network in the model can be used to extract features, thereby obtaining the sample x m The image feature f(x m ) and sample x n The image feature f(x n ), the image feature f(x m ) and image features f(x n ) to calculate the feature distance, we can get the sample x m and sample x n The characteristic distance D(f(x m ),f(x n By traversing any two samples in the target domain dataset in this manner, the feature distances between each pair of samples in the target domain dataset can be obtained, and the sum of the distances is the feature distance between the samples in the target domain dataset.
[0093] Then, a feature similarity loss function for model training can be determined based on the feature distances between samples in the source domain dataset and the feature distances between samples in the target domain dataset. Specifically, based on a preset weighting factor, the feature distances between samples in the source domain dataset and the feature distances between samples in the target domain dataset are weighted and summed to obtain the feature similarity loss function for model training, as shown in the following formula:
[0094]
[0095] Among them, λ sim is a preset weighting factor, the specific value of which can be flexibly set according to actual conditions, and is not specifically limited in the present embodiment. sim It is a feature similarity loss function that ensures the consistency of sample features in the source domain dataset and the target domain dataset, so that the model can learn more consistent feature representations in the same domain.
[0096] Step S1052: Determine a domain label guided loss function for model training.
[0097] The domain label guided loss function is a loss function used to distinguish the sample features of the source domain dataset and the target domain dataset.
[0098] In an embodiment of the present application, different domain labels can be introduced for samples in the source domain dataset and samples in the target domain dataset, respectively, and the domain labels can be used to guide the model to distinguish the sample features from the source domain dataset and the target domain dataset. The specific domain label value can be flexibly set according to the actual situation, and the embodiment of the present application does not specifically limit this. As an example, the domain label of the sample in the source domain dataset can be set to 0, and the domain label of the sample in the target domain dataset can be set to 1. A domain classifier for distinguishing the sample features of the source domain dataset and the target domain dataset can be added to the model, so that the model can find a suitable boundary between the source domain dataset and the target domain dataset.
[0099] In each batch of model training, the first domain label and second domain label of the samples in the joint training dataset can be determined. The first domain label is the actual domain label, and the second domain label is the domain label output by the model. Then, the domain label guidance loss function for model training can be determined based on the first and second domain labels, as shown in the following formula:
[0100]
[0101] Among them, y i is the first domain label, is the second domain label, Ldomain Bootstrapping the loss function for domain labels.
[0102] Step S1053: Determine the target detection loss function for model training.
[0103] Among them, the target detection loss function may include a classification loss function and a position loss function. The specific form can be found in the existing technical content, and the embodiments of this application will not be repeated here.
[0104] Step S1054: Determine a joint loss function for model training based on the target detection loss function, the feature similarity loss function, and the domain label guidance loss function.
[0105] In an embodiment of the present application, the target detection loss function can be weighted according to a preset target detection weighting factor to obtain a weighted target detection loss function; the feature similarity loss function can be weighted according to a preset feature similarity weighting factor to obtain a weighted feature similarity loss function; and the domain label guidance loss function can be weighted according to a preset domain label guidance weighting factor to obtain a weighted domain label guidance loss function. Then, the weighted target detection loss function, the weighted feature similarity loss function, and the weighted domain label guidance loss function can be summed to obtain a joint loss function for model training, as shown in the following formula:
[0106] L total =λ1·L cls +λ2·L loc +λ3·L sim +λ4·L domain
[0107] Among them, L total is the joint loss function, L cls is the classification loss function, L loc is the position loss function, λ1 is the function of L cls The corresponding target detection weighting factor, λ2 is the same as L loc The corresponding target detection weighting factor, λ3 is the feature similarity weighting factor, λ4 is the domain label guidance weighting factor, and the specific values of λ1, λ2, λ3 and λ4 can be flexibly set according to actual conditions, and the embodiment of the present application does not make specific limitations on this.
[0108] Step S1055: Based on the joint training data set and the joint loss function, the first target detection model is trained to obtain a trained second target detection model.
[0109] In each batch of model training, the training loss value of the batch can be calculated according to the joint loss function, and the model parameters can be adjusted according to the training loss value. In the embodiment of the present application, it is assumed that in the initial state, the model parameter is W1, and the training loss value is back-propagated to modify the model parameter W1 to obtain the modified model parameter W2. After modifying the parameters, the next training process is continued. In this training process, the training loss value is recalculated and the training loss value is back-propagated to modify the model parameter W2 to obtain the modified model parameter W3, ..., and so on. The above process is repeated continuously. The model parameters can be modified in each training process until the preset training conditions are met. The training condition can be that the number of training times reaches a preset number threshold. The number threshold can be set according to actual conditions. For example, it can be set to thousands, tens of thousands, hundreds of thousands or even larger values; the training condition can also be model convergence; since the number of training times may not reach the number threshold, but the model has converged, it may cause unnecessary work to be repeated; or the model may not converge, which may lead to an infinite loop and the training process cannot be terminated. Based on the above two situations, the training condition can also be that the number of training times reaches the number threshold or the model converges. When the training conditions are met, the trained second target detection model can be obtained.
[0110] After the second target detection model is trained, the second target detection model can be used to perform actual target detection. Specifically, an image to be detected can be obtained, and the second target detection model can be used to perform target detection on the image to be detected, thereby obtaining a target detection result for the image to be detected.
[0111] In summary, the embodiment of the present application obtains a source domain dataset; wherein the source domain dataset is a dataset collected and labeled in a first scenario; a preset artificial intelligence model is trained based on the source domain dataset to obtain a trained first target detection model; a target domain dataset is obtained; wherein the target domain dataset is a dataset collected and labeled in a second scenario different from the first scenario; a joint training dataset is constructed based on the source domain dataset and the target domain dataset; the first target detection model is trained based on the joint training dataset to obtain a trained second target detection model. Through the embodiment of the present application, a joint training dataset can be constructed based on the dataset of the existing scenario (i.e., the first scenario) and the dataset of the new scenario (i.e., the second scenario) to train the target detection model, thereby guiding the target detection model to adapt to the noise labels in the new scenario and improving the adaptability of the trained target detection model to the new scenario.
[0112] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0113] Corresponding to the target detection model training method described in the above embodiment, Figure 4 A structural diagram of an embodiment of a target detection model training device provided in an embodiment of the present application is shown.
[0114] In this embodiment, a target detection model training device may include:
[0115] The source domain dataset acquisition module 401 is used to acquire a source domain dataset; wherein the source domain dataset is a dataset collected and labeled in the first scenario;
[0116] A first object detection model training module 402 is configured to train a preset artificial intelligence model based on the source domain dataset to obtain a trained first object detection model;
[0117] The target domain dataset acquisition module 403 is configured to acquire a target domain dataset; wherein the target domain dataset is a dataset collected and labeled in a second scenario different from the first scenario;
[0118] A joint training dataset construction module 404 is configured to construct a joint training dataset based on the source domain dataset and the target domain dataset;
[0119] The second target detection model training module 405 is used to train the first target detection model based on the joint training data set to obtain a trained second target detection model.
[0120] In a specific implementation of the embodiment of the present application, the second target detection model training module may include:
[0121] A feature similarity loss function determination submodule, configured to determine a feature similarity loss function for model training; wherein the feature similarity loss function is a loss function for minimizing the feature distance between samples in the source domain dataset and minimizing the feature distance between samples in the target domain dataset;
[0122] A domain label guided loss function determination submodule, configured to determine a domain label guided loss function for model training; wherein the domain label guided loss function is a loss function for distinguishing sample features of the source domain dataset and the target domain dataset;
[0123] The target detection loss function determination submodule is used to determine the target detection loss function for model training;
[0124] a joint loss function determination submodule, configured to determine a joint loss function for model training based on the target detection loss function, the feature similarity loss function, and the domain label guidance loss function;
[0125] The model training submodule is used to train the first target detection model based on the joint training data set and the joint loss function to obtain a trained second target detection model.
[0126] In a specific implementation of the embodiment of the present application, the feature similarity loss function determination submodule may include:
[0127] A first feature distance determining unit, configured to determine a feature distance between samples in the source domain dataset;
[0128] a second feature distance determining unit, configured to determine the feature distance between samples in the target domain dataset;
[0129] The feature similarity loss function determining unit is used to determine a feature similarity loss function for model training based on the feature distances between samples in the source domain dataset and the feature distances between samples in the target domain dataset.
[0130] In a specific implementation of an embodiment of the present application, the feature similarity loss function determination unit can be specifically used to: based on a preset weighting factor, perform weighted summation on the feature distances between samples in the source domain dataset and the feature distances between samples in the target domain dataset to obtain a feature similarity loss function for model training.
[0131] In a specific implementation of an embodiment of the present application, the domain label guided loss function determination submodule can be specifically used to: determine the first domain label and the second domain label of the sample in the joint training dataset; wherein the first domain label is the real domain label, and the second domain label is the domain label output by the model; based on the first domain label and the second domain label, determine the domain label guided loss function for model training.
[0132] In a specific implementation of an embodiment of the present application, the joint loss function determination submodule can be specifically used to: weight the target detection loss function according to a preset target detection weighting factor to obtain the weighted target detection loss function; weight the feature similarity loss function according to a preset feature similarity weighting factor to obtain the weighted feature similarity loss function; weight the domain label guided loss function according to a preset domain label guided weighting factor to obtain the weighted domain label guided loss function; sum the weighted target detection loss function, the weighted feature similarity loss function and the weighted domain label guided loss function to obtain a joint loss function for model training.
[0133] In a specific implementation of the embodiment of the present application, the target detection model training device may further include:
[0134] The target detection module is used to obtain an image to be detected; use the second target detection model to perform target detection on the image to be detected, and obtain a target detection result of the image to be detected.
[0135] Those skilled in the art will clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described devices, modules and units can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0136] In the above embodiments, the description of each embodiment has its own focus. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant description of other embodiments.
[0137] Figure 5 A schematic block diagram of an electronic device provided in an embodiment of the present application is shown. For ease of explanation, only the parts related to the embodiment of the present application are shown.
[0138] like Figure 5 As shown, the electronic device 5 of this embodiment includes: a processor 50, a memory 51, and a computer program 52 stored in the memory 51 and executable on the processor 50. When the processor 50 executes the computer program 52, the steps in the above-mentioned target detection model training method embodiments are implemented, such as Figure 1 Alternatively, when the processor 50 executes the computer program 52, the functions of the modules / units in the above-mentioned device embodiments are realized, for example, Figure 4 Functions of modules 401 to 405 are shown.
[0139] Exemplarily, the computer program 52 may be divided into one or more modules / units, which are stored in the memory 51 and executed by the processor 50 to implement the present application. The one or more modules / units may be a series of computer program instruction segments capable of performing specific functions, and the instruction segments are used to describe the execution process of the computer program 52 in the electronic device 5.
[0140] The electronic device 5 may include but is not limited to mobile phones, tablet computers, desktop computers, notebooks, PDAs, sweepers, robots, servers and other computing devices. It will be understood by those skilled in the art that Figure 5It is only an example of the electronic device 5 and does not constitute a limitation of the electronic device 5. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the electronic device 5 may also include input and output devices, network access devices, buses, etc.
[0141] The processor 50 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor.
[0142] The memory 51 can be an internal storage unit of the electronic device 5, such as a hard disk or memory of the electronic device 5. The memory 51 can also be an external storage device of the electronic device 5, 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 5. Furthermore, the memory 51 can also include both an internal storage unit of the electronic device 5 and an external storage device. The memory 51 is used to store the computer program and other programs and data required by the electronic device 5. The memory 51 can also be used to temporarily store data that has been output or is about to be output.
[0143] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated into one processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0144] In the above embodiments, the description of each embodiment has its own focus. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant description of other embodiments.
[0145] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0146] In the embodiments provided in the present application, it should be understood that the disclosed devices / electronic devices and methods can be implemented in other ways. For example, the device / electronic device embodiments described above are merely schematic. For example, the division of the modules or units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0147] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.
[0148] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0149] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the process in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and when the computer program is executed by the processor, it can implement the steps of the above-mentioned various method embodiments. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable storage medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the computer-readable storage medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable storage media do not include electric carrier signals and telecommunication signals.
[0150] The above-described embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present application, and should all be included in the scope of protection of the present application.
Claims
1. A target detection model training method, characterized in that: include: Acquire a source domain dataset; wherein the source domain dataset is a dataset collected and labeled in the first scenario; Training a preset artificial intelligence model based on the source domain dataset to obtain a trained first object detection model; Acquire a target domain dataset; wherein the target domain dataset is a dataset collected and labeled in a second scenario different from the first scenario; Constructing a joint training dataset based on the source domain dataset and the target domain dataset; The first target detection model is trained based on the joint training data set to obtain a trained second target detection model.
2. The target detection model training method according to claim 1, characterized in that The training of the first target detection model based on the joint training data set to obtain a trained second target detection model includes: Determining a feature similarity loss function for model training; wherein the feature similarity loss function is a loss function for minimizing the feature distance between samples in the source domain dataset and minimizing the feature distance between samples in the target domain dataset; Determining a domain label guided loss function for model training; wherein the domain label guided loss function is a loss function used to distinguish sample features of the source domain dataset and the target domain dataset; Determine the target detection loss function for model training; Determining a joint loss function for model training based on the target detection loss function, the feature similarity loss function, and the domain label guidance loss function; Based on the joint training data set and the joint loss function, the first target detection model is trained to obtain a trained second target detection model.
3. The target detection model training method according to claim 2, characterized in that Determining the feature similarity loss function for model training includes: Determining feature distances between samples in the source domain dataset; Determining feature distances between samples in the target domain dataset; A feature similarity loss function for model training is determined based on the feature distances between samples in the source domain dataset and the feature distances between samples in the target domain dataset.
4. The target detection model training method according to claim 3, characterized in that The determining of a feature similarity loss function for model training based on the feature distances between samples in the source domain dataset and the feature distances between samples in the target domain dataset includes: Based on a preset weighting factor, a weighted sum is performed on the feature distances between samples in the source domain dataset and the feature distances between samples in the target domain dataset to obtain a feature similarity loss function for model training.
5. The target detection model training method according to claim 2, characterized in that Determining the domain label guided loss function for model training includes: Determine a first domain label and a second domain label of a sample in the joint training dataset; wherein the first domain label is a true domain label, and the second domain label is a domain label output by the model; A domain label guided loss function for model training is determined according to the first domain label and the second domain label.
6. The target detection model training method according to claim 2, characterized in that Determining a joint loss function for model training based on the target detection loss function, the feature similarity loss function, and the domain label guidance loss function includes: Weighting the target detection loss function according to a preset target detection weighting factor to obtain the weighted target detection loss function; Weighting the feature similarity loss function according to a preset feature similarity weighting factor to obtain the weighted feature similarity loss function; weighting the domain label guided loss function according to a preset domain label guided weighting factor to obtain the weighted domain label guided loss function; The weighted object detection loss function, the weighted feature similarity loss function, and the weighted domain label guidance loss function are summed to obtain a joint loss function for model training.
7. The target detection model training method according to any one of claims 1 to 6, characterized in that: After training the first object detection model based on the joint training dataset to obtain a trained second object detection model, the method further includes: Obtain the image to be detected; Use the second target detection model to perform target detection on the image to be detected to obtain a target detection result of the image to be detected.
8. A target detection model training device, characterized in that: include: A source domain dataset acquisition module, configured to acquire a source domain dataset; wherein the source domain dataset is a dataset collected and labeled in the first scenario; A first target detection model training module is used to train a preset artificial intelligence model based on the source domain dataset to obtain a trained first target detection model; a target domain dataset acquisition module, configured to acquire a target domain dataset; wherein the target domain dataset is a dataset collected and annotated in a second scenario different from the first scenario; A joint training dataset construction module, configured to construct a joint training dataset based on the source domain dataset and the target domain dataset; The second target detection model training module is used to train the first target detection model based on the joint training data set to obtain a trained second target detection model.
9. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the target detection model training method according to any one of claims 1 to 7 are implemented.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the steps of the target detection model training method according to any one of claims 1 to 7 are implemented.
Citation Information
Cited By
Visual recognition method and device based on local region adaptive training enhancement
CN122368747A