Training method, device, equipment and medium for image description information generation model
By adjusting the parameters of the image description generation model, combined with the BERT algorithm and reward mechanism, the fluency and accuracy of the generated descriptions are optimized, which solves the problem of low sentence fluency and accuracy in the image description generation model and achieves higher quality images. Description generation.
Patent Information
- Application Number
- CN202210507712.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-10
- Publication Date
- 2024-10-25
- Estimated Expiration
- 2042-05-10
AI Technical Summary
Existing image description generation models generate sentences with low fluency and accuracy in novel object description tasks, resulting in poor quality image description text.
By obtaining labeled and unlabeled data sets, identify image targets and extract regional features, calculate the cross entropy between generated descriptions and real descriptions, adjust model parameters, use the BERT algorithm to optimize word generation, and optimize generation through preset reward mechanisms and penalty mechanisms. Parameters to ensure the fluency and grammatical accuracy of the generated description.
It improves the fluency and grammatical accuracy of the image description generation model, reduces the dependence on annotated data sets, and generates more accurate and visually content-rich image descriptions.
Smart Images

Figure CN114842299B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image recognition, and in particular to a training method, device, equipment and medium for generating an image description information model. Background Art
[0002] Image description generation is a comprehensive research direction combining natural language processing and computer vision, and has made a lot of progress and applications. The current novel object captioning (NOC) task learns the target information and text information in the image to fully cover the image representation content, but the semantic features such as the coherence and accuracy of the generated sentences are poor. That is, in the current novel object description task, the fluency and accuracy of the description text generated for the image are low. Summary of the invention
[0003] The main purpose of this application is to provide a training method, device, equipment and medium for an image description information generation model, aiming to solve the problems of low fluency and accuracy of image description text.
[0004] In order to achieve the above-mentioned invention object, the present application proposes a training method for an image description information generation model, the method comprising:
[0005] Obtain labeled and unlabeled datasets;
[0006] Identify a first image in the labeled data set, and obtain an object of the first image and an object category label corresponding to the object;
[0007] Extracting regional features of the first image according to the target category label, and obtaining a generated description of the first image by a model according to the regional features;
[0008] Calculating the cross entropy between the generated description and the true description, and modifying the generation parameters of the model according to the cross entropy;
[0009] Inputting the unlabeled data set into the modified model to obtain description information of the second image in the unlabeled data set;
[0010] The objectivity and accuracy of the description information are calculated, and generation parameters of the model are determined according to the objectivity and accuracy to complete the training of the model.
[0011] Furthermore, the calculating the cross entropy between the generated description and the true description, and modifying the generation parameters of the model according to the cross entropy, includes:
[0012] Calculating the cross entropy between the generated description and the true description;
[0013] If the cross entropy does not meet the preset condition, obtaining context information of the generated description;
[0014] The words to be replaced in the generated description are replaced in sequence according to the context information, and the generation parameters are modified until the cross entropy between the generated description and the real description after replacement meets a preset condition.
[0015] Furthermore, after inputting the unlabeled data set into the modified model to obtain the description information of the second image in the unlabeled data set, the method further includes:
[0016] Use the BERT algorithm to mask the generated words in the description information;
[0017] Acquire context information of the description information;
[0018] Determining a replacement word for the generated word according to context information of the description information;
[0019] The generated word is modified to the replacement word to obtain modified description information of the second image.
[0020] Furthermore, the step of modifying the generated word to the replacement word to obtain modified description information of the second image includes:
[0021] Calculating a first cosine similarity between the description information including the generated word and the second image;
[0022] Calculating a second cosine similarity between the description information including the replacement word and the second image;
[0023] If the second cosine similarity is greater than the first cosine similarity, the generated word in the description information is modified to the replacement word to obtain modified description information of the second image.
[0024] Furthermore, before extracting the regional features of the first image according to the target category label, the method further includes:
[0025] Get the starting position coordinates of the bounding box;
[0026] Learning the variables in the position coordinates based on linear regression makes the bounding box approach the real box, and obtains the target position coordinates of the bounding box;
[0027] The area range information of the first image is determined according to the bounding box of the target position coordinates.
[0028] Furthermore, after calculating the cross entropy between the generated description and the true description and modifying the generation parameters of the model according to the cross entropy, the method further includes:
[0029] Calculating a relevance score between the generated description and the first image;
[0030] Obtaining preset relevance evaluation rules;
[0031] Calculate the score of the relevance score according to the relevance evaluation rule;
[0032] The generation parameters of the model are modified according to the score value.
[0033] Further, the calculating the objectivity and accuracy of the description information and determining the generation parameters of the model according to the objectivity and accuracy to complete the training of the model includes:
[0034] Get pre-set reward and punishment mechanisms;
[0035] Calculating a first score of the targetness and the accuracy according to the reward mechanism;
[0036] Calculating a second score of the targetness and the accuracy according to the penalty mechanism;
[0037] The generation parameters of the model are modified and determined according to the first score and the second score to complete the training of the model.
[0038] The present application also provides a training device for an image description information generation model, the device comprising:
[0039] A data acquisition module, used to acquire labeled data sets and unlabeled data sets;
[0040] An object recognition module is used to recognize a first image in the labeled data set, and obtain an object of the first image and an object category label corresponding to the object;
[0041] A feature description module, used to extract regional features of the first image according to the target category label, and obtain a generated description of the first image by a model according to the regional features;
[0042] A parameter adjustment module, used to calculate the cross entropy between the generated description and the true description, and modify the generation parameters of the model according to the cross entropy;
[0043] An image description module, used for inputting the unlabeled data set into the modified model to obtain description information of a second image in the unlabeled data set;
[0044] The parameter determination module is used to calculate the objectivity and accuracy of the description information, and determine the generation parameters of the model according to the objectivity and accuracy to complete the training of the model.
[0045] The present application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the training method of the image description information generation model described in any one of the above items is implemented.
[0046] The embodiment of the present application provides a training method for a new object image description generation model based on multimodality, by training the image description generation model, so that the image description generation model can describe different images input into the model with fluent and grammatically accurate sentences, firstly obtain a data set, divide the data set into two parts, one part is a data set with text annotations, i.e., a labeled data set, and the other part is a data set without text annotations, i.e., an unlabeled data set, identify a first image in the labeled data set, obtain a target of the first image and a target category label corresponding to the target, segment the first image according to the target category label, segment it into several different regions, then extract the features of the image in each region, and then input the regional features of the first image into the generation network of the model, the generation network outputs the corresponding generation description after identifying the first image, thereby generating a new object image according to the image description. The regional feature acquisition model generates a description of the first image, calculates the cross entropy between the generated description and the true description, and the true description is the annotation corresponding to the first image in the labeled data set. Then, the generation parameters of the model are modified according to the cross entropy, so that the model tends to generate a generated description with a smaller cross entropy with the true description. The unlabeled data set is input into the modified model to obtain the description information of the second image in the unlabeled data set, and the objectivity and accuracy of the description information are calculated. The generation parameters of the model are determined according to the objectivity and accuracy. By continuously optimizing the generation parameters, a fluent and grammatically accurate description of the unlabeled second image can be obtained based on the generation parameters, and the training of the model is completed. The trained model can reduce the dependence on the labeled data set and can generate a more accurate and visually rich image description for the input image. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] Figure 1 A flowchart of an embodiment of a method for training an image description information generation model of the present application;
[0048] Figure 2 A schematic flow chart of an embodiment of calculating the cross entropy between the generated description and the true description for the present application, and modifying the generation parameters of the model according to the cross entropy;
[0049] Figure 3 A schematic diagram of a flow chart of an embodiment of the present application after obtaining description information of the second image in the unlabeled data set;
[0050] Figure 4 A flowchart of an embodiment of modifying the generated word to the replacement word to obtain modified description information of the second image for the present application;
[0051] Figure 5 This is a schematic diagram of an embodiment of the present application before extracting the regional features of the first image according to the target category label;
[0052] Figure 6 A schematic flow chart of an embodiment of calculating the cross entropy between the generated description and the true description for the present application, and modifying the generation parameters of the model according to the cross entropy;
[0053] Figure 7 A flowchart of an embodiment of calculating the objectivity and accuracy of the description information for the present application, and determining the generation parameters of the model according to the objectivity and accuracy to complete the training of the model;
[0054] Figure 8 A schematic diagram of the structure of an embodiment of a training device for an image description information generation model of the present application;
[0055] Fig. 9 This is a schematic block diagram of the structure of an embodiment of a computer device of the present application.
[0056] The realization of the purpose, functional features and advantages of this application will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0057] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0058] Reference Figure 1 An embodiment of the present application provides a training method for an image description information generation model. The training method for the image description information generation model includes steps S101-S106. The detailed description of each step of the training method for the image description information generation model is as follows.
[0059] S101. Obtain a labeled data set and an unlabeled data set.
[0060] This embodiment is applied to image recognition scenarios, including the generation scenario of novel object captioning (NOC), and the image description information generation model is defined as an FTA (Fluency & Targeting & Adequacy) image description generation model. By training the image description generation model, the image description generation model can describe different images input into the model in fluent and grammatically accurate sentences. In this embodiment, a data set is first obtained. In one embodiment, the data set includes a deep learning image data set (MSCOCO). The MSCOCO data set is a large image data set developed and maintained by Microsoft. Then, the data set is divided into two parts, one part is a data set with text annotations, i.e., a labeled data set, and the other part is a data set without text annotations, i.e., an unlabeled data set, thereby obtaining a labeled data set and an unlabeled data set, and then the labeled data set and the unlabeled data set are used to jointly train the model.
[0061] S102: Identify a first image in the labeled data set, and obtain an object in the first image and an object category label corresponding to the object.
[0062] In this embodiment, after obtaining a labeled data set and an unlabeled data set, the first image in the labeled data set is identified, and the target of the first image and the target category label corresponding to the target are obtained. In one implementation, a Faster R-CNN network is used to identify the first image in the labeled data set, that is, target detection is performed on the first image in the labeled data set, and the target contained in the first image is identified and labeled with a target category label, thereby obtaining the target of the first image and the target category label corresponding to the target.
[0063] S103: extracting regional features of the first image according to the target category label, and obtaining a generated description of the first image by a model according to the regional features.
[0064] In this embodiment, after identifying the first image in the labeled data set and obtaining the target of the first image and the target category label corresponding to the target, the regional features of the first image are extracted according to the target category label. Specifically, the first image is segmented into a number of different regions according to the target category label, and then the features of the image in each region are extracted. The features include mean, standard deviation, smoothness, third-order moment, consistency and other features, so as to obtain the regional features of the first image. The regional features of the first image are then input into the generative network of the model. The generative network outputs a corresponding generative description after identifying the first image, so as to obtain the model's generative description of the first image according to the regional features.
[0065] S104. Calculate the cross entropy between the generated description and the true description, and modify the generation parameters of the model according to the cross entropy.
[0066] In this embodiment, after extracting the regional features of the first image according to the target category label and obtaining the generated description of the first image by the model according to the regional features, for the labeled data set with text annotations, define X l ,Y l There are the first image set and the corresponding annotations respectively; for the unlabeled dataset without text annotations, define X u is the second image set. The FTA image description generation model is represented as C θ , θ is the generation parameter of the model. For NOC, it is hoped that for X u By C θ Generate corresponding description Specifically, the cross entropy between the generated description and the true description is calculated, where the true description is the annotation corresponding to the first image in the labeled data set, and then the generation parameters of the model are modified according to the cross entropy so that the model tends to generate a generated description with a smaller cross entropy with the true description.
[0067] S105 . Input the unlabeled data set into the modified model to obtain description information of the second image in the unlabeled data set.
[0068] In this embodiment, after calculating the cross entropy between the generated description and the true description and modifying the generation parameters of the model according to the cross entropy, the unlabeled data set is input into the modified model, and the model first identifies the second image in the labeled data set, obtains the target of the second image and the target category label corresponding to the target, and then extracts the regional features of the second image according to the target category label, and then obtains the generated description of the second image by the model according to the regional features, thereby obtaining the description information of the second image in the unlabeled data set.
[0069] S106, calculating the objectivity and accuracy of the description information, and determining generation parameters of the model according to the objectivity and accuracy to complete the training of the model.
[0070] In this embodiment, after the unlabeled data set is input into the modified model to obtain the description information of the second image in the unlabeled data set, in order to enable the model to generate a fluent and grammatically accurate sentence description for the unlabeled image, the target and accuracy of the description information are calculated, the target is whether the generated description information matches the input image, and the accuracy is whether the generated description information contains enough details. Specifically, the matching degree between the description information and the target in the second image is calculated based on the BERT algorithm, and the target of the description information is determined according to the matching degree. In addition, the proportion of key information contained in the description information is calculated based on a pre-established indicator evaluation system, and the accuracy of the description information is determined according to the proportion, so as to determine the generation parameters of the model according to the target and accuracy, and by continuously optimizing the generation parameters, a fluent and grammatically accurate description of the unlabeled second image can be obtained based on the generation parameters, and the training of the model is completed. The trained model can reduce the dependence on the labeled data set and can generate a more accurate and visually rich image description for the input image.
[0071] The present embodiment provides a training method for a new object image description generation model based on multimodality, by training the image description generation model, so that the image description generation model can describe different images input into the model in fluent and grammatically accurate sentences, firstly obtain a data set, divide the data set into two parts, one part is a data set with text annotations, i.e., a labeled data set, and the other part is a data set without text annotations, i.e., an unlabeled data set, identify a first image in the labeled data set, obtain a target of the first image and a target category label corresponding to the target, segment the first image according to the target category label, segment it into several different regions, then extract the features of the image in each region, and then input the regional features of the first image into the generation network of the model, the generation network outputs the corresponding generation description after identifying the first image, thereby generating a new object image according to the image description. The regional feature acquisition model generates a description of the first image, calculates the cross entropy between the generated description and the true description, the true description being the annotation corresponding to the first image in the labeled data set, and then modifies the generation parameters of the model according to the cross entropy, so that the model tends to generate a generated description with a smaller cross entropy with the true description, inputs the unlabeled data set into the modified model, obtains the description information of the second image in the unlabeled data set, calculates the objectivity and accuracy of the description information, determines the generation parameters of the model according to the objectivity and accuracy, and continuously optimizes the generation parameters so that a fluent and grammatically accurate description of the unlabeled second image can be obtained based on the generation parameters, thereby completing the training of the model. The trained model can reduce the dependence on the labeled data set, and can generate a more accurate and visually rich image description for the input image.
[0072] In one embodiment, Figure 2 As shown, the calculating of the cross entropy between the generated description and the true description and modifying the generation parameters of the model according to the cross entropy include steps S201-203:
[0073] S201, calculating the cross entropy between the generated description and the true description;
[0074] S202, if the cross entropy does not meet a preset condition, obtaining context information of the generated description;
[0075] S203, replacing the words to be replaced in the generated description in sequence according to the context information, and modifying the generation parameters until the cross entropy between the generated description and the real description after replacement meets a preset condition.
[0076] In this embodiment, in the process of calculating the cross entropy between the generated description and the real description and modifying the generation parameters of the model according to the cross entropy, in order to make the generated description have semantic fluency, the cross entropy between the generated description and the real description is first calculated. If the cross entropy does not meet the preset conditions, the context information of the generated description is obtained, and then the words to be replaced in the generated description are replaced in sequence according to the context information, and the generation parameters are modified until the cross entropy between the generated description and the real description after replacement meets the preset conditions. In one implementation, a method is used to randomly select a sequence token according to the context information and replace it with a [mask] mark to replace the words to be replaced in the generated description, and then the cross entropy between the generated description and the real description after replacement is calculated until the cross entropy between the generated description and the real description after replacement meets the preset conditions. At this time, the generation parameters are determined according to the generated description after replacement, thereby modifying the generation parameters, so that the generated description has semantic fluency.
[0077] In one embodiment, Figure 3 As shown, after inputting the unlabeled data set into the modified model to obtain the description information of the second image in the unlabeled data set, the method further includes steps S301-S304:
[0078] S301, masking generated words in the description information using the BERT algorithm;
[0079] S302, obtaining context information of the description information;
[0080] S303, determining a replacement word for the generated word according to context information of the description information;
[0081] S304: Modify the generated word to the replacement word to obtain modified description information of the second image.
[0082] In this embodiment, after the unlabeled data set is input into the modified model to obtain the description information of the second image in the unlabeled data set, a semantic fluency training operation is performed on the description information. Since the unlabeled data set has no real description for comparison, this embodiment first masks the generated words in the description information through the BERT algorithm. Specifically, [mask] is used to mask a certain generated word, and then the context information of the description information is obtained. The replacement word of the generated word is determined according to the context information of the description information, and the generated word is modified to the replacement word to obtain the modified description information of the second image. The context information is used to generate a description that is more in line with the semantic representation for replacement, thereby improving the semantic accuracy of the description information.
[0083] In one embodiment, Figure 4 As shown, the step of modifying the generated word to the replacement word to obtain modified description information of the second image includes steps S401-S403:
[0084] S401, calculating a first cosine similarity between the description information including the generated word and the second image;
[0085] S402, calculating a second cosine similarity between the description information including the replacement word and the second image;
[0086] S403: If the second cosine similarity is greater than the first cosine similarity, modify the generated word in the description information to the replacement word to obtain modified description information of the second image.
[0087] In this embodiment, in the process of modifying the generated word to the replacement word to obtain the modified description information of the second image, considering that not every word can be inferred through context information and the replacement effects of different words may be different, firstly, the first cosine similarity between the description information including the generated word and the second image is calculated, and then the second cosine similarity between the description information including the replacement word and the second image is calculated. The cosine similarity represents the visual similarity between the description information and the image. In one implementation, it is defined by the CLIP score. If the second cosine similarity is greater than the first cosine similarity, the generated word in the description information is modified to the replacement word to obtain the modified description information of the second image. By respectively calculating the CLIP scores of the second image and the generated description before masking and the generated description after masking, if the CLIP scores of the input image and the generated description after masking are higher, then the replacement is selected, otherwise, the replacement is not selected, thereby ensuring the accuracy of the replacement and improving the semantic accuracy of the description information.
[0088] In one embodiment, Figure 5 As shown, before extracting the regional features of the first image according to the target category label, steps S501-S503 are also included:
[0089] S501, obtaining the starting position coordinates of the bounding box;
[0090] S502, learning the variables in the position coordinates based on linear regression so that the bounding box approaches the real box, and obtaining the target position coordinates of the bounding box;
[0091] S503: Determine area range information of the first image according to a boundary box of the target position coordinates.
[0092] In this embodiment, before extracting the regional features of the first image according to the target category label, the starting position coordinates of the bounding box are first obtained, and the variables in the position coordinates are learned based on linear regression so that the bounding box approaches the real box, and the target position coordinates of the bounding box are obtained. Then, the regional range information of the first image is determined according to the bounding box of the target position coordinates. In one implementation, in order to better cover the image space features, the bounding box is introduced for encoding, and four coordinates are used. It represents the starting position coordinates of the bounding box. The four parameters represent the center point coordinates and the width and height of the bounding box respectively. The four scalars are learned through linear regression so that the bounding box continuously approaches the real box to obtain the precise bounding box coordinates. Then, the area range information of the first image is determined according to the bounding box of the target position coordinates to ensure the accuracy of image feature extraction.
[0093] In one embodiment, Figure 6 As shown, the calculation of the cross entropy between the generated description and the true description, and the modification of the generation parameters of the model according to the cross entropy, includes steps S601-S604:
[0094] S601, calculating a correlation score between the generated description and the first image;
[0095] S602, obtaining a preset correlation evaluation rule;
[0096] S603: Calculate the score of the relevance score according to the relevance evaluation rule.
[0097] S604: Modify generation parameters of the model according to the score value.
[0098] In this embodiment, after calculating the cross entropy between the generated description and the true description and modifying the generation parameters of the model according to the cross entropy, the relevance score between the generated description and the first image is calculated, and then a preset relevance evaluation rule is obtained, and the scoring value of the relevance score is calculated according to the relevance evaluation rule; the generation parameters of the model are modified according to the scoring value. In one implementation, the relevance score between the generated description and the first image is calculated, and then the relevance score is scored, that is, whether the generated description matches the first image is evaluated, and then the generation parameters of the model are continuously modified based on the matching result, which can be a sum of the cross entropy generated by the labeled input image set part and the loss function generated by the unlabeled input image set part to obtain the total loss function of this stage, and then the gradient back propagation is calculated through the optimization algorithm to update the generation model C. θ The generated parameters θ are used to improve the accuracy of the generated parameters.
[0099] In one embodiment, Figure 7As shown, the calculation of the objectivity and accuracy of the description information and the determination of the generation parameters of the model according to the objectivity and accuracy to complete the training of the model include steps S701-S704:
[0100] S701, obtaining a preset reward mechanism and punishment mechanism;
[0101] S702, calculating a first score of the target and the accuracy according to the reward mechanism;
[0102] S703, calculating a second score of the target and the accuracy according to the penalty mechanism;
[0103] S704: Modify and determine generation parameters of the model according to the first score and the second score to complete the training of the model.
[0104] In this embodiment, in the process of calculating the objectiveness and accuracy of the descriptive information and determining the generation parameters of the model based on the objectiveness and accuracy to complete the training of the model, a pre-set reward mechanism and penalty mechanism are obtained, a first score of the objectiveness and the accuracy is calculated based on the reward mechanism, a second score of the objectiveness and the accuracy is calculated based on the penalty mechanism, and the generation parameters of the model are modified and determined based on the first score and the second score to complete the training of the model. In one embodiment, the reward concept in reinforcement learning is borrowed to establish an indicator evaluation system for unlabeled legal person unlabeled data sets to reward according to the generated description, so as to encourage the generated description to contain better target and accuracy. The target is whether the generated description matches the input image, and the accuracy is whether the generated description contains enough details. At the same time, in order to make the generated description more accurate and more in line with the description norms of the language and to prevent the same descriptive words from appearing repeatedly in the generated description, a repetition penalty mechanism is established. If repeated words appear in the generated description, the score is reduced for punishment. Then, the generation parameters of the model are modified and determined according to the first score and the second score to complete the training of the model, thereby improving the accuracy of the production parameters and improving the target and accuracy of the generated description of the model for the image.
[0105] Reference Figure 8 The present application also provides a training device for an image description information generation model, comprising:
[0106] A data acquisition module 101 is used to acquire a labeled data set and an unlabeled data set;
[0107] The target recognition module 102 is used to recognize the first image in the labeled data set, obtain the target of the first image and the target category label corresponding to the target;
[0108] A feature description module 103, configured to extract regional features of the first image according to the target category label, and obtain a generated description of the first image by a model according to the regional features;
[0109] A parameter adjustment module 104, used to calculate the cross entropy between the generated description and the true description, and modify the generation parameters of the model according to the cross entropy;
[0110] An image description module 105, configured to input the unlabeled data set into the modified model to obtain description information of a second image in the unlabeled data set;
[0111] The parameter determination module 106 is used to calculate the objectivity and accuracy of the description information, and determine the generation parameters of the model according to the objectivity and accuracy to complete the training of the model.
[0112] As described above, it can be understood that the various components of the training device for the image description information generation model proposed in the present application can realize the functions of any of the training methods for the image description information generation model described above.
[0113] In one embodiment, calculating the cross entropy between the generated description and the true description, and modifying the generation parameters of the model according to the cross entropy, includes:
[0114] Calculating the cross entropy between the generated description and the true description;
[0115] If the cross entropy does not meet the preset condition, obtaining context information of the generated description;
[0116] The words to be replaced in the generated description are replaced in sequence according to the context information, and the generation parameters are modified until the cross entropy between the generated description and the real description after replacement meets a preset condition.
[0117] In one embodiment, after inputting the unlabeled data set into the modified model to obtain the description information of the second image in the unlabeled data set, the method further includes:
[0118] Use the BERT algorithm to mask the generated words in the description information;
[0119] Acquire context information of the description information;
[0120] Determining a replacement word for the generated word according to context information of the description information;
[0121] The generated word is modified to the replacement word to obtain modified description information of the second image.
[0122] In one embodiment, the step of modifying the generated word to the replacement word to obtain modified description information of the second image includes:
[0123] Calculating a first cosine similarity between the description information including the generated word and the second image;
[0124] Calculating a second cosine similarity between the description information including the replacement word and the second image;
[0125] If the second cosine similarity is greater than the first cosine similarity, the generated word in the description information is modified to the replacement word to obtain modified description information of the second image.
[0126] In one embodiment, before extracting the regional features of the first image according to the target category label, the method further includes:
[0127] Get the starting position coordinates of the bounding box;
[0128] Learning the variables in the position coordinates based on linear regression makes the bounding box approach the real box, and obtains the target position coordinates of the bounding box;
[0129] The area range information of the first image is determined according to the bounding box of the target position coordinates.
[0130] In one embodiment, after calculating the cross entropy between the generated description and the true description and modifying the generation parameters of the model according to the cross entropy, the method further includes:
[0131] Calculating a relevance score between the generated description and the first image;
[0132] Obtaining preset relevance evaluation rules;
[0133] Calculate the score of the relevance score according to the relevance evaluation rule;
[0134] The generation parameters of the model are modified according to the score value.
[0135] In one embodiment, the calculating the objectivity and accuracy of the description information and determining the generation parameters of the model according to the objectivity and accuracy to complete the training of the model includes:
[0136] Get pre-set reward and punishment mechanisms;
[0137] Calculating a first score of the targetness and the accuracy according to the reward mechanism;
[0138] Calculating a second score of the targetness and the accuracy according to the penalty mechanism;
[0139] The generation parameters of the model are modified and determined according to the first score and the second score to complete the training of the model.
[0140] Reference Fig. 9 In the embodiment of the present application, a computer device is also provided. The computer device may be a mobile terminal, and its internal structure may be as follows: Fig. 9 As shown. The computer device includes a processor, a memory, a network interface, a display device and an input device connected through a system bus. Among them, the network interface of the computer device is used to communicate with an external terminal through a network connection. The display device of the computer device is used to display offline applications. The input device of the computer device is used to receive user input in offline applications. The processor designed by the computer is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium. The non-volatile storage medium stores an operating system, a computer program and a database. The database of the computer device is used to store raw data. When the computer program is executed by the processor, a training method for an image description information generation model is implemented.
[0141] The above-mentioned processor executes the above-mentioned training method of the image description information generation model, and the method includes: obtaining a labeled data set and an unlabeled data set; identifying a first image in the labeled data set, obtaining a target of the first image and a target category label corresponding to the target; extracting regional features of the first image according to the target category label, and obtaining a generated description of the first image by the model according to the regional features; calculating the cross entropy between the generated description and the true description, and modifying the generation parameters of the model according to the cross entropy; inputting the unlabeled data set into the modified model to obtain the description information of the second image in the unlabeled data set; calculating the target and accuracy of the description information, and determining the generation parameters of the model according to the target and accuracy to complete the training of the model.
[0142] The computer device provides a training method for a new object image description generation model based on multimodality. By training the image description generation model, the image description generation model can be used to describe different images input into the model in fluent and grammatically accurate sentences. First, a data set is obtained, and the data set is divided into two parts, one part is a data set with text annotations, i.e., a labeled data set, and the other part is a data set without text annotations, i.e., an unlabeled data set. A first image in the labeled data set is identified, and a target of the first image and a target category label corresponding to the target are obtained. The first image is segmented according to the target category label into several different regions, and then the features of the image in each region are extracted. The regional features of the first image are then input into the generation network of the model. The generation network outputs the corresponding generation description after identifying the first image, thereby generating a new object image based on the image description. The regional feature acquisition model generates a description of the first image, calculates the cross entropy between the generated description and the true description, the true description being the annotation corresponding to the first image in the labeled data set, and then modifies the generation parameters of the model according to the cross entropy, so that the model tends to generate a generated description with a smaller cross entropy with the true description, inputs the unlabeled data set into the modified model, obtains description information of the second image in the unlabeled data set, calculates the objectivity and accuracy of the description information, determines the generation parameters of the model according to the objectivity and accuracy, and continuously optimizes the generation parameters so that a fluent and grammatically accurate description of the unlabeled second image can be obtained based on the generation parameters, thereby completing the training of the model. The trained model can reduce dependence on the labeled data set and can generate a more accurate and visually rich image description for the input image.
[0143] An embodiment of the present application also provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by the processor, a training method for an image description information generation model is implemented, comprising the following steps: obtaining a labeled data set and an unlabeled data set; identifying a first image in the labeled data set, obtaining a target of the first image and a target category label corresponding to the target; extracting regional features of the first image according to the target category label, and obtaining a generated description of the first image by the model according to the regional features; calculating a cross entropy between the generated description and a true description, and modifying the generation parameters of the model according to the cross entropy; inputting the unlabeled data set into the modified model to obtain description information of the second image in the unlabeled data set; calculating the target and accuracy of the description information, and determining the generation parameters of the model according to the target and accuracy to complete the training of the model.
[0144] The computer-readable storage medium provides a training method for a new object image description generation model based on multimodality. By training the image description generation model, the image description generation model can describe different images input into the model in fluent and grammatically accurate sentences. First, a data set is obtained, and the data set is divided into two parts, one part is a data set with text annotations, i.e., a labeled data set, and the other part is a data set without text annotations, i.e., an unlabeled data set. A first image in the labeled data set is identified, and an object of the first image and an object category label corresponding to the object are obtained. The first image is segmented according to the object category label into several different regions, and then the features of the image in each region are extracted. The regional features of the first image are then input into the generative network of the model. The generative network outputs a corresponding generated description based on the recognition of the first image, thereby A generated description of the first image by the model is obtained according to the regional features, and a cross entropy between the generated description and the true description is calculated, where the true description is the annotation corresponding to the first image in the labeled data set. Then, the generation parameters of the model are modified according to the cross entropy, so that the model tends to generate a generated description with a smaller cross entropy with the true description. The unlabeled data set is input into the modified model to obtain description information of the second image in the unlabeled data set, and the objectivity and accuracy of the description information are calculated. The generation parameters of the model are determined according to the objectivity and accuracy. By continuously optimizing the generation parameters, a fluent and grammatically accurate description of the unlabeled second image can be obtained based on the generation parameters, and the training of the model is completed. The trained model can reduce the dependence on the labeled data set and can generate a more accurate and visually rich image description for the input image.
[0145] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media provided in this application and used in the embodiments may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (SSRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0146] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, device, article or method including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, device, article or method. In the absence of further restrictions, an element defined by the sentence "includes a ..." does not exclude the existence of other identical elements in the process, device, article or method including the element.
[0147] The above description is only a preferred embodiment of the present application, and does not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. A training method for an image description information generation model, characterized in that: The method comprises: Obtain labeled and unlabeled datasets; Identify a first image in the labeled data set, and obtain an object of the first image and an object category label corresponding to the object; Extracting regional features of the first image according to the target category label, and obtaining a generated description of the first image by a model according to the regional features; Calculating the cross entropy between the generated description and the true description, and modifying the generation parameters of the model according to the cross entropy; Inputting the unlabeled data set into the modified model to obtain description information of the second image in the unlabeled data set; The objectiveness and accuracy of the description information are calculated, and generation parameters of the model are determined according to the objectiveness and accuracy to complete the training of the model; wherein, the degree of matching between the description information and the target in the second image is calculated based on the BERT algorithm, and the objectiveness of the description information is determined according to the matching degree; the proportion of key information contained in the description information is calculated based on a pre-established indicator evaluation system, and the accuracy of the description information is determined according to the proportion.
2. The training method for the image description information generation model according to claim 1, characterized in that: The calculating the cross entropy between the generated description and the true description, and modifying the generation parameters of the model according to the cross entropy, includes: Calculating the cross entropy between the generated description and the true description; If the cross entropy does not meet the preset condition, obtaining context information of the generated description; The words to be replaced in the generated description are replaced in sequence according to the context information, and the generation parameters are modified until the cross entropy between the generated description and the real description after replacement meets a preset condition.
3. The training method for the image description information generation model according to claim 1, characterized in that: After inputting the unlabeled data set into the modified model to obtain description information of the second image in the unlabeled data set, the method further includes: Use the BERT algorithm to mask the generated words in the description information; Obtaining context information of the description information; Determining a replacement word for the generated word according to context information of the description information; The generated word is modified to the replacement word to obtain modified description information of the second image.
4. The training method for the image description information generation model according to claim 3, characterized in that: The step of modifying the generated word to the replacement word to obtain modified description information of the second image includes: Calculating a first cosine similarity between the description information including the generated word and the second image; Calculating a second cosine similarity between the description information including the replacement word and the second image; If the second cosine similarity is greater than the first cosine similarity, the generated word in the description information is modified to the replacement word to obtain modified description information of the second image.
5. The training method for an image description information generation model according to claim 1, characterized in that: Before extracting the regional features of the first image according to the target category label, the method further includes: Get the starting position coordinates of the bounding box; Learning the variables in the position coordinates based on linear regression makes the bounding box approach the real box, and obtains the target position coordinates of the bounding box; The area range information of the first image is determined according to the bounding box of the target position coordinates.
6. The training method for an image description information generation model according to claim 1, characterized in that: After calculating the cross entropy between the generated description and the true description and modifying the generation parameters of the model according to the cross entropy, the method further includes: Calculating a relevance score between the generated description and the first image; Obtaining preset relevance evaluation rules; Calculate the score of the relevance score according to the relevance evaluation rule; The generation parameters of the model are modified according to the score value.
7. The training method for an image description information generation model according to claim 1, characterized in that: The calculating the objectivity and accuracy of the description information and determining the generation parameters of the model according to the objectivity and accuracy to complete the training of the model includes: Get pre-set reward and punishment mechanisms; Calculating a first score of the targetness and the accuracy according to the reward mechanism; Calculating a second score of the targetness and the accuracy according to the penalty mechanism; The generation parameters of the model are modified and determined according to the first score and the second score to complete the training of the model.
8. A training device for an image description information generation model, characterized in that: The device comprises: A data acquisition module, used to acquire labeled data sets and unlabeled data sets; An object recognition module is used to recognize a first image in the labeled data set, and obtain an object of the first image and an object category label corresponding to the object; A feature description module, used to extract regional features of the first image according to the target category label, and obtain a generated description of the first image by a model according to the regional features; A parameter adjustment module, used to calculate the cross entropy between the generated description and the true description, and modify the generation parameters of the model according to the cross entropy; An image description module, used for inputting the unlabeled data set into the modified model to obtain description information of a second image in the unlabeled data set; A parameter determination module is used to calculate the objectivity and accuracy of the description information, and determine the generation parameters of the model according to the objectivity and accuracy to complete the training of the model; wherein, the matching degree between the description information and the target in the second image is calculated based on the BERT algorithm, and the objectivity of the description information is determined according to the matching degree; based on a pre-established indicator evaluation system, the proportion of key information contained in the description information is calculated, and the accuracy of the description information is determined according to the proportion.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the training method of the image description information generation model described in any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the training method of the image description information generation model described in any one of claims 1 to 7 is implemented.
