Object detection method and apparatus, device, and storage medium

By pre-training the visual Transformer model with noise data samples and fine-tuning new category data samples, combined with correlation aggregation and attention operations, the problem of scarcity of new category target detection data and overfitting in deep learning is solved, and the small sample target is improved. Detection precision and recall.

WO2024183181A1PCT designated stage expired Publication Date: 2024-09-12WUHAN AI RES

Patent Information

Application Number
PCT/CN2023/099947
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-03-09
Filing Date
2023-06-13
Publication Date
2024-09-12

AI Technical Summary

Technical Problem

Target detection algorithms based on deep learning require a large amount of training data in new category target detection, making it difficult to apply in real scenarios. There are also over-fitting or under-fitting problems, and it is difficult to effectively utilize the supervision information in small sample target detection.

Method used

The visual Transformer model is pre-trained using noisy data samples and fine-tuned with new category data samples. It combines correlation aggregation operations and self-attention/cross-attention operations to extract features of supporting images and query images, and predict bounding boxes and categories. Confidence.

Benefits of technology

Efficient training and rapid convergence on a large amount of public data improve the precision and recall rate of small-sample new category target detection tasks, and can transfer abstract meta-knowledge to downstream small-sample fine-tuning tasks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2023099947_12092024_PF_FP_ABST
    Figure CN2023099947_12092024_PF_FP_ABST
Patent Text Reader

Abstract

Embodiments of the present application relate to the technical field of graphical data reading, and provide an object detection method and apparatus, a device, and a storage medium. The method comprises: on the basis of a result, obtained by a vision Transformer model, of performing correlation aggregation operation on a query feature map sequence and a support feature map sequence, determining a second query feature map sequence; and on the basis of a result of a self-attention operation and / or a cross-attention operation of the second query feature map sequence, determining a prediction result corresponding to a query image for obtaining the query feature map sequence. According to the object detection method provided by the present application, the convergence time of the vision Transformer model is greatly shortened, the difficulty of predicting a bounding box by using the model is reduced, a target feature area related to a support category in the query image can be effectively extracted, and the query branches are not limited to target instances of specific support categories, and thus a target instance of any category can be detected.
Need to check novelty before this filing date? Find Prior Art

Description

Target detection method, device, equipment and storage medium

[0001] CROSS-REFERENCE TO RELATED APPLICATIONS

[0002] This application claims priority to Chinese patent application number 202310221030.4, filed on March 9, 2023, entitled “A target detection method, device, equipment and storage medium”, which is incorporated herein by reference in its entirety. Technical Field

[0003] The present application relates to the field of graphic data reading technology, and in particular to a target detection method, device, equipment and storage medium. Background Art

[0004] Over the past decade, the performance of deep learning-based object detection algorithms has greatly improved. However, these algorithms typically require extensive training data, making it difficult to apply trained models to real-world scenarios involving new object categories not found in common object detection datasets. Labeling new categories in real-world scenarios requires significant human and material resources, and obtaining large amounts of raw image data is even difficult in some applications, such as medical applications or rare species detection. However, compared to deep learning-based object detection algorithms, humans have an innate ability to learn new concepts from very few examples. Even infants and toddlers can learn the abstract concept of a new object category from just one or a few encounters. This has made few-shot object detection (FSOD) a promising research area. However, when applied to deep learning, few-shot object detection still suffers from overfitting and underfitting.

[0005] Therefore, in real application scenarios, in the process of deep learning, effectively utilizing as little supervisory information as possible required for small sample target detection is still an important issue that needs to be urgently addressed in the industry.

[0006] Summary of the Invention

[0007] In response to the problems existing in the prior art, embodiments of the present application provide a target detection method, apparatus, device, and storage medium.

[0008] In a first aspect, an embodiment of the present application provides a target detection method, comprising:

[0009] Determine a second query feature graph sequence based on the result of performing a correlation aggregation operation on the query feature graph sequence and the support feature graph sequence obtained by the visual Transformer model;

[0010] Determining, based on a result of a self-attention operation and / or a cross-attention operation on the second query feature map sequence, a prediction result corresponding to a query image for obtaining the query feature map sequence; the prediction result comprising: a predicted bounding box, a predicted category, and a corresponding category confidence;

[0011] The visual Transformer model is pre-trained based on noise data samples and fine-tuned using new category data samples. The noise data samples are obtained by adding random noise to the original basic category samples.

[0012] Optionally, the visual Transformer model is pre-trained based on noise data samples and fine-tuned using new category data samples, wherein the noise data samples are obtained by adding random noise to original base category samples, and the method of adding random noise includes:

[0013] Obtaining a bounding box and a category in the original base category sample as a first bounding box and a first category, respectively;

[0014] determining a noise center point corresponding to the center point of the first bounding box based on a random jitter result of the center point of the first bounding box;

[0015] determining a noise bounding box corresponding to the first bounding box based on a result of randomly scaling the width or height of the first bounding box;

[0016] Determining a noise category corresponding to the first category based on a random flipping result of the first category;

[0017] The noise data sample is determined based on the original base category sample and any one or a combination of the noise center point, the noise bounding box and the noise category.

[0018] Optionally, the visual Transformer model is pre-trained based on noisy data samples and fine-tuned using new category data samples. The corresponding training methods include:

[0019] Determining a loss function for the visual Transformer model based on a cross entropy loss function, a generalized intersection-over-union loss function, and a shallow feature score map loss function;

[0020] adding an attention mask to a noise target query sequence determined by the noise data sample as a first target query sequence;

[0021] The pre-training of the visual Transformer model is completed when the loss function is determined to be minimum based on the target query sequence determined by the anchor box and the first target query sequence, as well as the true bounding box and the true category corresponding to the noise data sample;

[0022] Based on the acquired new category data samples, the pre-trained visual Transformer model is fine-tuned.

[0023] Optionally, determining the loss function of the visual Transformer model based on the cross entropy loss function, the generalized intersection-over-union loss function, and the shallow feature score map loss function includes:

[0024] Based on the cross entropy loss function, determine the category reconstruction loss function;

[0025] Determine the bounding box loss based on the weighted sum of the generalized intersection-over-union (IoU) and shallow feature score map loss functions;

[0026] The loss function of the visual Transformer model is determined based on the category reconstruction loss function and the bounding box loss function.

[0027] Optionally, determining the second query feature graph sequence based on the result of performing a correlation aggregation operation on the query feature graph sequence and the support feature graph sequence obtained based on the visual Transformer model includes:

[0028] receiving the supporting feature graph sequence input according to a first input format and the query feature graph sequence input according to a second input format;

[0029] Extracting the category object instances contained in the support feature map sequence based on the region of interest operator;

[0030] Based on the global average pooling operator, each category object is fused into the vector of the corresponding category to obtain the supporting category prototype;

[0031] A second query feature graph sequence is determined based on the encoding matching result and the feature matching result between the query feature graph sequence and the support category prototype.

[0032] Optionally, determining a second query feature graph sequence based on a coding matching result and a feature matching result between the query feature graph sequence and the support category prototype includes:

[0033] Determining a first parameter V and a second parameter K for feature matching in a single-head self-attention operation based on the support type prototype and the background category prototype;

[0034] Determining a first parameter V and a second parameter K for encoding matching in a single-head self-attention operation based on the support type prototype, the background category prototype, and the task encoding matrix;

[0035] Determining a third parameter Q for feature matching and encoding matching in a single-head self-attention operation based on the query feature map sequence;

[0036] Based on the first parameter V, the second parameter K and the third parameter Q, code matching and feature matching are performed respectively, and the corresponding matching results are output as the second query feature graph sequence.

[0037] Optionally, determining a prediction result corresponding to a query image of the query feature graph sequence for obtaining the query feature graph sequence based on a result of a self-attention operation and / or a cross-attention operation of the second query feature graph sequence includes:

[0038] Determining an updated second query feature graph sequence based on a self-attention operation result of the second query feature graph sequence;

[0039] Based on the self-attention operation and the cross-attention operation, the operation result between the target query sequence and the updated second query feature map sequence is determined as the prediction result corresponding to the query image for obtaining the query feature map sequence.

[0040] Optionally, the method further includes:

[0041] performing normalization processing on the prediction result corresponding to the query image;

[0042] The prediction results with the top N largest category confidences are selected as the target detection results corresponding to the query image; N is a positive integer.

[0043] In a second aspect, an embodiment of the present application further provides a visual Transformer model, comprising a correlation aggregation module consisting of a multi-head self-attention unit and a single-head self-attention unit;

[0044] The multi-head self-attention unit is used to map the support feature map sequence to a feature map of a specified size based on alignment of the region of interest, and determine the support category prototype;

[0045] The single-head self-attention unit is used to determine a second query feature graph sequence based on the encoding matching result and feature matching result of the query feature graph sequence and the support category prototype.

[0046] In a third aspect, an embodiment of the present application further provides a target detection device, comprising:

[0047] A correlation aggregation module is used to determine a second query feature graph sequence based on the query feature graph sequence and the support feature graph sequence obtained by the visual Transformer model through a correlation aggregation operation.

[0048] a deformable transformer module for determining, based on results of a self-attention operation and / or a cross-attention operation on the second query feature map sequence, a prediction result corresponding to a query image for obtaining the query feature map sequence; the prediction result comprising: a predicted bounding box, a predicted category, and a corresponding category confidence;

[0049] The visual Transformer model is pre-trained based on noise data samples and fine-tuned using new category data samples. The noise data samples are obtained by adding random noise to the original basic category samples.

[0050] In a fourth aspect, an embodiment of the present application further provides an electronic device, including a memory, a transceiver, and a processor;

[0051] A memory for storing computer programs; a transceiver for sending and receiving data under the control of the processor; and a processor for reading the computer program in the memory and implementing the target detection method described in the first aspect above.

[0052] In a fifth aspect, an embodiment of the present application further provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the target detection method described in the first aspect above is implemented.

[0053] In a sixth aspect, an embodiment of the present application further provides a processor-readable storage medium, wherein the processor-readable storage medium stores a computer program, and the computer program is used to enable the processor to execute the target detection method described in the first aspect above.

[0054] In a seventh aspect, an embodiment of the present application further provides a communication device-readable storage medium, wherein the communication device-readable storage medium stores a computer program, and the computer program is used to enable the communication device to execute the target detection method described in the first aspect above.

[0055] In an eighth aspect, an embodiment of the present application further provides a chip product readable storage medium, wherein the chip product readable storage medium stores a computer program, and the computer program is used to enable the chip product to execute the target detection method described in the first aspect above.

[0056] In a ninth aspect, an embodiment of the present application further provides a computer program product, comprising a computer program, which, when executed by a processor, implements the target detection method described in the first aspect above.

[0057] The target detection method, apparatus, device and storage medium provided in the embodiments of the present application use noise data samples to pre-train the visual Transformer model, and use new category data samples to fine-tune the visual Transformer model. Based on the visual Transformer model, a target detection method is constructed, feature extraction is performed on the support image and the query image, and correlation aggregation operations, as well as self-attention operations and / or cross-attention operations are performed to determine the predicted bounding box, predicted category and corresponding category confidence corresponding to the query image. Not only can efficient training and rapid convergence be performed on a large amount of public data, but the abstract meta-knowledge learned from a large amount of public data can also be transferred to downstream small sample fine-tuning tasks, thereby improving the precision and recall of downstream small sample new category target detection tasks. BRIEF DESCRIPTION OF THE DRAWINGS

[0058] In order to more clearly illustrate the technical solutions in the present application or the prior art, a brief introduction will be given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0059] FIG1 is a schematic diagram of a flow chart of a target detection method provided in an embodiment of the present application;

[0060] FIG2 is a schematic diagram of a true bounding box and a noise bounding box provided in an embodiment of the present application;

[0061] FIG3 is a schematic diagram of the structure of a correlation aggregation module provided in an embodiment of the present application;

[0062] FIG4 is a schematic diagram illustrating an implementation of feature matching and encoding matching by a single-head self-attention module in a correlation aggregation module according to an embodiment of the present application;

[0063] FIG5 is a schematic diagram of the overall structure of a deformable Transformer provided in an embodiment of the present application;

[0064] FIG6 is a schematic structural diagram of a deformable encoder provided in an embodiment of the present application;

[0065] FIG7 is a schematic structural diagram of a deformable decoder provided in an embodiment of the present application;

[0066] FIG8 is a schematic diagram of an implementation process of deformable self-attention and / or cross-attention operations provided by an embodiment of the present application;

[0067] FIG9 is a schematic structural diagram of a target detection device provided in an embodiment of the present application;

[0068] FIG10 is a schematic structural diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0069] To make the purpose, technical solutions, and advantages of the embodiments of this application more clear, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the described embodiments are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.

[0070] FIG1 is a flow chart of a target detection method provided in an embodiment of the present application. As shown in FIG1 , the method includes:

[0071] Step 101: Determine a second query feature graph sequence based on the result of performing a correlation aggregation operation on the query feature graph sequence and the support feature graph sequence obtained by the visual Transformer model;

[0072] Step 102: Determine a prediction result corresponding to a query image for obtaining the query feature map sequence based on the results of the self-attention operation and / or the cross-attention operation of the second query feature map sequence; the prediction result includes: a predicted bounding box, a predicted category, and a corresponding category confidence;

[0073] The visual Transformer model is pre-trained based on noise data samples and fine-tuned using new category data samples. The noise data samples are obtained by adding random noise to the original basic category samples.

