Text image matching method, device, computer equipment and storage medium

By encoding multi-scale text features and image features and adding attention weights, the problem of low text-image matching accuracy in the existing technology is solved and the matching accuracy is improved.

CN113516143BActive Publication Date: 2024-08-27TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202011350030.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-11-26
Publication Date
2024-08-27
Estimated Expiration
2040-11-26

AI Technical Summary

Technical Problem

In text-image matching in the existing technology, local text features cannot effectively determine the image matching situation, resulting in poor matching accuracy.

Method used

By encoding multi-scale text features and image features, and adding attention weights, the similarity between features is calculated to determine the matching relationship and improve the matching accuracy.

Benefits of technology

It achieves the acquisition of matching information between different feature scales and improves the accuracy of text image feature matching.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113516143B
    Figure CN113516143B
Patent Text Reader

Abstract

The present application is about a text image matching method, device, computer equipment and storage medium, belonging to the field of image processing technology. The method includes: obtaining a first feature and a second feature; the first feature is obtained by encoding text features of at least two scales contained in the first text; the second feature is obtained by encoding image features of at least two scales contained in the first image, and the first feature similarity between the first feature and the second feature is obtained; based on the first feature similarity, the first feature and the second feature are weighted to obtain a first weighted feature and a second weighted feature; based on the first feature, the second feature, the first weighted feature and the second weighted feature, the second feature similarity between the first text and the first image is obtained; based on the second feature similarity, matching information is obtained. Through the above scheme, the accuracy of text image feature matching is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of image processing technology, and in particular to a text image matching method, apparatus, computer equipment and storage medium. Background Art

[0002] Image processing is an important research direction in the field of computer vision. Building an image classification model based on machine learning and performing image recognition through the image classification model is a widely used image recognition method.

[0003] In the related art, when it is necessary to find a matching image for text information input by a user, the global text feature vector corresponding to the text input by the user and the global image feature vector corresponding to each candidate image can be extracted based on a machine learning method through a predefined image-text feature alignment method, or the local text feature vector corresponding to the text input by the user and the local image feature vector corresponding to each candidate image can be extracted, and the degree of matching between the image and the text can be determined based on the similarity between the global vectors or the similarity between the local vectors, thereby selecting an image that is closest to the input text.

[0004] In the above technical solution, the method of aligning and calculating only the image-text features may result in a situation where it is impossible to determine whether the image matches through the local features of the text. For example, "thin" belongs to the local text features and it is impossible to determine whether the image matches through the local image features. This leads to poor accuracy in text-image matching. Summary of the invention

[0005] The embodiments of the present application provide a text image matching method, apparatus, computer equipment and storage medium. In the text image matching process, by adding corresponding attention weights to the encoded multi-scale text features and multi-scale image features, the text image matching relationship is obtained, which can improve the accuracy of text image matching. The technical solution is as follows:

[0006] In one aspect, a text image matching method is provided, the method comprising:

[0007] Acquire a first feature and a second feature; the first feature is obtained by encoding text features of at least two scales contained in the first text; the second feature is obtained by encoding image features of at least two scales contained in the first image;

[0008] Obtaining a first feature similarity between the first feature and the second feature;

[0009] Based on the first feature similarity, weighting the first feature and the second feature to obtain a first weighted feature and a second weighted feature;

[0010] Based on the first feature, the second feature, the first weighted feature, and the second weighted feature, obtaining a second feature similarity between the first text and the first image;

[0011] Based on the second feature similarity, matching information is acquired, where the matching information is used to indicate a matching relationship between the first text and the first image.

[0012] In one aspect, a text image matching device is provided, the device comprising:

[0013] A feature acquisition module, used to acquire a first feature and a second feature; the first feature is obtained by encoding text features of at least two scales contained in the first text; the second feature is obtained by encoding image features of at least two scales contained in the first image;

[0014] A first similarity acquisition module, used to acquire a first feature similarity between the first feature and the second feature;

[0015] A weighted feature acquisition module, used for weighting the first feature and the second feature based on the first feature similarity to obtain a first weighted feature and a second weighted feature;

[0016] A second similarity acquisition module, configured to acquire a second feature similarity between the first text and the first image based on the first feature, the second feature, the first weighted feature, and the second weighted feature;

[0017] A matching information acquisition module is used to acquire matching information based on the second feature similarity, where the matching information is used to indicate a matching relationship between the first text and the first image.

[0018] In a possible implementation, the feature acquisition module includes:

[0019] A first key feature generation submodule, used for encoding text features including at least two scales through a first encoder to generate a first key feature;

[0020] A first value feature generation submodule, used for encoding text features including at least two scales through a second encoder to generate a first value feature;

[0021] A second query feature generation submodule, used for encoding the image features including at least two scales through a third encoder to generate a second query feature;

[0022] A second value feature generation submodule, used for encoding the image features including at least two scales through a fourth encoder to generate a second value feature;

[0023] The first feature includes the first key feature and the first value feature; the second feature includes the second query feature and the second value feature.

[0024] In a possible implementation, the first similarity acquisition module includes:

[0025] The first similarity acquisition submodule is used to acquire the similarity between the first key feature and the second query feature as the first feature similarity.

[0026] In a possible implementation, the second similarity acquisition module includes:

[0027] A first weight acquisition submodule, configured to acquire a first attention weight based on a first similarity; the first similarity is the first feature similarity between a first text feature and each encoded image feature; the first text feature is any encoded text feature;

[0028] A first weighted feature generating submodule, configured to weight the first value feature with the first attention weight to generate a first weighted value feature;

[0029] A second weight acquisition submodule is used to acquire a second attention weight based on a second similarity; the second similarity is the first feature similarity between the first image feature and each of the encoded text features; the first image feature is any of the encoded image features;

[0030] The second weighted feature generation submodule is used to weight the second value feature with the second attention weight to generate a second weighted value feature.

[0031] In a possible implementation, the second similarity acquisition module includes:

[0032] A first target similarity acquisition submodule, configured to calculate the similarity between the first weighted value feature and the second value feature to obtain a first target similarity;

[0033] A second target similarity acquisition submodule, used to calculate the similarity between the first value feature and the second weighted value feature to obtain a second target similarity;

[0034] The second similarity acquisition submodule is used to acquire the second feature similarity based on the first target similarity and the second target similarity.

[0035] In a possible implementation, the feature acquisition module includes:

[0036] A text feature acquisition submodule, used to input the first text into a text feature extraction layer in a text image matching model to acquire text features of at least two scales corresponding to the first text;

[0037] An image feature acquisition submodule, used to input the first image into the image feature extraction layer in the text image matching model to acquire image features of at least two scales corresponding to the first image;

[0038] a feature acquisition submodule, configured to input text features of at least two scales corresponding to the first text and image features of at least two scales corresponding to the first image into a fully connected layer in the text-image matching model to obtain the first feature and the second feature;

[0039] The text-image matching model is obtained by training text samples, image samples, and the matching relationship between the text samples and the image samples.

[0040] In a possible implementation manner, the device further includes:

[0041] A first sample feature extraction submodule, used for inputting the text sample into the text feature extraction layer in the text image matching model to obtain text features of at least two scales corresponding to the text sample;

[0042] A second sample feature extraction submodule, used for inputting the image sample into the image feature extraction layer in the text image matching model to obtain image features of at least two scales corresponding to the image sample;

[0043] A sample feature acquisition submodule, used to input text features of at least two scales corresponding to the text sample and image features of at least two scales corresponding to the image sample into the fully connected layer in the text-image matching model, and acquire a first sample feature corresponding to the text sample and a second sample feature corresponding to the image sample;

[0044] A first sample similarity acquisition submodule, used to acquire first sample feature similarities corresponding to the text sample and the image sample based on the first sample feature and the second sample feature;

