Model training and application method and device for target detection and storage medium

The target detection architecture that combines the DETR detector and the graphic pre-training model solves the problems of insufficient data and new category detection capabilities in the existing technology, and achieves high-performance target detection, which is suitable for monitoring scenarios.

CN118799608APending Publication Date: 2024-10-18CHINA MOBILE COMM LTD RES INST +1
View PDF 0 Cites 12 Cited by

Patent Information

Application Number
CN202311501535.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-11-10
Publication Date
2024-10-18

AI Technical Summary

Technical Problem

When existing target detection algorithms have insufficient training data or encounter new categories, it is difficult to obtain high-performance models, and they are not effectively compatible with target detection of new categories, resulting in limited recognition capabilities in actual scenarios.

Method used

Using a target detection architecture based on DETR detectors and graphic and text pre-training models, by acquiring multi-scale features, feature fusion, encoding and decoding, and combining location query information and text query information, the encoder and decoder are optimized to achieve model training and detection.

Benefits of technology

It improves the target detection performance of the model, shortens the training time, is compatible with new categories of target detection, meets the needs of monitoring scenarios, and enhances the robustness and adaptability of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118799608A_ABST
    Figure CN118799608A_ABST
Patent Text Reader

Abstract

The invention discloses a model training and application method and device for target detection and a storage medium. The model training method comprises the following steps: acquiring multi-scale features of a training image; performing feature fusion on the multi-scale features to obtain fused image features; encoding the fused image features based on an encoder to obtain feature encoding information; decoding the feature coding information based on a decoder and the query information to obtain a detection value of the training image; based on the detection value and the label value of the training image, optimizing an encoder and a decoder until a trained target detection model is obtained; wherein the query information comprises initialized position query information and text query information generated based on an image-text pre-training model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image monitoring, and in particular to a model training and application method, device and storage medium for target detection. Background Art

[0002] Object detection is the task of finding all the objects of interest in an image and determining their categories and locations. It is one of the core issues in the field of computer vision. Object detection has always been a challenging problem in the field of computer vision because various objects have different appearances, shapes, and postures, and are interfered by factors such as illumination and occlusion during imaging.

[0003] In the related technology, there are two types of classic target detection algorithms, namely the two-stage R-CNN series and the one-stage YOLO series.

[0004] The detection method based on the classic target detection algorithm mainly improves the Faster R-CNN, YOLO and other network models according to the actual scenarios and needs, and deploys them into the project to classify and detect images. In this process, if there are many bad cases due to the large gap between the test scenario and the training data, some bad cases can be collected, mixed with the previous training data, and fine-tuned on the previous model using a smaller learning rate.

[0005] However, the above solution still has the following defects: In classic classification tasks, in order to obtain a reliable classification model, the amount of data in the training set must be large enough to ensure that the model can learn the characteristics of the data itself. However, in actual scenarios, there may be only a few training samples, which are not enough to support the training of a high-performance model, and it is also possible to encounter categories that are not in the training set during the test process. For example, in the training set of chef hats, if there are only white chef hats, the model will learn the feature of white. If a red hat appears during the test, the model may not be able to recognize it. In response to the above defects, there is no effective solution to the relevant technology. Summary of the invention

[0006] In view of this, the embodiments of the present application provide a model training and application method, device and storage medium for target detection, aiming to improve the performance of target detection.

[0007] The technical solution of the embodiment of the present application is implemented as follows:

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

[0009] Obtain multi-scale features of training images;

[0010] Performing feature fusion on the multi-scale features to obtain fused image features;

[0011] Encoding the fused image features based on an encoder to obtain feature encoding information;

[0012] Decoding the feature encoding information based on a decoder and query information to obtain a detection value of the training image, wherein the query information includes: initialized position query information and text query information generated based on a graphic and text pre-training model;

[0013] Based on the detection value and the label value of the training image, the encoder and the decoder are optimized until a trained object detection model is obtained.

[0014] In the above scheme, the method further comprises:

[0015] The initialized position query information is generated based on the multi-scale features and the set detection frame size.

[0016] In the above scheme, the method further comprises:

[0017] The reference image and the text prompt word are input into the image-text pre-training model to obtain the text query information.

[0018] In the above scheme, the image-text pre-training model adopts a cross-modal deep fusion model based on an image encoder and a text encoder, and the method further includes:

[0019] The initial image-text pre-training model is trained based on a preset training set to obtain a trained image-text pre-training model.

[0020] In the above scheme, the method further comprises:

[0021] The initial reference image is subjected to mask processing based on the target object to obtain the reference image.

[0022] In the above solution, the step of fusing the multi-scale features to obtain fused image features includes:

[0023] The multi-scale features are fused based on a feature pyramid network to obtain fused image features.

[0024] In the above solution, decoding the feature encoding information based on the decoder and the query information to obtain the detection value of the training image includes:

[0025] The decoder uses a cross-attention mechanism to extract target features similar to the query information from the feature encoding information to obtain the detection value of the training image.

[0026] In a second aspect, an embodiment of the present application provides a target detection method, including:

[0027] The target detection model trained by the model training method described in the first aspect of the embodiment of the present application is used to detect the acquired image to be detected to obtain a target detection result.

[0028] In a third aspect, an embodiment of the present application provides a model training device for target detection, comprising:

[0029] A feature acquisition module, used to acquire multi-scale features of training images;

[0030] A feature fusion module, used to fuse the multi-scale features to obtain fused image features;

[0031] An encoding module, used for encoding the fused image features based on an encoder to obtain feature encoding information;

[0032] A decoding module, configured to decode the feature encoding information based on a decoder and query information to obtain a detection value of the training image, wherein the query information includes: initialized position query information and text query information generated based on a graphic-text pre-training model;

[0033] An optimization module is used to optimize the encoder and the decoder based on the detection value and the label value of the training image until a trained target detection model is obtained.

[0034] In a fourth aspect, an embodiment of the present application provides a target detection device, including:

[0035] The detection module is used to detect the acquired image to be detected using the target detection model trained by the model training device described in the third aspect of the embodiment of the present application to obtain the target detection result.

[0036] In a fifth aspect, an embodiment of the present application provides an electronic device, comprising: a processor and a memory for storing a computer program that can be run on the processor, wherein when the processor is used to run the computer program, the steps of the method described in any aspect of the embodiment of the present application are executed.

[0037] In a sixth aspect, an embodiment of the present application provides a computer storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the method described in any aspect of the embodiment of the present application are implemented.

[0038] The technical solution provided by the embodiment of the present application obtains multi-scale features of the training image; performs feature fusion on the multi-scale features to obtain fused image features; encodes the fused image features based on the encoder to obtain feature encoding information; decodes the feature encoding information based on the decoder and query information to obtain the detection value of the training image; optimizes the encoder and decoder based on the detection value and the label value of the training image until a trained target detection model is obtained; wherein the query information includes: initialized location query information and text query information generated based on the image and text pre-training model. Due to the introduction of location query information and text query information, the feature encoding information can be double-queried based on the decoder, which speeds up the model convergence speed, can effectively improve the target detection performance of the decoder, and can make the trained model compatible with new categories of target detection based on the text query information, so as to better meet the target detection needs in monitoring scenarios. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] Figure 1 This is a schematic diagram of the structure of the target detection architecture combining the DETR detector and the image and text pre-training model in an embodiment of the present application;

[0040] Figure 2 A flow chart of a model training method for target detection in an embodiment of the present application;

[0041] Figure 3 This is a schematic diagram of the structure of the target detection model in the application embodiment of this application;

[0042] Figure 4 This is a schematic diagram of the structure of the image and text pre-training model in the application embodiment of this application;

[0043] Figure 5 This is a schematic diagram of the structure of a model training device for target detection according to an embodiment of the present application;

[0044] Figure 6 This is a schematic diagram of the structure of the target detection device according to an embodiment of the present application;

[0045] Figure 7 It is a schematic diagram of the structure of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION

[0046] The present application is further described in detail below in conjunction with the accompanying drawings and embodiments.

[0047] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein in the specification of this application are only for the purpose of describing specific embodiments and are not intended to limit this application.

[0048] In related technologies, Ross Girshick et al. first proposed the R-CNN algorithm in 2014. The following year, Ross Girshick proposed Fast R-CNN. Subsequently, He Kaiming's team proposed Faster R-CNN based on this, which greatly improved the efficiency and accuracy of detection. The core idea of ​​the two-stage detection is to first obtain a large number of candidate regions, and then classify and regress the candidate regions.

[0049] Unlike the R-CNN series, the single-stage YOLO algorithm converts object detection into a regression problem. First, the image is divided into S*S grids, and each grid predicts the location information (x, y, w, h) and confidence of B bounding boxes. If the center of an object falls within a grid, this grid is responsible for predicting the object. Since Joseph Redmon et al. proposed YOLOv1 in 2015, the YOLO algorithm has been improved and enhanced several times, and has now been updated to YOLOv8.

