A domain adaptation object detection method and system based on domain-specific sample selection

By acquiring datasets from the target domain, source domain, and external domain, and by fine-tuning the model using domain-specific sample selection strategies and domain adaptation modules, the problem of decreased performance in new domain detection models was solved, thus improving cross-domain detection performance.

CN118015334BActive Publication Date: 2026-11-27XI AN JIAOTONG UNIV
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202410022218.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-01-05
Publication Date
2026-11-27
Estimated Expiration
2044-01-05

AI Technical Summary

Technical Problem

The problem of significantly reduced performance of existing object detection models in new domains is mainly due to the fact that the training and test sets come from the same domain, resulting in a significant performance drop when the data perspective, appearance, background and lighting change.

Method used

By acquiring target domain, source domain, and external domain datasets, and using domain-specific sample selection strategies to select image-level, instance-level, and class-level specific samples from the external domain dataset, fine-tuning is performed in conjunction with the domain adaptation module to learn domain-invariant features and improve the model's cross-domain detection performance.

Benefits of technology

It significantly improves the performance of the target detection model in cross-domain detection, especially in new domains with changes in viewpoint, appearance, and lighting, thus improving detection accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118015334B_ABST
    Figure CN118015334B_ABST
Patent Text Reader

Abstract

This invention proposes a domain-adaptive object detection method and system based on domain-specific sample selection, belonging to the field of computer vision. The method includes the following steps: 1) Obtaining a first dataset comprising a target domain dataset, a source domain dataset, and an external domain dataset; 2) Pre-training an object detection model using the first dataset to obtain an initial object detection model; 3) Selecting specific samples corresponding to the image from the external domain dataset; 4) Merging the specific samples, the target domain dataset, and the source domain dataset to obtain a second dataset, and labeling each image in the second dataset with a domain label; 5) Fine-tuning the initial object detection model using the second dataset to make it focus on domain-invariant features, thus obtaining a domain-adaptive object detection model; 6) Inputting the image to be detected into the domain-adaptive object detection model to obtain the detection result.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer vision technology, and more specifically, to a domain-adaptive target detection method and system based on domain-specific sample selection. Background Technology

[0002] The rise of deep learning has fostered a boom in the field of computer vision. At the same time, most deep learning models are trained in a supervised manner, by collecting large amounts of annotated datasets, which enables the learning of highly accurate models.

[0003] However, a significant problem is that in real-world scenarios, the performance of object detectors degrades significantly when factors such as the shooting angle, appearance, background, lighting, and image quality change. Currently, training a convolutional neural network in object detection requires a large set of supervised image samples. However, obtaining a large-scale image dataset is often difficult and costly. Furthermore, since the test and training sets come from the same domain, the model's detection performance is greatly weakened when encountering targets in new domains. Summary of the Invention

[0004] This application provides a domain-adaptive target detection method and system based on domain-specific sample selection to solve the problem that the target detection model's performance is greatly reduced in new domains.

[0005] To achieve the above objectives, the present invention employs the following technical solution:

[0006] In a first aspect, this application provides a domain-adaptive target detection method based on domain-specific sample selection, comprising the following steps:

[0007] Step s1: Obtain the first dataset; the first dataset includes a target domain dataset, a source domain dataset, and an external domain dataset; the external domain dataset is expanded based on the target domain dataset, and the sample categories of the external domain dataset are the same as or similar to the sample categories of the target domain dataset;

[0008] Step s2: Use the first dataset to pre-train the object detection model to obtain the initial object detection model;

[0009] Step s3: For each image in the target domain dataset, select a specific sample corresponding to the image from the external domain dataset based on the domain-specific sample selection strategy. The selected specific sample corresponding to the image includes: image-level specific samples obtained based on the image-level selection strategy, instance-level specific samples obtained based on the instance-level selection strategy, and class-level specific samples obtained based on the class-level selection strategy.

[0010] Step s4: Merge the specific sample, the target domain dataset, and the source domain dataset to obtain a second dataset, and label each image in the second dataset with a domain label;

[0011] Step s5: Fine-tune the initial object detection model using the second dataset to make the initial object detection model focus on domain-invariant features, thus obtaining a domain-adapted object detection model;

[0012] Step s6: Input the image to be detected into the domain-adaptive target detection model to obtain the detection result.

[0013] Based on the first aspect, in step s3, the image-specific sample obtained based on the image-level selection strategy is obtained according to the following steps:

[0014] The feature extractor φ with parameter θ in the initial object detection model is used to extract the external domain dataset D. e and the target domain dataset D t Each image in the dataset generates an image feature vector;

[0015] The image feature vector is defined as:

[0016]

[0017] in, Indicates for D t The i-th image (img) i The feature vector is obtained by averaging all pixels of the feature map extracted by the feature extractor φ with parameter θ. D t There are m images, D e There are n images, and the set of image feature vectors is represented as:

[0018]

[0019]

[0020] against For each image feature vector in the set, calculate the sum with... The Euclidean distance between the feature vectors of each image in the set, in D e Select the k images with the closest Euclidean distance, where k is an integer greater than 0 and less than n;

[0021] From D e All images selected are used as image-specific samples.

[0022] Based on the first aspect, in step s3, the instance-specific sample obtained based on the instance-level selection strategy is obtained according to the following steps:

[0023] The feature extractor φ with parameter θ in the initial object detection model is used to extract the external domain dataset D. e and the target domain dataset D t For each instance in each image, an instance feature vector is generated; the instance feature vector is the vector representing the center position of the feature map region corresponding to the instance's bounding box in the image. The instance-level feature map is represented as follows:

[0024]

[0025] in, This represents the image region corresponding to the bounding box of the j-th instance. Indicates for D t The bounding box of the j-th instance is processed by a feature extractor φ with parameter θ to obtain the instance-level feature map. By taking the center point of the feature map region, the final instance-level feature vector is obtained. D t There are p instances, D e There are q instances, and the set of instance feature vectors is represented as:

[0026]

[0027]

[0028] against For each instance feature vector in the set, calculate the sum of the features vectors and the feature vectors of the instances in the set. The Euclidean distance between the feature vectors of each instance in the set, selected The feature vectors of the k nearest instances in the Euclidean distance, where k is an integer greater than 0 and less than q;

[0029] Will The images corresponding to the feature vectors of all selected instances are used as instance-specific samples.

[0030] Based on the first aspect, in step s3, the class-specific sample obtained based on the class-level selection strategy is obtained according to the following steps:

[0031] The feature extractor φ with parameter θ in the initial object detection model is used to extract the external domain dataset D. e and the target domain dataset D t For each instance in each image, an instance feature vector is generated;

[0032] D tAll instance feature vectors in the dataset are classified by category, and given as D t Each category generates a category center vector, and each category corresponds to a set of category center vectors, represented as:

[0033]

[0034]

[0035] Where c represents D t In the context of category c, N indicates that category c has N fields. D t The average value of all instance feature vectors corresponding to category c in the i-th domain;

[0036] against For each category center vector in the set, calculate the sum of the vectors. The Euclidean distance between the feature vectors of each instance in the set, selected The feature vectors of the k nearest instances in the Euclidean distance, where k is an integer greater than 0 and less than q;

[0037] Will The images corresponding to the feature vectors of all selected instances are used as class-specific samples.

[0038] Based on the first aspect, the initial target detection model includes a feature extractor φ with parameter θ; in step s5, fine-tuning the initial target detection model using the second dataset to make the initial target detection model focus on domain-invariant features, thereby obtaining a domain-adapted target detection model, includes:

[0039] A domain adaptation module is added to the initial object detection model. This module includes a domain classifier and a gradient inversion layer. The domain classifier uses multiple convolutional layers to predict the domain labels of the input image, and its loss function L... dc Represented as:

[0040]

[0041] Among them, y i p represents the one-hot true label of the i-th input image. i The gradient inversion layer represents the predicted domain label probability of the input image; the gradient inversion layer is used to establish an adversarial relationship between the feature extractor and the domain classifier, so that the feature extractor extracts domain-invariant features.

[0042] After the domain-adapted target detection model is trained, the domain adaptation module is removed.

[0043] Secondly, embodiments of this application provide a domain-adaptive target detection system based on domain-specific sample selection, comprising:

[0044] The data acquisition module is used in step s1 to acquire a first dataset; the first dataset includes a target domain dataset, a source domain dataset, and an external domain dataset; the external domain dataset is obtained by expanding the target domain dataset, and the sample categories of the external domain dataset are the same as or similar to the sample categories of the target domain dataset.

[0045] The pre-training module is used in step s2: to pre-train the object detection model using the first dataset to obtain an initial object detection model;

[0046] A specific sample selection module is used in step s3: for each image in the target domain dataset, selects a specific sample corresponding to the image from the external domain dataset based on a domain-specific sample selection strategy, including: obtaining image-level specific samples based on an image-level strategy; obtaining instance-level specific samples based on an instance-level selection strategy; and obtaining class-level specific samples based on a class-level selection strategy.

[0047] The dataset merging module is used in step s4 to merge the specific sample, the target domain dataset, and the source domain dataset to obtain a second dataset, and to label each image in the second dataset with a domain label.

