Single-stage cross-domain target detection method, device, electronic equipment and storage medium
By introducing K instance-level subdomain classifiers and image-level domain classifiers into a single-stage cross-domain object detection model, and utilizing the global loss function and the Focal Loss focus loss function, the negative transfer problem in the single-stage cross-domain object detection model is solved, thereby improving the detection performance and applicability.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SOUTH CHINA AGRICULTURAL UNIVERSITY
- Filing Date
- 2023-02-27
- Publication Date
- 2026-05-26
AI Technical Summary
Existing single-stage cross-domain object detection models based on deep domain adaptation suffer from negative transfer during feature alignment, which affects the domain adaptation process and results in poor object detection performance.
A single-stage cross-domain object detection model is trained using K instance-level subdomain classifiers and an image-level domain classifier through a global loss function. The model combines object detection loss, image-level domain alignment loss, and instance-level domain alignment loss, and uses the Focal Loss function to address the sample imbalance problem. Furthermore, the feature alignment process is controlled by setting foreground confidence weights and a guidance function to reduce negative transfer.
It improves the target detection performance and applicability of single-stage cross-domain target detection, reduces negative transfer in the feature alignment process, and enhances detection efficiency and accuracy.
Smart Images

Figure CN116168248B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of target detection technology, and more specifically, to a single-stage cross-domain target detection method, apparatus, electronic device, and storage medium. Background Technology
[0002] Currently, due to its advantages such as fast inference speed and low hardware requirements, single-stage cross-domain object detection is gradually becoming a research focus in cross-domain object detection for industrial applications. Depth-domain adaptive single-stage cross-domain object detection models are one type with superior performance. However, in existing technologies, depth-domain adaptive single-stage cross-domain object detection models suffer from negative transfer during feature alignment, affecting the domain adaptation process and resulting in poor object detection performance. Summary of the Invention
[0003] The purpose of this application is to provide a single-stage cross-domain target detection method, apparatus, electronic device, and storage medium to improve the target detection effect of the single-stage cross-domain target detection method.
[0004] In a first aspect, embodiments of this application provide a single-stage cross-domain target detection method, comprising: acquiring a source domain dataset and a target domain dataset according to cross-domain target detection requirements; constructing a single-stage cross-domain target detection model; setting an image-level domain classifier and an instance-level domain classifier for the single-stage cross-domain target detection model; the instance-level domain classifier comprising K instance-level sub-domain classifiers; the K instance-level sub-domain classifiers respectively using K target features contained in the source domain dataset and the target domain dataset to identify the domain to which the instance features belong; jointly training the single-stage cross-domain target detection model, the image-level domain classifier, and the instance-level domain classifier; and performing target detection using the trained single-stage cross-domain target detection model.
[0005] In the implementation of the above scheme, by setting K instance-level sub-domain classifiers that perform domain discrimination for different features in the instance-level domain classifier, fine-grained domain adaptation related to the category is achieved, which effectively improves the target detection effect of the above single-stage cross-domain target detection method.
[0006] In one implementation of the first aspect, the joint training of the single-stage cross-domain object detection model, the image-level domain classifier, and the instance-level domain classifier includes: determining the object detection loss function of the single-stage cross-domain object detection model, the image-level domain alignment loss function of the image-level domain classifier, and the instance-level domain alignment loss function of the instance-level domain classifier; and jointly training the single-stage cross-domain object detection model, the image-level domain classifier, and the instance-level domain classifier using a global loss function composed of the object detection loss function, the image-level domain alignment loss function, and the instance-level domain alignment loss function.
[0007] In the implementation of the above scheme, a global loss function is used to jointly train the single-stage cross-domain object detection model, the image-level domain classifier, and the instance-level domain classifier. The image-level domain alignment loss function and the instance-level domain alignment loss function are determined by an adversarial discrimination method, which improves the training efficiency of the single-stage cross-domain object detection model. At the same time, the instance-level domain alignment loss function is determined based on K instance-level sub-domain classifiers, realizing fine-grained domain adaptation related to the category, which effectively improves the object detection performance of the above single-stage cross-domain object detection method.
[0008] In one implementation of the first aspect, the target detection loss function includes: source domain data classification loss and source domain data regression loss; or, source domain data classification loss, source domain data regression loss, and source domain image pixel center perceptual loss.
[0009] In the implementation of the above scheme, the target detection loss function can adopt source domain data classification loss and source domain data regression loss, or it can add a center perception loss to make the model pay more attention to foreground features on the basis of adopting source domain data classification loss and source domain data regression loss. This makes the above single-stage cross-domain target detection method applicable to more scenarios and improves the applicability of the above single-stage cross-domain target detection method. At the same time, due to the adoption of center perception loss, the model can pay more attention to foreground features and appropriately ignore background features, effectively reducing negative transfer in the feature alignment process and improving the target detection effect of the above single-stage cross-domain target detection method.
[0010] In one implementation of the first aspect, the instance-level domain alignment loss function includes: foreground confidence weights of source domain image pixels; the foreground confidence weights of source domain image pixels are obtained based on the center perceptual loss of source domain image pixels.
[0011] In the implementation of the above scheme, by setting the foreground confidence weight of the source domain image pixels for the instance-level domain alignment loss function, the model can pay more attention to foreground features, effectively reducing negative transfer in the feature alignment process and improving the target detection effect of the above single-stage cross-domain target detection method.
[0012] In one implementation of the first aspect, the global loss function includes: a guidance function, used to control the instance-level domain alignment loss function to be enabled after the training rounds reach a preset threshold.
[0013] In the implementation of the above scheme, by setting a guiding function for the global loss function, the error accumulation caused by prematurely starting instance-level domain feature alignment is avoided, which enables the single-stage cross-domain object detection model to obtain better training results and improves the object detection effect of the above single-stage cross-domain object detection.
[0014] In one implementation of the first aspect, the construction of the single-stage cross-domain target detection model includes: constructing the backbone network, feature fusion network, and head network of the single-stage cross-domain target detection model respectively; the head network includes a classification sub-network and a regression sub-network.
[0015] In the implementation of the above scheme, a single-stage cross-domain target detection model composed of a backbone network, a feature fusion network, and a head network is adopted to perform single-stage cross-domain target detection, which greatly improves the detection efficiency of the above single-stage cross-domain target detection.
[0016] In one implementation of the first aspect, both the image-level domain alignment loss function and the instance-level domain alignment loss function employ the Focal Loss focus loss function.
[0017] In the implementation of the above scheme, the problem of imbalance between positive and negative samples is solved by setting Focal Loss, which effectively reduces negative transfer in the feature alignment process and effectively improves the target detection effect of the above single-stage cross-domain target detection method.
[0018] Secondly, embodiments of this application provide a single-stage cross-domain target detection device, comprising:
[0019] The dataset acquisition module is used to acquire source domain datasets and target domain datasets according to cross-domain object detection requirements;
[0020] The target detection model building module is used to build a single-stage cross-domain target detection model;
[0021] The domain classifier setting module is used to set an image-level domain classifier and an instance-level domain classifier for the single-stage cross-domain target detection model; the instance-level domain classifier includes K instance-level sub-domain classifiers; the K instance-level sub-domain classifiers respectively use K target features contained in the source domain dataset and the target domain dataset to identify the domain to which the instance features belong;
[0022] The training module is used to jointly train the single-stage cross-domain object detection model, the image-level domain classifier, and the instance-level domain classifier;
[0023] The cross-domain object detection module is used to perform object detection using a pre-trained single-stage cross-domain object detection model.
[0024] Thirdly, embodiments of this application provide a computer-readable storage medium storing computer program instructions, which, when read and executed by a processor, perform the method provided in the first aspect or any possible implementation thereof.
[0025] Fourthly, embodiments of this application provide an electronic device, including: a memory and a processor, wherein the memory stores computer program instructions, and the computer program instructions are read and executed by the processor to perform the method provided in the first aspect or any possible implementation of the first aspect.
[0026] Other features and advantages of this application will be set forth in the following description and will be apparent in part from the description or may be learned by practicing embodiments of this application. The objectives and other advantages of this application may be realized and obtained by means of the structures particularly pointed out in the written description, claims, and drawings. Attached Figure Description
[0027] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments of this application will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0028] Figure 1 A flowchart illustrating the single-stage cross-domain target detection method provided in this application embodiment;
[0029] Figure 2 A schematic diagram of the structure of a single-stage cross-domain target detection model with an image-level domain classifier and an instance-level domain classifier provided in an embodiment of this application;
[0030] Figure 3This is a schematic diagram of the structure of a single-stage cross-domain target detection device provided in an embodiment of this application;
[0031] Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0032] The technical solutions of the embodiments of this application will now be described with reference to the accompanying drawings. The following embodiments are only used to more clearly illustrate the technical solutions of this application, and are therefore merely examples and should not be used to limit the scope of protection of this application.
[0033] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains; the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the application; the terms “comprising” and “having”, and any variations thereof, in the specification, claims, and foregoing description of the drawings are intended to cover non-exclusive inclusion.
[0034] In the description of the embodiments of this application, technical terms such as "first" and "second" are used only to distinguish different objects and should not be construed as indicating or implying relative importance or implicitly specifying the number, specific order, or primary and secondary relationship of the indicated technical features. In the description of the embodiments of this application, "multiple" means two or more, unless otherwise explicitly defined.
[0035] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0036] Please see Figure 1 This application provides a single-stage cross-domain target detection method, including:
[0037] Step S110: Based on the cross-domain object detection requirements, obtain the source domain dataset and the target domain dataset;
[0038] Step S120: Construct a single-stage cross-domain target detection model;
[0039] Step S130: Set up an image-level domain classifier and an instance-level domain classifier for the single-stage cross-domain object detection model; the instance-level domain classifier includes K instance-level sub-domain classifiers, and the K instance-level sub-domain classifiers use K target features contained in the source domain dataset and the target domain dataset to identify the domain to which the instance features belong;
[0040] Step S140: Jointly train a single-stage cross-domain object detection model, an image-level domain classifier, and an instance-level domain classifier;
[0041] Step S150: Perform target detection using the trained single-stage cross-domain target detection model.
[0042] Step S110 is described in detail below:
[0043] In step S110, the source domain represents a domain different from the test sample, whose dataset contains rich supervised information. The target domain, on the other hand, represents the domain in which the test sample resides, whose dataset contains no supervised information or only a small amount of supervised information. Another interpretation of source and target domains is that when training the object detection model, the training data is the source domain data, and the test data is the target domain data. The cross-domain object detection requirement upon which step S110 is based is to determine the source domain training data and the target domain test data for the single-stage cross-domain object detection model.
[0044] Step S120 is described in detail below:
[0045] As an optional implementation of the aforementioned single-stage cross-domain object detection method, constructing a single-stage cross-domain object detection model includes: constructing a backbone network, a feature fusion network, and a head network for the single-stage cross-domain object detection model; wherein the head network includes a classification sub-network and a regression sub-network. For example, the single-stage cross-domain object detection model constructed in this application embodiment is as follows: Figure 2 As shown, it includes:
[0046] The backbone network is used to extract image features;
[0047] Feature Fusion Network The head network is used to enhance and fuse the image features extracted by the backbone network. It includes a classification subnetwork for classifying pixels and a regression subnetwork for predicting feature anchor boxes.
[0048] In this embodiment, the backbone network can be a ResNet50 neural network, and the feature fusion layer can be a Feature Pyramid Network (FPN).
[0049] It is understood that the backbone network used in the embodiments of this application can be a pre-trained network.
[0050] Step S130 is described in detail below:
[0051] The embodiments of this application provide a single-stage cross-domain object detection model structure after setting an image-level domain classifier and an instance-level domain classifier, as shown below. Figure 2As shown, Figure 2 In GCA, we have an image-level domain classifier. It should be noted that... Figure 2 In this context, GRL stands for inverse gradient layer, which is used to connect the backbone network to the domain classifier. and Represents an image-level subdomain classifier; These represent K instance-level subdomain classifiers.
[0052] It should be noted that the number of instance-level subdomain classifiers is equal to the number of features in the source and target domain datasets, while the number of image-level subdomain classifiers is not limited and can be any number of classes. Figure 2 There can be 3, or any other number.
[0053] Step S140 is described in detail below:
[0054] As an optional implementation of the above-mentioned single-stage cross-domain object detection method, step S140 jointly trains the single-stage cross-domain object detection model, the image-level domain classifier, and the instance-level domain classifier, including: determining the object detection loss function of the single-stage cross-domain object detection model, and simultaneously using an adversarial discrimination method to determine the image-level domain alignment loss function of the image-level domain classifier and the instance-level domain alignment loss function of the instance-level domain classifier; and using a global loss function composed of the object detection loss function, the image-level domain alignment loss function, and the instance-level domain alignment loss function to jointly train the single-stage cross-domain object detection model, the image-level domain classifier, and the instance-level domain classifier. For example, this implementation involves: for the joint training of a single-stage cross-domain object detection model, an image-level domain classifier, and an instance-level domain classifier, determining the object detection loss function, the image-level domain alignment loss function, and the instance-level domain alignment loss function, wherein the instance-level domain alignment loss function is determined based on K instance-level sub-domain classifiers; combining the object detection loss function, the image-level domain alignment loss function, and the instance-level domain alignment loss function into a global loss function, and then jointly training the single-stage cross-domain object detection model, the image-level domain classifier, and the instance-level domain classifier.
[0055] As an optional implementation of the aforementioned single-stage cross-domain object detection method, the object detection loss function includes: source domain data classification loss and source domain data regression loss; or, source domain data classification loss, source domain data regression loss, and source domain image pixel center perceptuality loss. These two implementations are described below:
[0056] In the first implementation, the object detection loss function includes: source domain data classification loss and source domain data regression loss. For example, when training a single-stage cross-domain object detection model using a source domain dataset, since the head network of the single-stage cross-domain object detection model includes a classification sub-network and a regression sub-network, the object detection loss function at least includes source domain data classification loss and source domain data regression loss.
[0057] The second implementation method includes an object detection loss function comprising: source domain data classification loss, source domain data regression loss, and source domain image pixel center perceptualization loss. For example, when training a single-stage cross-domain object detection model using a source domain dataset, since object features are generally foreground features rather than background features, the pixel center perceptualization loss can be added to enable the object detection model to focus more on foreground features and appropriately ignore background features, thereby reducing negative transfer during feature alignment.
[0058] As an optional implementation of the aforementioned single-stage cross-domain object detection method, the instance-level domain alignment loss function includes: foreground confidence weights of source domain image pixels; these foreground confidence weights are obtained based on the perceptual loss of the center of the source domain image pixels. For example, in the instance-level feature alignment process, foreground confidence weights of source domain image pixels are set for the instance-level domain alignment loss function, enabling the model to focus more on foreground features and appropriately ignore background features.
[0059] As an optional implementation of the aforementioned single-stage cross-domain object detection method, the global loss function includes: a guidance function, used to control the activation of the instance-level domain alignment loss function after the training epochs reach a preset threshold. For example, to avoid error accumulation caused by prematurely activating instance-level domain feature alignment, a guidance function is set to guide when instance-level domain feature alignment takes effect by setting a threshold for the number of iterations.
[0060] As an optional implementation of the aforementioned single-stage cross-domain object detection method, both the image-level domain alignment loss function and the instance-level domain alignment loss function employ the Focal Loss function. For example, this implementation addresses the imbalance between positive and negative samples in the source and target domain datasets by assigning a smaller loss weight to correctly classified samples and a larger loss weight to misclassified samples, thus resolving the sample imbalance problem.
[0061] The following is based on Figure 2 The above detailed descriptions of steps S130 and S140, as well as the detailed descriptions of the object detection loss function, image-level domain alignment loss function, and instance-level domain alignment loss function, are provided respectively:
[0062] First, the target detection loss function will be described in detail:
[0063] Step A-1: Train the single-stage cross-domain target detection model using the source domain image, and then use the source domain image X... s Before inputting the backbone network of the single-stage cross-domain object detection model, the source domain images in the source domain dataset are preprocessed and data augmented. Then, the preprocessed and data-augmented source domain images and their corresponding source domain labels are input into the backbone network of the single-stage cross-domain object detection model for feature extraction. In this embodiment, the backbone network can extract three layers of feature maps. and in and Representing low-dimensional features such as shape and texture, Represents high-dimensional features such as semantic information and illumination;
[0064] Step A-2: Input the three-layer feature maps into the feature fusion network to obtain multi-scale fused features. and By using feature fusion networks, the ability of single-stage cross-domain target detection models to perceive targets of different scales is improved.
[0065] Step A-3: Input the multi-scale feature map output by the feature fusion network into the head network to obtain a K-dimensional channel feature map, where each channel represents the classification result for each feature category, and obtain the classification prediction value P for each pixel. cls Feature anchor box prediction P reg And center perception prediction P ctn ; Calculate the source domain classification loss:
[0066]
[0067] in, Represents the Focal Loss function; y S Indicates the source domain dataset label;
[0068] Calculate the regression loss:
[0069]
[0070] in, Represents the GIOU loss function;
[0071] Computational center perception loss:
[0072]
[0073] Among them, P ctn Centrality predicted value; T represents the binary cross-entropy loss function; S The center receptivity of image pixels in the source domain dataset is calculated as follows:
[0074]
[0075] Where l, r, t, and b represent the distances from the current pixel to the left, right, top, and bottom borders of the actual label anchor box, respectively;
[0076] Finally, the target detection loss function was determined as follows:
[0077]
[0078] The image-level domain alignment loss function is described in detail below:
[0079] Step B-1: Determining whether the image belongs to the source domain;
[0080] The three-layer feature maps extracted from the backbone network and Input after passing through gradient inversion layer and Three image-level subdomain classifiers are used to obtain multi-layer discriminative predictions of whether an image belongs to the source domain.
[0081] It should be noted that, due to the three-layer feature map and In and Low-dimensional features As high-dimensional features, when using and When three image-level subdomain classifiers perform neighborhood discrimination on the feature maps respectively and A progressive design approach can be adopted, for example: Configure three 3×3 convolutional networks with progressively reduced dimensionality. Configured as four progressively dimensionality-reduced 3×3 convolutional networks, Five progressively dimensionality-reduced 3×3 convolutional networks are configured to ultimately obtain multi-layer discriminative predictions.
[0082] Step B-2: Determining whether the image belongs to the target domain;
[0083] Set the target domain dataset X T Input the backbone network to obtain three layers of feature maps. and Then the 3D feature maps are input respectively. and Three image-level subdomain classifiers are used to obtain multi-level discriminative predictions of whether an image belongs to the target domain.
[0084] Step B-3: Calculate the image-level domain alignment loss function;
[0085] By using an adversarial discrimination method, pseudo-labels 1 and 0 are assigned to the source and target domains, and Focal Loss is used as the loss function to calculate the domain alignment loss for the source and target domains.
[0086] The image-level domain alignment loss function is as follows:
[0087]
[0088] Where, x S and x T Let F(x) represent the source domain features and the target domain features, respectively; F(x) represents the feature map input to the classifier. represents the prediction result output by the classifier; HS represents the size of the input feature map; γ is the focusing parameter, used to balance the importance of difficult-to-classify samples and easy-to-classify samples.
[0089] The instance-level domain alignment loss function is described in detail below:
[0090] Step C-1: Combine the 5 instance-level features output by the feature fusion network. and as well as and After passing through the gradient flipping layer, each instance-level subdomain classifier is output cyclically. Obtain pixel-level domain discrimination prediction results, and combine the classifiers of each instance-level subdomain into a discriminative prediction using a concat operation.
[0091] Each instance-level subdomain classifier can consist of two 3×3 convolutional networks and one 1×1 convolutional network, using the ReLU function as the activation function;
[0092] Step C-2: Calculate the foreground confidence weights;
[0093] To prevent the classification prediction value from being too small, the classification prediction value P is... cls Multiply by a constant value, and multiply the predicted value for each channel in the classification predictions for each scale by the corresponding center receptivity P. ctn The results are then processed using the sigmoid function to obtain the foreground confidence weight value W. GCA W GCA The specific calculation method is as follows:
[0094] W GCA =σ((θP)cks )*P ctn )
[0095] Where θ represents a constant value; σ represents the sigmoid function;
[0096] It should be noted that, based on the characteristics of the single-stage cross-domain target detection model, generally, samples with a classification prediction value greater than 0.05 are considered positive samples. Therefore, the constant value θ is set to 20 so that the prediction value of positive samples is not less than 1.
[0097] Step C-3: Calculate the instance-level domain alignment loss;
[0098] Using an adversarial discrimination method, pseudo-labels 1 and 0 are assigned to the source and target domains, respectively. Focal Loss is used as the loss function to calculate the domain alignment loss for the source and target domains, as follows:
[0099]
[0100] Where, x S and x T Let M(x) represent the source domain features and the target domain features, respectively; M(x) represents the instance features input to the instance-level subdomain classifier. HW represents the prediction result of the instance-level subdomain classifier; W represents the size of the input feature map; GCA γ is the confidence weight for the foreground; γ is the focusing parameter, used to balance the importance of difficult-to-classify samples and easy-to-classify samples.
[0101] The global loss function is described in detail below:
[0102] The global loss function includes the object detection loss function of the single-stage cross-domain object detection model, the image-level domain alignment loss function of the image-level domain classifier, and the instance-level domain alignment loss function of the instance-level domain classifier. In practical applications, to avoid error accumulation caused by prematurely initiating instance-level domain feature alignment, a guidance function is set. This function guides when instance-level domain feature alignment should take effect by setting a threshold for the number of iterations. The specific guidance function is as follows:
[0103]
[0104] Where α and β are the balancing loss hyperparameters used to balance the overall optimization; t represents the current training epoch; T represents the training epoch threshold for enabling instance-level feature alignment, and the optimal value of this threshold can be determined experimentally.
[0105] The final global loss function determined for joint training of the single-stage cross-domain object detection model, the image-level domain classifier, and the instance-level domain classifier is as follows:
[0106]
[0107] A single-stage cross-domain object detection model with a global loss function, an image-level domain classifier, and an instance-level domain classifier are trained together.
[0108] Finally, a pre-trained single-stage cross-domain object detection model was used for cross-domain object detection.
[0109] Please see Figure 3 Based on the same inventive concept, this application also provides a single-stage cross-domain target detection device 200, comprising:
[0110] The dataset acquisition module 210 is used to acquire the source domain dataset and the target domain dataset according to the cross-domain target detection requirements;
[0111] The target detection model building module 220 is used to build a single-stage cross-domain target detection model.
[0112] The domain classifier setting module 230 is used to set an image-level domain classifier and an instance-level domain classifier for the single-stage cross-domain target detection model; the instance-level domain classifier includes K instance-level sub-domain classifiers; the K instance-level sub-domain classifiers respectively use K target features contained in the source domain dataset and the target domain dataset to identify the domain to which the instance features belong;
[0113] Training module 240 is used to jointly train the single-stage cross-domain object detection model, the image-level domain classifier, and the instance-level domain classifier;
[0114] The cross-domain object detection module 250 is used to perform object detection using a trained single-stage cross-domain object detection model.
[0115] As an optional implementation of the aforementioned single-stage cross-domain object detection device, the training module 240 jointly trains the single-stage cross-domain object detection model, the image-level domain classifier, and the instance-level domain classifier, including: determining the object detection loss function of the single-stage cross-domain object detection model, the image-level domain alignment loss function of the image-level domain classifier, and the instance-level domain alignment loss function of the instance-level domain classifier; and using a global loss function composed of the object detection loss function, the image-level domain alignment loss function, and the instance-level domain alignment loss function to jointly train the single-stage cross-domain object detection model, the image-level domain classifier, and the instance-level domain classifier.
[0116] As an optional implementation of the aforementioned single-stage cross-domain target detection device, the target detection loss function includes: source domain data classification loss and source domain data regression loss; or, source domain data classification loss, source domain data regression loss, and source domain image pixel center perceptual loss.
[0117] As an optional implementation of the above-mentioned single-stage cross-domain target detection device, the instance-level domain alignment loss function includes: foreground confidence weights of source domain image pixels; the foreground confidence weights of source domain image pixels are obtained based on the center perceptual loss of source domain image pixels.
[0118] As an optional implementation of the aforementioned single-stage cross-domain target detection device, the global loss function includes: a guidance function, used to control the activation of the instance-level domain alignment loss function after the training rounds reach a preset threshold.
[0119] As an optional implementation of the above-mentioned single-stage cross-domain target detection device, the target detection model construction module 220 constructs a single-stage cross-domain target detection model, including: constructing the backbone network, feature fusion network and head network of the single-stage cross-domain target detection model respectively; the head network includes a classification sub-network and a regression sub-network.
[0120] As an optional implementation of the above-mentioned single-stage cross-domain target detection device, both the image-level domain alignment loss function and the instance-level domain alignment loss function adopt the Focal Loss focus loss function.
[0121] Figure 4 This is a schematic diagram of an electronic device provided in an embodiment of this application. (Refer to...) Figure 4 The electronic device 300 includes a processor 310, a memory 320, and a communication interface 330. These components are interconnected and communicate with each other via a communication bus 340 and / or other forms of connection mechanism (not shown).
[0122] The memory 320 includes one or more (only one is shown in the figure), which 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. The processor 310 and other possible components may access the memory 320 to read and / or write data therein.
[0123] Processor 310 includes one or more (only one is shown in the figure), which can be an integrated circuit chip with signal processing capabilities. The processor 310 described above can be a general-purpose processor, including a central processing unit (CPU), a microcontroller unit (MCU), a network processor (NP), or other conventional processors; it can also be a special-purpose processor, including 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.
[0124] Communication interface 330 includes one or more (only one is shown in the figure) and can be used to communicate directly or indirectly with other devices to exchange data. For example, communication interface 330 can be an Ethernet interface; it can be a mobile communication network interface, such as an interface for 3G, 4G, or 5G networks; or it can be other types of interfaces with data transmission and reception functions.
[0125] One or more computer program instructions may be stored in the memory 320, and the processor 310 may read and run these computer program instructions to implement the single-stage cross-domain target detection method provided in the embodiments of this application and other desired functions.
[0126] Understandable. Figure 4 The structure shown is for illustrative purposes only; the electronic device 300 may also include components that are more advanced than those shown. Figure 4 The more or fewer components shown, or having the same Figure 4 The different configurations shown. Figure 4 The components shown can be implemented using hardware, software, or a combination thereof. For example, electronic device 300 can be a single server (or other device with computing power), a combination of multiple servers, a cluster of a large number of servers, etc., and can be either a physical device or a virtual device.
[0127] This application also provides a computer-readable storage medium storing computer program instructions. These instructions are read and executed by a computer's processor to perform the single-stage cross-domain target detection method provided in this application. For example, the computer-readable storage medium can be implemented as follows: Figure 4The memory 320 in the electronic device 300.
[0128] In the embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. The apparatus embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. Furthermore, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Additionally, the displayed or discussed mutual couplings, direct couplings, or communication connections may be through some communication interfaces; indirect couplings or communication connections between devices or units may be electrical, mechanical, or other forms.
[0129] Furthermore, the units described as separate components may or may not be physically separate. 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 the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0130] Furthermore, 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.
[0131] The above description is merely an embodiment of this application and is not intended to limit the scope of protection of 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 scope of protection of this application.
Claims
1. A single-stage cross-domain target detection method, characterized in that, include: To meet the requirements of cross-domain object detection, obtain the source domain dataset and the target domain dataset; Construct a single-stage cross-domain target detection model; An image-level domain classifier and an instance-level domain classifier are set for the single-stage cross-domain object detection model; the instance-level domain classifier includes... Instance-level subdomain classifiers; Each instance-level subdomain classifier uses data from the source and target domain datasets respectively. The target features identify the domain to which the instance features belong; wherein, the K instance-level subdomain classifiers correspond one-to-one with the K target categories in the source domain dataset and the target domain dataset, and are used to perform domain discrimination on instance features of different categories respectively; The single-stage cross-domain object detection model, the image-level domain classifier, and the instance-level domain classifier are jointly trained. The global loss function used for joint training includes an instance-level domain alignment loss function. This instance-level domain alignment loss function includes: foreground confidence weights of source domain image pixels; these weights are obtained based on the center perceptual loss of the source domain image pixels. The global loss function also includes: a guidance function, used to control the instance-level domain alignment loss function to be enabled after a preset threshold is reached in the training rounds. A pre-trained single-stage cross-domain target detection model is used for target detection.
2. The single-stage cross-domain target detection method according to claim 1, characterized in that, The joint training of the single-stage cross-domain object detection model, the image-level domain classifier, and the instance-level domain classifier includes: Determine the target detection loss function of the single-stage cross-domain target detection model, the image-level domain alignment loss function of the image-level domain classifier, and the instance-level domain alignment loss function of the instance-level domain classifier; The single-stage cross-domain object detection model, the image-level domain classifier, and the instance-level domain classifier are jointly trained using a global loss function consisting of the object detection loss function, the image-level domain alignment loss function, and the instance-level domain alignment loss function.
3. The single-stage cross-domain target detection method according to claim 2, characterized in that, The target detection loss function includes: Source domain data classification loss and source domain data regression loss; Alternatively, source domain data classification loss, source domain data regression loss, and source domain image pixel center perceptual loss.
4. The single-stage cross-domain target detection method according to any one of claims 2 to 3, characterized in that, The construction of the single-stage cross-domain target detection model includes: A single-stage cross-domain target detection model is constructed by constructing a backbone network, a feature fusion network, and a head network; the head network includes a classification subnetwork and a regression subnetwork.
5. The single-stage cross-domain target detection method according to any one of claims 2 to 3, characterized in that, Both the image-level domain alignment loss function and the instance-level domain alignment loss function adopt the Focal Loss focus loss function.
6. A single-stage cross-domain target detection device, characterized in that, include: The dataset acquisition module is used to acquire source domain datasets and target domain datasets according to cross-domain object detection requirements; The target detection model building module is used to build a single-stage cross-domain target detection model; The domain classifier setting module is used to set an image-level domain classifier and an instance-level domain classifier for the single-stage cross-domain object detection model; the instance-level domain classifier includes... Instance-level subdomain classifiers; Each instance-level subdomain classifier uses data from the source and target domain datasets respectively. The target features identify the domain to which the instance features belong; wherein, the K instance-level subdomain classifiers correspond one-to-one with the K target categories in the source domain dataset and the target domain dataset, and are used to perform domain discrimination on instance features of different categories respectively; The training module is used to jointly train the single-stage cross-domain object detection model, the image-level domain classifier, and the instance-level domain classifier; wherein, the global loss function for joint training includes an instance-level domain alignment loss function; the instance-level domain alignment loss function includes: foreground confidence weights of source domain image pixels; the foreground confidence weights of source domain image pixels are obtained based on the center perceptual loss of source domain image pixels; the global loss function also includes: a guidance function, used to control the instance-level domain alignment loss function to be activated after the training rounds reach a preset threshold; The cross-domain object detection module is used to perform object detection using a pre-trained single-stage cross-domain object detection model.
7. An electronic device, characterized in that, include: A processor, a memory, and a bus, wherein the processor and the memory communicate with each other via the bus; The memory stores program instructions that can be executed by the processor, and the processor can execute the method as described in any one of claims 1 to 5 by calling the program instructions.
8. A non-transitory computer-readable storage medium, characterized in that, The non-transitory computer-readable storage medium stores computer instructions, which, when executed by a computer, cause the computer to perform the method as described in any one of claims 1 to 5.