[0050] Faster R-CNN and YOLO have their own advantages. Faster R-CNN has higher accuracy, but YOLO is faster. However, the above classic object detection algorithms are not scalable in terms of detectable categories. For example, the object detector trained on COCO can only detect 80 categories and cannot handle new categories beyond the training categories. If new categories need to be detected, it is necessary to collect training images of the new categories and add them to the original dataset, and then retrain or fine-tune the detection model. However, due to the high cost of data collection and model training, this is both impractical and inefficient.

[0051] Based on this, in various embodiments of the present application, a target detection architecture based on a combination of a DETR detector and a graphic pre-training model is adopted, which can be compatible with new categories of target detection and thus better meet the target detection needs in monitoring scenarios.

[0052] For example, Figure 1 The structure diagram of the target detection architecture is shown, wherein the DETR detector can be understood as a target detector based on the DETR algorithm, which is the abbreviation of DEtection Transformer, a relatively new target detection algorithm proposed by Facebook AI Research (FAIR), mainly used for target detection. The DETR detector includes a feature extraction network, a feature fusion network, an encoder and a decoder connected in sequence, and the image-text pre-training model is used to generate text query information based on reference images and / or text prompt words.

[0053] The embodiment of the present application provides a model training method based on the above-mentioned target detection architecture. The training method can be independently applied to electronic devices with data processing capabilities, such as terminal devices, servers, etc., or can be implemented by the cooperation between terminal devices and servers; wherein the terminal device can specifically be a computer, a smart phone, a personal digital assistant (PDA), etc.; the server can specifically be an application server or a Web server. In actual deployment, the server can be an independent server or a cluster server. Figure 2 As shown, the method includes:

[0054] Step 201, obtaining multi-scale features of a training image.

[0055] It can be understood that, for an input training image, the feature extraction network can perform feature extraction on the training image to obtain multi-scale features of the training image.

[0056] It should be noted that the embodiments of the present application can have the following benefits by obtaining multi-scale features of training images:

[0057] First, the target objects in the image may have different scales. If only fixed-scale features are used for segmentation, smaller target objects may be ignored or larger target objects may be segmented inaccurately. Based on this, by extracting multi-scale features of the training image, the image can be analyzed at different scales, thereby better capturing the scale changes of the target objects.

[0058] Secondly, the contextual information of the image is crucial for the segmentation task. For example, at a certain scale, a larger range of contextual information can be used to infer the position and boundary of the target object, while at another scale, the internal details and texture of the target object can be better captured. Therefore, multi-scale features can integrate contextual information at different scales to provide a more comprehensive feature expression.

[0059] Thirdly, due to the presence of noise, occlusion and other factors, image segmentation tasks are often difficult. By using multi-scale features, the impact of these noises and interferences can be effectively reduced and the robustness of the algorithm can be enhanced. For example, in some cases, larger-scale features can capture the overall shape and outline of the target, while smaller-scale features can provide more detailed local information, thereby further improving the accuracy of segmentation.

[0060] Step 202: perform feature fusion on the multi-scale features to obtain fused image features.

[0061] It can be understood that the feature fusion network can perform feature fusion on the multi-scale features of the training image to obtain fused image features.

[0062] Exemplarily, the feature fusion network can be a feature pyramid network (FPN), based on which multi-scale features are fused. It is possible to fuse feature maps with strong low-resolution semantic information and feature maps with weak high-resolution semantic information but rich spatial information with less increase in computational complexity, thereby better meeting fine-grained target detection tasks.

[0063] Step 203: Encode the fused image features based on the encoder to obtain feature encoding information.

[0064] Here, the encoder may be a Transformer Encoder, which is used to learn the fused image features to obtain feature encoding information.

[0065] It should be noted that Transformer is a sequence model based on self-attention mechanism and multi-attention mechanism, which was originally proposed by Google's research team and applied to machine translation tasks. Unlike traditional recurrent neural networks (RNN) and convolutional neural networks (CNN), Transformer introduces self-attention mechanism and multi-attention mechanism to process input sequences and output sequences, so that the neural network can better capture the long-range dependencies in the sequence, and can also perform parallel calculations, greatly improving the computational efficiency. Among them, Decoder is mainly used to generate output data based on the input vector. Its input data is the output data from the previous time step, so it can generate output data with contextual information; Encoder is mainly used to encode the input data into a high-dimensional vector. This vector contains all the information of the input data and can be used for subsequent task processing.