[0048] The fine-tuning module is used in step s5 to fine-tune the initial target detection model using the second dataset, so that the initial target detection model focuses on domain-invariant features to obtain a domain-adapted target detection model.

[0049] The detection module is used in step s6: inputting the image to be detected into the domain-adaptive target detection model to obtain the detection result.

[0050] Thirdly, embodiments of this application provide an electronic device, which includes a memory for storing one or more programs; a processor; and when the one or more programs are executed by the processor, implements the target detection method as described in any one of the first aspects above.

[0051] Fourthly, embodiments of this application provide a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the target detection method as described in any one of the first aspects above.

[0052] Compared with the prior art, the embodiments of the present invention have the following advantages:

[0053] This invention provides a domain-adaptive target detection method and system based on domain-specific sample selection, comprising the following steps: Step s1: Obtaining a first dataset; the first dataset includes a target domain dataset, a source domain dataset, and an external domain dataset; the external domain dataset is expanded based on the target domain dataset, and the sample categories of the external domain dataset are the same as or similar to those of the sample categories of the target domain dataset; Step s2: Pre-training an target detection model using the first dataset to obtain an initial target detection model; Step s3: For each image in the target domain dataset, selecting the corresponding image from the external domain dataset based on a domain-specific sample selection strategy. Specific samples, the specific samples corresponding to the image selected include: image-level specific samples obtained based on image-level selection strategy, instance-level specific samples obtained based on instance-level selection strategy, and class-level specific samples obtained based on class-level selection strategy; Step s4: merge the specific samples, the target domain dataset, and the source domain dataset to obtain a second dataset, and label each image in the second dataset with a domain label; Step s5: fine-tune the initial object detection model using the second dataset, so that the initial object detection model focuses on domain-invariant features, to obtain a domain-adaptive object detection model; Step s6: input the image to be detected into the domain-adaptive object detection model to obtain the detection result.

[0054] This invention addresses the distribution offset problem in cross-domain target detection by selecting domain-specific samples to fill the feature differences between different domains. Furthermore, through the domain adaptation module in the fine-tuning step, it further aligns the features of different domains, enabling the model to learn domain-invariant features and greatly improving the performance of the target detection model in cross-domain detection. Attached Figure Description

[0055] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0056] Figure 1 A flowchart of a domain-adaptive target detection method based on domain-specific sample selection is provided in an embodiment of the present invention;

[0057] Figure 2(a) is a schematic diagram of the domain-specific sample image-level selection strategy provided in an embodiment of the present invention;

[0058] Figure 2(b) is a schematic diagram of the domain-specific sample instance-level selection strategy provided in an embodiment of the present invention;

[0059] Figure 2(c) is a schematic diagram of the domain-specific sample class-level selection strategy provided in an embodiment of the present invention;

[0060] Figure 3 This is a schematic diagram of the domain adaptation module provided in an embodiment of the present invention;

[0061] Figure 4(a) is a visualization of the initial image feature distribution in an embodiment of the present invention;

[0062] Figure 4(b) is a visualization of the image feature distribution after domain-specific sample selection in an embodiment of the present invention;

[0063] Figure 4(c) is a visualization of the image feature distribution after domain adaptation fine-tuning according to an embodiment of the present invention;

[0064] Figure 5 A block diagram of a domain-adaptive target detection system based on domain-specific sample selection is provided in this embodiment of the invention.

[0065] Figure 6 This is a schematic structural block diagram of an electronic device provided in an embodiment of the present invention. Detailed Implementation

[0066] Exemplary embodiments of the present disclosure will now be described in more detail with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the disclosure to those skilled in the art. It should be noted that, unless otherwise specified, the embodiments and features described herein can be combined with each other. The present invention will now be described in detail with reference to the accompanying drawings and embodiments.

[0067] Object detection has wide applications in real-world scenarios. While deep neural network-based object detection has achieved excellent performance on benchmark datasets such as COCO, in real-world scenarios, the performance of object detectors can significantly degrade (i.e., the distribution shift problem) when factors such as the shooting perspective, appearance, background, lighting, and image quality change.

[0068] To address the distribution shift problem in cross-domain object detection, this application fills in the feature differences between different domains by selecting domain-specific samples, and further aligns the features of different domains by fine-tuning the domain adaptation module, enabling the model to learn domain-invariant features and greatly improving the performance of the object detection model in cross-domain detection.

[0069] See Figure 1 , Figure 1A flowchart of a domain-adaptive target detection method based on domain-specific sample selection provided in this embodiment of the invention includes the following steps:

[0070] Step s1: Obtain the first dataset; the first dataset includes a target domain dataset, a source domain dataset, and an external domain dataset; the external domain dataset is expanded based on the target domain dataset, and the sample categories of the external domain dataset are the same as or similar to the sample categories of the target domain dataset;

[0071] In this context, "different domains" refers to different data distributions. For example, images A and B taken of the same target will have different data distributions due to differences in shooting angle, background, and lighting conditions, thus belonging to different domains. The source domain dataset is an existing dataset with labeled information. The target domain dataset is a dataset extracted from the model's target application scenario, which may have few or no labeled samples. The target domain may contain multiple domains. Therefore, to train a model capable of spanning multiple domains, an external domain dataset is needed. External domain datasets can be obtained through web scraping or by directly using publicly available datasets; their categories should be the same as or similar to those in the target domain dataset. For example, if the target domain dataset contains images of cars and trucks, the external domain dataset should also contain images of cars and trucks.

[0072] Step s2: Use the first dataset to pre-train the object detection model to obtain the initial object detection model;

[0073] Step s3: For each image in the target domain dataset, select a specific sample corresponding to the image from the external domain dataset based on the domain-specific sample selection strategy. The selected specific sample corresponding to the image includes: image-level specific samples obtained based on the image-level selection strategy, instance-level specific samples obtained based on the instance-level selection strategy, and class-level specific samples obtained based on the class-level selection strategy.

[0074] In this embodiment of the invention, three strategies are used in combination to screen external domain datasets in order to select specific samples that can produce positive effects, and to use these specific samples to help improve the model's domain adaptability.

[0075] Referring to Figure 2(a), Figure 2(a) is a schematic diagram of the image-level selection strategy provided in an embodiment of the present invention.

[0076] The feature extractor φ with parameter θ in the initial object detection model is used to extract the external domain dataset D. e and the target domain dataset D t Each image in the dataset generates an image feature vector;

[0077] The image feature vector is defined as:

[0078]

[0079] in, Indicates for D t The i-th image (img) i The feature vector is obtained by averaging all pixels of the feature map extracted by the feature extractor φ with parameter θ. (For example, the feature map obtained by the feature extractor of an RGB image has a dimension of H*W*C, where C is the number of channels, H and W are the length and width of the image. Averaging all pixels means averaging all pixels in each channel and using the average result of each channel as a component of the feature vector, finally obtaining a feature vector with a dimension of 1*C).

[0080] D t There are m images, D e There are n images, and the set of image feature vectors is represented as:

[0081]

[0082]

[0083] against For each image feature vector in the set, calculate the sum with... The Euclidean distance between the feature vectors of each image in the set, in D e Select the k images with the closest Euclidean distance, where k is an integer greater than 0 and less than n;

[0084] From D e All images selected are used as image-specific samples.

[0085] Referring to Figure 2(b), Figure 2(b) is a schematic diagram of the instance-level selection strategy provided in the embodiment of the present invention.

[0086] The feature extractor φ with parameter θ in the initial object detection model is used to extract the external domain dataset D. e and the target domain dataset D t For each instance in each image, an instance feature vector is generated; the instance feature vector is the vector representing the center position of the feature map region corresponding to the instance's bounding box in the image. The instance-level feature map is represented as follows:

[0087]

[0088] in, This represents the image region corresponding to the bounding box of the j-th instance. Indicates for D t The bounding box of the j-th instance is processed by a feature extractor φ with parameter θ to obtain the instance-level feature map. By taking the center point of the feature map region, the final instance-level feature vector is obtained.

[0089] D t There are p instances, D e There are q instances, and the set of instance feature vectors is represented as:

[0090]

[0091]

[0092] against For each instance feature vector in the set, calculate the sum of the features vectors and the feature vectors of the instances in the set. The Euclidean distance between the feature vectors of each instance in the set, selected The feature vectors of the k nearest instances in the Euclidean distance, where k is an integer greater than 0 and less than q;

[0093] Will The images corresponding to the feature vectors of all selected instances are used as instance-specific samples.

[0094] Referring to Figure 2(c), Figure 2(c) is a schematic diagram of the class-level selection strategy provided in an embodiment of the present invention.

[0095] The feature extractor φ with parameter θ in the initial object detection model is used to extract the external domain dataset D. e and the target domain dataset D t For each instance in each image, an instance feature vector is generated;

[0096] D t All instance feature vectors in the dataset are classified by category, and given as D t Each category generates a category center vector, and each category corresponds to a set of category center vectors, represented as:

[0097]

[0098]

[0099] Where c represents D t In the context of category c, N indicates that category c has N fields. D t The average value of all instance feature vectors corresponding to category c in the i-th domain;