[0045] A second sample similarity acquisition submodule, configured to weight the first sample feature and the second sample feature based on the first sample feature similarity, and acquire the second sample feature similarity corresponding to the text sample and the image sample;

[0046] A loss function value acquisition submodule, used to acquire a loss function value based on the second sample feature similarity and a matching relationship between the text sample and the image sample;

[0047] A model updating submodule is used to update the text image matching model based on the loss function value.

[0048] On the other hand, a computer device is provided, which includes a processor and a memory, wherein the memory stores at least one instruction, at least one program, a code set or an instruction set, and the at least one instruction, the at least one program, the code set or the instruction set is loaded and executed by the processor to implement the text image matching method as described above.

[0049] On the other hand, a computer-readable storage medium is provided, in which at least one instruction, at least one program, a code set or an instruction set is stored, and the at least one instruction, the at least one program, the code set or the instruction set is loaded and executed by a processor to implement the text image matching method as described above.

[0050] According to one aspect of the present application, a computer program product or a computer program is provided, the computer program product or the computer program includes computer instructions, the computer instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the text image matching method provided in various optional implementations of the above aspects.

[0051] The technical solution provided by this application may have the following beneficial effects:

[0052] In the scheme shown in the embodiment of the present application, the obtained text features with at least two scales and the image features with at least two scales are encoded to obtain the corresponding first feature and second feature, and the similarity between the first feature and the second feature is calculated, and the first feature and the second feature are weighted to perform similarity calculation, thereby determining the matching relationship between the text and the image. Through the above scheme, the matching relationship between multi-scale features can be determined by adding attention weights to the first feature and the second feature, thereby achieving the acquisition of matching information between different feature scales, thereby improving the accuracy of text image feature matching.

[0053] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0054] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0055] Figure 1 is a schematic diagram of a text image matching system according to an exemplary embodiment;

[0056] Figure 2 is a flowchart of a text image matching method according to an exemplary embodiment;

[0057] Figure 3 is a flowchart of a text image matching and model training method according to an exemplary embodiment;

[0058] Figure 4 yes Figure 3 A schematic diagram of a model training structure involved in the illustrated embodiment;

[0059] Figure 5 yes Figure 3 A schematic diagram of a text image matching application involved in the illustrated embodiment;

[0060] Figure 6 is a structural schematic diagram of a text image matching system according to an exemplary embodiment;

[0061] Figure 7 is a block diagram of a text image matching device according to an exemplary embodiment;

[0062] Figure 8 is a structural schematic diagram of a computer device according to an exemplary embodiment;

[0063] Fig. 9 It is a structural block diagram of a computer device according to an exemplary embodiment. DETAILED DESCRIPTION

[0064] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.

[0065] It should be understood that the "several" mentioned in this article refers to one or more, and "multiple" refers to two or more. "And / or" describes the association relationship of the associated objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the associated objects before and after are in an "or" relationship.

[0066] For ease of understanding, the nouns involved in the embodiments of the present application are explained below.

[0067] 1) Artificial Intelligence (AI)

[0068] Artificial intelligence is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology in computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence. Artificial intelligence is to study the design principles and implementation methods of various intelligent machines so that machines have the functions of perception, reasoning and decision-making.

[0069] Artificial intelligence technology is a comprehensive discipline that covers a wide range of fields, including both hardware-level and software-level technologies. The basic technologies of artificial intelligence generally include sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics and other technologies. Artificial intelligence software technology mainly includes computer vision technology, speech processing technology, natural language processing technology, and machine learning / deep learning.

[0070] 2) Computer Vision (CV)

[0071] Computer vision is a science that studies how to make machines "see". To put it more specifically, it refers to machine vision such as using cameras and computers to replace human eyes to identify and measure targets, and further perform graphic processing to make computer processing into images that are more suitable for human eye observation or transmission to instruments for detection. As a scientific discipline, computer vision studies related theories and technologies, and attempts to establish an artificial intelligence system that can obtain information from images or multi-dimensional data. Computer vision technology usually includes image processing, image recognition, image semantic understanding, image retrieval, optical character recognition (OCR), video processing, video semantic understanding, video content / behavior recognition, three-dimensional object reconstruction, 3D (3 Dimensional) technology, virtual reality, augmented reality, synchronization and map construction, etc.

[0072] 3) Machine Learning (ML)

[0073] Machine learning is a multi-disciplinary subject that involves probability theory, statistics, approximation theory, convex analysis, algorithm complexity theory and other disciplines. It specializes in studying how computers simulate or implement human learning behavior to acquire new knowledge or skills and reorganize existing knowledge structures to continuously improve their performance. Machine learning is the core of artificial intelligence and the fundamental way to make computers intelligent. Its applications are spread across all areas of artificial intelligence. Machine learning and deep learning usually include artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and teaching learning.

[0074] 4) Natural Language Processing (NLP)

[0075] Natural language processing is an important direction in the fields of computer science and artificial intelligence. It studies various theories and methods that can achieve effective communication between people and computers using natural language. Natural language processing is a science that integrates linguistics, computer science, and mathematics. Therefore, research in this field will involve natural language, that is, the language people use in daily life, so it is closely related to the study of linguistics. Natural language processing technology usually includes text processing, semantic understanding, machine translation, robot question answering, knowledge graph and other technologies.

[0076] The solutions provided in the embodiments of the present application involve technologies such as natural language processing, image processing, and machine learning of artificial intelligence, which are specifically described by the following embodiments:

[0077] The solution of the embodiment of the present application includes a model training stage and a text image matching stage. Figure 1FIG. 1 is a schematic diagram of a text image matching system according to an exemplary embodiment. Figure 1 As shown, in the model training stage, the model training device 110 trains a text image matching model with high accuracy through a pre-set training sample set. In the text image matching stage, the text image matching device 120 searches for the image with the highest similarity to the input target text in the candidate image set based on the trained text image matching model and the input target text, as a candidate image matching the target text.

[0078] Among them, the above-mentioned model training device 110 and text image matching device 120 can be computer devices with machine learning capabilities, for example, the computer device can be a terminal or a server.

[0079] Optionally, the above-mentioned model training device 110 and the text image matching device 120 can be the same device, or the model training device 110 and the text image matching device 120 can also be different devices. Moreover, when the model training device 110 and the text image matching device 120 are different devices, the model training device 110 and the text image matching device 120 can be the same type of device, such as the model training device 110 and the text image matching device 120 can both be servers; or, the model training device 110 and the text image matching device 120 can also be different types of devices. The above-mentioned server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms. The above-mentioned terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, etc., but is not limited to this. The terminal and the server may be connected directly or indirectly via wired or wireless communication, which is not limited in this application.

[0080] Figure 2 is a flowchart of a text image matching method according to an exemplary embodiment. The text image matching method can be executed by a computer device. The computer device can be a server. The method can be executed by the computer device. Figure 1 The text image matching device in the embodiment shown is executed. Figure 2 As shown, the text image matching method may include the following steps:

[0081] In step 201, a first feature and a second feature are obtained; the first feature is obtained by encoding text features of at least two scales contained in the first text; the second feature is obtained by encoding image features of at least two scales contained in the first image.

[0082] In an embodiment of the present application, a computer device obtains a first feature obtained by encoding text features of at least two scales contained in a first text, and obtains a second feature obtained by encoding image features of at least two scales contained in a first image.

[0083] The first feature includes encoded text features of at least two scales, and the second feature includes encoded image features of at least two scales.

[0084] In a possible implementation manner, the first text is text containing description information, and the first image is any image in a candidate image set corresponding to the first text.

[0085] The candidate image set is pre-stored in the database and contains at least two images.