[0066] Step 204: decode the feature encoding information based on a decoder and query information to obtain a detection value of the training image, wherein the query information includes: initialized position query information and text query information generated based on a graphic and text pre-training model.

[0067] Here, the decoder can be a Transformer Decoder. The query information received by the decoder includes: the initialized position query information and the text query information generated based on the image-text pre-training model. The decoder continuously extracts features similar to the query information from the feature encoding information, and updates the detection box, and finally obtains a set of prediction boxes, and then decodes the prediction results of all objects in the training image at one time, that is, obtains the detection value of the training image. It can be understood that the detection value includes the target object corresponding to the prediction box and the position of the target object.

[0068] Step 205: Optimize the encoder and the decoder based on the detection value and the label value of the training image until a trained object detection model is obtained.

[0069] Exemplarily, bipartite graph matching can be performed based on the detection value and the label value (ground truth) of the training image, and the encoder and decoder are optimized by minimizing the matching loss until a trained object detection model is obtained.

[0070] It can be understood that the embodiment of the present application introduces location query information and text query information, and can then perform dual queries on feature encoding information based on the decoder, thereby accelerating the model convergence speed, effectively improving the target detection performance of the decoder, and making the trained model compatible with new categories of target detection based on text query information, thereby better meeting the target detection needs in monitoring scenarios.

[0071] Exemplarily, the method further includes:

[0072] The initialized position query information is generated based on the multi-scale features and the set detection frame size.

[0073] It should be noted that in the embodiment of the present application, the initialized location query information is not randomly set, but is generated based on the multi-scale features of the training image and the set detection frame size. In this way, the position prior parameters can be introduced to realize the local constraints of the position query, which is conducive to the convergence of the model.

[0074] Exemplarily, the method further includes:

[0075] The reference image and the text prompt word are input into the image-text pre-training model to obtain the text query information.

[0076] Here, the reference image can be understood as an image used to indicate the target object, and the text prompt word can be understood as a prompt word used to indicate the category to which the target object belongs. It should be noted that compared with the reference image, the semantics of the text prompt word is sparser, that is, it is difficult to describe some detailed information. Therefore, based on the combination of the reference image and the text prompt word, the text query information obtained can more comprehensively indicate the target object.

[0077] It should be noted that in the original DETR, the content information of the first decoder is initialized to 0, while the content information of the decoders in the following layers is derived from the output of the decoders in the previous layers; in addition, the position information is randomly initialized and continuously approaches the coordinates of the ground truth during the training process. In the embodiment of the present application, the text query information generated by the image and text pre-training model is deeply fused with the decoder embedding as context queries during cross-attention, so that the decoder can directly focus on the features similar to the target to be detected during the cross-attention process.

[0078] At the same time, the embodiment of the present application takes into account that the randomness of randomly initialized position queries is too large, and introduces explicit position priors to constrain queries on local areas. Exemplarily, the coordinates (x, y, w, h) of the dynamically updated anchor box (detection box) can be used as position query information. The center coordinates (x, y) of the anchor box come from each point on the feature map output by the feature extraction network, and (w, h) are used to dynamically adjust the size of the anchor box. The coordinates of the anchor box are further converted into sinusoidal position encoding, and positional queries are generated. In the multi-layer Decoder, (Δx, Δy, Δw, Δh) are continuously calculated to dynamically adjust the anchor box so that (x, y) gradually approaches the center position of the target, and (w, h) gradually approaches the size of the target.

[0079] Exemplarily, the image-text pre-training model adopts a cross-modal deep fusion model based on an image encoder and a text encoder, and the method further includes:

[0080] The initial image-text pre-training model is trained based on a preset training set to obtain a trained image-text pre-training model.

[0081] For example, the initial image-text pre-training model can be pre-trained on the COCO dataset to obtain a trained image-text pre-training model. COCO stands for Common Objects in Context, which originated from the Microsoft COCO dataset funded and annotated by Microsoft in 2014.

[0082] Exemplarily, the image encoder may adopt CNN, and the text encoder may adopt BERT (Bidirectional Encoder Representation from Transformers, a bidirectional semantic encoding representation model built based on transformer).

[0083] It should be noted that if the reference image adopts a complete initial image (for example, a rectangular image), unnecessary interference information may be introduced. Based on this, in some embodiments, the method also includes: performing mask processing on the initial reference image based on the target object to obtain the reference image.

[0084] Exemplarily, an embodiment of the present application determines the target area in an initial reference image by using a segmentation model, and masks the target area, and uses the masked image as a reference image, so that the features used for the query are completely derived from the target object, and the interference caused by the background part in the reference image can be completely eliminated.