[0100] against For each category center vector in the set, calculate the sum of the vectors. The Euclidean distance between the feature vectors of each instance in the set, selected The feature vectors of the k nearest instances in the Euclidean distance, where k is an integer greater than 0 and less than q;

[0101] Will The images corresponding to the feature vectors of all selected instances are used as class-specific samples.

[0102] Taking the automotive category as an example, we represent the center of the automotive category as follows:

[0103]

[0104] Each It is dataset D t The average value of all car instance-level feature vectors in the i-th domain. For D e We still use instance-level vector sets. Select the k car instances that are most similar to the car category center vector, and repeat the same operation for other categories. Finally, The images corresponding to all selected instance feature vectors are aggregated together as class-specific samples, and the number of class-specific sample images should be consistent with the first two methods.

[0105] Step s4: Merge the specific sample, the target domain dataset, and the source domain dataset to obtain a second dataset, and label each image in the second dataset with a domain label;

[0106] Step s5: Fine-tune the initial object detection model using the second dataset to make the initial object detection model focus on domain-invariant features, thus obtaining a domain-adapted object detection model;

[0107] The initial object detection model includes a feature extractor φ with parameter θ; a domain adaptation module is added to the initial object detection model, the domain adaptation module including a domain classifier and a gradient inversion layer; the domain classifier uses multiple convolutional layers to predict the domain labels of the input image, and its loss function L dc Represented as:

[0108]

[0109] Among them, y i p represents the one-hot true label of the i-th input image. i The gradient inversion layer represents the predicted domain label probability of the input image; the gradient inversion layer is used to establish an adversarial relationship between the feature extractor and the domain classifier, so that the feature extractor extracts domain-invariant features.

[0110] After the domain-adapted target detection model is trained, the domain adaptation module is removed.

[0111] See Figure 3 , Figure 3 The domain adaptation module provided in this embodiment of the invention, after domain labeling, uses a domain adaptation module to reduce the domain feature gap. The domain adaptation module includes a gradient inversion layer and a domain classifier. The domain classifier uses multiple convolutional layers to predict the domain label of the input image, while the gradient inversion layer is an operator that establishes an adversarial relationship between the feature extractor and the classifier. This adversarial relationship causes the feature extractor to output domain-invariant features, thereby improving the performance of cross-domain detection. On the other hand, to reduce the domain gap, the features extracted by the feature extractor of the object detection model should possess domain-invariant properties, that is, the features should be indistinguishable across different domains. Therefore, the feature extractor should be optimized to extract indistinguishable features, contrary to the goal of the domain classifier. The gradient inversion layer is used to accomplish this adversarial optimization; it is a bidirectional operator inserted between the feature extractor and the domain classifier. In the forward propagation direction, the gradient inversion layer acts as an identity operator, directly passing features through the domain classifier. In the feedback direction, the gradient inversion layer becomes a negative scalar, reversing all gradient updates passed by the domain classifier.

[0112] Step s6: Input the image to be detected into the domain-adaptive target detection model to obtain the detection result.

[0113] The embodiments of the present invention address the distribution offset problem in cross-domain target detection by using the above steps. Through domain-specific sample selection, the feature differences between different domains are filled in, and through the domain adaptation module in the fine-tuning step, the features of different domains are further aligned, enabling the model to learn domain-invariant features, which greatly improves the performance of the target detection model in cross-domain detection.

[0114] Referring to Figure 4(a), Figure 4(a) is a visualization of the initial image feature distribution in an embodiment of the present invention. Before selection, the training dataset contains a large number of additional data samples. Fine-tuning on a large and redundant dataset will not only consume too many computing resources, but will also cause the model to perform excessive feature alignment in the feature space, thereby reducing the performance of the model on the target domain dataset.

[0115] Referring to Figure 4(b), Figure 4(b) is a visualization of the image feature distribution after domain-specific sample selection in an embodiment of the present invention. After domain-specific sample selection, the number of image samples is significantly reduced, retaining data that has a positive effect on domain adaptation, filling the gap between target domain datasets, and greatly shortening the time for domain adaptive fine-tuning, thus avoiding excessive feature alignment in the sample space.

[0116] Referring to Figure 4(c), Figure 4(c) is a visualization of the image feature distribution after domain adaptation fine-tuning in an embodiment of the present invention. After domain adaptation fine-tuning, all image features are mixed together, and the boundaries between different domains are no longer clearly visible. This indicates that the model has learned to distinguish the features of objects in different domains, and the differences between domains no longer play a decisive role in image features.

