Model training method and device, identification method and device, equipment, storage medium and computer program product

Through the fusion processing of image and text features and the combination of cross-modal attention modules, the problem of poor generalization ability of the open vocabulary target detection network in the existing technology is solved, and the reliability of the recognition results is improved.

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

Patent Information

Application Number
CN202410281894.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-03-12
Publication Date
2024-10-18

AI Technical Summary

Technical Problem

When the existing open vocabulary target detection scheme has a large data style difference between image modality and text modality, the network generalization ability is poor, resulting in large errors in the output results.

Method used

A model training method is adopted. By obtaining image sample data and corresponding text labels, model training is performed on the model to be trained. The fusion processing network is used to fuse text features and image features. The visual backbone network and the text backbone network are combined to set up a cross-model Stateful multi-head attention module and group hybrid attention mechanism improve the generalization ability of the model.

Benefits of technology

It improves the generalization ability of the network, ensures the reliability of the output results, and can more accurately identify and detect unknown object categories.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118799674A_ABST
    Figure CN118799674A_ABST
Patent Text Reader

Abstract

The invention discloses a model training method. The method comprises the steps of obtaining to-be-trained sample data; wherein the to-be-trained sample data comprises image sample data and a text label corresponding to the image sample data; performing model training on a to-be-trained model by adopting the to-be-trained sample data until a trained object recognition model is obtained; wherein the to-be-trained model at least comprises a fusion processing network for performing text feature and image feature fusion processing on the to-be-trained sample data, and a visual backbone network for performing visual analysis on the to-be-trained sample data, and the text backbone network is used for performing text analysis on the to-be-trained sample data and an output result of the fusion processing network. The invention further discloses an identification method and device, equipment, a storage medium and a computer program product.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a model training method, recognition method, device, equipment, storage medium and computer program product. Background Art

[0002] As computer technology becomes increasingly mature, its application is becoming more and more extensive. In the process of computer technology application, a large amount of data of various types is usually generated. How to analyze and utilize these data has become a current research topic. For example, for image processing, it is currently proposed to cover more target detection categories with the help of a large amount of image text data, so that target detection is no longer limited to a few categories of data with annotations, that is, with real bounding box labels, thereby achieving more generalized target detection and identifying more unknown object categories of open vocabulary target detection (Open-Vocabulary Object Detection, OVD), that is, training on the visible class (Base Class) data, and then completing the recognition and detection of the unseen class (Unseen / Target Class) data to obtain the final result. One of the implementation algorithms of the open vocabulary target detection scheme currently proposed is the Grounded Language-Image Pre-training (GLIP) model, which implements the visual localization (grounding) task, that is, inputting pictures and corresponding object descriptions, outputting object descriptions, and realizing fine-grained cross-modal alignment.

[0003] However, in the above implementation process, an image encoder is used to encode the image, and a text encoder is used to encode the text. There is no correlation between the two image modalities and the text modality. As a result, when the data style difference between the image modality and the text modality is large, the generalization ability of the network of the above implementation method is poor, and the final output result has a large error.

[0004] Application Contents

[0005] In order to solve the above technical problems, the present application hopes to provide a model training method, recognition method, device, equipment, storage medium and computer program product, and proposes an open vocabulary target detection scheme to improve the generalization ability of the network and ensure the reliability of the output results.

[0006] The technical solution of this application is implemented as follows:

[0007] The present application provides a model training method, the method comprising:

[0008] Acquire sample data to be trained; wherein the sample data to be trained includes image sample data and text labels corresponding to the image sample data;

[0009] The model to be trained is trained using the sample data to be trained until a trained object recognition model is obtained; wherein the model to be trained at least includes: a fusion processing network that fuses text features and image features of the sample data to be trained, a visual backbone network that performs visual analysis on the sample data to be trained, and a text backbone network that performs text analysis on the sample data to be trained and the output results of the fusion processing network.

[0010] In the above solution, the step of obtaining sample data to be trained includes:

[0011] acquiring a first image;

[0012] Detecting a target object included in the first image, determining an image region including at least one of the target objects, and obtaining the image sample data;

[0013] Determine the text label set for the first image; wherein the sample data to be trained includes the image sample data and the text label.

[0014] In the above solution, the step of using the sample data to be trained to perform model training on the model to be trained includes:

[0015] Inputting the image sample data into the visual backbone network to obtain image analysis results;

[0016] Obtaining a first image feature parameter outputted after the encoding module in the visual backbone network performs encoding processing on the image sample data;

[0017] Inputting the first image feature parameter and the text label into the fusion processing network to obtain a first text feature parameter;

[0018] Inputting the first text feature parameter into the text backbone network to obtain a text analysis result;

[0019] Obtaining a prediction result based on the text analysis result and the image analysis result;

[0020] Based on the prediction results, the variable parameters in the visual backbone network, the text backbone network and the fusion processing network are adjusted to obtain a trained model to be trained.

[0021] In the above solution, the inputting of the first image feature parameter and the text label into the fusion processing network to obtain the first text feature parameter includes:

[0022] Connecting at least one tag included in the text tags by using a preset connection symbol to obtain a phrase to be analyzed;

[0023] Processing the first image feature data through the global attention pooling layer set by the fusion processing network to obtain a second image feature parameter;

[0024] The first text feature parameter is generated based on the phrase to be analyzed and the second image feature parameter.

[0025] In the above solution, the step of generating the first text feature parameter based on the phrase to be analyzed and the second image feature parameter includes:

[0026] splicing the phrase to be analyzed with the adjustable learning text feature parameters to obtain the text parameters to be analyzed;

[0027] Processing the second image feature parameter by a language prompt word generator to obtain a condition clue parameter;

[0028] The text parameter to be analyzed and the condition clue parameter are added to obtain the text analysis feature.