[0086] In a possible implementation, text features of different scales include features corresponding to text extracted from text features of different information levels. The above information level can be any one of an article, a paragraph, a sentence, or a word, that is, text features of different scales can be text features corresponding to an article, a paragraph, a sentence, or a word. Image features of different scales are features extracted from images of different sizes, where the size of the image can refer to the resolution of the image. For images of different resolutions, the amount of information contained in the image is also different. Generally, an image with a larger resolution contains more information, so the scale of the image features obtained from an image with a larger resolution is also larger.

[0087] In a possible implementation manner, encoding of at least two scales of text features contained in the first text and at least two scales of image features contained in the first image is implemented by an encoder.

[0088] In step 202, the first feature similarity between the first feature and the second feature is obtained.

[0089] In the embodiment of the present application, the computer device calculates and determines the first feature similarity between each encoded text feature included in the first feature and each encoded image feature included in the second feature based on the acquired first feature and second feature.

[0090] The first feature similarity is used to indicate the degree of feature similarity between each encoded text feature included in the first feature and each encoded image feature included in the second feature.

[0091] In step 203, based on the first feature similarity, the first feature and the second feature are weighted to obtain a first weighted feature and a second weighted feature.

[0092] In an embodiment of the present application, a computer device calculates the attention weights corresponding to each encoded text feature contained in the first feature and each encoded image feature contained in the second feature based on the attention mechanism according to the calculated similarity of the first feature, and weights the first feature and the second feature according to the calculated attention weights to obtain a first weighted feature after the first feature is weighted, and a second weighted feature after the second feature is weighted.

[0093] In a possible implementation, in the process of matching encoded text features of different scales and encoded image features of different scales, text-image feature pairs are formed, and corresponding attention weights are calculated for different text-image feature pairs. After obtaining the attention weights corresponding to each encoded text feature contained in the first feature and each encoded image feature contained in the second feature, a first weighted feature after weighting the first feature and a second weighted feature after weighting the second feature are obtained.

[0094] In step 204, based on the first feature, the second feature, the first weighted feature and the second weighted feature, the second feature similarity between the first text and the first image is obtained.

[0095] In a possible implementation, the second feature similarity is calculated based on the first feature and the second weighted feature to obtain the feature similarity between the first text and the first image. Alternatively, the second feature similarity is calculated based on the first weighted feature and the second feature to obtain the feature similarity between the first text and the first image. Alternatively, the second feature similarity is calculated based on the first feature and the second weighted feature, and the first weighted feature and the second feature, and the feature similarity is jointly calculated and determined.

[0096] In step 205, matching information is obtained based on the second feature similarity, where the matching information is used to indicate a matching relationship between the first text and the first image.

[0097] In an embodiment of the present application, a computer device obtains a matching relationship between each feature based on the second feature similarity between each encoded text feature and the image feature, thereby obtaining a matching relationship between the first text and the first image.

[0098] In a possible implementation manner, the matching relationship between the first text and the first image is determined based on the relationship between the second feature similarity and the similarity threshold.

[0099] After obtaining the second feature similarity between the first text and the first image, the second feature similarity can be compared with the similarity threshold. When the second feature similarity is higher than the similarity threshold, it can be determined that the first text matches the first image; when the second feature similarity is not higher than the similarity threshold, it can be determined that the first text does not match the first image.

[0100] In a possible implementation manner, the computer device acquires the first image corresponding to the second feature similarity greater than the similarity threshold as the target image.

[0101] That is, images with feature similarity greater than the similarity threshold have a probability of being target images corresponding to the first text. At this time, all images with second feature similarity greater than the similarity threshold are regarded as target images corresponding to the first text, thereby improving the accuracy of obtaining images matching the first text.

[0102] In summary, the scheme shown in the embodiment of the present application encodes the acquired text features with at least two scales and the image features with at least two scales to obtain the corresponding first feature and second feature, calculates the similarity between the first feature and the second feature, and weights the first feature and the second feature to perform similarity calculation, thereby determining the matching relationship between the text and the image. Through the above scheme, the matching relationship between multi-scale features can be determined by adding attention weights to the first feature and the second feature, thereby achieving the acquisition of matching information between different feature scales, thereby improving the accuracy of text image feature matching.

[0103] Figure 3 1 is a flowchart of a text image matching and model training method according to an exemplary embodiment. The text image matching and model training method can be executed by a model training device and a text image matching device, respectively. The model training device can be a server, and the text image matching device can be a terminal. Figure 3 As shown, the text image matching and model training method may include the following steps:

[0104] Steps 301 to 308 are a training process of a text image matching model performed by a model training device, and include the following steps:

[0105] In step 301, a training sample set is obtained.

[0106] In an embodiment of the present application, the model training device obtains text samples and image samples.

[0107] The training sample set may include text samples, image samples that match the text samples, and image samples that do not match the text samples.

[0108] In step 302, the text sample is input into the text feature extraction layer in the text image matching model to obtain text features of at least two scales corresponding to the text sample.

[0109] In an embodiment of the present application, the model training device inputs the text sample into the text feature extraction layer in the text image matching model, and through feature extraction, text features of at least two scales corresponding to the text sample can be obtained.

[0110] In one possible implementation, the text feature extraction layer is a BERT (Bidirectional Encoder Representations from Transformers) model.

[0111] Among them, the BERT model is a pre-trained model obtained by running a self-supervised learning method based on a massive corpus. The BERT model fine-tunes the model parameters through a small amount of sample text, that is, it can more accurately convert text samples into feature vectors containing the semantic features of the text samples.

[0112] The text sample is input into the BERT model, and the feature vector of the semantic features corresponding to the text sample is output. Since the feature vector (i.e., the global feature of the text) is the feature vector obtained by inputting the entire text of the text sample into the BERT model, the feature vector contains the global features corresponding to the text sample, that is, the vector information obtained based on the overall semantics of the sample text.

[0113] By inputting part of the text content of the text sample into the text feature extraction layer, the local features corresponding to the part of the text content can be output.

[0114] Among them, each local feature and global feature can belong to text features of different scales.

[0115] In step 303, the image sample is input into the image feature extraction layer in the text image matching model to obtain image features of at least two scales corresponding to the image sample.

[0116] In an embodiment of the present application, the model training device inputs the image sample into the text image matching model for feature extraction, and obtains image features of at least two scales corresponding to the image sample through feature extraction at different scales by the image feature extraction layer.

[0117] In one possible implementation, image features of at least two scales include global image features and local image features of at least one scale; the image feature extraction layer includes a global feature extraction layer and at least one local feature extraction layer; the global feature extraction layer includes at least two feature extraction layers; the local feature extraction layer includes at least one feature extraction layer; the feature extraction layer is used to extract image features.

[0118] In a possible implementation manner, the global features of the image sample are obtained based on the image sample and each feature extraction layer of the global feature extraction layer.

[0119] In one possible implementation, the image feature extraction layer is a convolutional neural network (CNN).

[0120] In step 304, text features of at least two scales corresponding to the text sample and image features of at least two scales corresponding to the image sample are input into a fully connected layer in the text image matching model to obtain a first sample feature corresponding to the text sample and a second sample feature corresponding to the image sample.

[0121] In an embodiment of the present application, the model training device inputs the acquired text features of at least two scales corresponding to the text sample and the acquired image features of at least two scales corresponding to the image sample into the fully connected layer in the text image matching model to respectively acquire the first sample features corresponding to the text sample and the second sample features corresponding to the image sample.

[0122] In one possible implementation, the obtained text features of at least two scales corresponding to the text sample and the image features of at least two scales corresponding to the image sample are encoded by different encoders of the fully connected layer to obtain the first sample features corresponding to the text sample and the second sample features corresponding to the image sample.