[0117] Table 1 shows a comparison of the test accuracy of the embodiments of the present invention with the benchmark method on datasets in multiple domains.

[0118] Table 1

[0119]

[0120] Specifically, the detection model used was the industry-standard YOLOv5 model, and the dataset mainly included multiple categories such as cars and pedestrians. Both the source and target domain datasets were obtained through drone aerial photography. The source domain dataset consisted of urban aerial photography, with a large number of samples and predominantly urban backgrounds. The target domain dataset came from multiple regions, including snowfields and deserts, showing significant regional differences. The datasets were labeled in YOLO format using the labeling software LabelImg. We collected 16 publicly available aerial photography and remote sensing datasets as external domain datasets, including VisDrone, AITOD, and DOTA, totaling over 60,000 sample images. The benchmark method used was YOLOv5, and tests were conducted in multiple domains, including mountainous and desert regions. Comparisons were made between the benchmark method, methods using only the pre-adaptation module, methods using only domain-specific sample selection, and methods using both domain-specific sample selection and the pre-adaptation module. It can be seen that the original YOLOv5 benchmark method performs well in other domains due to inter-domain differences, but its performance in the mountainous domain is only 58.5%, which is far lower than its performance in other domains. However, the domain-adaptive target detection method based on domain-specific sample selection proposed in this invention significantly improves its performance in the mountainous domain by 19.4%, and its performance in other domains is basically unchanged. Finally, the detection accuracy in all domains is also significantly improved compared with the benchmark.

[0121] Based on the same inventive concept, this invention also proposes a domain-adaptive target detection system based on domain-specific sample selection, please refer to... Figure 5 , Figure 5 A block diagram of a domain-adaptive target detection system based on domain-specific sample selection, provided in an embodiment of the present invention, includes:

[0122] The data acquisition module 110 is used in step s1 to acquire a first dataset; the first dataset includes a target domain dataset, a source domain dataset, and an external domain dataset; the external domain dataset is obtained by expanding the target domain dataset, and the sample categories of the external domain dataset are the same as or similar to the sample categories of the target domain dataset.

[0123] Pre-training module 120 is used in step s2: pre-training the object detection model using the first dataset to obtain an initial object detection model; the initial object detection model includes a feature extractor φ with parameter θ;

[0124] The specific sample selection module 130 is used in step s3: for each image in the target domain dataset, selects a specific sample corresponding to the image from the external domain dataset based on a domain-specific sample selection strategy, including: obtaining image-level specific samples based on an image-level strategy; obtaining instance-level specific samples based on an instance-level selection strategy; and obtaining class-level specific samples based on a class-level selection strategy.

[0125] The dataset merging module 140 is used in step s4 to merge the specific sample, the target domain dataset, and the source domain dataset to obtain a second dataset, and to label each image in the second dataset with a domain label.

[0126] The fine-tuning module 150 is used in step s5 to fine-tune the initial target detection model using the second dataset, so that the initial target detection model focuses on domain-invariant features, thereby obtaining a domain-adaptive target detection model.

[0127] The detection module 160 is used in step s6: inputting the image to be detected into the domain-adaptive target detection model to obtain the detection result.

[0128] See Figure 6 , Figure 6 This is a schematic structural block diagram of an electronic device provided in an embodiment of this application. The electronic device includes a memory 101, a processor 102, and a communication interface 103. The memory 101, processor 102, and communication interface 103 are electrically connected to each other directly or indirectly to realize data transmission or interaction. For example, these components can be electrically connected to each other through one or more communication buses or signal lines. The memory 101 can be used to store software programs and modules, such as the program instructions / modules corresponding to the domain-adaptive target detection system based on domain-specific sample selection provided in an embodiment of this application. The processor 102 executes various functional applications and data processing by executing the software programs and modules stored in the memory 101. The communication interface 103 can be used to communicate with other node devices for signaling or data.

[0129] The memory 101 may be, but is not limited to, random access memory (RAM), read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), etc.

[0130] The processor 102 can be an integrated circuit chip with signal processing capabilities. The processor 102 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.

[0131] Understandable. Figure 6 The structure shown is for illustrative purposes only; the electronic device may also include components that are more advanced than those shown. Figure 6 The more or fewer components shown, or having the same Figure 6 The different configurations shown. Figure 6 The components shown can be implemented using hardware, software, or a combination thereof.

[0132] In the embodiments provided in this application, it should be understood that the disclosed systems and methods can also be implemented in other ways. The apparatus embodiments described above are merely illustrative. For example, the flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram and / or flowchart, and combinations of blocks in block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.

[0133] In addition, the functional modules in the various embodiments of this application can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.