[0074] Specifically, based on the meta-learning algorithm, the overall architecture of the visual Transformer model is constructed, and the same visual Transformer model with parameter sharing is used to extract features of the support image and the query image respectively. Specifically, the convolutional network module in the visual Transformer model divides the input support image and the query image into two branches, and performs preliminary multi-scale feature map extraction. The multi-scale feature map extracted by the convolutional neural network of the convolutional network module corresponds to the number of channels from the shallowest layer to the deepest layer, and the number of channels of each layer is not equal. Assuming that the number of channels of the largest feature map in the multi-scale feature map at the shallowest layer is Ch, then the number of channels of the multi-scale feature map from shallow to deep layers can be expressed as Ch, 2Ch, 4Ch, 8Ch,..., where Ch represents a specific number and is greater than or equal to 1. The number of multi-scale feature maps extracted by the convolutional network module can be set according to demand. If a finer division of the image is required, the number of channels can be set to a larger value. Otherwise, a smaller value can be set. The value usually set is 3 or 4. After the above processing, each support image obtains multiple feature maps of different scales. The feature map of each scale can be represented by a feature vector. All feature maps of different scales constitute a sequence, that is, the support feature map sequence corresponding to the support image. Similarly, each query image can also obtain a corresponding query feature map sequence.

[0075] In order to make the feature map sequence extracted by the convolutional network module convenient for subsequent deformable transformer processing, the number of channels of feature maps of different scales at each layer is generally kept consistent. Therefore, for each of the multi-scale feature maps, convolution and GroupNorm are combined to uniformly map the number of channels of different numbers of channels to the same value by the normalization layer at the same layer. The parameters of the above convolution and normalization layers are not shared between feature maps of different scales. After completing the alignment of the above-mentioned feature maps of different scales in the channel dimension, the multi-scale feature maps are flattened in the spatial dimension as the input feature map sequence of the Correlational Aggregation Module (CAM) in the subsequent visual transformer model.

[0076] The relevance aggregation module performs multi-head self-attention operations on the support feature map sequence to extract support category prototypes. This support category prototype does not limit the specific support categories, but only the number of support categories. Any category can be mapped to the vector corresponding to the multiple support categories corresponding to the support category prototype through encoding matching, thereby achieving class-agnostic target detection. The query feature map sequence and the support category elements are then interactively and subjected to relevance aggregation operations to extract feature regions related to the support category prototype from the query feature map sequence. This allows the relevance aggregation module to perform bounding box and category confidence prediction for class-agnostic objects without relying on the determined support categories, thereby obtaining a second query feature map sequence.

[0077] The second query feature map sequence is input into the deformable transformer module of the visual Transformer model. Feature extraction is further performed on the second query feature map sequence. Specifically, a deformable self-attention operation is performed on the second query feature map sequence to extract regions containing target examples from the input second query feature map sequence, while suppressing background regions or portions of the image that lack semantic information. The target query sequence is then used to detect the target in the query feature map sequence, further classifying and localizing it to determine a prediction result corresponding to the query image. The prediction result includes a predicted bounding box, a predicted category, and the corresponding category confidence. This prediction result can be used as the result of target detection.

[0078] The above-mentioned visual Transformer model is constructed based on a meta-learning algorithm and is obtained after pre-training with noise data samples and fine-tuning with new category data samples. The noise data samples are obtained by adding random noise to the original basic category samples. The original basic category samples are usually sample data with sufficient data volume and easy to obtain. The new category data samples are usually data that is difficult to obtain and has a small amount of data. Generally, after determining the target domain, such as medical applications or rare species detection as the target domain, data samples belonging to the target domain are screened as new category data samples. The original basic category samples and the above-mentioned noise data samples are used to pre-train the visual Transformer model to obtain the relevant parameters of the visual Transformer model. The corresponding noise reduction pre-training method accelerates the convergence of the visual Transformer model and improves the algorithm performance. The new category data samples are further used to train the visual Transformer model to achieve parameter fine-tuning of the visual Transformer model, so that the visual Transformer model can more accurately predict the bounding box offset based on the reference point.

[0079] The target detection method provided in the embodiment of the present application uses noise data samples to pre-train the visual Transformer model, and uses new category data samples to fine-tune the visual Transformer model. Based on the visual Transformer model, a target detection method is constructed, and feature extraction is performed on the support image and the query image. Correlation aggregation operations, as well as self-attention operations and / or cross-attention operations are performed to determine the predicted bounding box, predicted category, and corresponding category confidence corresponding to the query image. Not only can efficient training and rapid convergence be performed on a large amount of public data, but the abstract meta-knowledge learned from a large amount of public data can also be transferred to downstream small sample fine-tuning tasks, thereby improving the precision and recall of downstream small sample new category target detection tasks.

[0080] Optionally, the visual Transformer model is pre-trained based on noise data samples and fine-tuned using new category data samples, wherein the noise data samples are obtained by adding random noise to original base category samples, and the method of adding random noise includes:

[0081] Obtaining a bounding box and a category in the original base category sample as a first bounding box and a first category, respectively;

[0082] determining a noise center point corresponding to the center point of the first bounding box based on a random jitter result of the center point of the first bounding box;

[0083] determining a noise bounding box corresponding to the first bounding box based on a result of randomly scaling the width or height of the first bounding box;

[0084] Determining a noise category corresponding to the first category based on a random flipping result of the first category;

[0085] The noise data sample is determined based on the original base category sample and any one or a combination of the noise center point, the noise bounding box and the noise category.

[0086] Specifically, the samples used for pre-training the visual Transformer model include noise data samples and original basic category samples, wherein the noise data samples are obtained by adding random noise to the original basic category samples, and the method of adding random noise includes:

[0087] Obtaining a bounding box in the original base category sample and a category corresponding to the original base category sample, where the bounding box in the original base category sample and the category corresponding to the original base category sample are usually labeled data information, as a first bounding box and a first category, respectively;

[0088] There are two main ways to add noise to the first bounding box: (1) randomly jitter the center point coordinates (center_x, center_y) of the first bounding box, and the noise size of the random jitter is (Δx, Δy), which is used as the noise center point; (2) use the preset hyperparameter λ2 in the range of (0, 1) to randomly scale the height or width of the first bounding box label as the noise bounding box. If the width and height of the first bounding box are w and h, then the numerical range of the randomly scaled bounding box width is [(1-λ2)w, (1+λ2)w], and the numerical range of the randomly scaled bounding box height is [(1-λ2)h, (1+λ2)h]. Figure 2 is a schematic diagram of a true bounding box and a noise bounding box provided in an embodiment of the present application. As shown in Figure 2, the solid rectangular box represents the true bounding box, the thinner dot represents the center point of the true bounding box, the dotted rectangular box represents the noise bounding box, and the thicker dot represents the center point of the noise bounding box; the width of the true bounding box is represented by w, and the height is represented by h; the width of the noise bounding box is represented by w', and the height is represented by h'.

[0089] Adding random noise to the first category mainly involves randomly flipping the category, that is, randomly changing the true category label of the first category to other categories and using it as the noise category.

