A method, device, equipment and storage medium for determining image text
By combining the sequence generation model and the pre-training model, the retrospective access information of the text sequence is used to determine the image text, which solves the problem of poor correlation and grammatical accuracy of image text description in the existing technology, and improves the accuracy of image and text matching and user experience.
Patent Information
- Application Number
- CN202111042129.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-07
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2041-09-07
AI Technical Summary
When the existing technology automatically generates image text descriptions, it is unable to effectively estimate the smoothness and grammatical accuracy of the description text, resulting in poor relevance of image text descriptions.
By obtaining image features and using the preset sequence generation model and pre-training model, the text sequence is generated and updated. Combined with the Monte Carlo search tree algorithm and the comparative language-image pre-training model, it is determined based on the retrospective access information of each node in the text sequence. Image text.
It improves the accuracy of image and text matching, ensures text smoothness and grammatical correctness, and improves automatic decision-making capabilities and user experience.
Smart Images

Figure CN113688936B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of image processing technology, and in particular to a method, device, equipment and storage medium for determining image text. Background Art
[0002] With the development of computer-related technologies, image processing, as a major component of the field of artificial intelligence, has attracted the attention of many researchers.
[0003] The current solution to automatically generate text descriptions for images is to train hundreds of millions of image texts to obtain a model that can estimate the relevance between text and image content, thereby matching relevant description text for images. However, the text data and image data used for training are relatively messy, and the model can only give relatively suitable image text, but cannot estimate the fluency and grammatical accuracy of the description text. Summary of the invention
[0004] The embodiments of the present invention provide a method, apparatus, device and storage medium for determining image text, so as to implement text description of an image.
[0005] In a first aspect, an embodiment of the present invention provides a method for determining image text, comprising:
[0006] Acquire image features of an image to be recognized, and obtain a text sequence of the image to be recognized based on the image features and a preset sequence generation model; wherein the text sequence includes a root node and a leaf node, and the leaf node includes an intermediate node and an end symbol node;
[0007] According to a preset pre-training model, updating the expected value of the terminator node in the text sequence;
[0008] Tracing back the nodes of the text sequence from the terminator node to the root node, and updating the tracing access information of any node in the text sequence according to the expected value of the terminator node; wherein the tracing access information includes the access frequency and expected value of the intermediate node;
[0009] According to a preset number of text sequence branches, determining whether the number of text sequences meets the requirement of the number of text sequence branches;
[0010] If so, the target leaf node is determined according to the traceability access information of the leaf node, and the text of the root node and the target leaf node are combined to be determined as the image text of the image to be identified.
[0011] In a second aspect, an embodiment of the present invention further provides a device for determining image text, comprising:
[0012] A text sequence acquisition module, used to acquire image features of an image to be recognized, and obtain a text sequence of the image to be recognized based on the image features and a preset sequence generation model; wherein the text sequence includes a root node and a leaf node, and the leaf node includes an intermediate node and an end symbol node;
[0013] An expected value updating module, used for updating the expected value of the terminator node in the text sequence according to a preset pre-training model;
[0014] An access information updating module, used to trace back the nodes of the text sequence from the terminator node to the root node, and update the traceback access information of any node in the text sequence according to the expected value of the terminator node; wherein the traceback access information includes the access frequency and expected value of the intermediate node;
[0015] A text sequence judgment module, used to judge whether the number of text sequences meets the text sequence branch number requirement according to a preset text sequence branch number;
[0016] The image text determination module is used to determine the target leaf node according to the traceability access information of the leaf node, and combine the text of the root node and the target leaf node to determine the image text of the image to be identified.
[0017] In a third aspect, an embodiment of the present invention further provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, a method for determining image text as described in any one of the embodiments of the present invention is implemented.
[0018] In a fourth aspect, an embodiment of the present invention further provides a storage medium comprising computer executable instructions, wherein the computer executable instructions, when executed by a computer processor, are used to execute a method for determining image text as described in any one of the embodiments of the present invention.
[0019] The technical solution of the embodiment of the present invention determines the description text of the image to be identified based on the retroactive access information of each node in the text sequence. In the process of determining the text, the node is selected by comparing the retroactive access information, which solves the shortcomings of the prior art of poor relevance, poor text coherence and poor grammatical accuracy of the image text description, improves the automatic decision-making ability and intelligence in the process of determining the image description text, and improves the user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 A flowchart of a method for determining image text provided in Embodiment 1 of the present invention;
[0021] Figure 2is a flow chart of a method for determining image text provided by Embodiment 2 of the present invention;
[0022] Figure 3 is a flow chart of a method for determining image text provided by Embodiment 3 of the present invention;
[0023] Figure 4 is a structural diagram of an image text determination device provided by a fourth embodiment of the present invention;
[0024] Figure 5 This is a structural diagram of an electronic device provided in Embodiment 5 of the present invention. DETAILED DESCRIPTION
[0025] The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the present invention, rather than to limit the present invention. It should also be noted that, for ease of description, only parts related to the present invention, rather than all structures, are shown in the accompanying drawings.
[0026] Embodiment 1
[0027] Figure 1 A flowchart of a method for determining image text is provided in Embodiment 1 of the present invention. This embodiment is applicable to the case of providing text description for a picture. The method can be executed by an image text determination device, which can be implemented in software and / or hardware and specifically configured in an electronic device.
[0028] refer to Figure 1 , specifically including the following steps:
[0029] S110, obtaining image features of the image to be recognized, and obtaining a text sequence of the image to be recognized based on the image features and a preset sequence generation model; wherein the text sequence includes a root node and a leaf node, and the leaf node includes an intermediate node and an end symbol node.
[0030] The image to be identified refers to an image that needs to be described in text, and can be a picture in any encoding format. Image features can include but are not limited to color features, texture features, shape features, and spatial relationship features of the image. The image features can be obtained by analyzing the image through a pre-trained neural network model. For example, the original image can be input into an image feature extraction model, and the model outputs the image features of the original image.
[0031] A sequence is an object or element arranged in a row. The elements in a text sequence are text, for example, words. The text sequence of an image to be identified refers to the order of text that describes the image. A sequence generation model is a pre-trained neural network model used to determine a text sequence. The acquired image features are input into a pre-trained sequence generation model, which outputs a text sequence used to describe the image to be identified. It is worth noting that the sequence generation model can select a model based on a Monte Carlo search tree, such as MCTS (Monte Carlo Tree Search), to generate multiple sequence branches to select the best description text sequence.
[0032] Among them, the text sequence can include a root node and a leaf node. The root node is the starting node. The image features of the image to be recognized are input to the sequence generation model. The sequence generation model will first generate the root node and generate each sequence branch from the root node. The root node indicates that the sequence is about to start generating. The root node can store symbols or strings representing the generated sequence, such as "#" or "$". The leaf node can include an intermediate node and a terminator node; the intermediate node can be used to store text to describe the image; the terminator node can be used to store the terminator, such as "." or "!". From the root node to the intermediate node and then to the terminator node, a complete sequence is formed.
[0033] S120: updating the expected value of the terminator node in the text sequence according to the preset pre-training model.
[0034] Among them, the preset pre-training model is used to calculate the expected value of the node. For example, the open source CLIP (Contrastive Language–Image Pre-training) model can be selected. The expected value is a parameter used to evaluate the selection of a node or sequence. The higher the expected value of a node, the more likely it is that the node will be selected as a node in the sequence. The higher the expected value of a sequence, the more likely it is that the sequence will be selected as a target sequence. Therefore, through the pre-training model, each time a text sequence is generated, the expected value of the terminator node of the text sequence is calculated and updated.
[0035] The expected value of the terminator node may be the expected value of a text sequence. The expected value of the text sequence is determined according to a preset pre-trained model, that is, the relevance of each node, text coherence, and grammatical accuracy of the text sequence are determined. The expected value of a text sequence is used as the expected value of the terminator node of the sequence.
[0036] S130, tracing back the nodes of the text sequence from the terminator node to the root node, and updating the tracing access information of any node in the text sequence according to the expected value of the terminator node; wherein the tracing access information includes the access frequency and expected value of the intermediate node.
[0037] Among them, the generation process from the root node to the terminator node is the process of establishing a text sequence. The process of reversing the order of the nodes in the text sequence and accessing the text sequence from the terminator node to the root node in reverse is called node tracing. Every time a text sequence branch is generated, the expected value of the terminator node of the text sequence branch is calculated, and then the node is traced. In the process of node tracing, every time an intermediate node is visited in the direction of the root node, the traceability access information of the intermediate node is updated according to the expected value of the previous node that has been visited. For example, the traceability access information of the intermediate node before the terminator node can be updated according to the expected value of the terminator node. The traceability access information can include the access frequency and expected value of the intermediate node, and the access frequency is the number of times the intermediate node is visited.
[0038] For example, after the first text sequence branch is generated, node tracing is performed from the terminator node to the root node, and all intermediate nodes are visited in sequence, so the number of visits to each intermediate node is increased by one. When the second text sequence is generated and node tracing is performed, if the text sequence branch contains an intermediate node of the first text sequence branch, the number of visits to the node should be increased by one. Therefore, it can be understood that no matter how many text sequence branches an intermediate node is included in at the same time, as long as it is visited once during the node tracing process, its number of visits should be increased by one.
[0039] Regarding the update of expected value, it is worth noting that the expected value of the complete text sequence can be evaluated through the CLIP model, and the expected value can be assigned to the end node of the text sequence. In the process of generating the complete text sequence, the expected value of all intermediate nodes can be temporarily marked as 0, and in the process of node tracing, the expected value of the intermediate nodes is recalculated and updated according to the expected value of the end node.
[0040] S140: According to a preset text sequence branch number, determine whether the number of text sequences meets a text sequence branch number requirement.
[0041] The preset number of text sequence branches is the maximum threshold of the number of generated text sequence branches preset by the user in the sequence generation model. And, it is determined whether the number of text sequence branches generated by the sequence generation model meets the maximum threshold. For example, after generating a text sequence branch, the number of all text sequence branches currently generated is compared with the preset number of text sequence branches, and it is determined whether the number of all text sequence branches currently generated meets the preset maximum threshold of the number of generated text sequence branches.
[0042] If the requirement on the number of text sequence branches is not met, the generation of text sequence branches will continue. Each time a text sequence branch is generated, the number of all generated text sequence branches will be compared with the preset number of text sequence branches until the index of all generated text sequences reaches the preset maximum threshold of the number of generated text sequence branches.
[0043] S150: If yes, determine the target leaf node according to the traceability access information of the leaf node, combine the text of the root node and the target leaf node, and determine them as the image text of the image to be recognized.
[0044] If the number of text sequence branches generated by the sequence generation model meets the preset text sequence branch number requirement, starting from the root node, the leaf nodes under the root node are selected according to the preset rules. Each selected leaf node is a target leaf node until the end symbol node is reached, and a complete text sequence branch is obtained. That is, the text combination of the root node and the target leaf node under the root node is obtained, and the combination is used as the text to describe the image to be recognized. The rule for selecting the target leaf node can be determined from the root node based on the traceback access information of each intermediate node. For example, the intermediate node with the highest access frequency and / or the highest expected value can be selected as the target leaf node.
[0045] If the number of text sequence branches generated by the sequence generation model does not meet the preset number of text sequence branches, the sequence generation model continues to generate branches for the text sequence. For example, if the number of text sequence branches is artificially set to 100, when the model does not generate 100 branches, the model continues to generate branches for the text sequence; when the model generates 100 branches, the generation of text sequence branches stops and the target leaf node is selected.
[0046] The technical solution of the embodiment of the present invention determines the description text of the image to be identified based on the retroactive access information of each node in the text sequence. In the process of determining the text, the node is selected by comparing the retroactive access information, which solves the shortcomings of the prior art of poor relevance of image text description, poor text coherence and poor grammatical accuracy, realizes the combination of Monte Carlo search tree algorithm and contrastive language-image pre-training model, improves the accuracy of image and text matching, ensures the degree of text coherence and grammatical correctness, improves the automatic decision-making ability and intelligence in the process of determining the image description text, and improves the user experience.
[0047] In an optional implementation, determining the target leaf node based on the retroactive access information of the leaf node may include: determining a leaf node under the current node that meets the access frequency requirement based on the access frequency of the leaf node, and determining it as the target leaf node.
[0048] Specifically, the current node can be a root node or an intermediate node that has been selected as a target leaf node. The access frequency requirement can be that the access frequency is the highest among the leaf nodes of the current node. Specifically, when selecting the next target leaf node based on the current node, the access frequencies of all leaf nodes under the current node can be compared. When the number of visits to a leaf node is the highest among all leaf nodes under the current node, the leaf node is selected as the target leaf node.
[0049] The technical solution of the above implementation method screens the leaf nodes according to the access frequency, refines the determination strategy of the target leaf nodes, and selects the target leaf nodes with a higher probability of accurate description, that is, it simultaneously determines the next specific text content in the text sequence, rather than directly comparing the expected values of each text sequence and selecting the text sequence with the highest expected value. By selecting the target leaf nodes in sequence, the accuracy of image and text matching is effectively improved, and the fluency and grammatical correctness of the text are guaranteed.
[0050] Embodiment 2
[0051] Figure 2 This is a flow chart of a method for determining image text provided by Embodiment 2 of the present invention. Based on the technical solutions of the above embodiments, the embodiment of the present invention optimizes the operation of obtaining the text sequence of the image to be recognized to improve the mechanism for determining the text sequence.
[0052] refer to Figure 2 The flowchart of a method for determining image text is shown, which specifically includes the following steps:
[0053] S210 : Determine a preset root node of the image to be recognized according to a preset sequence generation model.
[0054] After the image features of the image to be recognized are input into the sequence generation model, the model will output a preset root node as the initial node of the text sequence. For example, a text sequence generation model can be pre-trained by MIE (Maximum Likelihood Estimate). This pre-trained text sequence generation model will output a preset root node after inputting the image features, and start with this root node to generate the text sequence.
[0055] S220 , decoding the text sequence of the image features to obtain candidate child nodes under the root node of the image to be identified.
[0056] By decoding the image features, all candidate child nodes under the current root node are obtained. The candidate child nodes are intermediate nodes that store text that can describe the image to be recognized. The prior probability of each candidate child node being selected is determined by the sequence generation model. For example, the sequence generation model can be called to calculate the probability distribution selection of each candidate child node corresponding to the current node, and this probability distribution is used as the prior probability of the candidate child node being selected.
[0057] S230: Determine a first intermediate node according to the selection probability of the candidate child nodes under the root node.
[0058] Among them, the selection probability of the candidate child node is the probability that each candidate child node may be selected. This probability is determined according to the sequence generation model. The sequence generation model can calculate the selection probability of each candidate child node under the parent node. For example, there is a puppy drawn on the image to be identified. The text sequence of the image to be identified can be "a dog" or "this dog". If the parent node is the root node, the candidate child node under the root node can be "one" or "this", and the selection probabilities of "one" and "this" can be obtained. The probability of "one" can be 70%, and the probability of "this" can be 30%. The first intermediate node refers to the first intermediate node determined after the root node. Specifically, the candidate child node of the root node with the highest selection probability can be used as the first intermediate node. For example, "one" can be used as the first intermediate node.
[0059] S240: Obtain candidate child nodes under the first intermediate node according to the image feature and the first intermediate node.
[0060] According to the image feature information of the image to be identified and the determined first intermediate node, at least one candidate child node under the first intermediate node is determined in the sequence generation model. For example, the text sequence of the image to be identified may be "a dog" or "a dog". If the parent node is a node storing the text "a", then the candidate child nodes under the node may store "only" or "a".
[0061] S250. Determine whether the candidate child node under the first intermediate node is an end symbol node. If so, obtain a text sequence of the image to be recognized based on the root node, the first intermediate node, and the end symbol node.
[0062] Among them, if the candidate child node after the first intermediate node is recognized as an end symbol node, a text sequence branch starting from the root node, passing through the first intermediate node, and ending at the end symbol node is successfully generated.
[0063] If the candidate child node is not an end symbol node or there are child nodes among the candidate child nodes that are not end symbol nodes, continue to generate new candidate child nodes based on the image features, the first intermediate node, and this candidate child node until an end symbol node is generated, and so on.
[0064] In this embodiment, optionally, after determining whether the candidate child node under the first intermediate node is an end symbol node, it further includes: if the candidate child node under the first intermediate node is not an end symbol node, determine the second intermediate node according to the selection probability of the candidate child node under the first intermediate node; obtain the candidate child node under the second intermediate node according to the image features, the first intermediate node, and the second intermediate node; determine whether the candidate child node under the second intermediate node is an end symbol node. If so, obtain a text sequence of the image to be recognized based on the root node, the first intermediate node, the second intermediate node, and the end symbol node.
[0065] Specifically, the second intermediate node is the second intermediate node determined after the root node, that is, the intermediate node immediately following the first intermediate node and is a child node of the first intermediate node. When the candidate child node of the first intermediate node is not an end symbol node, select the node with the highest selection probability among all candidate child nodes of the first intermediate node as the second intermediate node. For example, the text sequence of the image to be recognized can be "a dog" or "one dog". If the first intermediate node is a node storing the text "a", the candidate child nodes stored under this node can be "dog" or "one", and the selection probabilities of "dog" and "one" can be obtained. The selection probability of "dog" can be 70%, and the selection probability of "one" can be 30%. Therefore, "dog" with a higher selection probability can be selected as the second intermediate node.
[0066] After obtaining the second intermediate node, generate the candidate child node under the second intermediate node through a text sequence generation model according to the image features and the already determined first intermediate node and second intermediate node. If the candidate child node after the second intermediate node is recognized as an end symbol node, a text sequence starting from the root node, passing through the first intermediate node to the second intermediate node, and then ending at the end symbol node is successfully generated.
[0067] If the candidate child node is not a terminator node, a new candidate child node is generated according to the image feature, the first intermediate node, the second intermediate node and the candidate child node until a terminator node is generated, and so on. The above implementation method finally determines the entire text sequence by generating intermediate nodes one by one, and refines the text sequence generation process.
[0068] S260: Update the expected value of the terminator node in the text sequence according to the preset pre-training model.
[0069] S270: trace back the nodes of the text sequence from the terminator node to the root node, and update the traceback access information of any node in the text sequence according to the expected value of the terminator node, wherein the traceback access information includes the access frequency and expected value of the intermediate node.
[0070] S280: According to a preset number of text sequence branches, determine whether the number of text sequences meets a requirement on the number of text sequence branches.
[0071] S290: If yes, determine the target leaf node according to the traceability access information of the leaf node, combine the text of the root node and the target leaf node, and determine them as the image text of the image to be recognized.
[0072] The technical solution of the embodiment of the present invention determines the root node according to a preset sequence generation model, and then determines the target subnode according to the selection probability of the root node and the candidate subnode. The technical solution improves the accuracy of image and text matching, improves the accuracy of selecting the target subnode, solves the shortcomings of the prior art of poor relevance of image and text description, poor text fluency and poor grammatical accuracy, improves the intelligence of selecting subnodes in the text sequence, makes the decision of selecting subnodes more complete, improves the determination mechanism of the text sequence, and improves the user experience.
[0073] Embodiment 3
[0074] Figure 3 This is a flowchart of a method for determining image text provided by Embodiment 3 of the present invention. Based on the technical solutions of the above embodiments, the present invention optimizes the operation of updating the expected value of the terminator node to improve the updating process of the expected value of the terminator node.
[0075] refer to Figure 3 The method for determining image text shown in the figure specifically comprises the following steps:
[0076] S310: Obtain image features of the image to be recognized, and obtain a text sequence of the image to be recognized based on the image features and a preset sequence generation model.
[0077] S320 : According to a preset CLIP model, based on the text content of the terminator node and the text content of the text sequence, an expected value of the text sequence is determined.
[0078] According to the open source CLIP model, the text content of the terminator node and the text content of the text sequence are used as input, and the expected value of the text sequence is obtained through the CLIP model output. For example, the CLIP model can be called to score the current text sequence, and then the recursive method in the model can be used to calculate the expected value of the sequence.
[0079] S330: Determine the expected value of the text sequence as the expected value of the terminator node of the text sequence.
[0080] The expected value of the entire text sequence output by the CLIP model is assigned to the terminator node of the sequence for subsequent calculations, that is, the expected value of the terminator node is consistent with the expected value of the text sequence to which it belongs.
[0081] S340, tracing back the nodes of the text sequence from the terminator node to the root node, and updating the tracing access information of any node in the text sequence according to the expected value of the terminator node; wherein the tracing access information includes the access frequency and expected value of the intermediate node.
[0082] In an optional embodiment, the node tracing of the text sequence from the terminator node to the root node and updating the tracing access information of any node in the text sequence according to the expected value of the terminator node may include: taking the terminator node as a child node and updating the access frequency of the parent node of the terminator node; determining the expected value of the parent node of the terminator node according to the expected value of the terminator node and the access frequency of the parent node of the terminator node; judging whether the parent node of the terminator node is a root node, and if not, determining that the parent node of the terminator node is an intermediate node and updating the access frequency of the parent node of the intermediate node; determining the expected value of the parent node of the intermediate node according to the expected value of the intermediate node and the access frequency of the parent node of the intermediate node; judging whether the parent node of the intermediate node is a root node, and if so, determining that the node tracing from the terminator node to the root node is completed.
[0083] The parent node of the terminator node is the node that generated the previous node of the terminator node. In the process of tracing back from the terminator node to the root node, the access frequency of the previous node of the terminator node is first updated. Optionally, the access frequency of the parent node of the terminator node can be increased by one.
[0084] In the process of tracing back from the terminator node to the root node, the expected value of the terminator node, the original expected value of the parent node of the terminator node, the original access frequency and the current access frequency of the parent node of the terminator node are used as input, and the current expected value of the parent node is output through the open source CLIP model. For example, the current expected value of the parent node of the terminator node can be calculated by multiplying the original expected value of the parent node of the terminator node by the original number of visits, adding the current expected value, and then dividing the obtained value by the current number of visits.
[0085] In the process of tracing back from the terminator node to the root node, if the parent node of the terminator node is not the root node, it proves that there is at least one intermediate node between the terminator node and the root node. First, update the access frequency and expected value of the intermediate node (the parent node of the terminator node). Then continue to determine whether the parent node of the intermediate node is the root node. If so, end the tracing process. If not, continue to update the access frequency and expected value of the previous node. Similarly, update the access frequency and expected value of the intermediate nodes in sequence until the root node is found to complete the entire node tracing process.
[0086] In the process of node tracing, the above implementation method updates the access frequency and expected value of each leaf node at once through the open source CLIP model, thereby optimizing the process of node tracing. In the process of generating text sequences, it provides a basis for selecting a better sequence and improves the intelligence of decision-making when selecting text sequences.
[0087] S350: According to a preset text sequence branch number, determine whether the number of text sequences meets a text sequence branch number requirement.
[0088] In an optional implementation, after determining whether the number of the text sequences meets the text sequence branch number requirement, the method may further include: if the number of the text sequences does not meet the text sequence branch number requirement, starting from the root node, based on the traceability access information of the current node, determining the traceability access information of the candidate child nodes under the current node; determining the target intermediate node under the current node based on the traceability access information of the candidate child nodes; determining whether the target intermediate node is a terminator node, and if so, generating a new text sequence for the image to be recognized; and executing according to a preset pre-trained model, updating the expected value of the terminator node in the new text sequence.
[0089] Specifically, when the number of text sequences does not meet the number of sequence branches required in this article, the sequence generation model should continue to generate text sequence branches starting from the root node. Starting from the root node, the number of visits and expected values of the candidate child nodes under the current node can be determined based on the number of visits and expected value of the current node. And the next target intermediate node of the current node can be determined based on the number of visits and expected value. For example, a node with a small number of visits, a high expected value and / or a high prior probability can be selected as the next target intermediate node. And so on, until the next target intermediate node is selected as the terminator node, the entire text sequence is generated, and the expected value of the terminator node of the sequence is updated.
[0090] The technical solution of the above implementation method refines the method of generating new sequence branches when the current text sequence branches do not meet the quantity requirements. According to the retrospective access information of the nodes, the nodes with high expected values, high prior probabilities and few access times are used as the next target intermediate nodes, thereby increasing the probability of selecting text that is more suitable for describing the image, improving the accuracy of image and text matching, and improving the intelligence of decision-making when selecting text sequence strategies.
[0091] S360: If yes, determine the target leaf node according to the traceability access information of the leaf node, combine the text of the root node and the target leaf node, and determine them as the image text of the image to be identified.
[0092] The technical solution of the embodiment of the present invention determines the expected value of all nodes in the text sequence through a preset CLIP model during the node tracing process, generates a new text sequence branch according to the expected value and the number of visits, and finally determines the text combination. The technical solution improves the mechanism for determining the expected value during the node tracing process, refines the scheme for generating a new text sequence, and optimizes the strategy for generating a new text sequence.
[0093] Embodiment 4
[0094] Figure 4 is a structural diagram of an image text determination device provided by the fourth embodiment of the present invention. The embodiment of the present invention can be applied to the case of text description of pictures. The device can be implemented by software and / or hardware and can be configured in an electronic device. Figure 4 As shown, the device may include: a text sequence acquisition module 410, an expected value update module 420, an access information update module 430, a text sequence determination module 440 and an image text determination module 450, wherein:
[0095] The text sequence acquisition module 410 is used to acquire image features of the image to be recognized, and obtain the text sequence of the image to be recognized according to the image features and a preset sequence generation model; wherein the text sequence includes a root node and a leaf node, and the leaf node includes an intermediate node and an end symbol node;
[0096] An expected value updating module 420, used to update the expected value of the terminator node in the text sequence according to a preset pre-trained model;
[0097] The access information updating module 430 is used to trace back the nodes of the text sequence from the terminator node to the root node, and update the traceback access information of any node in the text sequence according to the expected value of the terminator node; wherein the traceback access information includes the access frequency and expected value of the intermediate node;
[0098] The text sequence determination module 440 is used to determine whether the number of text sequences meets the text sequence branch number requirement according to a preset text sequence branch number;
[0099] The image text determination module 450 is used to determine the target leaf node according to the traceability access information of the leaf node, and combine the text of the root node and the target leaf node to determine the image text of the image to be identified.
[0100] The technical solution of the embodiment of the present invention determines the description text of the image to be identified based on the retroactive access information of each node in the text sequence. In the process of determining the text, the node is selected by comparing the retroactive access information, which solves the shortcomings of the prior art of poor relevance of image and text description, poor text coherence and poor grammatical accuracy, improves the accuracy of image and text matching, ensures the degree of text coherence and grammatical correctness, improves the automatic decision-making ability and intelligence in the process of determining the image description text, and improves the user experience.
[0101] In an optional implementation, the text sequence acquisition module 410 may include:
[0102] A root node determination unit, used to determine a preset root node of the image to be identified according to a preset sequence generation model;
[0103] An image decoding unit, used to decode the text sequence of the image features to obtain candidate child nodes under the root node of the image to be identified;
[0104] A first intermediate node determination unit, configured to determine a first intermediate node according to a selection probability of a candidate child node under the root node;
[0105] A first candidate child node determining unit, configured to obtain a candidate child node under the first intermediate node according to the image feature and the first intermediate node;
[0106] The text sequence acquisition unit is used to determine whether the candidate child node under the first intermediate node is a terminator node, and if so, obtain a text sequence of the image to be recognized according to the root node, the first intermediate node and the terminator node.
[0107] In an optional implementation, the text sequence acquisition module 410 may further include:
[0108] A second intermediate node determination unit is configured to determine a second intermediate node according to a selection probability of the candidate child node under the first intermediate node after determining whether the candidate child node under the first intermediate node is a terminator node, if the candidate child node under the first intermediate node is not a terminator node;
[0109] A second candidate child node determination unit, configured to obtain a candidate child node under the second intermediate node according to the image feature, the first intermediate node, and the second intermediate node;
[0110] The terminator determination unit is used to determine whether the candidate child node under the second intermediate node is a terminator node. If so, a text sequence of the image to be recognized is obtained according to the root node, the first intermediate node, the second intermediate node and the terminator node.
[0111] In an optional implementation, the pre-trained model is a CLIP model;
[0112] Accordingly, the expected value updating module 420 may include:
[0113] an expected value determination unit, configured to determine the expected value of the text sequence based on the text content of the terminator node and the text content of the text sequence according to a preset CLIP model;
[0114] The expected value determination unit for the terminator is used to determine the expected value of the text sequence as the expected value of the terminator node of the text sequence.
[0115] In an optional implementation manner, the image text determination device may further include:
[0116] A retroactive access information determination module is used to determine the retroactive access information of the candidate child nodes under the current node from the root node according to the retroactive access information of the current node after determining whether the number of the text sequence meets the text sequence branch number requirement. If the number of the text sequence does not meet the text sequence branch number requirement, the retroactive access information of the candidate child nodes under the current node is determined;
[0117] A target intermediate node determination module, used to determine the target intermediate node under the current node according to the traceability access information of the candidate child node;
[0118] A new text sequence generation module is used to determine whether the target intermediate node is a terminator node, and if so, to generate a new text sequence of the image to be recognized;
[0119] The expected update execution module is used to execute the update of the expected value of the terminator node in the new text sequence according to the preset pre-training model.
[0120] In an optional implementation, the image text determination module 450 may include:
[0121] The target leaf node determination module is used to determine the leaf node that meets the access frequency requirement under the current node according to the access frequency of the leaf node, and determine it as the target leaf node.
[0122] The image text determination device provided in the embodiment of the present invention can execute the image text determination method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects for executing each image text determination method.
[0123] Embodiment 5
[0124] Figure 5 This is a structural diagram of an electronic device provided in Embodiment 5 of the present invention. Figure 5 A block diagram of an exemplary electronic device 512 suitable for implementing embodiments of the present invention is shown. Figure 5 The electronic device 512 shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0125] like Figure 5 As shown, the electronic device 512 is in the form of a general purpose computing device. The components of the electronic device 512 may include, but are not limited to: one or more processors or processing units 516, a system memory 528, and a bus 518 connecting different system components (including the system memory 528 and the processing unit 516).
[0126] Bus 518 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor or a local bus using any of a variety of bus architectures. By way of example, these architectures include, but are not limited to, an Industry Standard Architecture (ISA) bus, a Micro Channel Architecture (MAC) bus, an Enhanced ISA bus, a Video Electronics Standards Association (VESA) local bus, and a Peripheral Component Interconnect (PCI) bus.
[0127] The electronic device 512 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by the electronic device 512, including volatile and non-volatile media, removable and non-removable media.
[0128] The system memory 528 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 530 and / or cache memory 532. The electronic device 512 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system 534 may be used to read and write non-removable, non-volatile magnetic media ( Figure 5 not shown, often referred to as a "hard drive"). Although Figure 5 Not shown, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk"), and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical medium) may be provided. In these cases, each drive may be connected to bus 518 via one or more data medium interfaces. Memory 528 may include at least one program product having a set (e.g., at least one) of program modules that are configured to perform the functions of various embodiments of the present invention.
[0129] A program / utility 540 having a set (at least one) of program modules 542 may be stored, for example, in the memory 528, such program modules 542 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment. The program modules 542 generally perform the functions and / or methods of the embodiments described herein.
[0130] The electronic device 512 may also communicate with one or more external devices 514 (e.g., keyboards, pointing devices, display devices 524, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device 512, and / or communicate with any device that enables the electronic device 512 to communicate with one or more other computing devices (e.g., network cards, modems, etc.). Such communication may be performed via an input / output (I / O) interface 522. In addition, the electronic device 512 may also communicate with one or more networks (e.g., local area networks (LANs), wide area networks (WANs), and / or public networks, such as the Internet) via a network adapter 520. As shown, the network adapter 520 communicates with other modules of the electronic device 512 via a bus 518. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 512, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0131] The processing unit 516 executes at least one of the other programs among the multiple programs stored in the system memory 528 to execute various functional applications and data processing, such as implementing the method for determining image text provided by the embodiment of the present invention.
[0132] Embodiment 6
[0133] Embodiment 6 of the present invention further provides a storage medium containing computer executable instructions, wherein the computer executable instructions are used to perform a method for determining image text when executed by a computer processor, the method comprising:
[0134] Acquire image features of an image to be recognized, and obtain a text sequence of the image to be recognized based on the image features and a preset sequence generation model; wherein the text sequence includes a root node and a leaf node, and the leaf node includes an intermediate node and an end symbol node;
[0135] According to a preset pre-training model, updating the expected value of the terminator node in the text sequence;
[0136] Tracing back the nodes of the text sequence from the terminator node to the root node, and updating the tracing access information of any node in the text sequence according to the expected value of the terminator node; wherein the tracing access information includes the access frequency and expected value of the intermediate node;
[0137] According to a preset number of text sequence branches, determining whether the number of text sequences meets the requirement of the number of text sequence branches;
[0138] If so, the target leaf node is determined according to the traceability access information of the leaf node, and the text of the root node and the target leaf node are combined to be determined as the image text of the image to be identified.
[0139] Of course, the computer executable instructions of a storage medium containing computer executable instructions provided by an embodiment of the present invention are not limited to the method operations described above, and can also execute related operations in the image text determination method provided by any embodiment of the present invention.
[0140] Through the above description of the implementation methods, the technicians in the relevant field can clearly understand that the present invention can be implemented by means of software and necessary general hardware, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as a computer floppy disk, read-only memory (ROM), random access memory (RAM), flash memory (FLASH), hard disk or optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, server, or network device, etc.) to execute the methods described in each embodiment of the present invention.
[0141] It is worth noting that in the embodiment of the above-mentioned search device, the various units and modules included are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of the present invention.
[0142] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.
Claims
1. A method for determining image text, characterized in that: include: Acquire image features of an image to be recognized, and obtain a text sequence of the image to be recognized based on the image features and a preset sequence generation model; wherein the text sequence includes a root node and a leaf node, and the leaf node includes an intermediate node and an end symbol node; According to a preset pre-training model, updating the expected value of the terminator node in the text sequence; Tracing back the nodes of the text sequence from the terminator node to the root node, and updating the tracing access information of any node in the text sequence according to the expected value of the terminator node; wherein the tracing access information includes the access frequency and expected value of the intermediate node; According to a preset number of text sequence branches, determining whether the number of text sequences meets the requirement of the number of text sequence branches; If so, the target leaf node is determined according to the traceability access information of the leaf node, and the text of the root node and the target leaf node are combined to be determined as the image text of the image to be identified.
2. The method according to claim 1, characterized in that According to the image features and a preset sequence generation model, a text sequence of the image to be recognized is simulated, including: Determining a preset root node of the image to be identified according to a preset sequence generation model; Decoding the text sequence of the image features to obtain candidate child nodes under the root node of the image to be identified; Determining a first intermediate node according to the selection probability of the candidate child nodes under the root node; Obtaining candidate child nodes under the first intermediate node according to the image feature and the first intermediate node; It is determined whether the candidate child node under the first intermediate node is a terminator node. If so, a text sequence of the image to be recognized is obtained according to the root node, the first intermediate node and the terminator node.
3. The method according to claim 2, characterized in that After determining whether the candidate child node under the first intermediate node is a terminator node, the method further includes: If the candidate child node under the first intermediate node is not a terminator node, determining a second intermediate node according to the selection probability of the candidate child node under the first intermediate node; Obtaining candidate child nodes under the second intermediate node according to the image feature, the first intermediate node, and the second intermediate node; It is determined whether the candidate child node under the second intermediate node is a terminator node. If so, a text sequence of the image to be recognized is obtained according to the root node, the first intermediate node, the second intermediate node and the terminator node.
4. The method according to claim 1, characterized in that: The pre-trained model is a CLIP model; Accordingly, according to the preset pre-training model, the expected value of the terminator node in the text sequence is updated, including: Determining the expected value of the text sequence based on the text content of the terminator node and the text content of the text sequence according to a preset CLIP model; The expected value of the text sequence is determined as the expected value of the terminator node of the text sequence.
5. The method according to claim 4, characterized in that Tracing back the nodes of the text sequence from the terminator node to the root node, and updating the tracing access information of any node in the text sequence according to the expected value of the terminator node, including: Taking the terminator node as a child node, updating the access frequency of the parent node of the terminator node; Determining the expected value of the parent node of the terminator node according to the expected value of the terminator node and the access frequency of the parent node of the terminator node; Determine whether the parent node of the terminator node is a root node, if not, determine that the parent node of the terminator node is an intermediate node, and update the access frequency of the parent node of the intermediate node; Determine the expected value of the parent node of the intermediate node according to the expected value of the intermediate node and the access frequency of the parent node of the intermediate node; It is determined whether the parent node of the intermediate node is a root node. If so, it is determined that the node tracing from the terminator node to the root node is completed.
6. The method according to claim 5, characterized in that After determining whether the number of the text sequences meets the text sequence branch number requirement, the method further includes: If the number of the text sequences does not meet the text sequence branch number requirement, starting from the root node, according to the retroactive access information of the current node, determine the retroactive access information of the candidate child nodes under the current node; Determine the target intermediate node under the current node according to the traceability access information of the candidate child node; Determine whether the target intermediate node is a terminator node, and if so, generate a new text sequence of the image to be recognized; Execute according to the preset pre-training model, and update the expected value of the terminator node in the new text sequence.
7. The method according to claim 1, characterized in that Determining a target leaf node according to the retroactive access information of the leaf node includes: According to the access frequency of the leaf node, a leaf node under the current node that meets the access frequency requirement is determined and determined as the target leaf node.
8. A device for determining image text, characterized in that: include: A text sequence acquisition module, used to acquire image features of an image to be recognized, and obtain a text sequence of the image to be recognized based on the image features and a preset sequence generation model; wherein the text sequence includes a root node and a leaf node, and the leaf node includes an intermediate node and an end symbol node; An expected value updating module, used for updating the expected value of the terminator node in the text sequence according to a preset pre-training model; An access information updating module, used to trace back the nodes of the text sequence from the terminator node to the root node, and update the traceback access information of any node in the text sequence according to the expected value of the terminator node; wherein the traceback access information includes the access frequency and expected value of the intermediate node; A text sequence judgment module, used to judge whether the number of text sequences meets the text sequence branch number requirement according to a preset text sequence branch number; The image text determination module is used to determine the target leaf node according to the traceability access information of the leaf node, and combine the text of the root node and the target leaf node to determine the image text of the image to be identified.
9. 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 program, the method for determining image text as described in any one of claims 1-7 is implemented.
10. A storage medium containing computer executable instructions, characterized in that: The computer executable instructions are used to execute a method for determining image text as described in any one of claims 1-7 when executed by a computer processor.