[0134] If the aforementioned functions are implemented as software functional modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0135] The above description is merely a preferred embodiment of this application and is not intended to limit this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.

[0136] It will be apparent to those skilled in the art that this application is not limited to the details of the exemplary embodiments described above, and that this application can be implemented in other specific forms without departing from the spirit or essential characteristics of this application. Therefore, the embodiments should be considered illustrative and non-limiting in all respects, and the scope of this application is defined by the appended claims rather than the foregoing description. Thus, all variations falling within the meaning and scope of equivalents of the claims are intended to be included within this application. No reference numerals in the claims should be construed as limiting the scope of the claims.

Claims

1. A domain-adaptive target detection method based on domain-specific sample selection, characterized in that, Includes the following steps: Step s1: Obtain the first dataset; The first dataset includes a target domain dataset, a source domain dataset, and an external domain dataset; the external domain dataset is obtained by expanding the target domain dataset, and the sample categories of the external domain dataset are the same as or similar to the sample categories of the target domain dataset. Step s2: Use the first dataset to pre-train the object detection model to obtain the initial object detection model; Step s3: For each image in the target domain dataset, select a specific sample corresponding to the image from the external domain dataset based on the domain-specific sample selection strategy. The selected specific sample corresponding to the image includes: image-level specific samples obtained based on the image-level selection strategy, instance-level specific samples obtained based on the instance-level selection strategy, and class-level specific samples obtained based on the class-level selection strategy. Step s4: Merge the specific sample, the target domain dataset, and the source domain dataset to obtain a second dataset, and label each image in the second dataset with a domain label; Step s5: Fine-tune the initial object detection model using the second dataset to make the initial object detection model focus on domain-invariant features, thus obtaining a domain-adapted object detection model; Step s6: Input the image to be detected into the domain-adaptive target detection model to obtain the detection result; In step s3, the instance-specific sample obtained based on the instance-level selection strategy is obtained by following these steps: The initial target detection model has parameters Feature extractor For each instance in each image of the external domain dataset and the target domain dataset, an instance feature vector is generated; the instance feature vector is the vector representing the center position of the feature map region corresponding to the instance bounding box on the image, and the instance-level feature map is represented as: in, Indicates the first The image region corresponding to the bounding box of each instance. Indicates for The The annotation box for each instance is used to pass it through parameters. Feature extractor , thus obtaining instance-level feature maps The center point of the feature map region is taken to obtain the final instance-level feature vector. , There is One example, There is There are instances, and the set of instance feature vectors is represented as follows: against For each instance feature vector in the set, calculate the sum of the features vectors and the feature vectors of the instances in the set. The Euclidean distance between the feature vectors of each instance in the set, selected Center front The nearest instance feature vectors in Euclidean distance, where k is greater than 0 and less than 1. Integers; Will The images corresponding to the feature vectors of all selected instances are taken as instance-specific samples; In step s3, the class-specific samples obtained based on the class-level selection strategy are obtained by following these steps: The initial target detection model has parameters Feature extractor , for the external domain dataset and the target domain dataset For each instance in each image, an instance feature vector is generated; Will All instance feature vectors are classified by category, and for Each category generates a category center vector, and each category corresponds to a set of category center vectors, represented as: Where c represents In the context of category c, N indicates that category c exists. Each domain for No. The average value of the feature vectors of all instances corresponding to category c in each domain; against For each category center vector in the set, calculate the sum of the vectors. The Euclidean distance between the feature vectors of each instance in the set, selected Center front The nearest instance feature vectors in Euclidean distance, where k is greater than 0 and less than 1. Integers; Will The images corresponding to the feature vectors of all selected instances are used as class-specific samples; The initial target detection model includes models with parameters. Feature extractor In step s5, the initial target detection model is fine-tuned using the second dataset to make it focus on domain-invariant features, resulting in a domain-adapted target detection model, including: A domain adaptation module is added to the initial object detection model. This module includes a domain classifier and a gradient inversion layer. The domain classifier uses multiple convolutional layers to predict the domain labels of the input image, and its loss function is... Represented as: in, Indicates the first One-hot true labels for each input image. The gradient inversion layer represents the predicted domain label probability of the input image; the gradient inversion layer is used to establish an adversarial relationship between the feature extractor and the domain classifier, so that the feature extractor extracts domain-invariant features. After the domain-adapted target detection model is trained, the domain adaptation module is removed.