[0085] Exemplarily, decoding the feature encoding information based on a decoder and query information to obtain a detection value of the training image includes:

[0086] The decoder uses a cross-attention mechanism to extract target features similar to the query information from the feature encoding information to obtain the detection value of the training image.

[0087] It is understandable that the query information received by the decoder includes: text query information and location query information. The decoder calculates the similarity measure between the query information and the features through the cross-attention mechanism, thereby collecting features from the feature map (i.e., feature encoding information) to obtain a set of prediction boxes, and then decodes the prediction results of all objects in the training image at one time, that is, obtains the detection value of the training image, and then matches the prediction box with the ground truth through the Hungarian algorithm and calculates the loss value of the loss function. The encoder and decoder are updated based on the loss value until a trained target detection model is obtained. Among them, the similarity measure takes into account the information of both content and location dimensions at the same time, that is, the similarity measure is determined based on the weighted results of content similarity and location similarity. Content similarity is used to collect semantically related features, and location similarity is used to provide location constraints around the query location.

[0088] The embodiment of the present application also provides a target detection method, which uses the target detection model trained by the model training method described above in the embodiment of the present application to detect the acquired image to be detected to obtain a target detection result.

[0089] It can be understood that in actual applications, the reference image and / or text prompt words of the target object to be detected are input into the image-text pre-training model to obtain text query information. The decoder in the target detection model can decode the feature coding information of the image to be detected based on the initialized position query information and text query information of the image to be detected, and detect the label and bounding box of the target from the image to be detected, thereby realizing the detection of the category and position of the target object.

[0090] The present application is further described in detail below in conjunction with an application example.

[0091] Figure 3 The schematic diagram of the structure of the target detection model of the present application embodiment is shown. Exemplarily, for a training image (Image), ResNet50 is first used as the Backbone (backbone network) to extract the multi-scale features of the image, and then an FPN is used for feature fusion. The fused features are input into an encoder (Encoder) to obtain refined CNN features and passed into a decoder (Decoder). Double queries are input into the decoder, which are positional queries (i.e., position query information) initialized with anchors (anchor points) and context queries (i.e., text query information) initialized with features from reference images (Masked Image) and text prompt words (Text). The decoder continuously extracts features similar to queries from the original training image, updates the detection box at the same time, and finally obtains a set of prediction boxes. A binary match is made between the prediction results (predictions) and the true value (annotations), and the model is optimized by minimizing the matching loss.

[0092] In a multi-layer convolutional network, the deep feature map has a wider receptive field and richer semantic information, thus losing a lot of detail information. If only the feature map obtained by the last layer of convolution is used, good detection performance for small targets cannot be achieved. Considering the detection items in monitoring scenarios, the target object often only occupies a small area in the image, and more detail information needs to be retained. Based on this, in the application embodiment of the present application, the backbone network adopts a ResNet50 network based on a feature pyramid, and the feature maps of the three scales obtained from the C3 to C5 stages of ResNet are input into a feature pyramid network (FPN) for feature fusion, so as to obtain a feature map containing rich detail information, which is suitable for fine-grained detection tasks.

[0093] like Figure 3As shown, the image-text pre-training model in this application embodiment adopts Image-Text Deep Fusion Pre-Training Module (image-text deep fusion pre-training model). Figure 4 A structural schematic diagram of the image-text pre-training model is shown.

[0094] For example, a category name or phrase can be used as a text prompt word. For example, when detecting a hat, the category name "hat" can be put into a template "this is a photo of{}", and then passed into the image-text pre-training model to obtain its corresponding text encoding information. However, compared with images, the semantics of text prompt words are sparser and it is difficult to describe some detailed information. For example, when it is necessary to detect a hat with a specific texture, it is difficult to clearly describe the characteristics of the hat using text, while using images as prompt words can greatly improve the detection accuracy.

[0095] In the related art, the image prompt word generally uses a complete rectangular picture. At this time, there is a problem: in the rich information contained in the reference image, is there any interference information that you don’t want to introduce? In order to reduce this interference information, in this application embodiment, the original image can be properly cropped to ensure that the target object occupies a large area in the center of the image. However, even so, the reference image after cropping still contains some background, which will still introduce unnecessary interference and affect the experimental performance. Based on this, in this application embodiment, a segmentation model is used to generate a mask for the target area, and the masked image is used as the reference image (i.e., the image prompt word), so that the features used for the query are completely from the target object, so as to completely eliminate the interference caused by the background part in the reference image.