[0029] In the above solution, obtaining a prediction result based on the text analysis result and the image analysis result includes:

[0030] Determining a similarity parameter between the text analysis result and the image analysis result;

[0031] A prediction result is determined based on the similarity parameter.

[0032] In the above scheme, a cross-modal multi-head attention module is arranged between each image encoding layer of the visual backbone network and the corresponding text encoding layer of the text backbone network.

[0033] In the above scheme, the method comprises:

[0034] Input the i-th image feature output of the i-th image coding layer and the i-th text feature output of the corresponding i-th text coding layer into the cross-modal multi-head attention module to obtain the i-th attention output; wherein i=0,1,2...,n, n is the number of image coding layers included in the visual backbone network;

[0035] Determine the addition of the i-th attention output and the i-th image feature output to obtain the i+1-th image feature input;

[0036] Determine the addition of the i-th attention output and the i-th text feature output to obtain the i+1-th text feature input;

[0037] Inputting the i+1th image feature into the i+1th image coding layer;

[0038] The i+1th text feature is input to the i+1th text encoding layer.

[0039] In the above scheme, the attention mechanism set in the visual backbone network is group mixed attention.

[0040] The present application provides an identification method, the method comprising:

[0041] Get the object to be identified;

[0042] Recognition is performed using a trained object recognition model to obtain a recognition result; wherein the object recognition model can be obtained by training using any of the model training methods described above.

[0043] The present application provides a model training device, the device comprising: a first acquisition unit and a model training unit; wherein:

[0044] The first acquisition unit is used to acquire sample data to be trained; wherein the sample data to be trained includes image sample data and text labels corresponding to the image sample data;

[0045] The model training unit is used to use the sample data to be trained to perform model training on the model to be trained until a trained object recognition model is obtained; wherein the model to be trained at least includes: a fusion processing network that fuses text features and image features of the sample data to be trained, a visual backbone network that performs visual analysis on the sample data to be trained, and a text backbone network that performs text analysis on the sample data to be trained and the output results of the fusion processing network.

[0046] The present application provides an identification device, the device comprising: a second acquisition unit and an identification unit; wherein:

[0047] The second acquisition unit is used to acquire the object to be identified;

[0048] The recognition unit is used to perform recognition through a trained object recognition model to obtain a recognition result; wherein the object recognition model can be trained through the model training device described above.

[0049] The present application provides a model training device, the device comprising at least: a first memory, a first processor and a first communication bus; wherein:

[0050] The first memory is used to store executable instructions;

[0051] The first communication bus is used to implement a communication connection between the first processor and the first memory;

[0052] The first processor is used to execute the model training program stored in the first memory to implement the steps of the model training method as described in any one of the above items.

[0053] The present application provides an identification device, the device comprising at least: a second memory, a second processor and a second communication bus; wherein:

[0054] The second memory is used to store executable instructions;

[0055] The second communication bus is used to realize the communication connection between the second processor and the second memory;

[0056] The second processor is used to execute the recognition program stored in the second memory to implement the steps of the recognition method as described above.

[0057] The present application provides a storage medium, on which a model training program is stored, and when the model training program is executed, it is used to implement the steps of the model training method as described in any one of the above items, or on which a recognition program is stored, and when the recognition program is executed, it is used to implement the steps of the recognition method as described in any one of the above items.

[0058] The present application provides a computer program product, comprising a computer program, wherein the computer program implements the steps of any of the above methods when executed by a processor.

[0059] The embodiment of the present application provides a model training method, a recognition method, an apparatus, a device, a storage medium and a computer program product. After the model training device obtains the sample data to be trained, the model to be trained is trained using the sample data to be trained until a trained object recognition model is obtained. Then, after the recognition device obtains the object to be recognized, the trained object recognition model is used to recognize the object to be recognized and obtain a recognition result. In this way, by training the model to be trained of the fusion processing network that has text features and image features for fusion processing, the visual backbone network that performs visual analysis and the text backbone network that performs text analysis, a trained object recognition model is obtained, and the comprehensive consideration of the text features and image features of the sample for recognition is realized, which solves the problem that the generalization ability of the implementation network of the current open vocabulary target detection scheme caused by the input sample is poor, and an open vocabulary target detection scheme is proposed, which improves the generalization ability of the network and ensures the reliability of the output results. BRIEF DESCRIPTION OF THE DRAWINGS

[0060] Figure 1 A schematic diagram of a model training method provided in an embodiment of the present application Figure 1 ;

[0061] Figure 2A schematic diagram of a model training method provided in an embodiment of the present application Figure 2 ;

[0062] Figure 3 A schematic diagram of a model training method provided in an embodiment of the present application Figure 3 ;

[0063] Figure 4 A schematic diagram of the structure of a model to be trained provided in an embodiment of the present application;

[0064] Figure 5 A structural diagram of a language prompt module provided in an embodiment of the present application;

[0065] Figure 6 A flowchart of an identification method provided in an embodiment of the present application;

[0066] Figure 7 A schematic diagram of the structure of a model training device provided in an embodiment of the present application;

[0067] Figure 8 A schematic diagram of the structure of an identification device provided in an embodiment of the present application;

[0068] Fig. 9 A schematic diagram of the structure of a model training device provided in an embodiment of the present application;

[0069] Fig.10 A schematic diagram of the structure of an identification device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0070] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application.

[0071] The embodiment of the present application provides a model training method, referring to Figure 1 As shown, the method is applied to a model training device, and the method comprises the following steps:

[0072] Step 101: Obtain sample data to be trained.

[0073] The sample data to be trained includes image sample data and text labels corresponding to the image sample data.

[0074] In an embodiment of the present application, a model training device obtains sample data to be trained from a training sample database, wherein the image sample data included in the sample data to be trained is composed of a partial local image in a target image sample, and may include one or more local images in the target image sample. Correspondingly, the text label corresponding to the image sample data is determined for the target image sample, and may be set by the user in advance according to the target image sample.