[0090] Then, based on any one or a combination of the noise center point, the noise bounding box, and the noise category, the center point, the first bounding box, and / or the first category of the corresponding first bounding box in the original basic category sample are replaced, thereby determining a noise data sample. For example, adding random noise is performed by adding category noise, and the determined noise category replaces the first category of the corresponding target instance in the original basic category sample as the noise data sample, or adding random noise is performed by adding noise to the bounding box, determining the noise center point and the noise bounding box, and replacing the center point and the first bounding box of the first bounding box corresponding to the target instance in the original basic category sample with the noise center point and the noise bounding box as the noise data sample.

[0091] For each iteration of pre-training, there can be multiple noise samples. After generating the noise data samples, the noise data samples are used as additional target query sequences for the deformable Transformer module and are merged with the original target query sequence that was originally input into the deformable Transformer module as the input of the deformable Transformer module. Prior to this, it is necessary to determine the loss function of the visual Transformer model. This loss function includes the category reconstruction loss function and the bounding box loss function, which can be determined specifically by the cross entropy loss function, the generalized intersection over union (GIoU), and the shallow feature score map loss function (L1 loss function). For example, the cross entropy loss function Focal loss is used to determine the category reconstruction loss function, and the bounding box loss function is determined by weighted summation based on the generalized intersection over union GIoU and the L1 loss function. The loss function of the visual Transformer model is then determined based on the category reconstruction loss function and the bounding box loss function.

[0092] In addition, the deformable Transformer module in the visual Transformer model also merges the noisy target query sequence composed of the above-mentioned noise data samples and the original target query sequence as input. Since the noisy target query sequence contains the information of the true bounding box label and the category label, in order to prevent overfitting in the training phase, an attention mask can also be added to the noisy target query sequence to prevent the true label information in the noisy target query sequence from leaking into the original target query sequence. Therefore, one true label generates multiple different versions of noise. The different versions of the noisy target query sequences should not interfere with each other, and an attention mask is also added between each different version of the noisy target query sequence.

[0093] The bipartite graph matching module in the visual Transformer model receives the prediction results output by the deformable Transformer module. The prediction results include the same number of predicted bounding boxes as the length of the target query sequence. In other words, the number of predicted bounding boxes is the same as the number of feature vectors in the target query sequence. Therefore, the number of true target bounding boxes in the query image is much smaller than the number of predicted bounding boxes output by the deformable Transformer module in the visual Transformer model. In order to form a one-to-one bipartite graph match between the predicted bounding boxes output by the deformable Transformer module and the true target bounding boxes, one or more feature vectors in the query feature graph sequence that do not match the true target bounding boxes are typically matched to an empty target category.

[0094] The purpose of the bipartite graph matching module is to minimize the loss value corresponding to the one-to-one matching between the target query sequence and the true target bounding box and the empty target category. The objective function of the bipartite graph matching module determined by the Hungarian algorithm can be expressed as:

[0095] Where σ represents any result of bipartite graph matching between the target query sequence and the true label and the empty target category; represents the set of bipartite graph matching results between the target query sequence and the true label and the empty target category, represents the optimal result of bipartite graph matching between the target query sequence and the true label and the empty target category; N represents the length of the target query sequence; Represents the abstract result of the i-th target bounding box in the query image or support image. Specifically, it includes the category label and rectangular bounding box label of the i-th target bounding box. The i-th bounding box may be an empty category. The so-called empty category is the background category. The background category has only a category label but no bounding box label. It is an abstract representation of the prediction result output by the visual Transformer model for the i-th bounding box in the query image or support image. Specifically, it includes the model's predicted category and predicted rectangular bounding box for the i-th target bounding box; i represents the sequence number of the predicted bounding box output by the model; The loss function represents the bipartite graph matching between a single feature vector in the target query sequence and a single prediction output by the deformable Transformer module in the visual Transformer model. The loss function compares the model prediction with the target label. It compares (1) whether the predicted category label and the true category label are the same, and then calculates the loss function value. This is a classification problem; (2) whether the predicted rectangular bounding box and the true rectangular bounding box are close. This is a regression problem. The closer the two are in center point and size (width and height of the rectangular box), the smaller the loss value. Otherwise, the loss value is larger.

[0096] Visual Transformer Model Loss Function The specific calculation formula can be expressed as follows:

[0097] in, represents the true label (target category and target bounding box) in the i-th target query and true label pair matched by the Hungarian algorithm, represents the predicted bounding box (true target category confidence and predicted rectangular bounding box) of the target query in the i-th target query matched by the Hungarian algorithm and the true label pair, [c i ≠φ] represents the Iverson bracket, when c i≠φ holds true, the Iverson bracket takes the value 1, when c i When ≠φ is not true, the value of the Iverson bracket is 0, c i represents the true target category label in the i-th target query and true label pair matched by the Hungarian algorithm, φ represents the empty target category, and b i represents the true rectangular bounding box label in the i-th target query and true label pair matched by the Hungarian algorithm, σ(i) represents the sequence number / index of the target query vector in the i-th target query and true label pair matched by the Hungarian algorithm in the original target query sequence, represents the rectangular bounding box of the target query prediction in the i-th target query and the true label pair matched by the Hungarian algorithm, represents the true category confidence of the target query prediction in the i-th target query and the true label pair matched by the Hungarian algorithm, represents the bounding box localization loss.

[0098] The bounding box localization loss It can be expressed by the following formula:

[0099] Among them, λ iou is the preset IoU loss hyperparameter, λ L1 is the default L1 loss hyperparameter, represents the calculation of the intersection-over-union (IoU) loss between the true rectangular bounding box and the predicted rectangular bounding box, and ‖·‖1 represents the determination of the proximity between the predicted rectangular bounding box and the true rectangular bounding box through the L1 loss function.

[0100] The bipartite graph matching module performs a one-to-one match between the prediction results output by the deformable Transformer module in the visual Transformer model and the true labels. Since the prediction results include multiple ones, the prediction results output by the deformable Transformer module and the true labels + empty categories can be regarded as two sets. The essence of the bipartite graph matching is set matching. Accordingly, the loss function of the visual Transformer model can be expressed as follows:

[0101] Among them, the meaning of each parameter in the above formula is the same as the visual Transformer loss function Exactly the same as in .

[0102] Optionally, determining the second query feature graph sequence based on the result of performing a correlation aggregation operation on the query feature graph sequence and the support category prototype includes:

[0103] receiving the supporting feature graph sequence input according to a first input format and the query feature graph sequence input according to a second input format;

[0104] Extracting the category object instances contained in the support feature map sequence based on the region of interest operator;

[0105] Based on the global average pooling operator, each category object is fused into the vector of the corresponding category to obtain the supporting category prototype;

[0106] A second query feature graph sequence is determined based on the encoding matching result and the feature matching result between the query feature graph sequence and the support category prototype.

[0107] Specifically, the correlation aggregation module in the visual Transformer model includes a multi-head self-attention module and a single-head self-attention module. In order to facilitate the processing of the support feature map sequence and the query feature map sequence separately, as well as the correlation aggregation, a unified format is usually adopted. For example, the support feature map sequence is usually input in the first format, which can be expressed as (C, P, d), while the query feature map sequence is usually input in the second format, which can be expressed as (P, d), where C represents the support category, P represents the number of pixels in the multi-scale feature map sequence, and d represents the number of channels. The second query feature map sequence output by the correlation aggregation module is also output in the second format.