[0123] The first sample features corresponding to the text samples include text features corresponding to each encoded text sample. The second sample features corresponding to the image samples include image features corresponding to each encoded image sample.

[0124] In step 305, based on the first sample feature and the second sample feature, the first sample feature similarity corresponding to the text sample and the image sample is obtained.

[0125] In an embodiment of the present application, the model training device calculates the similarity of the first sample features corresponding to the text sample and the first sample features corresponding to the image sample based on the first sample features corresponding to the text sample and the second sample features corresponding to the image sample.

[0126] In a possible implementation, the similarity calculation method is to calculate the similarity using cosine distance or Euclidean distance.

[0127] In step 306, based on the first sample feature similarity, the first sample feature and the second sample feature are weighted to obtain the second sample feature similarity corresponding to the text sample and the image sample.

[0128] In an embodiment of the present application, the model training device performs weighted calculation on the first sample features corresponding to the text samples and the second sample features corresponding to the image samples based on the similarities of the first sample features corresponding to the acquired text samples and the image samples, and obtains the similarities of the second sample features corresponding to the text samples and the image samples.

[0129] In a possible implementation, when weighted calculation is performed on the first sample feature corresponding to the text sample and the second sample feature corresponding to the image sample, the attention weight corresponding to each feature is obtained by calculating the attention weight based on the similarity of the first sample feature corresponding to the text sample and the image sample.

[0130] In step 307, a loss function is input based on the second sample feature similarity and a matching relationship between the text sample and the image sample to obtain a loss function value.

[0131] In an embodiment of the present application, the model training device inputs the second sample feature similarity corresponding to the text sample and the image sample into the loss function, and calculates the corresponding loss function value based on the matching relationship between the text sample and the image sample.

[0132] Among them, each text sample and each image sample can form an image-text pair, and the image-text pair can indicate the matching status of the text sample and the image sample.

[0133] For example, an image-text pair can be represented as,

[0134]

[0135] Among them, y i,j It can indicate whether the i-th image sample and the j-th text sample match. If y i,j = 0, it means that the i-th image sample and the j-th text sample do not match. If y i,j =1, it means that the i-th image sample matches the j-th text sample. B is the number of matching image-text pairs. i represents the encoded feature corresponding to the i-th image sample, T j Represents the encoded features corresponding to the j-th text sample.

[0136] In one possible implementation, the loss function is a relative entropy (Kullback-Leibler Divergence, KL divergence) function.

[0137] The KL divergence function can be used to measure the distance between different continuous distributions and perform direct regression on the space of continuous output distributions.

[0138] Among them, the loss function is defined as follows,

[0139] L CSAL =L i +L t

[0140]

[0141]

[0142] Among them, S(I i ,T j ) is used to indicate the second feature similarity between the image sample and the text sample, S′(T j ,I i ) is used to indicate the second feature similarity between the text sample and the image sample. CSAL Used to indicate the loss function value, y i,j It can indicate whether the i-th image sample and the j-th text sample match.

[0143] In step 308, the text image matching model is updated based on the loss function value.

[0144] In an embodiment of the present application, the model training device updates various model parameters in the text image model according to the calculated loss function value, thereby updating the text image matching model and improving the accuracy of the text image matching model.

[0145] Figure 4 is a schematic diagram of a model training structure involved in an embodiment of the present application, such as Figure 4As shown, the multi-scale image sample feature outputs the second value feature and the second query feature respectively through the value encoder and the query encoder; the multi-scale text feature outputs the first sample key feature and the first sample value feature respectively through the key encoder and the value encoder; the attention weight is calculated and determined based on the first sample key feature and the second sample query feature (S401), the first sample value feature and the second sample value feature are weighted to generate attention-weighted text features and attention-weighted image features, the similarity is calculated by the first sample value feature and the second weighted sample value feature and the similarity is calculated by the first weighted sample value feature and the second sample value feature (S402), the loss function value is determined according to the obtained similarity value, and the text image matching model is updated based on the loss function value.

[0146] Steps 309 to 313 are a text image matching process performed by the text image matching device, including the following steps:

[0147] In step 309, the first feature and the second feature are obtained through the updated text image matching model.

[0148] In an embodiment of the present application, a user inputs a first text that needs to be image matched on the text image matching device side, obtains a first feature of the first text through an updated text image matching model, and inputs each image stored in the database into the updated text image matching model to obtain a second feature.

[0149] In one possible implementation, a first text is input into a text feature extraction layer in a text image matching model to obtain text features of at least two scales corresponding to the first text; a first image is input into an image feature extraction layer in a text image matching model to obtain image features of at least two scales corresponding to the first image; text features of at least two scales corresponding to the first text and image features of at least two scales corresponding to the first image are input into a fully connected layer in the text image matching model to obtain first features and second features.

[0150] Among them, the text-image matching model is obtained by training text samples, image samples and the matching relationship between text samples and image samples.

[0151] The first feature is obtained by encoding text features of at least two scales contained in the first text; and the second feature is obtained by encoding image features of at least two scales contained in the first image.

[0152] In a possible implementation, the first feature is a feature matrix obtained by encoding text features of at least two scales contained in the first text; the second feature is a feature matrix obtained by encoding image features of at least two scales contained in the first image.

[0153] In a possible implementation, the text image matching device simultaneously encodes text features containing at least two scales through a first encoder to generate a first key feature; encodes text features containing at least two scales through a second encoder to generate a first value feature; encodes image features containing at least two scales through a third encoder to generate a second query feature; and encodes image features containing at least two scales through a fourth encoder to generate a second value feature.

[0154] The first feature may include a first key feature and a first value feature; the second feature may include a second query feature and a second value feature. The first encoder, the second encoder, the third encoder, and the fourth encoder may be located in a fully connected layer in the text image recognition model, for encoding each text feature and image feature.

[0155] In a possible implementation, the first key feature is identical to each encoded text feature included in the first value feature, and the second query feature is identical to each encoded image feature included in the second value feature.

[0156] Exemplarily, the first encoder may be a key encoder, and the second encoder may be a value encoder. The multi-scale text features corresponding to the first text are encoded by the key encoder and the value encoder to obtain the first key features and the first value features corresponding to the multi-scale text features, wherein the feature dimensions of the first key features and the first value features may be 768 dimensions. The obtained multi-scale first key features may be recorded as,

[0157] T K ={t k1 , t k2 ,…,t kn}

[0158] The obtained multi-scale first value features can be recorded as,

[0159] T V ={t v1 , t v2 ,…,t vn}

[0160] Where n can be the number of multi-scale text features. The key encoder and the value encoder can be different encoders, and both are 768 to 768 fully connected layers.

[0161] Exemplarily, the third encoder may be a query encoder, and the fourth encoder may be a value encoder. The query encoder and the value encoder are used to encode the multi-scale image features corresponding to the first image to obtain a second query feature and a second value feature corresponding to the multi-scale image features, wherein the feature dimensions of the second query feature and the second value feature may be 768 dimensions. The obtained multi-scale second query feature may be recorded as,

[0162] I Q = {I q1 , I q2 ,…,I qm}

[0163] The obtained multi-scale second value features can be recorded as,

[0164] I V ={i v1 ,i v2 ,…,i vm}

[0165] Where m can be the number of multi-scale image features. The query encoder and the value encoder can be different encoders, and both are 768 to 768 fully connected layers.

[0166] In step 310, the first feature similarity between the first feature and the second feature is obtained.

[0167] In the embodiment of the present application, the text image matching device calculates the similarity based on the first feature corresponding to the acquired first text and the second feature corresponding to the first image to obtain the first feature similarity.

[0168] The first image may be any one of the images.