[0075] Step 102: Use the sample data to be trained to perform model training on the model to be trained until a trained object recognition model is obtained.

[0076] Among them, the model to be trained includes at least: a fusion processing network that fuses text features and image features of training sample data, a visual backbone network that performs visual analysis on the training sample data, and a text backbone network that performs text analysis on the training sample data and the output results of the fusion processing network.

[0077] In an embodiment of the present application, the model to be trained is used to implement at least the following process: input the sample data to be trained into the visual backbone network of visual analysis to obtain the image analysis result, input the sample data to be trained and the processed intermediate image features of the visual backbone network of visual analysis into the fusion processing network to obtain the text features, and then use the text backbone network to predict the text features including the fused image feature output to obtain the text analysis result, and determine the final prediction result based on the text analysis result and the image analysis result. In this way, the model training method is adopted, and the sample data to be trained is used to train the model to be trained until a trained object recognition model is obtained. Among them, the fusion processing network is a network for preprocessing the image sample data in the sample data to be trained in the visual backbone network.

[0078] The model training method provided in the embodiment of the present application, after obtaining the sample data to be trained through the model training device, uses the sample data to be trained to train the model to be trained until a trained object recognition model is obtained. In this way, by training the model to be trained of the fusion processing network with text features and image features, the visual backbone network for visual analysis, and the text backbone network for text analysis, a trained object recognition model is obtained, and the comprehensive consideration of the text features and image features of the sample is realized. The problem that the generalization ability of the implementation network of the current open vocabulary target detection scheme caused by the input sample is poor is solved, and an open vocabulary target detection scheme is proposed, which improves the generalization ability of the network and ensures the reliability of the output results.

[0079] Based on the foregoing embodiments, an embodiment of the present application provides a model training method, which is applied to a model training device and includes the following steps:

[0080] Step 201: Acquire a first image.

[0081] In an embodiment of the present application, the model training device obtains the first image from the sample database. The model training device obtains the first image from the sample database in a random manner. The model training device is a device with computing capabilities, such as a server device, a desktop computer, or a laptop computer.

[0082] Step 202: Detect target objects included in the first image, determine an image region including at least one target object, and obtain image sample data.

[0083] In an embodiment of the present application, the target object is a recognition and analysis object pre-set when recognizing an image, and may be any one or more recognizable image contents included in the image. The model training device performs image detection on the first image, determines the target object included in the first image, determines the image area where each target object is located from the first image, and obtains image sample data.

[0084] Step 203: Determine a text label set for the first image.

[0085] The sample data to be trained includes image sample data and text labels.

[0086] In the embodiment of the present application, the text label set for the first image may be pre-set, or may be a text label obtained by performing image content recognition on the first image to obtain the image content name.

[0087] Step 204: Use the sample data to be trained to perform model training on the model to be trained until a trained object recognition model is obtained.

[0088] The model to be trained includes at least: a fusion processing network for fusing text features and image features of training sample data, a visual backbone network for visual analysis of training sample data, and a text backbone network for text analysis of training sample data and output results of the fusion processing network. The attention mechanism set in the visual backbone network is group mixed attention.

[0089] In an embodiment of the present application, after the sample data to be trained is input into the model to be trained, a prediction result is obtained; a predetermined loss function is used to calculate the loss value corresponding to the sample data to be trained; if the loss value is within the prediction threshold range, the model to be trained is determined to be a trained object recognition model; if the loss value exceeds the prediction threshold range, the adjustable parameters in the model to be trained are adjusted according to the loss value to obtain the model to be trained after the parameters are updated, and the model to be trained is updated to the model to be trained after the parameters are updated, and then the model training device repeats steps 201 to 204 of "using the sample data to be trained to perform model training on the model to be trained" until an object recognition model with a loss value within the preset threshold range is determined.

[0090] Based on the above embodiments, in other embodiments of the present application, the "using the to-be-trained sample data to perform model training on the to-be-trained model" in step 204 can be implemented by steps 204a to 204f:

[0091] Step 204a: input image sample data into the visual backbone network to obtain image analysis results.

[0092] In an embodiment of the present application, during the model training process, the model training device inputs the image sample data included in the sample data to be trained into the visual backbone network of the model to be trained, and recognizes and processes the image sample data through the visual backbone network to obtain an image analysis result.

[0093] Step 204b: Obtain the first image feature parameter output by the encoding module in the visual backbone network after encoding the image sample data.

[0094] In an embodiment of the present application, after the model training device inputs the image sample data into the visual backbone network, it also obtains from the visual backbone network the processing result of the encoding module in the visual backbone network encoding the image sample data to obtain the first image feature parameter of the image sample data.

[0095] Step 204c: input the first image feature parameter and the text label into the fusion processing network to obtain the first text feature parameter.

[0096] In an embodiment of the present application, the model training device performs feature fusion on the first image feature parameter output by the encoding module in the visual backbone network and the text label included in the sample data to be trained to obtain the first text feature parameter.

[0097] Step 204d: input the first text feature parameter into the text backbone network to obtain the text analysis result.

[0098] In an embodiment of the present application, a text backbone network for performing text analysis processing performs predictive analysis on an input first text feature parameter to obtain a text analysis result.

[0099] Step 204e: Obtain prediction results based on the text analysis results and the image analysis results.

[0100] In the embodiment of the present application, a similarity matrix between the text analysis result and the image analysis result is determined, and then the similarity matrix is ​​analyzed to determine a prediction result.

[0101] Step 204f: Based on the prediction results, the variable parameters in the visual backbone network, the text backbone network and the fusion processing network are adjusted to obtain the trained model to be trained.