[0108] FIG3 is a schematic diagram of the correlation aggregation module structure provided by an embodiment of the present application. As shown in FIG3 , the correlation aggregation module mainly includes a multi-head self-attention module and a single-head self-attention module, wherein the multi-head self-attention module is used to perform a global self-attention operation on the support feature graph sequence or the query feature graph sequence. The single-head self-attention module interacts and performs correlation aggregation operations between the support category prototype and the query sequence. In addition, due to the limitations of the model size and the amount of computation, there is only one multi-head self-attention module in the CAM module, so the parameters of the multi-head self-attention module used for the global self-attention operation of the support feature graph sequence and the query feature graph sequence are completely shared. After passing through the multi-head self-attention module, the formats of the support feature graph sequence and the query feature graph sequence remain unchanged, that is, the format of the support feature graph sequence is still (C, P, d), and the format of the query feature graph sequence is still (P, d).

[0109] The multi-head self-attention module in the correlation aggregation module uses the Region of Interest (RoI) alignment operator on the above-mentioned support feature map sequence to extract the relevant regions containing instance objects corresponding to the support category from the support feature map sequence, that is, mapping feature maps of any size to feature maps of a specified size. The specified size feature map is generally a square with equal width and height. It can be assumed that the size of the feature map of any size is m×n. Through the RoI alignment operator, the feature map of any size is mapped according to the specified size to obtain a feature map of k×k size. Then, using the global average pooling operator, the spatial dimension information of objects belonging to the same category is fused into a vector corresponding to the category as the support category prototype.

[0110] The single-head self-attention module in the correlation aggregation module interacts and performs correlation aggregation operations between the support category prototypes and the query feature map sequence. The single-head self-attention module in the correlation aggregation module has the following two functions: feature matching and encoding matching. Due to the limitations of model size and computational complexity, the parameters of the single-head self-attention module for feature matching and the single-head self-attention module for encoding matching are completely shared. Specifically, the role of feature matching is to extract feature regions related to the support category prototype from the query feature map sequence, and the role of encoding matching is to make the trained model independent of specific support categories, so that bounding boxes and category confidence predictions of unknown categories can be performed.

[0111] Optionally, determining a second query feature graph sequence based on a coding matching result and a feature matching result between the query feature graph sequence and the support category prototype includes:

[0112] Determining a first parameter V and a second parameter K for feature matching in a single-head self-attention operation based on the support type prototype and the background category prototype;

[0113] Determining a first parameter V and a second parameter K for encoding matching in a single-head self-attention operation based on the support category prototype, the background category prototype, and the task encoding matrix;

[0114] Determining a third parameter Q for feature matching and encoding matching in a single-head self-attention operation based on the query feature map sequence;

[0115] Based on the first parameter V, the second parameter K and the third parameter Q, code matching and feature matching are performed respectively, and the corresponding matching results are output as the second query feature graph sequence.

[0116] Specifically, FIG4 is a schematic diagram of the implementation of the single-head self-attention module in the correlation aggregation module provided in an embodiment of the present application to achieve feature matching and encoding matching. As shown in FIG4, C represents vector concatenation and S represents normalization using the sigmoid function. The single-head self-attention module is used to determine the second query feature graph sequence based on the correlation aggregation operation results of the query feature graph sequence and the support category prototype.

[0117] The input to the single-head self-attention module is a sequence of support class prototypes and query feature maps. Since true target instances in the input images (query and support images) typically occupy only a small area, while the background area occupies the majority of the input image, an additional background class prototype is added to the support class prototypes. Both the support class prototype and the background class prototype are represented in vector form. The parameters in the vector corresponding to the background class prototype serve as parameters of the visual Transformer model and are continuously updated during training. The format of the support class prototype after adding the background class prototype is (C+1, d). When the single-head self-attention module performs feature matching, the query feature map sequence is directly used as the third parameter Q of the single-head self-attention module, the support class prototype sequence after adding the background class prototype is used as the second parameter K of the single-head self-attention module, and the support class prototype after adding the background class prototype is normalized using the sigmoid function as the first parameter V of the self-attention. Based on these first parameter V, second parameter K, and third parameter Q, single-head self-attention feature matching is performed. Among them, the support category prototype normalized by the sigmoid function is used as the filter of the attention matrix to filter out the feature vectors in the query feature map sequence that are not related to the support category, so as to achieve the effect of feature matching or filtering the query feature sequence according to the support category prototype.

[0118] On the other hand, when the single-head self-attention module performs encoding matching, an additional task encoding matrix is ​​added as a learnable parameter of the visual Transformer model. The task encoding matrix consists of a background category task encoding vector and a target category task encoding matrix. Since the visual Transformer model determined by the meta-learning algorithm supports samples of specific support categories in each iterative training process, it is easy to cause the visual Transformer model to overfit to specific support categories, that is, to cause the visual Transformer model to be too dependent on specific support categories. In order to solve this problem, the present application introduces a task encoding matrix, which consists of a background category task encoding vector and a target category task encoding matrix, that is, the background category task encoding vector is added as a row vector to the first row or the last row of the target category task encoding matrix. The support categories input in each iterative training are mapped to the corresponding task encoding vectors in the task encoding matrix. Then, all support categories are mapped to the corresponding task encoding matrices in each iterative training process, so that the correlation aggregation module gets rid of its dependence on specific support categories through the task encoding matrix, and realizes small-sample target detection of unknown categories based on meta-learning. The target category task encoding matrix input for each iteration is in the format of (C, d). Since the Transformer's self-attention operation is essentially a fully connected layer, and fully connected layers are permutation-invariant to the input sequence, that is, input sequences of different permutations are input to the fully connected layer and the output is exactly the same. Therefore, the target category task encoding matrix is ​​introduced. Each category task encoding vector in the target category task encoding matrix is ​​used to identify a specific position and is added element-by-element to the matrix composed of attention coefficients obtained by the self-attention operation, namely the attention feature map. Accordingly, an additional background category task encoding vector is added to the end of the target category task encoding matrix. The background category task encoding vector has a dimension of d. Therefore, the format of the first parameter V input for each iterative training is (C+1, d).

[0119] After the single-head self-attention module performs encoding matching, it outputs an encoding matching output sequence; after the single-head self-attention module performs feature matching, it outputs a feature matching output sequence; and the encoding matching output sequence and the feature matching output sequence have the same format, both of which can be expressed as (P, d). The correlation aggregation module adds the above encoding matching output sequence and feature matching output sequence one by one to obtain the final output of the correlation aggregation module, the second query feature map sequence. The correlation aggregation module not only filters out the feature areas in the query feature map sequence that are not related to the support category, but also realizes that it is independent of the specific support category and can perform small sample target detection of unknown categories. The second query feature map sequence output by the correlation aggregation module serves as the input of the subsequent deformable Transformer module to perform deformable self-attention and cross-attention operations.