[0096] like Figure 4 As shown, in this application embodiment, CNN is used as the image encoder to extract masked image features, and BERT is used as the text encoder to extract text features consisting of class names and templates. Then, the two features are deeply fused across modalities. Finally, the image encoder and text encoder are jointly trained by calculating the matching matrix of the image and text, maximizing the elements on the diagonal, and minimizing the elements at other positions.

[0097] In this application embodiment, the image-text pre-training model may include multiple cross-modal deep feature fusion modules, each of which is Figure 4 As shown in the dotted box in the figure, the image features I extracted by the image encoder i ∈R w×h×c After global pooling, it becomes a 1×c-dimensional vector, which is combined with the text feature T extracted by the text encoder. i ∈R 1×dThe spliced ​​features are combined with an MLP (multi-layer perceptron) to obtain image features. Then it is fed into the next image encoder module, or it is passed through a 1×1 convolution to obtain text features. Then it is fed into the next text encoder module. It can be expressed as follows:

[0098]

[0099]

[0100]

[0101] Among them, IE stands for Image Encoder, and TE stands for Text Encoder.

[0102] It should be noted that the pre-trained model for deep fusion of images and text in this application embodiment can be trained in advance on the COCO dataset.

[0103] It should be noted that DETR is a method that treats object detection as a set prediction problem. The feature map obtained by CNN and Encoder is input into the Decoder, and the learnable object query is input into the Decoder. The decoder predicts the coordinates of the box on the feature map based on the object query, obtains a set of predicted boxes, and then matches the predicted boxes with the ground truth through the Hungarian algorithm and calculates the loss function.

[0104] In this application embodiment, each query received by the decoder mainly includes two parts: content information (decoderembedding) and location information (learnable location query). The decoder calculates the similarity measure from the query to the feature through cross-attention, thereby collecting features from the feature map. The similarity measure takes into account both content and location information, where content similarity is to collect semantically related features, and location similarity is to provide location constraints around the query location. In this way, the features of the deep fusion of the image and text from the prompt are fused with the Decoder embedding as context queries during cross-attention, so that the decoder can directly focus on features similar to the target to be detected during the cross-attention process.

[0105] At the same time, considering that the randomly initialized position query is too random, this application embodiment introduces an explicit position prior to constrain the query on the local area, that is, the coordinates (x, y, w, h) of the dynamically updated anchor box are used as the position query. Among them, the center coordinates (x, y) of the anchor box come from each point on the feature map output by the ResNet C5 stage, and (w, h) are used to dynamically adjust the size of the box. The coordinates of the anchor box can be converted into sinusoidal position encoding, and positional queries are generated. In the multi-layer Decoder, (Δx, Δy, Δw, Δh) are continuously calculated to dynamically adjust the anchor box so that (x, y) gradually approaches the center position of the target, and (w, h) gradually approaches the size of the target.

[0106] Exemplarily, M context queries that integrate features from the prompt and N positional queries initialized with anchorbox coordinates can be obtained, the context queries are copied N times, and the positional queries are copied M times and then added together to obtain the final query and input into the Decoder. The Decoder uses a cross-attention mechanism to extract target features similar to the query information from the feature encoding information of the image to obtain the detection value of the image.

[0107] In the related art, when fine-tuning using badcases, since the number of badcases is often far less than the original training data, the features learned from the badcases are likely to be overwritten by the features learned from the original training set, resulting in the model still being unable to learn the required features after fine-tuning with the addition of badcases.

[0108] In this application embodiment, for bad cases encountered during the actual test process, the fine-tuning method of adding the bad cases to the training set can be avoided, but the bad cases and their text descriptions can be directly used as prompt word recall targets. In this way, the bad cases can be used to improve the recall rate.

[0109] In order to implement the method of the embodiment of the present application, the embodiment of the present application also provides a model training device for target detection, which corresponds to the above-mentioned model training method for target detection, and each step in the above-mentioned model training method embodiment for target detection is also fully applicable to the embodiment of the model training device for target detection.

[0110] like Figure 5As shown, the model training device for target detection includes: a feature acquisition module 501, a feature fusion module 502, an encoding module 503, a decoding module 504 and an optimization module 505. The feature acquisition module 501 is used to acquire multi-scale features of the training image; the feature fusion module 502 is used to perform feature fusion on the multi-scale features to obtain fused image features; the encoding module 503 is used to encode the fused image features based on the encoder to obtain feature encoding information; the decoding module 504 is used to decode the feature encoding information based on the decoder and query information to obtain the detection value of the training image, wherein the query information includes: initialized position query information and text query information generated based on the image-text pre-training model; the optimization module 505 is used to optimize the encoder and the decoder based on the detection value and the label value of the training image until a trained target detection model is obtained.