[0169] In a possible implementation, the first feature similarity is calculated by using a cosine distance similarity calculation method.

[0170] In a possible implementation manner, the similarity between the first key feature and the second query feature is obtained as the first feature similarity.

[0171] The first feature similarity is obtained by obtaining the second query feature corresponding to the first image and the first key feature corresponding to the first text and performing cosine distance calculation.

[0172] The similarity formula for calculating the second query feature corresponding to the first image and the first key feature corresponding to the first text is as follows:

[0173]

[0174] Among them, i qb is the second query feature, belonging to I Q In, t ka is the first bond feature, belonging to T K In it, n is the number of multi-scale text features and m is the number of multi-scale image features.

[0175] In step 311, based on the first feature similarity, the first feature and the second feature are weighted to obtain a first weighted feature and a second weighted feature.

[0176] In an embodiment of the present application, a text image matching device determines the attention weight corresponding to each feature based on the acquired first feature similarity, performs weighted calculation on the first feature and the second feature based on the attention weight, and obtains a first weighted feature corresponding to the first feature and a second weighted feature corresponding to the second feature.

[0177] In a possible implementation, a first attention weight is obtained based on a first similarity; the first similarity is a first feature similarity between a first text feature and each encoded image feature; the first text feature is any encoded text feature, and then the first value feature is weighted with the first attention weight to generate a first weighted value feature.

[0178] Exemplarily, the first attention weight calculation formula is as follows:

[0179]

[0180] Among them, s′ a,b is the first feature similarity, and λ1 is the set scaling factor.

[0181] Exemplarily, the calculation formula of the first weighted value feature is as follows:

[0182]

[0183] Among them, r va is the first weighted feature, t va is the first value feature.

[0184] In one possible implementation, a second attention weight is obtained based on a second similarity; the second similarity is the first feature similarity between the first image feature and each encoded text feature; the first image feature is any encoded image feature, and then the second value feature is weighted with the second attention weight to generate a second weighted value feature.

[0185] Exemplarily, the second attention weight calculation formula is as follows:

[0186]

[0187] Among them, s′ a,b is the first feature similarity, and λ1 is the set scaling factor.

[0188] Exemplarily, the calculation formula of the second weighted value feature is as follows:

[0189]

[0190] Among them, r vb is the second weighted feature, t vb is the second value feature.

[0191] In step 312, based on the first feature, the second feature, the first weighted feature and the second weighted feature, the second feature similarity between the first text and the first image is obtained.

[0192] In the embodiment of the present application, the text image matching device can calculate the second feature similarity between the first text and the first image according to the acquired first feature, second feature, first weighted feature and second weighted feature.

[0193] In a possible implementation, similarity is calculated between the first weighted value feature and the second value feature to obtain a first target similarity; similarity is calculated between the first value feature and the second weighted value feature to obtain a second target similarity; and a second feature similarity is obtained based on the first target similarity and the second target similarity.

[0194] The second feature similarity may be the first target similarity, or the second feature similarity may be the second target similarity, or the second feature similarity may be obtained by adding the first target similarity and the second target similarity.

[0195] Exemplarily, the first target similarity corresponds to the similarity between the first image and the first text, and the calculation formula of the similarity is as follows:

[0196]

[0197]

[0198] Among them, i va is the second value feature, r va is the first weighted feature. S(I,T) is the first target similarity.

[0199] Exemplarily, the second target similarity corresponds to the similarity between the first text and the first image, and the calculation formula of the similarity is as follows:

[0200]

[0201]

[0202] Among them, t va is the first value feature, r vb is the second weighted feature. S′(I,T) is the second target similarity.

[0203] In step 313, matching information is obtained based on the second feature similarity.

[0204] In an embodiment of the present application, the text image matching device obtains a matching relationship between the first text and the first image according to the second feature similarity.

[0205] In a possible implementation, the second feature similarity is positively correlated with the matching relationship.

[0206] Exemplarily, the sum of the first target similarity and the second target similarity is taken as the second feature similarity.

[0207] For example, calculate the similarities S(I,T) and S′(I,T) between the descriptive text features of the person to be searched and the features of all pedestrian images in the database, and add the two together as the final similarity. The image with the highest similarity is the pedestrian image that meets the descriptive text information.