[0120] Optionally, determining a prediction result corresponding to the query image based on a result of a self-attention operation and / or a cross-attention operation of the second query feature map sequence includes:

[0121] Determining an updated second query feature graph sequence based on a self-attention operation result of the second query feature graph sequence;

[0122] Based on the self-attention operation and the cross-attention operation, the operation result between the target query sequence and the updated second query feature map sequence is determined as the prediction result corresponding to the query image.

[0123] Specifically, Figure 5 is a schematic diagram of the overall structure of the deformable Transformer provided in an embodiment of the present application. As shown in Figure 5, after the correlation aggregation module in the visual Transformer model outputs the second query feature map sequence, it serves as the input of the deformable Transformer module in the visual Transformer model. The deformable Transformer module further extracts features from the second feature map sequence and detects the extracted second feature map sequence based on the target query sequence to determine the prediction result corresponding to the query image.

[0124] The deformable Transformer includes a deformable encoder and a deformable decoder, wherein the input of the deformable encoder is the second query feature map sequence. The main function of the deformable encoder is to further extract features from the second query feature map sequence, that is, to perform a deformable self-attention operation on the second query feature map sequence output by the correlation aggregation module. The deformable self-attention operation of the second query feature map sequence emphasizes the area containing the target instance in the input query image and suppresses the background area or the part of the image that does not contain semantic information. The deformable decoder has two inputs, namely (1) the query feature map sequence output by the above-mentioned deformable encoder and (2) the target query sequence of the visual Transformer model. The target query sequence is continuously updated during the model training process as a learnable parameter of the visual Transformer model. The role of the target query sequence is similar to the anchor box in the traditional target detection algorithm, which is responsible for detecting the target to be detected in the query feature map sequence, and further using the multi-layer perceptron for classification and positioning, that is, determining the category prediction result and bounding box prediction result of the target to be detected. That is, after each feature vector in the query feature map sequence or the support feature map sequence passes through the multi-layer perceptron, the output is a prediction of the category and target bounding box of the target in the query image or the support image. The target category can be an empty category, and the target bounding box is the rectangular bounding box predicted by the model. Specifically, the deformable decoder mainly performs two operations, namely (1) conventional self-attention operation on the target query sequence. Conventional self-attention is a global attention mechanism, and each vector in the sequence performs self-attention operation on all vectors in the sequence; (2) cross-attention operation between the target query sequence and the query feature sequence output by the deformable encoder. The role of the deformable self-attention operation on the target query sequence in the deformable decoder is to exchange information between the target query sequences, emphasizing the target query vectors containing rich semantic information or target instance information, while suppressing the target query vectors that do not contain any useful information. Deformable self-attention is a sparse self-attention mechanism, and each vector in the sequence performs self-attention operation on some vectors in the sequence.The deformable decoder takes the query feature map sequence and the target query sequence output by the deformable encoder as input and performs a cross-attention operation. The role of the cross-attention operation in the deformable decoder is equivalent to the network head part in the traditional target detection algorithm. The structure of the deformable encoder is shown in Figure 6. The deformable encoder consists of 4 layers. Each deformable encoder layer consists of a deformable self-attention layer, a dropout layer, a layer normalization layer, and a multi-layer perceptron. The above dropout layer and the layer normalization layer are connected by residual connections. Accordingly, unlike the convolutional neural network, the input sequence of the deformable Transformer does not contain position information and time series information. Therefore, position coding information is added to the input query feature map sequence of the deformable Transformer encoder. The way to add position coding information is to add the query feature map sequence and the position coding vector element by element. The position coding vector used in the embodiment of the present application is mainly expressed as sine-cosine position coding. Specifically, the calculation formula of the position coding vector is as follows:

[0125] T represents the temperature coefficient, a preset temperature coefficient that, to some extent, reflects the length of the position encoding prior; D represents the total dimension of the position encoding vector; 2i and 2i+1 represent the index of the position encoding vector in the channel dimension; and x represents the position of the position encoding vector in space. PE() is a function identifier, which is a real number that calculates the specific value of the position encoding using the vector's position in the sequence and the index of its dimension.

[0126] Figure 7 is a structural diagram of the deformable decoder provided in an embodiment of the present application. As shown in Figure 7, the deformable decoder is also composed of 7 layers. Each deformable decoder layer is composed of a deformable self-attention layer, a drop layer 1, a layer normalization layer 1, a deformable cross attention layer, a drop layer 2, a layer normalization layer 2 and a multi-layer perceptron, wherein the drop layer 1 and the layer normalization layer 1, and the drop layer 2 and the layer normalization layer 2 are connected by residual connections. The deformable self-attention layer only performs deformable self-attention operations on the target query sequence of the visual Transformer. The deformable cross attention module uses the target query sequence of the visual Transformer as the Q sequence and the query feature map sequence output by the deformable encoder as the V sequence, wherein any vector in the Q sequence can be represented as a q vector. Because the deformable attention mechanism is sparse attention, it only performs attention operations on vectors around the reference point. The reference point of each q vector in the Q sequence in the deformable cross attention is learned using an additional fully connected layer. The reference point of the q vector here is the position of the target detection object in the original image. Using sparse attention to learn the vectors around the reference point can accelerate the convergence of model training. The reference point in the deformable cross-attention is mapped using a fully connected layer. Furthermore, the conventional self-attention operation in the deformable decoder module only adds positional encoding information to the input Q and K sequences, but not to the V sequence. The deformable cross-attention operation only adds positional encoding information to the input Q sequence. The deformable self-attention layer includes two fully connected layers that map the input Q sequence to obtain the attention coefficient and the sampling offset relative to the reference point, respectively.

[0127] Figure 8 is a schematic diagram of the implementation process of the deformable self-attention and / or cross-attention operation provided by an embodiment of the present application. As shown in Figure 8, the difference between deformable self-attention and cross-attention is that the V sequence of the attention module is different. The V sequence of the deformable self-attention operation is the target query sequence, and the V sequence of the deformable cross-attention operation is the query feature map sequence. Among them, each element in the V sequence can be represented as a v vector. Unlike the conventional attention mechanism, each q vector in the Q sequence in the deformable attention does not perform a dot product operation on all the v vectors in the V sequence, but only performs a dot product operation on some v vectors around the reference point corresponding to the current q vector. Specifically, the deformable attention mechanism can be expressed by the following formula:

[0128] Among them, DeformAttn() is the result of the deformable self-attention operation; q Indicates the specific value of the q vector; p q represents the reference point corresponding to the q vector; x represents the input sequence of deformable self-attention; W′ m and W mrepresents the coefficient matrix; M represents the total number of attention heads in the deformable self-attention operation; m represents the index corresponding to the self-attention head in the deformable self-attention operation; K represents the total number of reference points corresponding to each q vector in the Q sequence; k is the index of the reference point, representing any one of the K reference points; A mqk represents the deformable self-attention coefficient; Δp mqk Indicates that the k vector for each q vector dot product operation is relative to the reference point p q The position offset.