[0111] Exemplarily, the model training device for target detection also includes: a first generation module 506, which is used to generate the initialized position query information based on the multi-scale features and the set detection frame size.

[0112] Exemplarily, the model training device for target detection further includes: a second generation module 507, which is used to input a reference image and a text prompt word into the image-text pre-training model to obtain the text query information.

[0113] Exemplarily, the image-text pre-training model adopts a cross-modal deep fusion model based on an image encoder and a text encoder, and the second generation module 507 is also used to: train the initial image-text pre-training model based on a preset training set to obtain a trained image-text pre-training model.

[0114] Exemplarily, the second generating module 507 is further configured to: perform mask processing on the initial reference image based on the target object to obtain the reference image.

[0115] Exemplarily, the feature fusion module 502 is specifically used for:

[0116] The multi-scale features are fused based on a feature pyramid network to obtain fused image features.

[0117] Exemplarily, the decoding module 504 is specifically used for:

[0118] The decoder uses a cross-attention mechanism to extract target features similar to the query information from the feature encoding information to obtain the detection value of the training image.

[0119] In actual application, the feature acquisition module 501, the feature fusion module 502, the encoding module 503, the decoding module 504, the optimization module 505, the first generation module 506 and the second generation module 507 can be implemented by a processor in the electronic device. Of course, the processor needs to run the computer program in the memory to realize its function.

[0120] It should be noted that: the model training device provided in the above embodiment only uses the division of the above program modules as an example when performing model training. In actual applications, the above processing can be assigned to different program modules as needed, that is, the internal structure of the device is divided into different program modules to complete all or part of the processing described above. In addition, the model training device provided in the above embodiment belongs to the same concept as the model training method embodiment. The specific implementation process is detailed in the method embodiment and will not be repeated here.

[0121] In order to implement the method of the embodiment of the present invention, the embodiment of the present invention further provides a target detection device, which corresponds to the above-mentioned target detection method, and each step in the above-mentioned target detection method embodiment is also fully applicable to the present target detection device embodiment.

[0122] like Figure 6 As shown, the target detection device includes: a detection module 601, which is used to detect the acquired image to be detected using the target detection model trained by the model training device described in the embodiment of the present application to obtain a target detection result.

[0123] Based on the hardware implementation of the above program modules and in order to implement the method of the embodiment of the present application, the embodiment of the present application also provides an electronic device. Figure 7 Only an exemplary structure of the electronic device is shown, not all structures, and can be implemented as needed. Figure 7 Partial or complete structure shown.

[0124] like Figure 7 As shown, the electronic device 700 provided in the embodiment of the present application includes: at least one processor 701, a memory 702, a user interface 703 and at least one network interface 704. The various components in the electronic device 700 are coupled together through a bus system 705. It can be understood that the bus system 705 is used to realize the connection and communication between these components. In addition to the data bus, the bus system 705 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, in Figure 7 Various buses are labeled as bus system 705.

[0125] The user interface 703 may include a display, a keyboard, a mouse, a trackball, a click wheel, keys, buttons, a touch pad or a touch screen.

[0126] The memory 702 in the embodiment of the present application is used to store various types of data to support the operation of the electronic device. Examples of such data include: any computer program used to operate on the electronic device.

[0127] The model training method or target detection method disclosed in the embodiment of the present application can be applied to the processor 701, or implemented by the processor 701. The processor 701 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the model training method or target detection method can be completed by the hardware integrated logic circuit or software instructions in the processor 701. The above-mentioned processor 701 may be a general-purpose processor, a digital signal processor (DSP, Digital Signal Processor), or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The processor 701 can implement or execute the various methods, steps and logic block diagrams disclosed in the embodiment of the present application. The general-purpose processor may be a microprocessor or any conventional processor, etc. In combination with the steps of the method disclosed in the embodiment of the present application, it can be directly embodied as a hardware decoding processor to execute, or it can be executed by a combination of hardware and software modules in the decoding processor. The software module may be located in a storage medium, which is located in the memory 702, and the processor 701 reads the information in the memory 702, and completes the steps of the model training method and / or target detection method provided in the embodiment of the present application in combination with its hardware.