[0208] Figure 5 Schematic diagram of a text image matching application involved in the embodiment of the present application. Figure 5 As shown, the text image matching method involved in the embodiment of the present application can be applied to finding people based on text. For example, the target text to be searched (i.e., the descriptive text of the person's appearance and clothing) is determined through the information in the missing person notice 51, and the target text is input into the text image matching application 52. At this time, the text image matching model obtains the target text, and performs text image matching with the target text through the method shown in the embodiment of the present application according to the candidate image set corresponding to the text image matching model, and outputs a target image containing the candidate person that matches the target text.

[0209] In summary, the scheme shown in the embodiment of the present application encodes the acquired text features with at least two scales and the image features with at least two scales to obtain the corresponding first feature and second feature, calculates the similarity between the first feature and the second feature, and weights the first feature and the second feature to perform similarity calculation, thereby determining the matching relationship between the text and the image. Through the above scheme, the matching relationship between multi-scale features can be determined by adding attention weights to the first feature and the second feature, thereby achieving the acquisition of matching information between different feature scales, thereby improving the accuracy of text image feature matching.

[0210] Figure 6The diagram is a structural diagram of a text image matching system according to an exemplary embodiment.

[0211] The model training process is performed in the model training device 610, and the text image matching process is performed in the text image matching device 620. Figure 6 As shown, the multi-scale image sample feature outputs the second sample value feature and the second sample query feature respectively through the value encoder and the query encoder; the multi-scale text sample feature outputs the first sample key feature and the first sample value feature respectively through the key encoder and the value encoder; the attention weight is calculated and determined based on the first sample key feature and the second sample query feature (S611), the first sample value feature and the second sample value feature are weighted to generate attention-weighted text sample features and attention-weighted image sample features, the similarity is calculated by the first sample value feature and the second weighted sample value feature and the similarity is calculated by the first weighted sample value feature and the second sample value feature respectively (S612), the loss function value is determined according to the obtained similarity value, and the text image matching model is updated based on the loss function value (S613). In the text image matching device 620, the information in the missing person notice 621 is input to determine the target text to be searched, and the target text is input into the text image matching model 622. Then, based on the candidate image set 623 corresponding to the text image matching model 622, text image matching is performed with the target text through the method shown in the embodiment of the present application, and a target image 624 containing candidate characters that matches the target text is output.

[0212] In summary, the scheme shown in the embodiment of the present application encodes the acquired text features with at least two scales and the image features with at least two scales to obtain the corresponding first feature and second feature, calculates the similarity between the first feature and the second feature, and weights the first feature and the second feature to perform similarity calculation, thereby determining the matching relationship between the text and the image. Through the above scheme, the matching relationship between multi-scale features can be determined by adding attention weights to the first feature and the second feature, thereby achieving the acquisition of matching information between different feature scales, thereby improving the accuracy of text image feature matching.

[0213] Figure 7 is a block diagram of a text image matching device according to an exemplary embodiment. Figure 7 As shown, the text image matching device can be implemented as all or part of a computer device by hardware or a combination of hardware and software to perform Figure 2 or Figure 3 All or part of the steps of the method shown in the corresponding embodiment. The text image matching device may include:

[0214] The feature acquisition module 710 is used to acquire a first feature and a second feature; the first feature is obtained by encoding text features of at least two scales contained in the first text; the second feature is obtained by encoding image features of at least two scales contained in the first image;

[0215] A first similarity acquisition module 720, configured to acquire a first feature similarity between the first feature and the second feature;

[0216] A weighted feature acquisition module 730, configured to weight the first feature and the second feature based on the first feature similarity to obtain a first weighted feature and a second weighted feature;

[0217] A second similarity acquisition module 740, configured to acquire a second feature similarity between the first text and the first image based on the first feature, the second feature, the first weighted feature, and the second weighted feature;

[0218] The matching information acquisition module 750 is used to acquire matching information based on the second feature similarity, where the matching information is used to indicate a matching relationship between the first text and the first image.

[0219] In a possible implementation, the feature acquisition module 710 includes:

[0220] A first key feature generation submodule, used for encoding text features including at least two scales through a first encoder to generate a first key feature;

[0221] A first value feature generation submodule, used for encoding text features including at least two scales through a second encoder to generate a first value feature;

[0222] A second query feature generation submodule, used for encoding the image features including at least two scales through a third encoder to generate a second query feature;

[0223] A second value feature generation submodule, used for encoding the image features including at least two scales through a fourth encoder to generate a second value feature;

[0224] The first feature includes the first key feature and the first value feature; the second feature includes the second query feature and the second value feature.

[0225] In a possible implementation, the first similarity acquisition module 720 includes:

[0226] The first similarity acquisition submodule is used to acquire the similarity between the first key feature and the second query feature as the first feature similarity.

[0227] In a possible implementation, the second similarity acquisition module 740 includes:

[0228] A first weight acquisition submodule, configured to acquire a first attention weight based on a first similarity; the first similarity is the first feature similarity between a first text feature and each encoded image feature; the first text feature is any encoded text feature;

[0229] A first weighted feature generating submodule, configured to weight the first value feature with the first attention weight to generate a first weighted value feature;

[0230] A second weight acquisition submodule is used to acquire a second attention weight based on a second similarity; the second similarity is the first feature similarity between the first image feature and each of the encoded text features; the first image feature is any of the encoded image features;

[0231] The second weighted feature generation submodule is used to weight the second value feature with the second attention weight to generate a second weighted value feature.

[0232] In a possible implementation, the second similarity acquisition module 740 includes:

[0233] A first target similarity acquisition submodule, configured to calculate the similarity between the first weighted value feature and the second value feature to obtain a first target similarity;

[0234] A second target similarity acquisition submodule, used to calculate the similarity between the first value feature and the second weighted value feature to obtain a second target similarity;

[0235] The second similarity acquisition submodule is used to acquire the second feature similarity based on the first target similarity and the second target similarity.

[0236] In a possible implementation, the feature acquisition module 710 includes:

[0237] A text feature acquisition submodule, used to input the first text into a text feature extraction layer in a text image matching model to acquire text features of at least two scales corresponding to the first text;

[0238] An image feature acquisition submodule, used to input the first image into the image feature extraction layer in the text image matching model to acquire image features of at least two scales corresponding to the first image;

[0239] a feature acquisition submodule, configured to input text features of at least two scales corresponding to the first text and image features of at least two scales corresponding to the first image into a fully connected layer in the text-image matching model to obtain the first feature and the second feature;

[0240] The text-image matching model is obtained by training text samples, image samples, and the matching relationship between the text samples and the image samples.

[0241] In a possible implementation manner, the device further includes:

[0242] A first sample feature extraction submodule, used for inputting the text sample into the text feature extraction layer in the text image matching model to obtain text features of at least two scales corresponding to the text sample;

[0243] A second sample feature extraction submodule, used for inputting the image sample into the image feature extraction layer in the text image matching model to obtain image features of at least two scales corresponding to the image sample;

[0244] A sample feature acquisition submodule, used to input text features of at least two scales corresponding to the text sample and image features of at least two scales corresponding to the image sample into the fully connected layer in the text-image matching model, and acquire a first sample feature corresponding to the text sample and a second sample feature corresponding to the image sample;

[0245] A first sample similarity acquisition submodule, used to acquire first sample feature similarities corresponding to the text sample and the image sample based on the first sample feature and the second sample feature;

[0246] A second sample similarity acquisition submodule, configured to weight the first sample feature and the second sample feature based on the first sample feature similarity, and acquire the second sample feature similarity corresponding to the text sample and the image sample;

[0247] A loss function value acquisition submodule, used to acquire a loss function value based on the second sample feature similarity and a matching relationship between the text sample and the image sample;

[0248] A model updating submodule is used to update the text image matching model based on the loss function value.

[0249] In summary, the scheme shown in the embodiment of the present application encodes the acquired text features with at least two scales and the image features with at least two scales to obtain the corresponding first feature and second feature, calculates the similarity between the first feature and the second feature, and weights the first feature and the second feature to perform similarity calculation, thereby determining the matching relationship between the text and the image. Through the above scheme, the matching relationship between multi-scale features can be determined by adding attention weights to the first feature and the second feature, thereby achieving the acquisition of matching information between different feature scales, thereby improving the accuracy of text image feature matching.

[0250] Figure 8 800 is a schematic diagram of a computer device according to an exemplary embodiment. The computer device 800 includes a central processing unit (CPU) 801, a system memory 804 including a random access memory (RAM) 802 and a read-only memory (ROM) 803, and a system bus 805 connecting the system memory 804 and the central processing unit 801. The computer device 800 also includes a basic input / output system (I / O system) 806 that helps transmit information between various devices in the computer device, and a large-capacity storage device 807 for storing an operating system 813, an application program 814, and other program modules 815.

[0251] The basic input / output system 806 includes a display 808 for displaying information and an input device 809 such as a mouse and a keyboard for user inputting information. The display 808 and the input device 809 are connected to the central processing unit 801 through an input / output controller 810 connected to the system bus 805. The basic input / output system 806 may also include an input / output controller 810 for receiving and processing inputs from a plurality of other devices such as a keyboard, a mouse, or an electronic stylus. Similarly, the input / output controller 810 also provides output to a display screen, a printer, or other types of output devices.

[0252] The mass storage device 807 is connected to the central processing unit 801 via a mass storage controller (not shown) connected to the system bus 805. The mass storage device 807 and its associated computer device readable medium provide non-volatile storage for the computer device 800. That is, the mass storage device 807 may include a computer device readable medium (not shown) such as a hard disk or a compact disc read-only memory (CD-ROM) drive.

[0253] Without loss of generality, the computer device readable medium may include computer device storage media and communication media. Computer device storage media include volatile and non-volatile, removable and non-removable media implemented by any method or technology for storing information such as computer device readable instructions, data structures, program modules or other data. Computer device storage media include RAM, ROM, Erasable Programmable Read-Only Memory (EPROM), Electrically Erasable Programmable Read-Only Memory (EEPROM), CD-ROM, Digital Video Disc (DVD) or other optical storage, cassette, tape, disk storage or other magnetic storage devices. Of course, those skilled in the art will know that the computer device storage medium is not limited to the above. The above-mentioned system memory 804 and mass storage device 807 can be collectively referred to as memory.

[0254] According to various embodiments of the present disclosure, the computer device 800 can also be connected to a remote computer device on a network through a network such as the Internet. That is, the computer device 800 can be connected to a network 812 through a network interface unit 811 connected to the system bus 805, or the network interface unit 811 can be used to connect to other types of networks or remote computer device systems (not shown).

[0255] The memory also includes one or more programs, which are stored in the memory. The CPU 801 implements the Figure 2 or Figure 3 All or part of the steps of the method shown.

[0256] Fig. 9 is a block diagram of a computer device 900 according to an exemplary embodiment. The computer device 900 may be Figure 1 A terminal in the text image matching system is shown.

[0257] Typically, the computer device 900 includes a processor 901 and a memory 902 .

[0258] The processor 901 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 901 may be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). The processor 901 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 901 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 901 may also include an AI (Artificial Intelligence) processor, which is used to process computing operations related to machine learning.

