A cross-modal image-text retrieval method
By unifying the multi-modal Transformer inference network and adaptive similarity fusion module, the problem of intra-modal and inter-modal interactive information separation in cross-modal image and text retrieval is solved, and fine-grained correlation of visual and text features is achieved. and complementarity, which improves retrieval accuracy and reduces computational costs.
Patent Information
- Application Number
- CN202210433101.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-24
- Publication Date
- 2024-09-27
- Estimated Expiration
- 2042-04-24
AI Technical Summary
Existing cross-modal image and text retrieval methods are fragmented in the acquisition of interactive reasoning information within the modality and between modalities, resulting in the failure to fully explore fine-grained interrelationships and affecting retrieval accuracy.
Design a unified multi-modal Transformer inference network to extract visual and text features through a deep neural network, and use an adaptive similarity fusion module to calculate the similarity between visual features and text features to achieve intra-modal and inter-modal interactive information. joint modeling and fusion.
It effectively improves the accuracy of cross-modal image and text retrieval, avoids the problem of modal feature separation, and efficiently handles cross-modal retrieval problems through pre-training and fine-tuning methods, reducing computational costs and deviations caused by data dependence.
Smart Images

Figure CN114911914B
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of machine learning, and specifically relates to a cross-modal image-text retrieval method based on a unified multimodal Transformer inference network. Background Art
[0002] Cross-modal image and text retrieval is a fundamental and promising research direction in the field of multimodal machine learning. This task aims to obtain the corresponding retrieval results of another modality through the query data samples of a certain modality submitted by the user. With the popularization of the Internet today, cross-modal image and text retrieval is gradually becoming the basis of daily life and work for the majority of Internet users. In order to make full use of the high-level semantic information of multiple modalities, many existing methods attempt to deeply mine the interactive semantic information within or between modalities.
[0003] However, the inventors found that these existing methods still have a common shortcoming, that is, the acquisition of intra-modal and inter-modal interactive reasoning information is separated, which also separates the fine-grained relationships between different modalities, and such fine-grained relationships are often critical to the accuracy of cross-modal retrieval.
[0004] Therefore, studying a model that can simultaneously obtain intra-modal and inter-modal interactive reasoning information of visual and textual features has strong academic and practical value. Summary of the invention
[0005] In view of the shortcomings of the prior art, the present invention proposes a cross-modal image and text retrieval method. The method jointly models the acquisition of multimodal interactive context information of vision and text, fully explores the correlation and complementarity between fine-grained features of different modalities, and can effectively improve the accuracy of cross-modal image and text retrieval.
[0006] In order to achieve the above object, the present invention adopts the following technical solutions:
[0007] A cross-modal image-text retrieval method comprises the following steps:
[0008] S1, uses deep neural networks to extract visual features of images and text features of sentences;
[0009] S2, designing a unified multimodal Transformer inference network to uniformly model data of different modalities; the unified multimodal Transformer inference network extracts intra-modal interaction information and inter-modal interaction information of vision and text, respectively, and calculates the similarity of visual features and text features through an adaptive similarity fusion module;
[0010] S3, train a unified multimodal Transformer inference network, input the visual features and text features extracted in step S1 into the trained unified multimodal Transformer inference network, obtain the similarity between the visual features and text features, and output the image-text retrieval results.
[0011] Furthermore, in step S1, the specific method of extracting the visual features of the image is:
[0012] For each input image, the pre-trained model of the Faster-R-CNN network on the Visual Genome dataset is used as a visual feature extractor to extract features of the region of interest;
[0013] For each selected region of interest, use a vector Represents its position embedding vector, where (x l ,y l ) and (x r ,y r ) represent the coordinates of the upper left corner and lower right corner of the region, W and H represent the width and height of the input image respectively;
[0014] The visual features of the image are represented as Among them, v represents the visual feature vector, is the vector space, k is the number of regions of interest, and D is the visual feature dimension.
[0015] Furthermore, in step S1, the specific method of extracting the text features of the sentence is:
[0016] For each sentence input, the pre-trained language model BERT is used to extract a set of word vectors, which are then input into the fully connected layer to obtain a set of text features with a dimension of D, expressed as Among them, t represents the text feature vector, is the vector space, n is the number of text segmentations, and D is the text feature dimension.
[0017] Furthermore, in step S2, a self-attention Transformer encoder is used to extract intra-modal interaction information and inter-modal interaction information of vision and text.
[0018] Furthermore, in step S3, a two-stage training method of pre-training and fine-tuning is used to train the unified multimodal Transformer inference network, wherein the first training stage generates intra-modal context representation information of a single modality of visual or text, and the second training stage generates interactive information between visual and text modalities.
[0019] Furthermore, the training process of the first training stage is: for the input image or text, a set of visual or text features are extracted respectively using the twin modal encoder module intra-MMTN, and the formula is: and where {v1, ··, v k} and {t1,·,t k} represents the fine-grained segment features of the input, i.e., the regional features of the image or the word features of the text, and Represents the output image or text context representation information; the encoders of the encoder module within the twin modality share parameters.
[0020] Furthermore, the training process of the second training stage is as follows: based on the training in the first stage, the segment features {v1,·,v k} and {t1,·,t k} are spliced and input into the inter-modal encoder module inter-MMTN. After the inter-modal encoder module reads the pre-trained model of the twin modal encoder module, it is trained in a fine-tuning manner. The formula is: in and Represents the contextual representation information of inter-modal interaction.
[0021] Furthermore, the specific method of calculating the similarity between visual features and text features by the adaptive similarity fusion module is as follows:
[0022] For a set of visual context representation information and text context representation information in Define the cross-modal fine-grained matching matrix A: The element A in A ij represents the semantic similarity between the i-th visual context representation information and the j-th text context representation information, W v and W t are network parameters;
[0023] The weighted sum of the cross-modal fine-grained matching matrix A is defined as the global image-text similarity S(I,T). Each fine-grained similarity is obtained by performing a softmax activation function operation on the weighted sum of the column elements of the matrix A. The formula is: where λ is the temperature coefficient of the softmax activation function.
[0024] The beneficial effects of the present invention are:
[0025] 1) The present invention alleviates the technical problem of the separation of intra-modal interactive information and inter-modal interactive information in the existing methods in the field of image and text retrieval, so that the features of different modalities can interact and complement each other.
[0026] 2) The present invention divides the training of the model into two stages: pre-training and fine-tuning, which can efficiently handle the problem of cross-modal retrieval. At the same time, the present invention does not rely on external knowledge and only uses a cross-modal image and text retrieval dataset to train the model, avoiding high computational costs and alleviating training bias caused by dependence on big data.
[0027] 3) The present invention designs a new adaptive multimodal data fusion method, which can effectively improve the accuracy of image and text retrieval. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] Figure 1 This is the Transformer module structure diagram.
[0029] Figure 2 It is a flow chart of the present invention.
[0030] Figure 3 Schematic diagram of the unified multimodal Transformer reasoning network of the present invention.
[0031] Figure 4 Schematic diagram of the adaptive similarity fusion module in the present invention. DETAILED DESCRIPTION
[0032] The present invention will be further described in detail below with reference to the accompanying drawings and specific examples, but they are not intended to limit the present invention.
[0033] A cross-modal image-text retrieval method uses a deep neural network to extract the visual features of sample images and the text features of query statements. A unified multimodal Transformer inference network (MMTN) is designed to uniformly model data of different modalities and extract interaction information within visual and textual modalities and interaction information between modalities respectively. A new adaptive similarity fusion module (ASA) is also designed to dynamically fuse the generated fine-grained cross-modal context representation information, calculate its similarity, and output image-text retrieval results.
[0034] The process of extracting visual features of sample images includes:
[0035] For each input image, Faster-R-CNN with ResNet-101 as the backbone network is used as a visual feature extractor. The pre-trained model of this extractor on the Visual Genome dataset is used to extract 2048-dimensional region of interest (ROI) features, and the 36 features with the highest ROI feature confidence are selected.
[0036] For each selected ROI, use a vector Represents its position embedding vector, where (x l ,y l ) and (x r ,y r ) represent the coordinates of the upper left and lower right corners of the region, W and H represent the width and height of the input image, respectively. Then the position vector of the ROI is converted to 1024 dimensions. Finally, the visual features of the image will be represented as
[0037] The process of extracting query text features includes:
[0038] For each sentence input, the pre-trained language model BERT is used to extract a set of word vectors, which are then input into the fully connected layer to obtain a set of D text instance features, expressed as
[0039] The generation process of interactive information of different modal contexts of vision and text includes:
[0040] The self-attention encoder Transformer is used to extract intra-modal and inter-modal interactive reasoning information of vision and text.
[0041] In addition, this method adopts a two-stage training method of pre-training and fine-tuning to train the MMTN network. The first training stage generates the intra-modal context representation information of a single modality, either visual or text, and the second training stage generates the interactive information between the visual and textual modalities.
[0042] Furthermore, the training process of the first training stage is: for the input image or text, a set of visual or text features are extracted using the twin encoder module intra-MMTN, and the formula is: and where {v1, ·, v k} and {t1,·,t k} represents the fine-grained segment features of the input (regional features of images or word features of text), and The image or text context representation information of the output.
[0043] The training process of the second training stage is as follows: based on the training of the first stage, the segment features {v1, ·, v k} and {t1,·,t k} are spliced and input into the inter-MMTN module, and the formula is: in and Represents the contextual representation information of inter-modal interaction.
[0044] The cross-modal matching calculation process of the adaptive similarity fusion module ASA includes:
[0045] For a set of visual context representation information and text context representation information in The present invention defines a cross-modal fine-grained matching degree matrix A: Among them A ij represents the semantic similarity between the i-th visual context representation information and the j-th text context representation information.
[0046] The global image-text similarity is defined as the weighted sum of the cross-modal fine-grained matching matrix A. Each fine-grained similarity is obtained by performing a softmax activation function operation on the weighted sum of the column elements of matrix A. The formula is: Where λ is the temperature coefficient of the softmax activation function. In general, the adaptive similarity fusion process can be expressed as:
[0047] With the rapid development of Internet technology, multimodal data such as images, videos and texts are gradually becoming an important medium for human perception of the world. Therefore, how to make computers accurately understand multimodal data and realize cross-modal retrieval is a very practical research topic. The Transformer used in this method is a new type of neural network with self-attention mechanism as its core, which has been widely used in recent years. The Transformer encoder can convert a set of sequence vectors into Mapped into another set of sequence vectors The self-attention mechanism enables the network to capture the implicit semantic associations between the input sequence vectors. Specifically, the Transformer module attention mechanism includes the query vector Q, the key vector K and the value vector V, and its corresponding feature matrix can be expressed as d q , d k , d vDimension. Each query vector Q is used as an anchor vector. According to the semantic relevance between the key vector K and the query vector Q, a weight is assigned to the value vector V. Therefore, the convex combination of the value vector V can be considered as the output of the query vector Q after self-attention processing. Transformer can be regarded as a feature enhancement operation method using the self-attention mechanism. Its matrix operation formula is: The Transformer module structure is as follows Figure 1 This method uses the Transformer module as the key component of the MMTN network. The encoder uses 2 layers, each layer contains 4 attention heads. The steps for implementing cross-modal image and text retrieval are as follows: Figure 2 shown.
[0048] Authoritative datasets for cross-modal image-text retrieval tasks include MS-COCO and Flickr30k. Taking the MS-COCO dataset as an example, it contains 123,287 images, each with 5 description sentences. In this embodiment, the experiment of the dataset is divided into: 5,000 images as a validation set, 5,000 images as a test set, and the remaining images as a training set. The experimental indicator uses the recall rate R@K, K = 1, 5, 10.
[0049] The following is a detailed description of the cross-modal image and text retrieval method:
[0050] S1. In this embodiment, the original two-dimensional image needs to be preprocessed. In this embodiment, ResNet-101 and Faster-R-CNN networks are used to extract 2048-dimensional ROI features of the two-dimensional image. The Faster-R-CNN network obtains a series of ROI features of the region of interest with different confidence levels. In this embodiment, the 36 features with the highest confidence levels are selected.
[0051] Among them, for each selected region of interest feature ROI, use a vector Indicates its position embedding vector, in which (x l ,y l ) and (x r ,y r ) represent the coordinates of the upper left and lower right corners of the region, W and H represent the width and height of the input image, respectively. Then the position vector of the ROI is converted to 1024 dimensions. Finally, the visual features of the image will be represented as
[0052] In this embodiment, the original text data also needs to be preprocessed. In this embodiment, the BERT network is used to extract the 768-dimensional word vector of each word in the text, and then it is input into the fully connected layer to obtain a set of 2048-dimensional text instance features, which is expressed as
[0053] The visual features and text features obtained in the above steps are used as input data of the self-attention Transformer encoder.
[0054] S2. Use the self-attention encoder Transformer to extract the intra-modal and inter-modal interactive reasoning information of vision and text. This embodiment adopts a two-stage strategy of pre-training and fine-tuning to train the MMTN network. The first stage generates the intra-modal context representation information of a single modality of vision or text, and the second stage generates the interactive information between the visual and textual modalities, such as Figure 3 shown.
[0055] The training process of the first training stage is as follows: for the input image and text, a set of visual or text features are extracted respectively using the parameter-sharing twin encoder module intra-MMTN (Multi-Modal Transformer). The specific formula is: and where {v1, ·, v k} and {t1,·,t k} represents the fine-grained segment features of the input (regional features of images or word features of text), and The image or text context representation information of the output.
[0056] The second stage of training is based on the first stage of training, and its essence is to fine-tune the model obtained in the first pre-training stage. The specific process is to transform the segment features {v1, ·, v k} and {t1,·,t k} are spliced and input into the inter-MMTN module, and the formula is: in and Represents the contextual representation information of inter-modal interaction.
[0057] S3. The cross-modal matching calculation process of the adaptive similarity fusion module ASA is as follows: for a set of visual context features and text context features in The present invention defines a cross-modal fine-grained matching degree matrix A: Among them A ij represents the semantic similarity between the i-th visual context representation information and the j-th text context representation information, such as Figure 4 shown.
[0058] The global image-text similarity is defined as the weighted sum of the cross-modal fine-grained matching matrix A. Each fine-grained similarity is obtained by performing a softmax activation function operation on the weighted sum of the column elements of matrix A. The formula is: Where λ is the temperature coefficient of the softmax activation function, and the value in the embodiment of the present disclosure is 20. In general, the adaptive similarity fusion process can be expressed as:
[0059] For each image-text pairing, ASA can obtain two similarity scores, the formula is: and
[0060] The training process uses triplet loss to train the model:
[0061]
[0062] The training learning rate is 0.00001.
[0063] In summary, the present invention inputs the visual and text features of the sample into a unified multimodal Transformer reasoning network MMTN to obtain interactive reasoning information within and between modalities. Among them, the training process of the network is divided into two stages. The first stage uses a twin multimodal Transformer encoder to encode the visual and text information to obtain the intra-modal context information; the second stage inputs the fused visual information and text information into the same multimodal Transformer encoder to obtain the interactive context information between modalities. Finally, the model uses a new adaptive similarity fusion mechanism to perform cross-modal image and text similarity matching calculations and output the results. The present invention uses a Transformer encoder to uniformly model the interactive information within and between visual and text modalities, and deeply explores the relevance and complementarity of different modalities as a whole.
[0064] According to the disclosure and teaching of the above description, those skilled in the art to which the present invention belongs can also change and modify the above embodiment. Therefore, the present invention is not limited to the above specific embodiment, and any obvious improvement, replacement or modification made by those skilled in the art on the basis of the present invention belongs to the protection scope of the present invention. In addition, although some specific terms are used in this specification, these terms are only for the convenience of description and do not constitute any limitation to the present invention.
Claims
1. A cross-modal image and text retrieval method, characterized in that: The following steps are involved: S1, uses deep neural networks to extract visual features of images and text features of sentences; S2, designing a unified multimodal Transformer inference network to uniformly model data of different modalities; the unified multimodal Transformer inference network extracts intra-modal interaction information and inter-modal interaction information of vision and text, respectively, and calculates the similarity of visual features and text features through an adaptive similarity fusion module; S3, training a unified multimodal Transformer inference network, inputting the visual features and text features extracted in step S1 into the trained unified multimodal Transformer inference network, obtaining the similarity between the visual features and the text features, and outputting the image-text retrieval results; In step S2, a self-attention Transformer encoder is used to extract intra-modal interaction information and inter-modal interaction information of vision and text; Among them, in step S2, the specific method of calculating the similarity between the visual features and the text features by the adaptive similarity fusion module is: For a set of visual context representation information and text context representation information in Define the cross-modal fine-grained matching matrix A: The element A in A ij represents the semantic similarity between the i-th visual context representation information and the j-th text context representation information, W v and W t are network parameters; The weighted sum of the cross-modal fine-grained matching matrix A is defined as the global image-text similarity S(I,T). Each fine-grained similarity is obtained by performing a softmax activation function operation on the weighted sum of the column elements of the matrix A. The formula is: Where λ is the temperature coefficient of the softmax activation function; In step S3, a two-stage training method of pre-training and fine-tuning is used to train the unified multimodal Transformer inference network, wherein the first training stage generates intra-modal context representation information of a single modality of vision or text, and the second training stage generates interactive information between visual and text modalities; The training process of the first training stage is as follows: for the input image or text, a set of visual or text features are extracted respectively using the twin modal encoder module intra-MMTN, and the formula is: and where {v1,…,v k } and {t1,…,t k } represents the fine-grained segment features of the input, i.e., the regional features of the image or the word features of the text, and Represents the output image or text context representation information; encoder shared parameters of the encoder module within the twin modality; The training process of the second training stage is as follows: based on the training in the first stage, the segment features {v1,…,v k } and {t1,…,t k } are spliced and input into the inter-modal encoder module inter-MMTN. After the inter-modal encoder module reads the pre-trained model of the twin modal encoder module, it is trained in a fine-tuning manner. The formula is: in and Represents the contextual representation information of inter-modal interaction.
2. A cross-modal image-text retrieval method as claimed in claim 1, characterized in that: In step S1, the specific method of extracting the visual features of the image is: For each input image, the pre-trained model of the Faster-R-CNN network on the Visual Genome dataset is used as a visual feature extractor to extract features of the region of interest; For each selected region of interest, use a vector Represents its position embedding vector, where (x l ,y l ) and (x r ,y r ) represent the coordinates of the upper left corner and lower right corner of the region, W and H represent the width and height of the input image respectively; The visual features of the image are represented as Among them, v represents the visual feature vector, is the vector space, k is the number of regions of interest, and D is the visual feature dimension.
3. A cross-modal image-text retrieval method as claimed in claim 1, characterized in that: In step S1, the specific method of extracting the text features of the sentence is: For each sentence input, the pre-trained language model BERT is used to extract a set of word vectors, which are then input into the fully connected layer to obtain a set of text features with a dimension of D, expressed as Among them, t represents the text feature vector, is the vector space, n is the number of text segmentations, and D is the text feature dimension.