[0102] In the embodiment of the present application, the corresponding loss value is determined according to the prediction result, and then the variable parameters in the visual backbone network, the text backbone network and the fusion processing network included in the training model are adjusted, for example, the adjustment can be made by reverse transmission of the loss value to obtain the trained model to be trained. After obtaining the trained model to be trained, the model to be trained is updated to the trained model to be trained, and the model training is continued until the object recognition model is obtained.

[0103] Based on the above embodiment, in other embodiments of the present application, step 204c can be implemented by steps a11 to a13:

[0104] Step a11: connect at least one tag included in the text tag by using a preset connection symbol to obtain a phrase to be analyzed.

[0105] In the embodiment of the present application, the preset connection symbol may be a pre-agreed symbol for connecting text in a text label, such as a space symbol, a dash symbol, etc. Exemplarily, when the preset connection symbol is "-", and the text label includes label 1, label 2, and label 3, the corresponding phrase to be analyzed may be recorded as: label 1-label 2-label 3.

[0106] Step a12: Process the first image feature data through the global attention pooling layer set by the fusion processing network to obtain the second image feature parameters.

[0107] In an embodiment of the present application, a global attention pooling layer is provided in the fusion processing network, which is used to process the first image feature data, generate global image features, and obtain second image feature parameters.

[0108] Step a13: Generate a first text feature parameter based on the phrase to be analyzed and the second image feature parameter.

[0109] In the embodiment of the present application, the phrase to be analyzed and the second image feature parameter are concatenated to obtain the first text feature parameter.

[0110] Based on the above embodiment, in other embodiments of the present application, step a13 can be implemented by steps a131 to a133:

[0111] Step a131, concatenate the phrase to be analyzed with the adjustable learning text feature parameters to obtain the text parameters to be analyzed.

[0112] In the embodiment of the present application, the learning text feature parameters are parameters obtained through model training, which are used to promote the zero-sample capability of the sample. The method of splicing the phrase to be analyzed with the adjustable learning text feature parameters can be implemented by using a coding splicing method. In this way, the phrase to be analyzed and the learning text feature parameters are coded and spliced ​​by using a coding splicing method to obtain the text parameters to be analyzed.

[0113] Step a132: Process the second image feature parameters through a language prompt word generator to obtain conditional clue parameters.

[0114] In the embodiment of the present application, the language prompt word generator is used to obtain image features. The language prompt word generator performs image feature extraction processing on the second image feature parameter to obtain the condition clue parameter.

[0115] Step a133: Add the parameters of the text to be analyzed and the condition clue parameters to obtain text analysis features.

[0116] In the embodiment of the present application, since the text parameters to be analyzed and the condition clue parameters are both parameters in matrix form, the text parameters to be analyzed and the condition clue parameters can be superimposed to obtain text analysis features.

[0117] Based on the above embodiment, in other embodiments of the present application, step 204e can be implemented by steps b11 to b12:

[0118] Step b11: Determine similarity parameters between the text analysis result and the image analysis result.

[0119] In the embodiment of the present application, similarity calculation parameters are used to perform similarity calculation on the text analysis result and the image analysis result to obtain the similarity parameters between the two.

[0120] Step b12: Determine the prediction result based on the similarity parameter.

[0121] In the embodiment of the present application, the similarity parameters are processed for final result matching at the optimal matching layer to obtain the final prediction result.

[0122] Based on the foregoing embodiment, in other embodiments of the present application, a cross-modal multi-head attention module is provided between each image encoding layer of the visual backbone network and the corresponding text encoding layer of the text backbone network. Figure 3 As shown, the model training device is also used to perform steps 205 to 209:

[0123] Step 205: Input the i-th image feature output of the i-th image coding layer and the i-th text feature output of the corresponding i-th text coding layer into the cross-modal multi-head attention module to obtain the i-th attention output.

[0124] Wherein, i=0,1,2...,n, and n is the number of image coding layers included in the visual backbone network.

[0125] Step 206: Determine the addition of the i-th attention output and the i-th image feature output to obtain the i+1-th image feature input.

[0126] Step 207: Determine the addition of the i-th attention output and the i-th text feature output to obtain the i+1-th text feature input.

[0127] Step 208: Input the i+1th image feature to the i+1th image coding layer.

[0128] Step 209: Input the i+1th text feature into the i+1th text encoding layer.

[0129] In this way, in order to ensure the generalization ability of the samples, a cross-modal multi-head attention module is set between each image encoding layer of the visual backbone network and the corresponding text encoding layer of the text backbone network to introduce the text feature output into the image encoding layer and the image feature output into the text encoding layer, thereby improving the zero-sample capability of the model.

[0130] Based on the above embodiments, the present application embodiment provides a schematic diagram of the model structure of a model to be trained, which can be referred to as Figure 4As shown, it includes an input layer A, a language prompt module B, a text backbone network C, a visual backbone network D, and an optimal matching layer E. Among them, the input layer recognizes the input original image and obtains image regions of multiple target objects in different regions. The input layer inputs multiple image regions into the visual backbone network D, wherein the visual backbone network can be composed of a visual encoder and a DyHeadModule. The image features are obtained through the visual backbone network D. The input layer inputs the output of the visual encoder of the visual backbone network D and the text label based on the original image input into the language prompt module B. The output of the language prompt module B is passed through the text backbone network C to obtain text features. Among them, the text backbone network C can be composed of a text encoder and a BERT layer newly added on top of the pre-trained BERT, and then passes through the intermediate cross-modality multi-head attention module (TheCross-modality Multi-head Attention Module, X-MHA), calculates cross attention for the two modal features of text features and image features corresponding to each layer, so that the model can start cross-modal feature learning at a shallow model stage. Finally, the optimal matching layer E calculates the similarity of the image features and text features finally output by the text backbone network C and the visual backbone network D, and performs matching analysis based on the calculated similarity matrix, so that the optimal matching layer E outputs the final similarity matrix that pays more attention to the overall matching to obtain the prediction result.