2. The method according to claim 1, characterized in that, In step s3, the image-level specific samples obtained based on the image-level selection strategy are obtained according to the following steps: The initial target detection model has parameters Feature extractor , for the external domain dataset and the target domain dataset Each image in the dataset generates an image feature vector; The image feature vector is defined as: in, Indicates for The One image , through parameters Feature extractor ; Operators represent the features extractor The image feature vector is obtained by averaging all pixels of the extracted feature map. ; There is One image, There is The set of image feature vectors is represented as: against For each image feature vector in the set, calculate the sum with... The Euclidean distance between each image feature vector in the set, Select before The image with the closest Euclidean distance, where k is greater than 0 and less than 1. Integers; From All images selected are used as image-specific samples.

3. A domain-adaptive target detection system based on domain-specific sample selection, characterized in that, The system includes: The data acquisition module is used in step s1 to acquire a first dataset; the first dataset includes a target domain dataset, a source domain dataset, and an external domain dataset; the external domain dataset is obtained by expanding the target domain dataset, and the sample categories of the external domain dataset are the same as or similar to the sample categories of the target domain dataset. The pre-training module is used in step s2: to pre-train the object detection model using the first dataset to obtain an initial object detection model; A specific sample selection module is used in step s3: for each image in the target domain dataset, selects a specific sample corresponding to the image from the external domain dataset based on a domain-specific sample selection strategy, including: obtaining image-level specific samples based on an image-level strategy; obtaining instance-level specific samples based on an instance-level selection strategy; and obtaining class-level specific samples based on a class-level selection strategy. The dataset merging module is used in step s4 to merge the specific sample, the target domain dataset, and the source domain dataset to obtain a second dataset, and to label each image in the second dataset with a domain label. The fine-tuning module is used in step s5 to fine-tune the initial target detection model using the second dataset, so that the initial target detection model focuses on domain-invariant features to obtain a domain-adapted target detection model. The detection module is used in step s6: inputting the image to be detected into the domain-adaptive target detection model to obtain the detection result; The specific sample selection module is further configured to: The initial target detection model has parameters Feature extractor For each instance in each image of the external domain dataset and the target domain dataset, an instance feature vector is generated; the instance feature vector is the vector representing the center position of the feature map region corresponding to the instance bounding box on the image, and the instance-level feature map is represented as: in, Indicates the first The image region corresponding to the bounding box of each instance. Indicates for The The annotation box for each instance is used to pass it through parameters. Feature extractor , thus obtaining instance-level feature maps The center point of the feature map region is taken to obtain the final instance-level feature vector. , There is One example, There is There are instances, and the set of instance feature vectors is represented as follows: against For each instance feature vector in the set, calculate the sum of the features vectors and the feature vectors of the instances in the set. The Euclidean distance between the feature vectors of each instance in the set, selected Center front The nearest instance feature vectors in Euclidean distance, where k is greater than 0 and less than 1. Integers; Will The images corresponding to the feature vectors of all selected instances are taken as instance-specific samples; The specific sample selection module is further configured to: The initial target detection model has parameters Feature extractor , for the external domain dataset and the target domain dataset For each instance in each image, an instance feature vector is generated; Will All instance feature vectors are classified by category, and for Each category generates a category center vector, and each category corresponds to a set of category center vectors, represented as: Where c represents In the context of category c, N indicates that category c exists. Each domain for No. The average value of the feature vectors of all instances corresponding to category c in each domain; against For each category center vector in the set, calculate the sum of the vectors. The Euclidean distance between the feature vectors of each instance in the set, selected Center front The nearest instance feature vectors in Euclidean distance, where k is greater than 0 and less than 1. Integers; Will The images corresponding to the feature vectors of all selected instances are used as class-specific samples; The initial target detection model includes models with parameters. Feature extractor The fine-tuning module is also used for: A domain adaptation module is added to the initial object detection model. This module includes a domain classifier and a gradient inversion layer. The domain classifier uses multiple convolutional layers to predict the domain labels of the input image, and its loss function is... Represented as: in, Indicates the first One-hot true labels for each input image. The gradient inversion layer represents the predicted domain label probability of the input image; the gradient inversion layer is used to establish an adversarial relationship between the feature extractor and the domain classifier, so that the feature extractor extracts domain-invariant features. After the domain-adapted target detection model is trained, the domain adaptation module is removed.

4. An electronic device, characterized in that, The method includes a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the domain-adaptive target detection method based on domain-specific sample selection as described in any one of claims 1-2.

5. A computer-readable storage medium having a computer program / instructions stored thereon, characterized in that, When the computer program / instruction is executed by the processor, it implements the domain-adaptive target detection method based on domain-specific sample selection as described in any one of claims 1-2.

Citation Information

Patent Citations

  • Adaptive target detection method and system based on foreground selection domain

    CN113343989A