Image description method, device, electronic device and storage medium
By determining the update of target information and attention information in the image description method, simulating people's attention conversion during image description, solves the problem of single descriptive text style in the existing technology, and improves the richness and interactivity of description. .
Patent Information
- Application Number
- CN202010916526.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-09-03
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2040-09-03
AI Technical Summary
The descriptive text generated by existing image description methods has a single style and content, cannot fit the interest points and knowledge points that users need to observe, and has poor interactivity.
By determining the target information in the image to be described, including multiple targets and the relationships between them, the current attention information to be described is determined from the target information based on the previous text sequence, and the current text sequence is generated to simulate people describing images. Switch your attention at different times to ensure the richness and pertinence of your description.
The generated description text can better fit the points of interest and knowledge points that users need to pay attention to during observation, improving the richness and user interactivity of image descriptions.
Smart Images

Figure CN112016493B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer vision technology, and in particular to an image description method, device, electronic device and storage medium. Background Art
[0002] Image Caption refers to the use of computer vision technology to generate descriptive text about the content of a given image, thereby achieving the conversion from image pixels to text.
[0003] The descriptive texts generated by existing image description methods usually present the same sentence structure, resulting in poor diversity in style and content of the generated descriptive texts. The descriptions of the images are not rich and vivid enough, and cannot fit the points of interest and knowledge that users need to pay attention to. Summary of the invention
[0004] The embodiments of the present invention provide an image description method, device, electronic device and storage medium, which are used to solve the problem that the descriptive text style and content generated by the existing image description method are single and the interactivity with the user is poor.
[0005] In a first aspect, an embodiment of the present invention provides an image description method, including:
[0006] Determine target information in the image to be described; the target information includes multiple targets and the relationship between them;
[0007] Based on the previous text sequence, determining the current attention information to be described from the target information, and generating the current text sequence based on the attention information, wherein the previous text sequence and the current text sequence are the text sequences obtained by the previous description task and the current description task respectively, and the current text sequence contains the previous text sequence;
[0008] The text sequence obtained from the last description task is used as the description text of the image to be described.
[0009] Optionally, the determining, based on the previous text sequence, the attention information to be described from the target information, and generating the current text sequence based on the attention information specifically includes:
[0010] Based on the previous text sequence, the attention information to be described last time is updated as the attention information to be described currently; wherein the attention information to be described for the first time is determined based on the target information;
[0011] Based on the current attention information to be described, a current text sequence is generated on the basis of the previous text sequence.
[0012] Optionally, the method for determining the attention information to be described for the first time comprises the following steps:
[0013] Extracting interest features from the scene graph corresponding to the target information to obtain interest features of each node in the scene graph;
[0014] Based on the attention distribution of the interest features of each node in the scene graph, the related nodes of each node are sampled, and the target features of each node are determined based on the related nodes of each node after sampling, and the target features of each node are used as the attention information to be described for the first time.
[0015] Optionally, the updating of the attention information to be described last time to the attention information to be described currently based on the previous text sequence specifically includes:
[0016] Based on the previous text sequence, target features updated after the previous description task is completed are updated to obtain target features after the previous description task is completed; the target features are feature representations of the target information;
[0017] Based on the previous text sequence and the target features after the previous description task is completed, the target flow update is performed on the attention information to be described last time to obtain the current attention information to be described.
[0018] Optionally, the target feature updated after the previous description task is completed based on the previous text sequence is updated to obtain the target feature after the previous description task is completed, specifically including:
[0019] The current feature update parameter is determined based on the correlation between the previous text sequence and the target feature updated after the previous description task is completed, and the target feature updated after the previous description task is completed is updated based on the current feature update parameter to obtain the target feature after the previous description task is completed.
[0020] Optionally, the target flow updating of the attention information to be described last time based on the last text sequence and the target feature after the last description task is completed to obtain the current attention information to be described specifically includes:
[0021] Determine the flow probability of the last description task corresponding to each information flow state based on the correlation between the last text sequence and each information flow state, and the correlation between the target feature after the last description task is completed and each information flow state;
[0022] Based on the representation and flow probability of each information flow state, the target flow is updated for the attention information to be described last time to obtain the current attention information to be described;
[0023] The representation of each information flow state is determined based on the target information and the current update times.
[0024] Optionally, the target information also includes preset relationships between target objects and / or target object attributes.
[0025] In a second aspect, an embodiment of the present invention provides an image description device, including:
[0026] An information determination unit, used to determine target information in the image to be described; the target information includes a plurality of target objects and the relationship between them;
[0027] A text generation unit is used to determine the current attention information to be described from the target information based on the previous text sequence, and generate a current text sequence based on the attention information, wherein the previous text sequence and the current text sequence are the text sequences obtained from the previous description task and the current description task respectively, and the current text sequence contains the previous text sequence; and the text sequence obtained from the last description task is used as the description text of the image to be described.
[0028] In a third aspect, an embodiment of the present invention provides an electronic device, comprising a processor, a communication interface, a memory and a bus, wherein the processor, the communication interface and the memory communicate with each other through the bus, and the processor can call logical commands in the memory to execute the steps of the image description method provided in the first aspect.
[0029] In a fourth aspect, an embodiment of the present invention provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the image description method provided in the first aspect.
[0030] The image description method, device, electronic device and storage medium provided by the embodiments of the present invention, during the image description process, determine the current attention information to be described from multiple targets and the relationship between them according to the previous text sequence, generate the current text sequence, and finally obtain the description text of the image to be described. By simulating the flow of attention conversion when describing an image, the description text obtained by the image description can fit the interest points and knowledge points that the user needs to pay attention to, thereby ensuring the richness and pertinence of the image description and improving the interactivity with the user. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0032] Figure 1 A schematic diagram of a flow chart of an image description method provided by an embodiment of the present invention;
[0033] Figure 2 A schematic diagram of an image to be described provided by an embodiment of the present invention;
[0034] Figure 3 A schematic diagram of a flow chart of a text sequence determination method provided by an embodiment of the present invention;
[0035] Figure 4 A flowchart of a text generation method based on Transformer provided in an embodiment of the present invention;
[0036] Figure 5 A flowchart of a method for determining attention information to be described for the first time provided by an embodiment of the present invention;
[0037] Figure 6 A scene graph of an image to be described provided by an embodiment of the present invention;
[0038] Figure 7 A flowchart of an attention information updating method provided by an embodiment of the present invention;
[0039] Figure 8 A schematic diagram of the structure of an image description device provided by an embodiment of the present invention;
[0040] Fig. 9 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0041] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0042] When describing an image, the prior art usually uses technologies such as CNN (Convolutional Neural Networks), RNN (Recurrent Neural Network) and Attention mechanism to establish a description model, encode the features in the image to obtain a feature vector in a fixed dimensional space, and then decode it based on a decoder in machine translation technology to generate a description text. The generated description text has a fixed sentence structure and a single content.
[0043] In view of the shortcomings of existing technologies, Figure 1 A schematic diagram of a flow chart of an image description method provided by an embodiment of the present invention, such as Figure 1 As shown, the method includes:
[0044] Step 110, determining target information in the image to be described; the target information includes multiple targets and the relationship between them.
[0045] Specifically, the image to be described is an image that needs to be converted into a description text by means of computer vision technology. The target information in the image to be described includes multiple targets in the image to be described and the relationship between each target.
[0046] The target objects may be concrete objects in the image to be described, such as people, plants, animals, scenery and buildings, etc., or abstract objects in the image to be described, such as graphics and logos, etc. The relationship between the target objects may be various types of relationships such as position relationship, size relationship, motion relationship, dependency relationship, etc.
[0047] For example, Figure 2 A schematic diagram of an image to be described provided by an embodiment of the present invention, such as Figure 2 As shown, during the driving process of the car, the car monitoring system can detect that the driver is not wearing a seat belt according to the status of the components, and thus display a seat belt unfastened reminder sign on the car display screen. Due to the different levels of drivers' cognition of the interior of the car, the driver may not be able to accurately identify the status monitoring information given on the car display screen. At this time, the driver needs to use the intelligent assisted driving system to identify the reminder sign. When identifying the reminder sign, the target information that the intelligent assisted driving system needs to provide to the driver includes not only the target objects "driver" and "seat belt", but also the relationship between the target objects, that is, the "fastened" relationship between the "driver" and the "seat belt".
[0048] To determine the target information in the image to be described, we can first perform target detection on the image to be described to obtain the various target objects in the image to be described, and then input every two target objects into a pre-trained relationship classification model to obtain the relationship between every two target objects output by the relationship classification model.
[0049] Furthermore, an end-to-end YOLO model (You Only Look Once, target detection model) can be used for target detection, so as to obtain the position frame information and corresponding semantic labels of multiple targets contained in the image to be described. For example, the fault warning light of a car is usually composed of lines, circles, rectangles and cartoon characters. When performing target detection, the human figure and the tilted rectangle in the seat belt unfastened reminder sign are detected, and their corresponding semantic labels are "driver" and "seat belt" respectively.
[0050] Furthermore, the regressed bounding boxes of multiple targets obtained by target detection can be paired in pairs, and a pre-trained relationship classification model can be used to perform relationship classification. The relationship classification model can be a multi-classification model constructed by stacking multiple convolutional layers. The relationship between the targets is classified using the relationship classification model, and the classification result with the highest confidence is used as the final result of the relationship between the two targets. For example, the relationship between the figure and the tilted rectangle in the seat belt unfastened reminder sign can be "carrying", "fastening" and "holding", etc. According to the relationship classification model, the classification result with the highest confidence, "fastening", is used as the final classification result.
[0051] Step 120, based on the previous text sequence, determine the current attention information to be described from the target information, and generate the current text sequence based on the attention information, the previous text sequence and the current text sequence are the text sequences obtained by the previous description task and the current description task respectively, and the current text sequence contains the previous text sequence;
[0052] The text sequence obtained from the last description task is used as the description text of the image to be described.
[0053] Specifically, the description text is a sentence that expresses the target information in the image to be described in natural language. After determining the target information in the image to be described, the target information needs to be summarized and organized into a natural sentence that conforms to the user's understanding and expression habits.
[0054] When people observe and describe images, they usually focus on the objects in the image and the relationships between them, and form an order of image description based on knowledge and experience. In the process of forming the descriptive text, people will shift their attention to the objects in the image and the relationships between them one by one according to the order of image description, and determine the focus of the description at the current moment through the flow of attention, thereby achieving a description of all the objects in the image and the relationships between them.
[0055] In an embodiment of the present invention, the description text obtained by the image description can be specifically expressed in the form of a text sequence. The generation of the description text can simulate the process of human image description, and can be divided into a process of generating word segments one by one in the text sequence. In this process, each time a new word segment is generated and the text sequence is updated can be regarded as a description task in the overall image description task. Referring to the image description habits of people, each description task can correspond to different focus points, that is, the attention information to be described each time is different. The attention information to be described each time can specifically focus on the part of the target information that has not been described, thereby avoiding repeated descriptions or description omissions, or can focus on the part of the target information that is described in a sequence after the previously described part, thereby ensuring the coherence and fluency of the description sequence.
[0056] Furthermore, the previous text sequence is the text sequence obtained in the previous description task. The previous text sequence contains the attention information in the previous description task and the description, which can guide the current description task to determine the points that need to be paid attention to from the target information, and then determine the attention information in the current description task. On this basis, the current text sequence is generated based on the current attention information to be described. It should be noted that the current text sequence is generated based on the previous text sequence. For example, the previous text sequence is "lying on the grass", and the current text sequence is "a puppy is lying on the grass".
[0057] By performing multiple description tasks, the text sequence obtained from the last description task can cover all the targets and the relationships between the targets in the image to be described without repetition or omission, and is used as the description text of the image to be described.
[0058] The image description method provided by the embodiment of the present invention determines the current attention information to be described from multiple targets and the relationship between them according to the text sequence generated last time during the image description process, generates the current text sequence, and finally obtains the description text of the image to be described. By simulating the flow of attention conversion when describing an image, the description text obtained by the image description can fit the interest points and knowledge points that the user needs to pay attention to, thereby ensuring the richness and pertinence of the image description and improving the interactivity with the user.
[0059] Based on the above embodiment, step 120 specifically includes:
[0060] Input the target information into the image description model to obtain the description text output by the image description model; wherein the image description model is trained based on the target information in the sample image and the sample description text of the sample image;
[0061] The image description model is used to determine the current attention information to be described from the target information based on the previous text sequence, and generate the current text sequence based on the attention information, and use the text sequence obtained from the last description task as the description text of the image to be described.
[0062] Specifically, the execution of step 120 can be implemented by a pre-trained image description model. After determining the target information, the image description model can be used to describe multiple targets and their relationships multiple times. Each time the description is performed, the attention information to be described is determined from the target information according to the previous text sequence, and the current text sequence is generated based on the attention information, and the text sequence obtained from the last description task is used as the description text of the image to be described.
[0063] Before executing step 120, the image description model can be pre-trained. Specifically, the image description model can be trained in the following manner: first, a large number of sample images are collected, and the sample target information in each sample image is determined. The sample target information includes multiple sample targets and the relationship between them. The multiple sample targets in each sample image and the relationship between them are described in natural language manually to obtain the corresponding sample description text. Then, each sample image and the sample description text of each sample image are input into the initial model for training, thereby obtaining the image description model.
[0064] Based on the above embodiments, Figure 3 A flowchart of a text sequence determination method provided by an embodiment of the present invention is shown in FIG. Figure 3 As shown, step 120 specifically includes:
[0065] Step 121, based on the previous text sequence, updating the attention information to be described last time as the attention information to be described currently; wherein the attention information to be described for the first time is determined based on the target information;
[0066] Specifically, before executing the current description task, the relationship between the target objects and the target objects described in the previous description task can be analyzed based on the previous text sequence, and then combined with the relationship between the target objects and the target objects described in the previous description task, the focus of the attention information to be described in the previous description task is transferred, and the focus of the current description task is updated, thereby obtaining the current attention information to be described. By updating the attention information before each description task is executed, each description task can focus more on the relationship between the target objects and the target objects to be described in the target information.
[0067] It should be noted that when the attention information to be described is obtained for the first time, since there is no text sequence and attention information before the first description task, the target information can be directly feature extracted to obtain the attention information to be described for the first time. Then, when performing the next description task, the current attention information to be described is determined based on the previous text sequence and the last attention information to be described.
[0068] Step 122, based on the current attention information to be described, generate the current text sequence on the basis of the previous text sequence.
[0069] Specifically, new word segmentation can be generated based on the previous text sequence according to the current attention information to be described, thereby obtaining the current text sequence. Furthermore, in order to improve the expressiveness of the description text of the image to be described, a language model with a structure such as Transformer can be used to generate a text sequence, thereby obtaining a description text with stronger expressiveness.
[0070] The image description method provided by the embodiment of the present invention updates the attention information to be described last time based on the previous text sequence, and then obtains the current attention information to be described, so as to realize the image description of the current word and obtain the current text sequence. By successively updating the attention information, the attention flow in the image description process is realized, so that the generated description text of the image to be described has richer expression ability.
[0071] Based on any of the above embodiments, Figure 4 A flowchart of a text generation method based on Transformer provided in an embodiment of the present invention is shown in FIG. Figure 4 As shown in the figure, when describing the image to be described, the current time step is t, and the previous text sequence Y is respectively described through LSTM (Long Short-Term Memory). t-1 ={y o ,y 1 ,…,y t-1} and the current attention information to be described Encode to obtain the hidden vector of the previous text sequence and the hidden vector of the current attention information to be described. Here, y o ,y 1 , …, y t-1 The word segmentation in the text sequence generated for time steps 0 to t-1, is the vector representation of the attention information of each node in the scene graph corresponding to the target information at the current time step t, and N is the number of nodes in the scene graph. Then, the hidden vectors of both are encoded and converted through a multilayer perceptron (MLP) to obtain vectors in the same dimensional space, which are then superimposed and the superimposed vectors and the previous text sequence are input into the pre-trained Transformer model to obtain the current text sequence.
[0072] The Transformer model here can be implemented using the open source xlnet structure. The Transformer model is obtained after pre-training on a large-scale corpus, has strong learning and expression capabilities, and can use a richer vocabulary to express and describe text.
[0073] Based on any of the above embodiments, Figure 5 A flowchart of a method for determining attention information to be described for the first time provided in an embodiment of the present invention is shown in FIG. Figure 5 As shown, the method for determining the attention information to be described for the first time includes the following steps:
[0074] Step 510, extracting interest features from the scene graph corresponding to the target information to obtain interest features of each node in the scene graph.
[0075] Specifically, the target information contains multiple targets and the relationships between multiple targets. The relationships between targets can be represented by a scene graph. A scene graph is a graph result consisting of nodes and connections between nodes. The scene graph corresponding to the target information contains nodes and lines between nodes. The targets and the relationships between targets in the target information correspond to nodes in the scene graph. The lines between nodes in the scene graph represent the directions between nodes. The scene graph can be represented by the following formula:
[0076] G={x i}
[0077] Where G is the scene graph, x i is any node in the scene graph, which can be a target node, an attribute node or an edge node, and i is the node number.
[0078] For example, Figure 6 The scene graph of the image to be described provided by the embodiment of the present invention is as follows: Figure 6As shown in FIG. 1 , the scene graph includes two target nodes and one edge node. The two target nodes are “driver” and “seat belt”, and the edge node is “fastened”.
[0079] As a carrier of the semantic labels of each target object in the image to be described and the relationship between the targets, the scene graph can fully display the target information. At the same time, applying the scene graph as a topological relationship graph to feature extraction based on graph neural networks can well extract the original information about the relationship between the targets, so as to facilitate the implementation of subsequent image description tasks.
[0080] In order to ensure that the description of the image to be described is strongly related to the image as a whole, that is, to be able to pay attention to the connection between important objects in the image, the features of the nodes and edges between nodes that need to be paid more attention to in the scene graph can be extracted, so as to obtain the interest features of each node in the scene graph. Furthermore, the Laplacian matrix corresponding to the scene graph can be used to calculate the attention matrix of the nodes and edges that the Laplacian matrix needs to pay attention to, so as to abstractly obtain the interest features of each node that needs to be paid attention to in the actual description, which can be expressed as follows:
[0081] X importance =σ(f(L))·(L)·(G)
[0082] L=DA
[0083] Where G is the scene graph, L is the Laplacian matrix corresponding to the scene graph G, and X importance is the interest feature matrix composed of the interest features of each node in the scene graph G, A is the adjacency matrix of the scene graph, D is the degree matrix of the scene graph, f is the feature transformation function, which can be obtained through multi-layer perceptron learning. After the output of f is activated by the activation function σ, the importance of the nodes or edges that should be noticed by the Laplace matrix L is obtained.
[0084] Step 520, based on the attention distribution of the interest feature of each node in the scene graph, sample the related nodes of each node, and determine the target feature of each node based on the related nodes of each node after sampling, and use the target feature of each node as the attention information to be described for the first time.
[0085] Specifically, the interest features of each node in the scene graph G are still distributed in a sparse high-dimensional space. In order to conveniently generate descriptive sentences using the interest features of the nodes, the interest features can be mapped to a dense low-dimensional space.
[0086] Here, the attention distribution is a prior distribution based on the correlation between each node and its neighboring nodes in the scene graph. The attention distribution can be obtained by the following method: importanceUse the attention mechanism algorithm to get the attention distribution, specifically for each node x i The features of interest are respectively represented by {M query ;M key ;M value}, and obtain each node x i The attention query value Attention Key and attention value Among them, M query is the attention query transformation matrix, M key is the attention key value transformation matrix, M value is the attention value transformation matrix. The above three attention transformation matrices are obtained through training. On this basis, the calculation of node x i and node x j The attention coefficient of node x i and node x j The attention coefficient of node x i and node x j The degree of correlation between them can be obtained by conversion and The correlation between them is used as the attention coefficient of the two nodes. After calculating the node x i After the attention coefficients of other nodes in the scene graph are normalized, the normalized attention coefficient is used as the attention coefficient of node x i The attention distribution of the feature of interest is used to randomly sample relevant nodes from the neighboring nodes of each node.
[0087] After obtaining the relevant nodes of each node through random sampling, the target feature of each node is determined based on the relevant nodes of each node. Here, any node x i The related node sequence can be expressed as:
[0088]
[0089] In the formula, To randomly sample node x according to the attention distribution i The 1st to jth related nodes.
[0090] Then we can directly aggregate the relevant node sequences obtained by sampling to get node x i The target feature h i , and use it as the attention information to be described for the first time, which can be expressed as the following formula:
[0091]
[0092] Where samp_neigh is the number of related node sequences obtained by sampling, Mf is a linear change with a bias term, which is used to realize the transformation of features from high-dimensional sparse to low-dimensional dense. j is the serial number of the relevant node, For the relevant node x j The corresponding attention value.
[0093] The image description method provided by the embodiment of the present invention uses a sampling method based on attention distribution to determine the target features of each node. It not only takes into account the node information previously associated with the node, but also combines the node information previously unassociated with the node, thereby better aggregating the information of other nodes in the scene graph to the target features of the node currently being studied, so as to improve the feature representation capability of the target features of each node in the scene graph.
[0094] Based on any of the above embodiments, Figure 7 A flow chart of the attention information updating method provided by an embodiment of the present invention is shown as follows: Figure 7 As shown, step 121 specifically includes:
[0095] Step 1211, based on the previous text sequence, the target feature updated after the previous description task is completed is updated to obtain the target feature after the previous description task is completed.
[0096] Specifically, all nodes in the scene graph should be expressed by the description text, and no missing or repeated phenomena should occur. After the description of a target node in the scene graph is completed, the features related to the target node in the scene graph can be updated. Here, the target feature is the feature representation of the target information. The target feature before the first description task is executed can be obtained by extracting the target information in the image to be described. The target feature after each subsequent description task is obtained by updating the target feature after the last description task. It should be noted that the target feature before the first description task is executed here can be consistent with the attention information to be described for the first time.
[0097] According to the information that has been described in the last description task reflected by the previous text sequence, the target features updated after the previous description task is completed can be updated to obtain the target features after the previous description task is completed. For example, if the previous text sequence is "a puppy is lying on the grass", the features associated with "grass", "lying", and "puppy" in the target features updated after the previous description task is completed can be weakened, and the feature representation of the previous text sequence is updated as the information that has been described to the target features updated after the previous description task is completed, thereby obtaining the target features after the previous description task is completed.
[0098] Step 1212, based on the last text sequence and the target features after the last description task is completed, the target flow of the attention information to be described last time is updated to obtain the current attention information to be described.
[0099] Specifically, the generation of text sequences is not only related to the node features in the scene graph, but also to the information flow state in the scene graph. The information flow state in the scene graph refers to the expected order of node descriptions in the scene graph. For example, if the currently focused node is a target node, then according to the information flow direction of the scene graph, the next node to be visited is likely to be a relationship node or an attribute node connected to the target node, rather than another target node that is not connected to the target node.
[0100] According to the previous text sequence and the target features after the last description task is completed, the information flow state of the scene graph nodes to be described is predicted, so as to update the attention information to be described last time to the attention information to be described currently.
[0101] Based on any of the above embodiments, step 1211 specifically includes:
[0102] The current feature update parameter is determined based on the correlation between the previous text sequence and the target feature updated after the previous description task is completed, and the target feature updated after the previous description task is updated based on the current feature update parameter to obtain the target feature after the previous description task is completed.
[0103] Specifically, after obtaining the previous text sequence, the current feature update parameters can be determined based on the correlation between the previous text sequence and the target features updated after the previous description task is completed, and then the target features updated after the previous description task is updated based on the current feature update parameters. At this time, you can choose to weaken the feature information with a high correlation with the described node features to avoid repeated descriptions, or you can add the information that has been described as reflected in the previous text sequence, so as to deepen the association between the scene graph features and the generated text sequence. Here, the current feature update parameters can specifically be weight parameters for weakening some of the target features updated after the previous description task is completed, and / or weight parameters for enhancing some of the target features updated after the previous description task is completed.
[0104] Assume that when the description time step is t, the previous text sequence generated is {y 1 ,y 2 ,····,y t-1}, the target feature updated after the last description task is completed is Where N is the number of nodes in the scene graph.
[0105] In order to facilitate the calculation of the correlation between the previous text sequence and the target features updated after the previous description task, the previous text sequence and the target features updated after the previous description task can be converted to the same dimensional space. Here, the dimensional conversion can be achieved through a BILSTM layer (Bi-directional Long Short-Term Memory) and a linear transformation layer. For example, the conversion of the previous text sequence can be reflected in the following formula:
[0106] y t-1 =BILSTM({y 1 ,y 2 ,····,y t-1})
[0107] In the formula, y t-1 That is, the feature representation of the previous text sequence after dimension conversion.
[0108] The current feature update parameters may include the current feature removal matrix and / or the current feature addition matrix. The current feature removal matrix may be used to weaken the features with high correlation with the previous text sequence in the target features updated after the previous description task is completed, and the current feature addition matrix may be used to supplement the features that have been described in the previous text sequence in the target features updated after the previous description task is completed. Assume that the correlation between the previous text sequence and the target feature of the i-th node updated after the previous description task is completed can be expressed as Indicates that the current feature removal parameters are expressed by matrix M clear Indicates that the current feature adding parameters are matrix M add Represented as: The current feature removal matrix and the current feature addition matrix can be expressed as:
[0109]
[0110]
[0111] Where I is the unit matrix.
[0112] Relevance It can be solved by using the multilayer perceptron (MLP) mechanism, or it can be calculated by distance similarity, cosine similarity and other algorithms and then normalized to between 0 and 1. It should be noted that The larger the value of , the weaker the correlation between the target feature updated after the previous description task and the previous text sequence. Here, the correlation solved by MLP can be expressed as:
[0113]
[0114] Where M clear_y is the preset text sequence feature cleaning parameter, M clear_g For the preset image target feature clearing parameters, is the target feature of the i-th node updated after the last description task is completed.
[0115] Based on the current feature update parameters, the target features updated after the last description task are updated can be expressed as:
[0116]
[0117] In the formula, is the target feature of the i-th node updated after the last description task. The current feature removal parameter M clear The target feature of the i-th node updated after the last description task is completed Multiplication achieves the weakening of the target features updated after the previous description task, which are highly correlated with the previous text sequence; the current feature adds parameter M add By multiplying the feature representation of the previous text sequence, the information described in the previous text sequence is supplemented, which helps to combine the previously generated context information in the current image description task.
[0118] For example, the previous text sequence is "lying on the grass", and the previous text sequence is "a puppy is lying on the grass". When generating the current text sequence, since the feature information of "on the grass" and "lying" in the target features updated after the previous description task is highly correlated with the previous text sequence, the current feature cleaning parameter can be multiplied with the target features updated after the previous description task to weaken the feature information of "grass" and "lying" in the target features updated after the previous description task, thereby avoiding repeated descriptions of "grass" and "lying".
[0119] In addition, the current feature addition parameter can be used to multiply the feature representation of the previous text sequence, and the described information embodied in the previous text sequence can be added to the target feature updated after the previous description task is completed, so that the newly generated target feature updated after the previous description task is completed can also contain the described information as the context information of the current image description task, so as to better combine with the generated text sequence during the execution of the current image description task, thereby improving the fluency of the newly generated text sequence.
[0120] The image description method provided by the embodiment of the present invention adopts a scene graph feature update mechanism to update the described scene graph features, selectively weaken and / or enhance some feature information, so that all nodes in the scene graph are expressed by the description text to avoid omissions or duplications.
[0121] Based on any of the above embodiments, step 1212 specifically includes:
[0122] Based on the correlation between the last text sequence and each information flow state, and the correlation between the target feature after the last description task and each information flow state, the flow probability corresponding to each information flow state of the last description task is determined;
[0123] Based on the representation and flow probability of each information flow state, the target flow is updated for the attention information to be described last time to obtain the current attention information to be described;
[0124] The representation of each information flow state is determined based on the target information and the current update times.
[0125] Specifically, the scene graph of the image to be described is described in real time. When the current text sequence is generated, the description order of the scene graph nodes to be described is controlled according to the described scene graph nodes, so as to simulate the process of human attention transfer and reflect the description order desired by the user.
[0126] The information flow state in the scene graph refers to the expected order of node descriptions in the scene graph, which can be determined based on the target information and the current update count. Generally, the information flow state can be divided into four different operations, corresponding to four different scene graph flow forms:
[0127] The first operation (op_1) is when the information flow state is represented by using multiple words to describe the same node:
[0128]
[0129] The second operation (op_2) is when the information flow state is represented by the description order in the scene graph migrating from one node to the next node clockwise:
[0130]
[0131] The third operation (op_3) is when the information flow state is represented by the order of description in the scene graph migrating from one node to the next in a counterclockwise direction:
[0132]
[0133] The fourth operation (op_4) is when the information flow state is represented by the description order in the scene graph, migrating from one node to the next node clockwise across nodes:
[0134]
[0135] In the above formula, t is the description time step, representing the current update number, α is the initial parameter of the information flow state, and L is the Laplacian matrix of the scene graph corresponding to the target information.
[0136] In the embodiment of the present invention, the probabilities P(op_1), P(op_2), P(op_3) and P(op_4) corresponding to the four information flow states described last can be calculated respectively according to the attention mechanism, and then the node described currently can be predicted according to the information flow state described last. The following describes the calculation method of the probability of the information flow state by calculating P(op_1).
[0137] According to the attention mechanism, the previous text sequence {y 1 ,y 2 ,…,y t-1} and the target characteristics after the last description task is completed Multiply by Get the attention mechanism feature vector of the previous text sequence and the target feature after the previous description task is completed:
[0138]
[0139]
[0140] in, is the attention query transformation matrix under the first information flow state, is the attention key value transformation matrix under the first information flow state, is the attention value transformation matrix under the first information flow state. The above three attention transformation matrices can be obtained through training.
[0141] On this basis, the attention feature value is calculated Among them, Q h is the query matrix of the target features after the last description task is completed K y is the key-value matrix of the previous text sequence d is Q h Matrix and K y The vector dimension of the matrix.
[0142] The attention feature value can be normalized by, for example, a softmax function, to obtain the flow probability P(op_1) corresponding to the first information flow state described last time.
[0143] Similarly, P(op_2), P(op_3) and P(op_4) can be solved.
[0144] According to the representation and flow probability of each information flow state, the attention information Z to be described last time is t-1 Update and get the current attention information Z to be described t , expressed as:
[0145]
[0146] It should be noted that the attention information Z to be described for the first time 0 It can be determined based on the initial target features of each node, for example, Z 0 is the initial target feature of each node
[0147] The image description method provided by the embodiment of the present invention adopts the attention mechanism of graph information flow to control the description order of scene graph nodes to be described according to the described scene graph nodes, thereby simulating the process of human attention transfer and being closer to the expected description order.
[0148] Based on any of the above embodiments, the target information further includes preset relationships between target objects and / or target object attributes.
[0149] Specifically, in order to better determine the points of interest and knowledge points that the user is concerned about in the image to be described, the preset relationship between the target objects can be added to the target information in the determined image to be described. For example, the fault alarm logo of the automobile airbag system is usually composed of a circular icon and a cartoon character graphic. If computer vision technology is used to describe the image, it is very likely that the description text obtained will be "the driver is holding the airbag", and the recognition result shows that it is not in line with the facts. The description text that is consistent with the user's correct understanding should be "the airbag protects the driver". Therefore, the preset relationship "protection" can be added between the already determined "airbag" and "driver" to make the relationship between the target objects in the image description more accurate.
[0150] When describing certain objects in the image to be described, there will be some attribute descriptions in the cultural background. The unrecognized object can be compared with the similar objects that have been recognized before. This analogy is used as an object attribute and is also added to the target information. For example, the automotive electronic safety system is generally identified by the system abbreviation letters and circular patterns. Specifically, the fault alarm logo of the automotive anti-lock brake system (ABS) is usually composed of the letters ABS and a circular pattern.
[0151] Since the ABS system is a basic configuration of the car, the ABS fault alarm logo is more common in the car monitoring system, while other types of electronic safety systems are configured according to different vehicle types, and the corresponding fault alarm logo is not common in the car monitoring system. If the image description is performed using computer vision technology, it may not be recognized. If the ABS fault alarm logo has been identified before, the analogy relationship between other electronic safety systems and the ABS system, "belonging to the car electronic safety system", can be added to the target information as an attribute of the node with a letter logo. When describing other icons displayed in the car monitoring system, "car electronic safety system failure" can be accurately identified.
[0152] The image description method provided by the embodiment of the present invention allows the user to update the target information of the image to be described by himself by adding preset relationships between targets and / or target attributes in the target information, and describe it according to the updated target information. The resulting description text can fit the interest points and knowledge points that the user needs to pay attention to, thereby ensuring the richness of the image description.
[0153] Based on any of the above embodiments, the nodes in the scene graph corresponding to the target information may include a target node (object), an attribute node (attribution), and an edge node (relationship). Among them, the target node represents the target object in the image to be described; the attribute node represents the attribute of the target object, such as color attribute, shape attribute or semantic attribute, etc.; the edge node represents the relationship between the target object and the target object, including position relationship, size relationship, motion relationship, dependency relationship, etc. According to the function of the edge node, the edge node can be divided into three categories: edge nodes of target pointing to attribute, edge nodes of target pointing to relationship, and edge nodes of relationship pointing to target.
[0154] It should be noted that the attributes of the target objects corresponding to the attribute nodes and the relationships between the target objects corresponding to the edge nodes can be obtained by directly identifying and detecting the image to be described, or can be additionally added in combination with the target objects and pre-set relationships or attributes. The embodiments of the present invention do not specifically limit this.
[0155] Based on any of the above embodiments, Figure 8 A schematic diagram of the structure of an image description device provided by an embodiment of the present invention is shown in FIG. Figure 8 As shown, the device comprises:
[0156] The information determination unit 810 is used to determine target information in the image to be described; the target information includes multiple targets and the relationship between them;
[0157] The text generation unit 820 is used to determine the current attention information to be described from the target information based on the previous text sequence, and generate the current text sequence based on the attention information. The previous text sequence and the current text sequence are the text sequences obtained from the previous description task and the current description task respectively, and the current text sequence contains the previous text sequence; the text sequence obtained from the last description task is used as the description text of the image to be described.
[0158] In the image description device provided by an embodiment of the present invention, during the image description process, a text generation unit determines the attention information to be described this time based on the text sequence generated last time and multiple target objects and the relationship between them determined by an information determination unit, generates the text sequence this time, and finally obtains a description text of the image to be described. By simulating the flow of attention conversion when describing an image, the description text obtained by the image description can fit the interest points and knowledge points that the user needs to pay attention to, thereby ensuring the richness and pertinence of the image description and improving the interactivity with the user.
[0159] Based on any of the above embodiments, the text generation unit 820 includes:
[0160] An attention updating subunit, used for updating the attention information to be described last time to the attention information to be described currently based on the previous text sequence; wherein the attention information to be described for the first time is determined based on the target information;
[0161] The text sequence generation subunit is used to generate the current text sequence based on the previous text sequence based on the attention information to be described.
[0162] Based on any of the above embodiments, the device further includes a target feature extraction unit, and the target feature extraction unit is used to:
[0163] Extracting interest features from the scene graph corresponding to the target information to obtain the interest features of each node in the scene graph;
[0164] Based on the attention distribution of the interest features of each node in the scene graph, the related nodes of each node are sampled, and the target features of each node are determined based on the related nodes of each node after sampling, and the target features of each node are used as the attention information to be described for the first time.
[0165] Based on any of the above embodiments, the attention updating subunit specifically includes:
[0166] A target feature updating module is used to update the target feature updated after the previous description task is completed based on the previous text sequence, and obtain the target feature after the previous description task is completed; the target feature is a feature representation of the target information;
[0167] The target flow update module is used to perform target flow update on the attention information to be described last time based on the previous text sequence and the target features after the previous description task is completed, so as to obtain the current attention information to be described.
[0168] Based on any of the above embodiments, the target feature updating module is specifically used for:
[0169] The current feature update parameter is determined based on the correlation between the previous text sequence and the target feature updated after the previous description task is completed, and the target feature updated after the previous description task is updated based on the current feature update parameter to obtain the target feature after the previous description task is completed.
[0170] Based on any of the above embodiments, the target flow update module is specifically used for:
[0171] Based on the correlation between the last text sequence and each information flow state, and the correlation between the target feature after the last description task and each information flow state, the flow probability corresponding to each information flow state of the last description task is determined;
[0172] Based on the representation and flow probability of each information flow state, the target flow is updated for the attention information to be described last time to obtain the current attention information to be described;
[0173] The representation of each information flow state is determined based on the target information and the current update times.
[0174] Based on any of the above embodiments, the target information further includes preset relationships between target objects and / or target object attributes.
[0175] Fig. 9 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention, such as Fig. 9 As shown, the electronic device may include: a processor (Processor) 910, a communication interface (Communications Interface) 920, a memory (Memory) 930 and a communication bus (Communications Bus) 940, wherein the processor 910, the communication interface 920, and the memory 930 communicate with each other through the communication bus 940. The processor 910 may call the logic command in the memory 930 to execute the following method:
[0176] Determine the target information in the image to be described; the target information includes multiple targets and the relationship between them; based on the previous text sequence, determine the current attention information to be described from the target information, and generate the current text sequence based on the attention information, the previous text sequence and the current text sequence are the text sequences obtained by the previous description task and the current description task respectively, and the current text sequence contains the previous text sequence; use the text sequence obtained by the last description task as the description text of the image to be described.
[0177] In addition, the logic commands in the above-mentioned memory 930 can be implemented in the form of software functional units and can be stored in a computer-readable storage medium when sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several commands to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.
[0178] An embodiment of the present invention further provides a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the method provided in each of the above embodiments is implemented, for example, including:
[0179] Determine the target information in the image to be described; the target information includes multiple targets and the relationship between them; based on the previous text sequence, determine the current attention information to be described from the target information, and generate the current text sequence based on the attention information, the previous text sequence and the current text sequence are the text sequences obtained by the previous description task and the current description task respectively, and the current text sequence contains the previous text sequence; use the text sequence obtained by the last description task as the description text of the image to be described.
[0180] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Those of ordinary skill in the art may understand and implement it without creative effort.
[0181] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of commands to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0182] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. An image description method, characterized in that: include: Determine target information in the image to be described; The target information includes multiple targets and the relationship between them; Based on the previous text sequence, the attention information to be described is determined from the target information, and the current text sequence is generated based on the attention information, wherein the previous text sequence and the current text sequence are text sequences obtained from the previous description task and the current description task respectively, and the current text sequence contains the previous text sequence; the previous text sequence includes the attention information of the previous description task and the description task before it; Using the text sequence obtained from the last description task as the description text of the image to be described; The step of determining the current attention information to be described from the target information based on the previous text sequence, and generating the current text sequence based on the attention information, specifically includes: Based on the previous text sequence, the attention information to be described last time is updated as the attention information to be described currently; wherein the attention information to be described for the first time is determined based on the target information; Based on the current attention information to be described, generating a current text sequence on the basis of the previous text sequence; The updating of the attention information to be described last time to the attention information to be described currently based on the previous text sequence specifically includes: Based on the previous text sequence, target features updated after the previous description task is completed are updated to obtain target features after the previous description task is completed; the target features are feature representations of the target information; Based on the previous text sequence and the target features after the previous description task is completed, the target flow is updated for the attention information to be described last time to obtain the current attention information to be described; The target flow updating of the attention information to be described last time based on the last text sequence and the target features after the last description task is completed to obtain the current attention information to be described specifically includes: Determine the flow probability of the last description task corresponding to each information flow state based on the correlation between the last text sequence and each information flow state, and the correlation between the target feature after the last description task is completed and each information flow state; Based on the representation and flow probability of each information flow state, the target flow is updated for the attention information to be described last time to obtain the current attention information to be described; The representation of each information flow state is determined based on the target information and the current update times.
2. The image description method according to claim 1, characterized in that: The method for determining the attention information to be described for the first time comprises the following steps: Extracting interest features from the scene graph corresponding to the target information to obtain interest features of each node in the scene graph; Based on the attention distribution of the interest features of each node in the scene graph, the related nodes of each node are sampled, and the target features of each node are determined based on the related nodes of each node after sampling, and the target features of each node are used as the attention information to be described for the first time.
3. The image description method according to claim 1, characterized in that: The target feature updated after the last description task is completed based on the last text sequence is updated to obtain the target feature after the last description task is completed, specifically including: The current feature update parameter is determined based on the correlation between the previous text sequence and the target feature updated after the previous description task is completed, and the target feature updated after the previous description task is completed is updated based on the current feature update parameter to obtain the target feature after the previous description task is completed.
4. The image description method according to any one of claims 1 to 3, characterized in that: The target information also includes preset relationships between targets and / or target attributes.
5. An image description device, characterized in that: include: An information determination unit, used for determining target information in the image to be described; The target information includes multiple targets and the relationship between them; A text generation unit, used to determine the attention information to be described from the target information based on the previous text sequence, and generate the current text sequence based on the attention information, wherein the previous text sequence and the current text sequence are text sequences obtained from the previous description task and the current description task respectively, and the current text sequence contains the previous text sequence; the previous text sequence includes the attention information of the previous description task and the description tasks before it; Using the text sequence obtained from the last description task as the description text of the image to be described; The text generation unit comprises: An attention updating subunit, used to update the attention information to be described last time to the attention information to be described currently based on the previous text sequence; wherein the attention information to be described for the first time is determined based on the attention distribution of the interest feature of each node in the scene graph corresponding to the target information; A text sequence generating subunit, configured to generate a current text sequence based on the attention information currently to be described and on the basis of the previous text sequence; The attention updating subunit specifically includes: A target feature updating module is used to update the target feature updated after the previous description task is completed based on the previous text sequence, so as to obtain the target feature after the previous description task is completed; the target feature is a feature representation of the target information; A target flow updating module, used to perform target flow updating on the attention information to be described last time based on the last text sequence and the target features after the last description task is completed, so as to obtain the current attention information to be described; The target flow update module is specifically used for: Determine the flow probability of the last description task corresponding to each information flow state based on the correlation between the last text sequence and each information flow state, and the correlation between the target feature after the last description task is completed and each information flow state; Based on the representation and flow probability of each information flow state, the target flow is updated for the attention information to be described last time to obtain the current attention information to be described; The representation of each information flow state is determined based on the target information and the current update times.
6. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the image description method according to any one of claims 1 to 4 are implemented.
7. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the image description method according to any one of claims 1 to 4 are implemented.