[0131] in, Figure 4 The language prompt module B shown in FIG. Figure 5 As shown, it includes three modules: predefined prompt, learnable prompt and language prompt generator. Among them:

[0132] The predefined prompt is used to form a phrase by connecting all the detection categories, that is, the text labels for the original image with a connection symbol. For example, a comma string is used to connect the text labels detected for the original image to convert the text labels into phrases. For example, the original image has 80 text category labels, and the 80 text category labels are connected with commas to get a phrase. In this way, the datasets of target detection and phrase grounding can be used for training and subsequent recognition, and the basic class and other categories can all be constructed into phrases for detection, which is more flexible and can easily migrate the task to the open vocabulary target detection task. Phrase t in =WordEmbedding(L)∈R D , where WordEmbedding() represents the phrase connection (embedding) processing of the predefined prompt, and D represents the embedding dimension.

[0133] The learnable prompt is a learnable prompt {c1,…,cn}, which learns the robust transferability of text embedding to promote the zero-shot capability of the model. It is an independent parameter that can be adjusted by the training data of downstream tasks. The learnable prompt {c1,…,cn} is concatenated with the predefined prompt phrase embedding, which can be denoted as t in '=[c1,…,cn,t in ]∈R (n+1)×D , where n is the number of learnable cues and ci∈R D .

[0134] The language prompt generator is used to obtain a prompt containing image features. Although predefined prompts and learnable prompts can effectively guide model learning, it may have limited few-sample or generalization capabilities when there is a large deviation between the test dataset and the training dataset. Therefore, the language prompt generator can be used to add features related to the current image to improve the generalization performance. Among them, the language prompt generator can actually be composed of a two-layer feedforward network, which is used to generate a feature vector from the global image feature Ig. The feature vector can be called a conditional cue (cc). The first two layers of the feedforward network are specifically composed of two layers of normalization and linear transformation, with a ReLU activation in the middle, which can be recorded as: cc = LN(σ(LN(Ig)W1+b1))W2+b2∈R D , where Ig is the global image feature generated by the image feature I0 through the global attention pooling layer, and the image feature I0 is the feature output after the visual encoder of the visual backbone network encodes the image region.

[0135] In this way, the final output of the language prompt module B is the combination of the output of the prompt generator and the output of the learnable prompt, which can be recorded as: Tin = cc + t in '∈R (n+1)×D .

[0136] When the cross-modal multi-head attention module is set between each layer corresponding to the text backbone network C and the visual backbone network D, the text features Ii output by each layer of the text backbone network and the image features Ti of the corresponding layer of the visual backbone network will interact in the cross-modal multi-head attention module to obtain the interactive features I i t2i , T i i2t =X-MHA(I i , T i), i = 0, 1, ..., L-1, the interactive features are added to the original features and input to the next layer for encoding, and the input features I(i+1) and T(i+1) of the next layer are obtained, which can be specifically recorded as: I(i+1) = DyHeadModule(Ii+I i t2i ), T(i+1)=BERTLayer(Ti+T i i2t ), where L represents the number of DyHeadModules in the text backbone network. BERTLayer is an additional layer added to the pre-trained BERT model of the visual backbone network. Its number of layers R usually matches the number of DyHeadModules in the text backbone network. This can improve the performance of phrase grounding and associate the learning of image features with text features, so that the text prompt can affect the prediction of the detection model. It should be noted that in the X-MHA module, cross attention can be used, that is, each head calculates the context vector of one modality by paying attention to another modality. Correspondingly, I i t2i , T i i2t =X-MHA(I i , T i ) can be calculated by the following formula:

[0137] I (q) =IW (q,R) , T (q) =TW (q,L) ,

[0138] T (v) =TW (v,L) , I t2i =SoftMax(Attn)T (v) W (out,R)

[0139] I (v) =IW (v,R) , T t2i =SoftMax(Attn)I (v) W (out,L)

[0140] Among them, W (symbol,R) , W (symbol,L) : symbol∈{q,v,out} is a trainable parameter, and d is the dimension of I and T.

[0141] In the visual backbone network, Group-Mix Attention (GMA) can be used to enhance visual recognition, which can model the correlation between single tokens and the correlation between token groups.

[0142] When the optimal matching layer performs the final matching of text features and image features, it treats the matching problem as a transmission problem, that is, it seeks a distribution matrix so that the points in the final image features and text features correspond correctly as much as possible, thus achieving global matching of image features and text features. The distribution matrix can be determined using an iterative algorithm, such as the Sinkhorn algorithm with n iterations.

[0143] Finally, during the model training process, in the process of determining the loss value, the regional image and the corresponding text label can be aligned and calculated. The corresponding calculation process can be expressed as: I = EncI (Img), T = EncL (Prompt), where EncI is the loss algorithm corresponding to the visual backbone network, and EncL is the loss algorithm of the text backbone network. In this way, the similarity between the corresponding regional image and text is optimized through the positioning loss and classification loss in the detection, so as to achieve the ultimate goal of learning regional prediction.

[0144] It should be noted that, for the description of the same steps and the same contents in this embodiment as those in other embodiments, reference can be made to the description in other embodiments and will not be repeated here.

[0145] The model training method provided in the embodiment of the present application obtains the sample data to be trained through the model training device, and then uses the sample data to be trained to train the model to be trained until a trained object recognition model is obtained. In this way, by training the model to be trained of the fusion processing network that has text features and image features for fusion processing, the visual backbone network for visual analysis, and the text backbone network for text analysis, a trained object recognition model is obtained, and the comprehensive consideration of the text features and image features of the sample is realized. An open vocabulary target detection scheme is proposed, which improves the generalization ability of the network and ensures the reliability of the output results.