[0259] The memory 902 may include one or more computer-readable storage media, which may be non-transitory. The memory 902 may also include a high-speed random access memory, and a non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In some embodiments, the non-transitory computer-readable storage medium in the memory 902 is used to store at least one instruction, which is used to be executed by the processor 901 to implement the method provided in the method embodiment of the present application.

[0260] In some embodiments, the computer device 900 may further optionally include: a peripheral device interface 903 and at least one peripheral device. The processor 901, the memory 902 and the peripheral device interface 903 may be connected via a bus or a signal line. Each peripheral device may be connected to the peripheral device interface 903 via a bus, a signal line or a circuit board. Specifically, the peripheral device includes: at least one of a radio frequency circuit 904, a display screen 905, a camera assembly 906, an audio circuit 907 and a power supply 909.

[0261] The peripheral device interface 903 may be used to connect at least one peripheral device related to I / O (Input / Output) to the processor 901 and the memory 902. In some embodiments, the processor 901, the memory 902, and the peripheral device interface 903 are integrated on the same chip or circuit board; in some other embodiments, any one or two of the processor 901, the memory 902, and the peripheral device interface 903 may be implemented on a separate chip or circuit board, which is not limited in this embodiment.

[0262] The radio frequency circuit 904 is used to receive and transmit RF (Radio Frequency) signals, also known as electromagnetic signals. The radio frequency circuit 904 communicates with communication networks and other communication devices through electromagnetic signals. The radio frequency circuit 904 converts electrical signals into electromagnetic signals for transmission, or converts received electromagnetic signals into electrical signals. Optionally, the radio frequency circuit 904 includes: an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a user identity module card, and the like. The radio frequency circuit 904 can communicate with other terminals through at least one wireless communication protocol. The wireless communication protocol includes, but is not limited to: the World Wide Web, a metropolitan area network, an intranet, various generations of mobile communication networks (2G, 3G, 4G and 5G), a wireless local area network and / or a WiFi (Wireless Fidelity) network. In some embodiments, the radio frequency circuit 904 may also include circuits related to NFC (Near Field Communication), which is not limited in this application.

[0263] The display screen 905 is used to display the UI (User Interface). The UI may include graphics, text, icons, videos, and any combination thereof. When the display screen 905 is a touch display screen, the display screen 905 also has the ability to collect touch signals on the surface or above the surface of the display screen 905. The touch signal can be input to the processor 901 as a control signal for processing. At this time, the display screen 905 can also be used to provide virtual buttons and / or virtual keyboards, also known as soft buttons and / or soft keyboards. In some embodiments, the display screen 905 can be one, and the front panel of the computer device 900 is set; in other embodiments, the display screen 905 can be at least two, which are respectively set on different surfaces of the computer device 900 or are folded; in some other embodiments, the display screen 905 can be a flexible display screen, which is set on the curved surface or folded surface of the computer device 900. Even, the display screen 905 can also be set to a non-rectangular irregular shape, that is, a special-shaped screen. The display screen 905 can be made of materials such as LCD (Liquid Crystal Display), OLED (Organic Light-Emitting Diode, organic light-emitting diode).

[0264] The camera assembly 906 is used to capture images or videos. Optionally, the camera assembly 906 includes a front camera and a rear camera. Typically, the front camera is arranged on the front panel of the terminal, and the rear camera is arranged on the back of the terminal. In some embodiments, there are at least two rear cameras, which are any one of a main camera, a depth of field camera, a wide-angle camera, and a telephoto camera, so as to realize the fusion of the main camera and the depth of field camera to realize the background blur function, the fusion of the main camera and the wide-angle camera to realize panoramic shooting and VR (Virtual Reality) shooting function or other fusion shooting functions. In some embodiments, the camera assembly 906 may also include a flash. The flash can be a monochrome temperature flash or a dual-color temperature flash. A dual-color temperature flash refers to a combination of a warm light flash and a cold light flash, which can be used for light compensation at different color temperatures.

[0265] The audio circuit 907 may include a microphone and a speaker. The microphone is used to collect sound waves from the user and the environment, and convert the sound waves into electrical signals and input them into the processor 901 for processing, or input them into the radio frequency circuit 904 to achieve voice communication. For the purpose of stereo acquisition or noise reduction, there may be multiple microphones, which are respectively arranged at different parts of the computer device 900. The microphone may also be an array microphone or an omnidirectional acquisition microphone. The speaker is used to convert the electrical signal from the processor 901 or the radio frequency circuit 904 into sound waves. The speaker may be a traditional film speaker or a piezoelectric ceramic speaker. When the speaker is a piezoelectric ceramic speaker, it can not only convert the electrical signal into sound waves audible to humans, but also convert the electrical signal into sound waves inaudible to humans for purposes such as ranging. In some embodiments, the audio circuit 907 may also include a headphone jack.

[0266] The power supply 909 is used to power various components in the computer device 900. The power supply 909 can be an alternating current, a direct current, a disposable battery, or a rechargeable battery. When the power supply 909 includes a rechargeable battery, the rechargeable battery can be a wired rechargeable battery or a wireless rechargeable battery. A wired rechargeable battery is a battery charged through a wired line, and a wireless rechargeable battery is a battery charged through a wireless coil. The rechargeable battery can also be used to support fast charging technology.

[0267] In some embodiments, the computer device 900 further includes one or more sensors 910 , including but not limited to: an acceleration sensor 911 , a gyroscope sensor 912 , a pressure sensor 913 , an optical sensor 915 , and a proximity sensor 916 .

[0268] The acceleration sensor 911 can detect the magnitude of acceleration on the three coordinate axes of the coordinate system established by the computer device 900. For example, the acceleration sensor 911 can be used to detect the components of gravity acceleration on the three coordinate axes. The processor 901 can control the touch display screen 905 to display the user interface in a horizontal view or a vertical view according to the gravity acceleration signal collected by the acceleration sensor 911. The acceleration sensor 911 can also be used for collecting game or user motion data.

[0269] The gyro sensor 912 can detect the body direction and rotation angle of the computer device 900, and the gyro sensor 912 can cooperate with the acceleration sensor 911 to collect the user's 3D actions on the computer device 900. The processor 901 can implement the following functions based on the data collected by the gyro sensor 912: motion sensing (such as changing the UI according to the user's tilt operation), image stabilization during shooting, game control, and inertial navigation.

[0270] The pressure sensor 913 can be set on the side frame of the computer device 900 and / or the lower layer of the touch display screen 905. When the pressure sensor 913 is set on the side frame of the computer device 900, it can detect the user's grip signal of the computer device 900, and the processor 901 performs left and right hand recognition or shortcut operation according to the grip signal collected by the pressure sensor 913. When the pressure sensor 913 is set on the lower layer of the touch display screen 905, the processor 901 controls the operability controls on the UI interface according to the user's pressure operation on the touch display screen 905. The operability controls include at least one of a button control, a scroll bar control, an icon control, and a menu control.

[0271] The optical sensor 915 is used to collect the ambient light intensity. In one embodiment, the processor 901 can control the display brightness of the touch display screen 905 according to the ambient light intensity collected by the optical sensor 915. Specifically, when the ambient light intensity is high, the display brightness of the touch display screen 905 is increased; when the ambient light intensity is low, the display brightness of the touch display screen 905 is reduced. In another embodiment, the processor 901 can also dynamically adjust the shooting parameters of the camera component 906 according to the ambient light intensity collected by the optical sensor 915.