[0129] The above coefficient matrix W′ m and W m They are used to map the vector for attention operation to the channel dimension of the head and map it back to the original channel dimension from the channel dimension of the head, where the attention coefficient A mqk and sampling offset Δp mqk The query feature sequence Q is mapped using a fully connected layer. The number of output channels of the fully connected layer is 3MK, where the first 2MK channels represent the sampling offset Δp of the two-dimensional reference point of each q vector. mqk , and finally, the MK channels are normalized by the softmax function to represent the attention coefficient of the q vector. Since the value of the sampling offset of the two-dimensional reference point is a fraction, the embodiment of the present application uses bilinear interpolation to calculate the specific value of the q vector corresponding to the sampling point in each channel.

[0130] Optionally, the method further includes:

[0131] performing normalization processing on the prediction result corresponding to the query image;

[0132] The prediction results with the top N largest category confidences are selected as the target detection results corresponding to the query image.

[0133] Specifically, the post-processing module in the visual Transformer model converts the output of the deformable decoder in the deformable Transformer module into a predicted bounding box and the corresponding predicted category and category confidence on the input image, where the input image includes the support image and the query image. The post-processing module of the visual Transformer model directly outputs the prediction result output by the deformable Transformer module, which includes the predicted bounding box, the corresponding category and the corresponding category confidence, or takes the top N prediction results as output. The post-processing module calculates the normalized confidence score of each predicted category, takes the top N largest predicted category confidence scores and the corresponding predicted bounding boxes as the final output of the visual Transformer model, and decodes the top N predicted bounding boxes from the range of [0, 1] to absolute values ​​relative to the size of the input image.

[0134] The target detection method provided in the embodiment of the present application uses noise data samples to pre-train the visual Transformer model, and uses new category data samples to fine-tune the visual Transformer model. Based on the visual Transformer model, a target detection method is constructed, and feature extraction is performed on the support image and the query image. Correlation aggregation operations, as well as self-attention operations and / or cross-attention operations are performed to determine the predicted bounding box, predicted category, and corresponding category confidence corresponding to the query image. Not only can efficient training and rapid convergence be performed on a large amount of public data, but the abstract meta-knowledge learned from a large amount of public data can also be transferred to downstream small sample fine-tuning tasks, thereby improving the precision and recall of downstream small sample new category target detection tasks.

[0135] The embodiment of the present application also provides a visual Transformer model, including a correlation aggregation module composed of a multi-head self-attention unit and a single-head self-attention unit;

[0136] The multi-head self-attention unit is used to map the support feature map sequence to a feature map of a specified size based on alignment of the region of interest, and determine the support category prototype;

[0137] The single-head self-attention unit is configured to determine a second query feature graph sequence based on the encoding and feature matching results between the query feature graph sequence and the support class prototypes. This second query feature graph sequence not only filters out query region vectors in the query feature graph sequence that are not related to the support class, but also eliminates dependence on specific support classes through the task encoding matrix, thereby achieving class-agnostic few-shot object detection based on meta-learning.

[0138] In addition, the visual Transformer model also includes a feature extraction module. This feature extraction module is built based on a convolutional neural network. It divides the input support image and query image into two branches and performs preliminary multi-scale feature map extraction. The multi-scale feature map extracted by the convolutional neural network corresponds to the number of channels in each layer from the shallowest to the deepest layer, and the number of channels in each layer is unequal. After each support image undergoes the above processing, multiple feature maps of different scales are obtained. Each feature map of different scales can be represented by a feature vector. All feature maps of different scales constitute a sequence, namely the support feature map sequence corresponding to the support image. Similarly, each query image can also obtain a corresponding query feature map sequence.

[0139] FIG9 is a schematic diagram of the structure of an object detection device provided in an embodiment of the present application. As shown in FIG9 , the device includes a correlation aggregation module 901 and a deformable transformer module 902, wherein:

[0140] A correlation aggregation module 901 is configured to determine a second query feature graph sequence based on the query feature graph sequence and the support feature graph sequence obtained by the visual Transformer model through correlation aggregation.

[0141] a deformable transformer module 902 for determining, based on the results of the self-attention operation and / or the cross-attention operation on the second query feature map sequence, a prediction result corresponding to the query image for obtaining the query feature map sequence; the prediction result comprising: a predicted bounding box, a predicted category, and a corresponding category confidence;

[0142] The visual Transformer model is pre-trained based on noise data samples and fine-tuned using new category data samples. The noise data samples are obtained by adding random noise to the original basic category samples.

[0143] Specifically, the above-mentioned target detection device provided in the embodiment of the present application can implement all the method steps implemented in the above-mentioned method embodiment, and can achieve the same technical effect. The parts and beneficial effects of this embodiment that are the same as those in the method embodiment will not be described in detail here.

[0144] FIG10 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application; as shown in FIG10 , the electronic device includes a processor 1010, a communication interface 1020, a memory 1030, and a communication bus 1040, wherein the processor 1010, the communication interface 1020, and the memory 1030 communicate with each other via the communication bus 1040. The processor 1010 can call the logic instructions in the memory 1030 to execute any of the target detection methods provided in the above embodiments, for example:

[0145] Determine a second query feature graph sequence based on the result of performing a correlation aggregation operation on the query feature graph sequence and the support feature graph sequence obtained by the visual Transformer model;

[0146] Determining, based on a result of a self-attention operation and / or a cross-attention operation on the second query feature map sequence, a prediction result corresponding to a query image for obtaining the query feature map sequence; the prediction result comprising: a predicted bounding box, a predicted category, and a corresponding category confidence;

[0147] The visual Transformer model is pre-trained based on noise data samples and fine-tuned using new category data samples. The noise data samples are obtained by adding random noise to the original basic category samples.

[0148] In addition, the logic instructions in the above-mentioned memory 1030 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when sold or used as an independent product. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0149] It should be noted here that the above-mentioned electronic device provided in the embodiment of the present application can implement all the method steps implemented in the above-mentioned method embodiment and can achieve the same technical effect. The parts and beneficial effects of this embodiment that are the same as those in the method embodiment will not be described in detail here.

[0150] On the other hand, an embodiment of the present application also provides a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium, and the computer program includes program instructions. When the program instructions are executed by a computer, the computer can execute the target detection method provided by the above embodiments.

[0151] On the other hand, an embodiment of the present application further provides a processor-readable storage medium, wherein the processor-readable storage medium stores a computer program, and the computer program is used to enable the processor to execute the target detection method provided by the above embodiments.

[0152] The processor-readable storage medium can be any available medium or data storage device that can be accessed by the processor, including but not limited to magnetic storage (such as floppy disks, hard disks, magnetic tapes, magneto-optical disks (MO)), optical storage (such as CDs, DVDs, BDs, HVDs, etc.), and semiconductor storage (such as ROMs, EPROMs, EEPROMs, non-volatile memories (NAND FLASH), solid-state drives (SSDs)), etc.