[0146] Based on the above embodiments, the embodiments of the present application provide a recognition method, which is applied to a recognition device, referring to Figure 6 As shown, the method comprises the following steps:

[0147] Step 301: Obtain an object to be identified.

[0148] In an embodiment of the present application, the recognition device and the model training device may be the same device or may not be the same device. When the recognition device and the model training device are not the same device, the recognition device and the model training device may be communicatively connected, and the model training device may send the trained object recognition model to the recognition device in advance so that the recognition device may use the received object recognition model for recognition processing. The model training device may periodically send the updated object recognition model to the recognition device, or the recognition device may obtain the object recognition model from the model training device only when it needs to use it. The specific situation may be determined by actual conditions and is not limited here. The object to be recognized may be an image to be recognized.

[0149] Step 302: Perform recognition using the trained object recognition model to obtain a recognition result.

[0150] Among them, the object recognition model can be obtained by Figures 1 to 3 The corresponding model training method is used for training, which will not be described in detail here.

[0151] Based on the foregoing embodiments, the embodiments of the present application provide an application embodiment of an object recognition model, which may specifically be: inputting a test image to the input layer of the object recognition model, and outputting a prediction result.

[0152] Among them, the input layer can detect the target in the test image through the target detection network, obtain the image where each detected target is located, and obtain the target area; the target area is input into the visual encoder of the visual backbone network, and the output content I0 of the visual encoder is output to the DyHeadModule layer set in the visual backbone network, and finally the image feature I is output; the category labels of the test image are connected by commas to form phrases, and converted into vectors t through word encoding. in , and then concatenated with the learnable prompt to get t in ', the output content I0 of the visual encoder is obtained through the global attention pooling layer to obtain Ig, and the language prompt generator is used to process Ig to obtain the conditional clue cc, and the conditional clue cc is combined with t in ' Combined to obtain Tin; then Tin is sent to the text backbone network so that the text backbone network outputs the final text feature T; finally, the similarity matrix of the image feature I and the text feature T is calculated, and the final matching result is determined according to the similarity matrix to obtain the prediction result.

[0153] In this way, the image features are combined with the original target category, that is, the prompt composed of the text label, to obtain the text features containing the image features, thereby improving the zero-sample capability and generalization capability of the model; and group mixed attention is used in the visual encoder to realize the modeling of the correlation between single tokens and the correlation between token groups. Finally, the similarity matrix calculated by the image features and the text features is processed through the optimal transmission layer to fully improve the overall matching degree, realize global matching, and ensure the overall matching effect.

[0154] The recognition method provided in the embodiment of the present application, after obtaining the sample data to be trained through the model training device, uses the sample data to be trained to train the model to be trained until a trained object recognition model is obtained, and then after the recognition device obtains the object to be recognized, it recognizes it through the trained object recognition model to obtain a recognition result. In this way, by training the model to be trained of the fusion processing network that has text features and image features for fusion processing, the visual backbone network for visual analysis, and the text backbone network for text analysis, a trained object recognition model is obtained, and the comprehensive consideration of the text features and image features of the sample is realized. An open vocabulary target detection scheme is proposed, which improves the generalization ability of the network and ensures the reliability of the output results.

[0155] Based on the above embodiments, the embodiments of the present application provide a model training device, which can be applied to Figures 1 to 3 In the model training method provided in the corresponding embodiment, refer to Figure 7 As shown, the model training device 4 may include: a first acquisition unit 41 and a model training unit 42; wherein:

[0156] A first acquisition unit 41 is used to acquire sample data to be trained; wherein the sample data to be trained includes image sample data and text labels corresponding to the image sample data;

[0157] The model training unit 42 is used to perform model training on the model to be trained using the sample data to be trained until a trained object recognition model is obtained; wherein the model to be trained at least includes: a fusion processing network that fuses text features and image features of the training sample data, a visual backbone network that performs visual analysis on the training sample data, and a text backbone network that performs text analysis on the training sample data and the output results of the fusion processing network.

[0158] In other embodiments of the present application, the first acquisition unit includes: a first acquisition module, a detection module and a determination module; wherein:

[0159] A first acquisition module, used to acquire a first image;

[0160] A detection module, configured to detect a target object included in the first image, determine an image region including at least one target object, and obtain image sample data;

[0161] The determination module is used to determine the text label set for the first image; wherein the sample data to be trained includes image sample data and text labels.

[0162] In other embodiments of the present application, the model training unit includes: an input module, a second acquisition module, a obtaining module and an adjustment module; wherein:

[0163] An input module is used to input image sample data into the visual backbone network to obtain image analysis results;

[0164] A second acquisition module is used to obtain a first image feature parameter output after the encoding module in the visual backbone network encodes the image sample data;

[0165] An input module, used for inputting a first image feature parameter and a text label into a fusion processing network to obtain a first text feature parameter;

[0166] An input module, used for inputting a first text feature parameter into a text backbone network to obtain a text analysis result;

[0167] A module is used to obtain a prediction result based on the text analysis result and the image analysis result;

[0168] The adjustment module is used to adjust the variable parameters in the visual backbone network, the text backbone network and the fusion processing network based on the prediction results to obtain the trained model to be trained.

[0169] In other embodiments of the present application, the input module is used to implement the step of inputting the first image feature parameter and the text label into the fusion processing network to obtain the first text feature parameter, which can be specifically implemented by the following steps:

[0170] Connecting at least one tag included in the text tags by using a preset connection symbol to obtain a phrase to be analyzed;

[0171] The first image feature data is processed by a global attention pooling layer set by the fusion processing network to obtain a second image feature parameter;

[0172] A first text feature parameter is generated based on the phrase to be analyzed and the second image feature parameter.