[0272] The proximity sensor 916, also called a distance sensor, is usually disposed on the front panel of the computer device 900. The proximity sensor 916 is used to collect the distance between the user and the front of the computer device 900. In one embodiment, when the proximity sensor 916 detects that the distance between the user and the front of the computer device 900 is gradually decreasing, the processor 901 controls the touch display screen 905 to switch from the screen-on state to the screen-off state; when the proximity sensor 916 detects that the distance between the user and the front of the computer device 900 is gradually increasing, the processor 901 controls the touch display screen 905 to switch from the screen-off state to the screen-on state.

[0273] Those skilled in the art will understand that Fig. 9 The structure shown in the figure does not constitute a limitation on the computer device 900, and the computer device 900 may include more or less components than those shown in the figure, or combine some components, or adopt a different arrangement of components.

[0274] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory including at least one instruction, at least one program, code set, or instruction set, wherein the at least one instruction, at least one program, code set, or instruction set can be executed by a processor to perform the above Figure 2 or Figure 3All or part of the steps of the method shown in any embodiment. For example, the non-transitory computer-readable storage medium may be a ROM, RAM, CD-ROM, magnetic tape, floppy disk, optical data storage device, etc.

[0275] Those skilled in the art should be aware that in one or more of the above examples, the functions described in the embodiments of the present disclosure can be implemented with hardware, software, firmware, or any combination thereof. When implemented using software, these functions can be stored in a computer device readable medium or transmitted as one or more instructions or codes on a computer device readable medium. Computer device readable media include computer device storage media and communication media, wherein the communication medium includes any medium that facilitates the transmission of computer device programs from one place to another. The storage medium can be any available medium that a general or special computer device can access.

[0276] According to one aspect of the present application, a computer program product or a computer program is provided, the computer program product or the computer program includes computer instructions, the computer instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the text image matching method provided in various optional implementations of the above aspects.

[0277] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any variations, uses or adaptations of the present application, which follow the general principles of the present application and include common knowledge or customary techniques in the art that are not disclosed in the present application. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the following claims.

[0278] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.

Claims

1. A text image matching method, characterized in that: The method comprises: Acquire a first feature and a second feature; the first feature is obtained by encoding text features of at least two scales contained in the first text, and the first feature includes a first value feature generated by encoding the text features of at least two scales through a second encoder; the second feature is obtained by encoding image features of at least two scales contained in the first image, and the second feature includes a second value feature generated by encoding the image features of at least two scales through a fourth encoder; Obtaining a first feature similarity between the first feature and the second feature; Based on a first similarity, obtaining a first attention weight; the first similarity is the first feature similarity between a first text feature and each encoded image feature; the first text feature is any encoded text feature; Weighting the first value feature with the first attention weight to generate a first weighted value feature; Based on a second similarity, obtaining a second attention weight; the second similarity is the first feature similarity between the first image feature and each of the encoded text features; the first image feature is any of the encoded image features; weighting the second value feature with the second attention weight to generate a second weighted value feature; Calculate the similarity between the first weighted value feature and the second value feature to obtain a first target similarity; Calculate the similarity between the first value feature and the second weighted value feature to obtain a second target similarity; Based on the first target similarity and the second target similarity, obtaining a second feature similarity between the first text and the first image; Based on the second feature similarity, matching information is acquired, where the matching information is used to indicate a matching relationship between the first text and the first image.

2. The method according to claim 1, characterized in that The obtaining of the first feature and the second feature further includes: Encoding the text features including at least two scales through a first encoder to generate a first key feature; Encoding the image features including at least two scales through a third encoder to generate a second query feature; Among them, the first feature also includes the first key feature; the second feature also includes the second query feature.

3. The method according to claim 2, characterized in that The obtaining the first feature similarity between the first feature and the second feature includes: The similarity between the first key feature and the second query feature is obtained as the first feature similarity.

4. The method according to claim 1, characterized in that: The obtaining of the first feature and the second feature includes: Inputting the first text into a text feature extraction layer in a text image matching model to obtain text features of at least two scales corresponding to the first text; Inputting the first image into the image feature extraction layer in the text image matching model to obtain image features of at least two scales corresponding to the first image; Inputting text features of at least two scales corresponding to the first text and image features of at least two scales corresponding to the first image into a fully connected layer in the text-image matching model to obtain the first feature and the second feature; The text-image matching model is obtained by training text samples, image samples, and the matching relationship between the text samples and the image samples.

5. The method according to claim 4, characterized in that The method further comprises: Inputting the text sample into the text feature extraction layer in the text image matching model to obtain text features of at least two scales corresponding to the text sample; Inputting the image sample into the image feature extraction layer in the text image matching model to obtain image features of at least two scales corresponding to the image sample; Inputting text features of at least two scales corresponding to the text sample and image features of at least two scales corresponding to the image sample into the fully connected layer in the text-image matching model to obtain a first sample feature corresponding to the text sample and a second sample feature corresponding to the image sample; Based on the first sample feature and the second sample feature, obtaining a first sample feature similarity corresponding to the text sample and the image sample; Based on the first sample feature similarity, weighting the first sample feature and the second sample feature to obtain the second sample feature similarity corresponding to the text sample and the image sample; Based on the second sample feature similarity and the matching relationship between the text sample and the image sample, obtaining a loss function value; Based on the loss function value, the text image matching model is updated.

6. A text image matching device, characterized in that: The device comprises: A feature acquisition module, used to acquire a first feature and a second feature; the first feature is obtained by encoding text features of at least two scales contained in the first text, and the first feature includes a first value feature generated by encoding the text features of at least two scales through a second encoder; the second feature is obtained by encoding image features of at least two scales contained in the first image, and the second feature includes a second value feature generated by encoding the image features of at least two scales through a fourth encoder; A first similarity acquisition module, used to acquire a first feature similarity between the first feature and the second feature; The weighted feature acquisition module includes: a first weight acquisition submodule, a first weighted feature generation submodule, a second weight acquisition submodule, and a second weighted feature generation submodule; The first weight acquisition submodule is used to acquire a first attention weight based on a first similarity; the first similarity is the first feature similarity between the first text feature and each encoded image feature; the first text feature is any encoded text feature; The first weighted feature generating submodule is used to weight the first value feature with the first attention weight to generate a first weighted value feature; The second weight acquisition submodule is used to acquire a second attention weight based on a second similarity; the second similarity is the first feature similarity between the first image feature and each of the encoded text features; the first image feature is any of the encoded image features; The second weighted feature generating submodule is used to weight the second value feature with the second attention weight to generate a second weighted value feature; The second similarity acquisition module includes: a first target similarity acquisition submodule, a second target similarity acquisition submodule, and a second similarity acquisition submodule; The first target similarity acquisition submodule is used to calculate the similarity between the first weighted value feature and the second value feature to obtain the first target similarity; The second target similarity acquisition submodule is used to calculate the similarity between the first value feature and the second weighted value feature to obtain the second target similarity; The second similarity acquisition submodule is used to acquire a second feature similarity between the first text and the first image based on the first target similarity and the second target similarity; A matching information acquisition module is used to acquire matching information based on the second feature similarity, where the matching information is used to indicate a matching relationship between the first text and the first image.

7. A computer device, characterized in that: The computer device includes a processor and a memory, wherein the memory stores at least one instruction, at least one program, a code set or an instruction set, and the at least one instruction, the at least one program, the code set or the instruction set is loaded and executed by the processor to implement the text image matching method as described in any one of claims 1 to 5.

8. A computer-readable storage medium, characterized in that: The storage medium stores at least one instruction, at least one program, a code set or an instruction set, and the at least one instruction, the at least one program, the code set or the instruction set is loaded and executed by the processor to implement the text image matching method as described in any one of claims 1 to 5.

9. A computer program product, characterized in that The computer program product includes computer instructions, which are stored in a computer-readable storage medium; the computer instructions are read and executed by a processor of a computer device, so that the computer device executes the text image matching method as described in any one of claims 1 to 5.