[0153] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, i.e., they may be located in one location or distributed across multiple network units. Some or all of the modules may be selected based on actual needs to achieve the objectives of the present embodiment. Persons of ordinary skill in the art will be able to understand and implement the present invention without inventive effort.

[0154] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus a necessary general hardware platform, or of course, by hardware. Based on this understanding, the essence of the above technical solution or the part that contributes to the existing technology can be embodied in the form of a software product. The computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a magnetic disk, an optical disk, etc., and includes a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or certain parts of the embodiments.

[0155] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. A target detection method, comprising: Determine a second query feature graph sequence based on the query feature graph sequence and the support feature graph sequence obtained by the visual Transformer model and the result of performing a correlation aggregation operation; Determine, based on the result of the self-attention operation and / or the cross-attention operation of the second query feature graph sequence, a prediction result corresponding to the query image for obtaining the query feature graph sequence; the prediction result includes: a prediction bounding box, a prediction category, and a corresponding category confidence; The visual Transformer model is pre-trained based on noise data samples and fine-tuned using new category data samples, wherein the noise data samples are obtained by adding random noise to the original basic category samples.

2. The target detection method according to claim 1, wherein: The noise data sample is obtained by adding random noise to the original basic category sample, and the method of adding random noise includes: Obtaining a bounding box and a category in the original base category sample as a first bounding box and a first category, respectively; Determine a noise center point corresponding to the center point of the first bounding box based on a random jitter result of the center point of the first bounding box; Determine a noise bounding box corresponding to the first bounding box based on a result of randomly scaling the width or height of the first bounding box; Based on the random flipping result of the first category, determining a noise category corresponding to the first category; The noise data sample is determined based on the original base category sample and any one or a combination of the noise center point, the noise bounding box and the noise category.

3. The target detection method according to claim 2, wherein: The visual Transformer model is pre-trained based on noise data samples and fine-tuned using new category data samples. The corresponding training methods include: Determining a loss function of the visual Transformer model based on a cross entropy loss function, a generalized intersection-over-union ratio, and a shallow feature score map loss function; adding an attention mask to a noise target query sequence determined by the noise data sample as a first target query sequence; The pre-training of the visual Transformer model is completed when the loss function is determined to be minimum based on the target query sequence determined by the anchor frame and the first target query sequence, as well as the true bounding box and the true category corresponding to the noise data sample; Based on the acquired new category data samples, the pre-trained visual Transformer model is fine-tuned.

4. The target detection method according to claim 1, wherein: The step of determining a second query feature graph sequence based on the query feature graph sequence and the support feature graph sequence obtained based on the visual Transformer model and performing a correlation aggregation operation includes: Receiving the supporting feature graph sequence input in a first input format and the query feature graph sequence input in a second input format; Extracting the category object instances contained in the supporting feature map sequence based on the region of interest alignment operator; Based on the global average pooling operator, each of the category objects is fused into the vector of the corresponding category to obtain the supporting category prototype; Based on the encoding matching result and feature matching result of the query feature graph sequence and the support category prototype, a second query feature graph sequence is determined.

5. The target detection method according to claim 4, wherein: The determining a second query feature graph sequence based on the encoding matching result and feature matching result of the query feature graph sequence and the supporting category prototype comprises: Based on the support type prototype and the background category prototype, determining a first parameter V and a second parameter K for feature matching in a single-head self-attention operation; Determine a first parameter V and a second parameter K for encoding matching in a single-head self-attention operation based on the support type prototype, the background category prototype and the task encoding matrix; Based on the query feature graph sequence, determine a third parameter Q for feature matching and encoding matching in the single-head self-attention operation; Based on the first parameter V, the second parameter K and the third parameter Q, code matching and feature matching are performed respectively, and the corresponding matching results are output as the second query feature graph sequence.

6. The target detection method according to claim 1, wherein: The step of determining a prediction result corresponding to a query image for obtaining the query feature graph sequence based on a result of a self-attention operation and / or a cross-attention operation of the second query feature graph sequence comprises: Determining an updated second query feature graph sequence based on a self-attention operation result of the second query feature graph sequence; Based on the self-attention operation and the cross-attention operation, the operation result between the target query sequence and the updated second query feature map sequence is determined as a prediction result corresponding to the query image for obtaining the query feature map sequence.

7. The target detection method according to claim 1, wherein: The visual Transformer model includes a correlation aggregation module consisting of a multi-head self-attention unit and a single-head self-attention unit; The multi-head self-attention unit is used to map the supporting feature map sequence to a feature map of a specified size based on alignment of the region of interest, and determine the supporting category prototype; The single-head self-attention unit is used to determine a second query feature graph sequence based on the encoding matching result and feature matching result of the query feature graph sequence and the support category prototype.

8. A target detection device, comprising: A correlation aggregation module, used to determine a second query feature graph sequence based on the query feature graph sequence obtained by the visual Transformer model and the result of correlation aggregation operation on the support feature graph sequence; A deformable transformer module, configured to determine a prediction result corresponding to a query image for obtaining the query feature map sequence based on a result of a self-attention operation and / or a cross-attention operation of the second query feature map sequence; the prediction result comprising: a prediction bounding box, a prediction category, and a corresponding category confidence; The visual Transformer model is pre-trained based on noise data samples and fine-tuned using new category data samples, wherein the noise data samples are obtained by adding random noise to the original basic category samples.

9. An electronic device comprising a memory, a transceiver, and a processor; wherein: Memory for storing computer programs; a transceiver, for transmitting and receiving data under the control of the processor; A processor is configured to read the computer program in the memory and perform the following operations: Determine a second query feature graph sequence based on the query feature graph sequence and the support feature graph sequence obtained by the visual Transformer model and the result of performing a correlation aggregation operation; Determine, based on the result of the self-attention operation and / or the cross-attention operation of the second query feature graph sequence, a prediction result corresponding to the query image for obtaining the query feature graph sequence; the prediction result includes: a prediction bounding box, a prediction category, and a corresponding category confidence; The visual Transformer model is pre-trained based on noise data samples and fine-tuned using new category data samples, wherein the noise data samples are obtained by adding random noise to the original basic category samples.

10. A computer-readable storage medium, wherein: The computer-readable storage medium stores a computer program, and the computer program is used to enable a computer to execute the target detection method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Target detection method and device, electronic equipment and computer readable storage medium

    CN113255719A

  • Defective spot identification method based on deep learning network

    CN113673594A

  • Target detection model training method, target detection method and related device

    CN114266945A

  • Transform-based slender object target detection method

    CN115546468A

  • Target detection method and device, equipment and storage medium

    CN115953665A

Cited By

  • Metal composite material lightning stroke ablation detection method

    CN119228792A

  • Few-sample semantic segmentation method based on image-text fusion

    CN119273914A

  • Visual prompt guided remote sensing image similar target detection method and device

    CN119360227A

  • Visual cue guided remote sensing image similar target detection method and device

    CN119360227B

  • Multi-mode unmanned aerial vehicle target detection framework based on scene language perception guidance

    CN119360243A