[0173] In other embodiments of the present application, when the input module is used to implement the step of generating the first text feature parameter based on the phrase to be analyzed and the second image feature parameter, it can be specifically implemented by the following steps:

[0174] The phrase to be analyzed is concatenated with the adjustable learning text feature parameters to obtain the text parameters to be analyzed;

[0175] The second image feature parameters are processed by a language prompt word generator to obtain conditional clue parameters;

[0176] Add the parameters of the text to be analyzed and the conditional clue parameters to obtain the text analysis features.

[0177] In other embodiments of the present application, the obtaining module is specifically used to implement the following steps:

[0178] Determine similarity parameters between text analysis results and image analysis results;

[0179] A prediction result is determined based on the similarity parameter.

[0180] In other embodiments of the present application, a cross-modal multi-head attention module is arranged between each image encoding layer of the visual backbone network and the corresponding text encoding layer of the text backbone network.

[0181] In other embodiments of the present application, the model training device further includes an input unit and a determination unit; wherein:

[0182] An input unit, used to input the i-th image feature output of the i-th image coding layer and the i-th text feature output of the corresponding i-th text coding layer into the cross-modal multi-head attention module to obtain the i-th attention output; wherein i = 0, 1, 2..., n, n is the number of image coding layers included in the visual backbone network;

[0183] A determination unit, used to determine the addition of the i-th attention output and the i-th image feature output to obtain the i+1-th image feature input;

[0184] The determination unit is further used to determine the addition of the i-th attention output and the i-th text feature output to obtain the i+1-th text feature input;

[0185] An input unit, used for inputting the i+1th image feature into the i+1th image coding layer;

[0186] The input unit is also used to input the i+1th text feature into the i+1th text encoding layer.

[0187] In other embodiments of the present application, the attention mechanism set in the visual backbone network is group mixed attention.

[0188] It should be noted that the interaction process between the units and modules in this embodiment can refer to the description in other embodiments and will not be repeated here.

[0189] The model training device provided in the embodiment of the present application obtains the sample data to be trained through the model training device, and then uses the sample data to be trained to perform model training on the model to be trained until a trained object recognition model is obtained. In this way, by training the model to be trained of the fusion processing network that performs fusion processing of text features and image features, the visual backbone network that performs visual analysis, and the text backbone network that performs text analysis, a trained object recognition model is obtained, and the comprehensive consideration of the text features and image features of the sample is realized. An open vocabulary target detection scheme is proposed, which improves the generalization ability of the network and ensures the reliability of the output results.

[0190] Based on the above embodiments, the embodiments of the present application provide an identification device, which can be applied to Figure 6 In the identification method provided in the corresponding embodiment, refer to Figure 8 As shown, the identification device 5 may include: a second acquisition unit 51 and an identification unit 52; wherein:

[0191] A second acquisition unit 51 is used to acquire an object to be identified;

[0192] The recognition unit 52 is used to perform recognition using a trained object recognition model to obtain a recognition result.

[0193] The object recognition model used in the recognition unit 52 can be Figure 7 The model training device shown is trained, and the specific implementation process can refer to the content of the aforementioned embodiment, which will not be repeated here.

[0194] It should be noted that the interaction process between the units and modules in this embodiment can refer to the description in other embodiments and will not be repeated here.

[0195] The recognition method provided in the embodiment of the present application, after obtaining the sample data to be trained through the model training device, uses the sample data to be trained to train the model to be trained until a trained object recognition model is obtained, and then after the recognition device obtains the object to be recognized, it recognizes it through the trained object recognition model to obtain a recognition result. In this way, by training the model to be trained of the fusion processing network that has text features and image features for fusion processing, the visual backbone network for visual analysis, and the text backbone network for text analysis, a trained object recognition model is obtained, and the comprehensive consideration of the text features and image features of the sample is realized. An open vocabulary target detection scheme is proposed, which improves the generalization ability of the network and ensures the reliability of the output results.

[0196] Based on the above embodiments, the embodiments of the present application provide a model training device, which can be applied to Figures 1 to 3In the model training method provided in the corresponding embodiment, refer to Fig. 9 As shown, the model training device 6 may include: a first memory 61, a first processor 62 and a first communication bus 63; wherein:

[0197] A first memory 61, used to store executable instructions;

[0198] A first communication bus 63, used to realize the communication connection between the first processor 62 and the first memory 61;

[0199] The first processor 62 is used to execute the model training program stored in the first memory 61 to implement the following Figures 1 to 3 The implementation process of the model training method provided in the corresponding embodiment will not be repeated here.

[0200] Based on the above embodiments, the embodiments of the present application provide an identification device, which can be applied to Figure 6 In the identification method provided in the corresponding embodiment, refer to Fig.10 As shown, the identification device 7 may include: a second memory 71, a second processor 72 and a second communication bus 73; wherein:

[0201] A second memory 71, used for storing executable instructions;

[0202] A second communication bus 73, used to realize the communication connection between the second processor 72 and the second memory 71;

[0203] The second processor 72 is used to execute the recognition program stored in the first memory 71 to implement the following Figure 6 The implementation process of the identification method provided in the corresponding embodiment will not be repeated here.

[0204] Based on the foregoing embodiments, the embodiments of the present application provide a computer-readable storage medium, referred to as a storage medium, which stores one or more programs, and the one or more programs can be executed by one or more processors to implement reference Figures 1 to 3 or Figure 6 The implementation process of the model training method provided in the corresponding embodiment will not be repeated here.

[0205] Based on the foregoing embodiments, the embodiments of the present application also provide a computer program product, including a computer program, which can be executed by the first processor 62 of the model training device 6, or the second processor 72 of the recognition device 7, to complete any of the foregoing method steps.

[0206] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of hardware embodiments, software embodiments, or embodiments in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage and optical storage, etc.) that contain computer-usable program code.