[0128] In an exemplary embodiment, the electronic device may be implemented by one or more application specific integrated circuits (ASIC), DSP, programmable logic device (PLD), complex programmable logic device (CPLD), field programmable gate array (FPGA), general processor, controller, microcontroller (MCU), microprocessor, or other electronic components to execute the aforementioned method.

[0129] It can be understood that the memory 702 can be a volatile memory or a non-volatile memory, and can also include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a magnetic random access memory (FRAM), a flash memory, a magnetic surface memory, an optical disk, or a compact disc read-only memory (CD-ROM); the magnetic surface memory can be a disk memory or a tape memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), synchronous static random access memory (SSRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), and direct rambus random access memory (DRRAM).The memories described in the embodiments of the present application are intended to include, but are not limited to, these and any other suitable types of memories.

[0130] In an exemplary embodiment, the present application also provides a computer storage medium, which can be a computer-readable storage medium, for example, a memory 702 storing a computer program, and the computer program can be executed by a processor 701 of an electronic device to complete the steps described in the method of the present application embodiment. The computer-readable storage medium can be a memory such as a ROM, a PROM, an EPROM, an EEPROM, a Flash Memory, a magnetic surface memory, an optical disk, or a CD-ROM.

[0131] It should be noted that: "first", "second", etc. are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.

[0132] In addition, the technical solutions described in the embodiments of the present application can be combined arbitrarily without conflict.

[0133] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A model training method for target detection, characterized in that: include: Obtain multi-scale features of training images; Performing feature fusion on the multi-scale features to obtain fused image features; Encoding the fused image features based on an encoder to obtain feature encoding information; Decoding the feature encoding information based on a decoder and query information to obtain a detection value of the training image, wherein the query information includes: initialized position query information and text query information generated based on a graphic and text pre-training model; Based on the detection value and the label value of the training image, the encoder and the decoder are optimized until a trained object detection model is obtained.

2. The method according to claim 1, characterized in that The method further comprises: The initialized position query information is generated based on the multi-scale features and the set detection frame size.

3. The method according to claim 1, characterized in that The method further comprises: The reference image and the text prompt word are input into the image-text pre-training model to obtain the text query information.

4. The method according to claim 3, characterized in that The image-text pre-training model adopts a cross-modal deep fusion model based on an image encoder and a text encoder, and the method further includes: The initial image-text pre-training model is trained based on a preset training set to obtain a trained image-text pre-training model.

5. The method according to claim 3, characterized in that: The method further comprises: The initial reference image is subjected to mask processing based on the target object to obtain the reference image.

6. The method according to claim 1, characterized in that The step of fusing the multi-scale features to obtain fused image features includes: The multi-scale features are fused based on a feature pyramid network to obtain fused image features.

7. The method according to claim 1, characterized in that The decoding of the feature encoding information based on the decoder and the query information to obtain the detection value of the training image includes: The decoder uses a cross-attention mechanism to extract target features similar to the query information from the feature encoding information to obtain the detection value of the training image.

8. A target detection method, characterized in that: include: The target detection model trained by the model training method according to any one of claims 1 to 7 is used to detect the acquired image to be detected to obtain a target detection result.

9. A model training device for target detection, characterized in that: include: A feature acquisition module, used to acquire multi-scale features of training images; A feature fusion module, used to fuse the multi-scale features to obtain fused image features; An encoding module, used for encoding the fused image features based on an encoder to obtain feature encoding information; A decoding module, used to decode the feature encoding information based on a decoder and query information to obtain a detection value of the training image, wherein the query information includes: initialized position query information and text query information generated based on a graphic and text pre-training model; An optimization module is used to optimize the encoder and the decoder based on the detection value and the label value of the training image until a trained target detection model is obtained.

10. A target detection device, characterized in that: include: The detection module is used to detect the acquired image to be detected using the target detection model trained by the model training device as described in claim 9 to obtain the target detection result.

11. An electronic device, characterized in that: include: A processor and a memory for storing a computer program that can be executed on the processor, wherein: The processor is used to execute the steps of the method according to any one of claims 1 to 8 when running a computer program.

12. A computer storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 8 are implemented.

Citation Information

Cited By

  • Model training method and device, text detection method and device, medium and program product

    CN119418319A

  • Textbook schematic diagram structured information analysis method and system and storage medium

    CN119513267A

  • A textbook schematic diagram structured information parsing method and system and a storage medium

    CN119513267B

  • Image understanding method and device, equipment and storage medium

    CN119579867A

  • Target key point detection model training method, target key point detection method, target key point detection equipment and medium

    CN119579869A