[0207] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0208] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0209] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0210] The above description is only a preferred embodiment of the present application and is not intended to limit the protection scope of the present application.

Claims

1. A model training method, characterized in that: The method comprises: Acquire sample data to be trained; wherein the sample data to be trained includes image sample data and text labels corresponding to the image sample data; The model to be trained is trained using the sample data to be trained until a trained object recognition model is obtained; wherein the model to be trained at least includes: a fusion processing network that fuses text features and image features of the sample data to be trained, a visual backbone network that performs visual analysis on the sample data to be trained, and a text backbone network that performs text analysis on the sample data to be trained and the output results of the fusion processing network.

2. The method according to claim 1, characterized in that The step of obtaining sample data to be trained includes: acquiring a first image; Detecting a target object included in the first image, determining an image region including at least one of the target objects, and obtaining the image sample data; Determine the text label set for the first image; wherein the sample data to be trained includes the image sample data and the text label.

3. The method according to claim 1, characterized in that The adopting the to-be-trained sample data to perform model training on the to-be-trained model comprises: Inputting the image sample data into the visual backbone network to obtain image analysis results; Obtaining a first image feature parameter outputted after the encoding module in the visual backbone network performs encoding processing on the image sample data; Inputting the first image feature parameter and the text label into the fusion processing network to obtain a first text feature parameter; Inputting the first text feature parameter into the text backbone network to obtain a text analysis result; Obtaining a prediction result based on the text analysis result and the image analysis result; Based on the prediction results, the variable parameters in the visual backbone network, the text backbone network and the fusion processing network are adjusted to obtain a trained model to be trained.

4. The method according to claim 3, characterized in that The step of inputting the first image feature parameter and the text label into the fusion processing network to obtain the first text feature parameter includes: Connecting at least one tag included in the text tags by using a preset connection symbol to obtain a phrase to be analyzed; Processing the first image feature data through the global attention pooling layer set by the fusion processing network to obtain a second image feature parameter; The first text feature parameter is generated based on the phrase to be analyzed and the second image feature parameter.

5. The method according to claim 4, characterized in that The step of generating the first text feature parameter based on the phrase to be analyzed and the second image feature parameter comprises: splicing the phrase to be analyzed with the adjustable learning text feature parameters to obtain the text parameters to be analyzed; Processing the second image feature parameter by a language prompt word generator to obtain a condition clue parameter; The text parameter to be analyzed and the condition clue parameter are added to obtain the text analysis feature.

6. The method according to any one of claims 3 to 5, characterized in that: The obtaining of prediction results based on the text analysis results and the image analysis results includes: Determining a similarity parameter between the text analysis result and the image analysis result; A prediction result is determined based on the similarity parameter.

7. The method according to claim 1, characterized in that A cross-modal multi-head attention module is arranged between each image encoding layer of the visual backbone network and the corresponding text encoding layer of the text backbone network.

8. The method according to claim 7, characterized in that The method comprises: Input the i-th image feature output of the i-th image coding layer and the i-th text feature output of the corresponding i-th text coding layer into the cross-modal multi-head attention module to obtain the i-th attention output; wherein i=0,1,2...,n, n is the number of image coding layers included in the visual backbone network; Determine the addition of the i-th attention output and the i-th image feature output to obtain the i+1-th image feature input; Determine the addition of the i-th attention output and the i-th text feature output to obtain the i+1-th text feature input; Inputting the i+1th image feature into the i+1th image coding layer; The i+1th text feature is input to the i+1th text encoding layer.

9. The method according to claim 1, characterized in that: The attention mechanism set in the visual backbone network is group mixed attention.

10. A recognition method, characterized in that: The method comprises: Get the object to be identified; Recognition is performed using a trained object recognition model to obtain a recognition result; wherein the object recognition model can be obtained by training using the model training method as described in any one of claims 1 to 9.

11. A model training device, characterized in that: The device comprises: a first acquisition unit and a model training unit; wherein: The first acquisition unit is used to acquire sample data to be trained; wherein the sample data to be trained includes image sample data and text labels corresponding to the image sample data; The model training unit is used to use the sample data to be trained to perform model training on the model to be trained until a trained object recognition model is obtained; wherein the model to be trained at least includes: a fusion processing network that fuses text features and image features of the sample data to be trained, a visual backbone network that performs visual analysis on the sample data to be trained, and a text backbone network that performs text analysis on the sample data to be trained and the output results of the fusion processing network.

12. An identification device, characterized in that: The device comprises: a second acquisition unit and an identification unit; wherein: The second acquisition unit is used to acquire the object to be identified; The recognition unit is used to perform recognition through a trained object recognition model to obtain a recognition result; wherein, the object recognition model can be trained by the model training device described in right 11.

13. A model training device, characterized in that: The device at least comprises: a first memory, a first processor and a first communication bus; wherein: The first memory is used to store executable instructions; The first communication bus is used to implement a communication connection between the first processor and the first memory; The first processor is used to execute the model training program stored in the first memory to implement the steps of the model training method as described in any one of claims 1 to 9.

14. An identification device, characterized in that: The device at least comprises: a second memory, a second processor and a second communication bus; wherein: The second memory is used to store executable instructions; The second communication bus is used to implement a communication connection between the second processor and the second memory; The second processor is used to execute the recognition program stored in the second memory to implement the steps of the recognition method as claimed in claim 10.

15. A storage medium, characterized in that: The storage medium stores a model training program, which, when executed, is used to implement the steps of the model training method as described in any one of claims 1 to 9, or the storage medium stores a recognition program, which, when executed, is used to implement the steps of the recognition method as described in claim 10.

16. A computer program product comprising a computer program, characterized in that The computer program implements the steps of the method according to any one of claims 1 to 9 or claim 10 when executed by a processor.

Citation Information

Cited By

  • Model training method and device and electronic equipment

    CN120526217A