Cross-modal retrieval method based on latent space semantic supervision based on knowledge distillation
By introducing knowledge distillation and semantic supervision technology into cross-modal retrieval, the problem of fine-grained matching in image-text retrieval is solved, efficient image-text retrieval accuracy is improved, and excellent performance on multiple databases is achieved.
Patent Information
- Application Number
- CN202211240066.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-11
- Publication Date
- 2024-10-11
- Estimated Expiration
- 2042-10-11
AI Technical Summary
Existing cross-modal retrieval technology is difficult to effectively perform fine-grained matching and semantic supervision between images and texts, resulting in low retrieval accuracy.
A latent space semantic supervision method based on knowledge distillation is adopted, which is transferred to the image latent space through the target and attribute classifiers in BUA, and combines the attention mechanism and multi-layer perceptron (MLP) for fine-grained consistency of image regions and text word features. matching, and supervised training using hinge loss, KL divergence, and cross-entropy loss functions.
Significantly improves the accuracy and consistency of image-text retrieval, achieving competitive results on multiple databases, especially on the Flickr30K and MS-COCO datasets.
Smart Images

Figure CN115565007B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a cross-modal retrieval method, and in particular to a cross-modal retrieval method with latent space semantic supervision based on knowledge distillation. Background Art
[0002] With the rapid development of multimedia, there is a huge amount of information on the Internet, such as images, text, video, audio, etc. It is becoming increasingly difficult to manually obtain useful information between different modalities in massive data. Therefore, a powerful method is needed to help us get the text, image or video we need. Cross-modal retrieval uses one modality of data as a query to retrieve related data in another modality. For example, we can use text to retrieve images of interest (as we do on Google Image Search), or use images to retrieve the corresponding text. Of course, modalities are not limited to images and text, other modalities such as speech, physical signals and videos can also be a component of cross-modal retrieval. Summary of the invention
[0003] In order to better perform cross-modal retrieval, the present invention provides a cross-modal retrieval method with latent space semantic supervision based on knowledge distillation.
[0004] The objective of the present invention is achieved through the following technical solutions:
[0005] A cross-modal retrieval method based on latent space semantic supervision of knowledge distillation includes the following steps:
[0006] Step 1: For the image part in the image-text pair, use BUA (Bottom Up Attention) as the basic image network of the image branch, select the image in the image-text pair as the input of the image branch, and output a set of salient area features for each image to represent the image V = {v1,...,v i ,...,v n}, n is the number of detection regions, d represents the dimension of the image region features, where:
[0007] v i =W x x i +b x ;
[0008] In the formula, v i represents the feature of the i-th image region, W x and b x represents the learnable parameters of the fully connected layer, x i represents the intermediate features of the i-th image region in BUA;
[0009] Step 2: For the text part of the image-text pair, use word encoding to encode each token into a word vector, and then use the bidirectional GRU as the basic text network of the text branch to convert the word sequence into a text representation U = {u1,...,u i ,...,u n}, u i Represents the features of the i-th text word, where:
[0010]
[0011]
[0012]
[0013] x i =W e w i ;
[0014] In the formula, and denote the forward and reverse hidden states respectively, m is the number of input words, W e is the learnable parameter matrix, w i Represents the one-hot encoding of the i-th text word;
[0015] Step 3: Construct a fine-grained similarity matrix between image region features and text word features, and use the attention mechanism to represent the contextualized word features U of the image region with the weighted sum of all image region features. c , using the weighted sum of all text words to represent the word feature contextualized image region feature V c , according to V and V c Define the image latent space, according to U and U c Define the text latent space, where:
[0016] The fine-grained similarity matrix between image region features and text word features is shown as follows:
[0017]
[0018] Among them, s ij Indicates the similarity between the i-th word and the j-th region;
[0019] Word feature contextualized image region feature V c As shown below:
[0020]
[0021]
[0022]
[0023] Where λ1 is the hyperparameter of the softmax function, represents the result of row-normalization of the fine-grained similarity matrix, represents the weight of all words in constituting the context information of the jth image region, Represents the context information of the jth image region;
[0024] Image region contextualized word features U c As shown below:
[0025]
[0026]
[0027]
[0028] In the formula, represents the result of column-normalization of the fine-grained similarity matrix, represents the weight of all image regions in constituting the context information of the i-th word, Represents the context information of the i-th word;
[0029] Step 4: Introduce the target classifier and attribute classifier of BUA into the image latent space. Through knowledge distillation, transfer the semantic knowledge in BUA to the image latent space, so as to perform semantic supervision on the image region features and the corresponding image context features, as shown in the following formula:
[0030]
[0031]
[0032]
[0033]
[0034] In the formula, and The target classifier representing the image region features and the corresponding image context features, o v and vc Respectively represent the target classification information of the image region features and the corresponding image context features, and are the attribute classifiers of image region features and corresponding image context features, a v and a vc Attribute classification information representing image region features and corresponding image context features;
[0035] Step 5: Introduce target classifiers and attribute classifiers into the text latent space, and perform target classification and attribute classification on each word feature and the corresponding word context feature, as shown in the following formula:
[0036]
[0037]
[0038]
[0039]
[0040] in, and The target classifier representing the word features and the corresponding word context features, o u and uc Represents the target classification information of word features and corresponding word context features respectively, and are attribute classifiers for word features and corresponding word context features, respectively. u and a uc Attribute classification information representing image region features and corresponding image context features;
[0041] Step 6: Perform fine-grained consistency matching of image regions and fine-grained consistency matching of words in the image latent space and text latent space respectively. The specific steps are as follows:
[0042] Step 61: Fine-grained consistency matching of image regions:
[0043] First, calculate the image region feature V and the corresponding image context feature V c Then t fully connected layers are applied to learn the correspondence between each image region, as shown in the following formula:
[0044]
[0045] In the formula, “||” means concate, and diag(·) returns the diagonal elements of the matrix as a vector. and is the parameter to be learned in the kth fully connected layer, σ represents the corresponding activation function, Represents the matching features of the image latent space;
[0046] The fine-grained consistency matching score of the image region is calculated as follows:
[0047] S v =σ(W v Vs +b v );
[0048] Where W v 、b v are the parameters of MLP;
[0049] Step 62: Fine-grained word consistency matching:
[0050] First, calculate the word feature U and the corresponding word context feature U c The word-by-word similarity between them is then calculated, and then t fully connected layers are applied to learn the correspondence between each word, as shown in the formula:
[0051]
[0052] in, and is the parameter to be learned by the kth fully connected layer, Represents the text latent space matching features;
[0053] The word fine-grained consistency matching score is calculated as follows:
[0054] S u =σ(W u V s +b u );
[0055] Among them, W u 、b u are the parameters of MLP;
[0056] Step 7: Optimization goal:
[0057] Step 71: Use the hinge loss function with hard negative sample mining for fine-grained similarity matching supervision, where:
[0058] The hinge loss function is shown as follows:
[0059]
[0060] In the formula, I′, T′ are negative samples, and the function [·] + Equivalent to max[·,0], s(·) is the similarity of the image-text pair, and γ represents the gap between the matching sample and the non-matching sample;
[0061] Step 72: Use the KL (Kullback-Leibler) divergence loss function to supervise the semantic consistency in the image latent space. The KL divergence loss function is shown as follows:
[0062]
[0063]
[0064] In the formula, and Represents the classification softmax vector;
[0065] Step 7.3: Use the cross entropy loss function to supervise the semantic consistency in the text latent space. The cross entropy loss function is shown as follows:
[0066]
[0067] In the formula, c o and c a is a one-hot vector of the target / attribute vocabulary defined by BUA, and N represents the size of the mini-batch.
[0068] Compared with the prior art, the present invention has the following advantages:
[0069] 1. The present invention introduces the target classifier and attribute classifier in BUA into the image latent space, and transfers the semantic knowledge in BUA to the image latent space through knowledge distillation.
[0070] 2. The present invention introduces target and attribute classifiers into the text latent space to keep the text features and the corresponding text context features consistent.
[0071] 3. The method of the present invention can perform cross-modal retrieval well and achieve competitive results on multiple databases. BRIEF DESCRIPTION OF THE DRAWINGS
[0072] Figure 1 This is a flow chart of cross-modal retrieval based on latent space semantic supervision of knowledge distillation in the present invention;
[0073] Figure 2 The training loss convergence curves of the present invention on Flickr30k and MS-COCO, (a) is the training loss curve on Flickr30k, (b) is the training loss curve on MS-COCO;
[0074] Figure 3 The visual results of the text retrieval of a given image query on the Flickr30K dataset by the method of the present invention are as follows;
[0075] Figure 4 The figure shows the visual results of image retrieval given a text query on the Flickr30K dataset using the method of the present invention. DETAILED DESCRIPTION
[0076] The technical solution of the present invention is further described below in conjunction with the accompanying drawings, but is not limited thereto. Any modification or equivalent replacement of the technical solution of the present invention without departing from the spirit and scope of the technical solution of the present invention should be included in the protection scope of the present invention.
[0077] The present invention provides a cross-modal retrieval method based on latent space semantic supervision of knowledge distillation. Figure 1 The overall structure of the entire network is shown, which can be roughly divided into four parts. The specific contents are as follows:
[0078] Part 1: Multimodal feature extraction network.
[0079] The present invention follows the commonly used spatial learning method to extract features of images and texts. Using BUA as the basic image network of the image branch, the image in the image-text pair is selected as the input of the image branch. Each image I can be represented by a set of features V = {v1,...,v i ,...,v n} to indicate that, So that each feature v i Encode a salient region in the image. Specifically, the present invention uses Faster R-CNN pre-trained on the Visual Genome dataset as BUA. The present invention uses the intermediate output of BUA to perform non-maximum suppression for each class with an IoU threshold of 0.7. The present invention sets a confidence threshold of 0.3 and selects all image regions where the probability of detecting any class is greater than the threshold. The top 36 candidate regions with the highest class detection confidence scores are selected. For each selected region i, features are extracted after the average pooling layer to obtain a vector x with 2048 dimensions i . Then a fully connected layer is applied to convert x i Convert to a d-dimensional vector as shown below:
[0080] v i =W x x i +b x .
[0081] For text, the words in the sentence are mapped to the same d-dimensional space as the image region. Given a one-hot encoding W = {w1,...,w i ,...,w m}, first through the word embedding layer x i =W e w i Convert the m input words in the sentence into a 300-dimensional vector, where W e is a learnable parameter matrix. Then the vector is input into Bi-GRU as shown below:
[0082]
[0083]
[0084] in, and Represent the hidden states of the forward and reverse directions respectively. The final word embedding u i is the mean of the two-way hidden state, as shown below:
[0085]
[0086] The second part: Construction of image and text latent space.
[0087] In order to construct the image latent space and text latent space respectively, the present invention first constructs the fine-grained similarity matrix of the image region and the text word. Then, the attention mechanism is used to represent each word feature U by a weighted combination of all image region features. c , each image region feature V is represented by a weighted combination of all text word features c . V and V c The image latent space, U and U can be defined c It is possible to define text hidden space.
[0088] Specifically, given an image with n detection regions V = {v1,...,v i ,...,v n}, Given a sentence containing m words U = {u1,...,u i ,...,u n}, First, the fine-grained similarity matrix between image region features and text word features is calculated as shown below:
[0089]
[0090] Among them, s ij In order to obtain the image region features contextualized by word features, the present invention first normalizes the similarity matrix by row, as shown in the following formula:
[0091]
[0092] Regarding the m words in the jth region U={u1,...,u i ,...,u n}, The attention weight is defined as follows:
[0093]
[0094] Among them, λ1 is the hyperparameter of the softmax function. Therefore, the word feature contextualizes the image region feature V c The definition is as follows:
[0095]
[0096] Similarly, the present invention can obtain the word features of the contextualization of the image region, as shown in the following formula:
[0097]
[0098]
[0099]
[0100] The third part: latent space semantic supervision based on knowledge distillation.
[0101] Since the objects and attributes in the image have high recognition, the present invention introduces the object classifier and attribute classifier in the BUA into the image latent space, and transfers the semantic knowledge in the BUA to the image latent space through knowledge distillation, thereby performing semantic supervision on the image region features and the corresponding image context features, as shown in the following formula:
[0102]
[0103]
[0104]
[0105]
[0106] in, and The target classifier representing the image region features and the corresponding image context features includes two fully connected layers. and They respectively represent the target classification information of the image region features and the corresponding image context features. and They are attribute classifiers of image region features and corresponding image context features, including two fully connected layers. and Represents the attribute classification information of the image region features and the corresponding image context features. The above classification results are supervised by the classification softmax vector generated by BUA. In this process, the target classifiers used by the image region features and the corresponding image context features are parameter-shared, and the attribute classifiers used are also parameter-shared.
[0107] Similarly, the present invention introduces a target classifier and an attribute classifier in the text latent space, and performs target classification and attribute classification on each word feature and the corresponding word context feature, as shown in the following formula:
[0108]
[0109]
[0110]
[0111]
[0112] in, and The target classifier representing word features and corresponding word context features consists of two fully connected layers. and Respectively represent the target classification information of word features and corresponding word context features. and They are attribute classifiers for word features and corresponding word context features, respectively, and contain two fully connected layers. and Represents the attribute classification information of the image region features and the corresponding image context features. The above classification results are supervised by the one-hot vector of the target / attribute vocabulary defined by BUA. In this process, the target classifier used by the word feature and the corresponding word context feature are parameter-shared, and the attribute classifier used is also parameter-shared.
[0113] The fourth part: image-text matching.
[0114] After obtaining the image region feature V contextualized by word features c and word features U contextualized by image region features c Finally, the present invention performs fine-grained correspondence matching in the image and text latent spaces respectively.
[0115] For fine-grained consistency matching in the image latent space, the present invention first calculates the image region feature V and the corresponding image context feature V c Then t fully connected layers are applied to learn the correspondence between each image region, as shown in the following formula:
[0116]
[0117] Here, “||” means concate, and diag(·) returns the diagonal elements of the matrix as a vector. and is the parameter to be learned in the kth fully connected layer, σ represents the corresponding activation function, Represents the image latent space matching feature. The fine-grained consistency matching score of the image region is calculated as follows:
[0118] S v =σ(W v V s +b v );
[0119] Among them, W v , b v are the parameters of MLP, which contains two fully connected layers.
[0120] Similarly, for fine-grained consistency matching in the text latent space, the present invention first calculates the word feature U and the corresponding word context feature U c The word-by-word similarity between them is then calculated, and then t fully connected layers are applied to learn the correspondence between each word, as shown in the formula:
[0121]
[0122] in, and is the parameter to be learned by the kth fully connected layer, Represents the text latent space matching feature. The fine-grained consistency matching score of a word is calculated as follows:
[0123] S u =σ(W u V s +b u );
[0124] Among them, W u , b u are the parameters of MLP, which includes two fully connected layers.
[0125] The overall matching score of the image text pair is calculated as follows:
[0126] s(I,T)=S v +S u .
[0127] Optimization goal:
[0128] The present invention adopts the hinge (MH) loss with hard negative sample mining as the objective function to optimize image-text matching. When using text T as a query, the present invention samples its matching images and non-matching images in each mini-batch to form positive pairs and negative pairs. The similarity of the positive pair should be γ higher than the similarity of the negative pair. Similarly, when using image I as a query, the negative samples should be texts that do not match the given query, and their similarity relative to the positive pair should also satisfy the above constraints, as shown in the following formula:
[0129]
[0130] Among them, I′, T′ are negative samples, and the function [·] + It is equivalent to max[·,0], where s(·) is the similarity between image and text pairs.
[0131] In the image latent space, the present invention transfers semantic knowledge from BUA to target / attribute classifier through knowledge distillation, and trains the target / attribute classifier of image region features and corresponding image context features using KL divergence loss function, as shown in the following formula:
[0132]
[0133]
[0134] in, and Represents the classification softmax vectors, which are generated by BUA.
[0135] In the text latent space, the present invention uses the cross entropy loss function to train the target / attribute classifier of the word features and the corresponding word context features, as shown in the following formula:
[0136]
[0137] in, and is a one-hot vector of the target / attribute vocabulary defined by BUA.
[0138] The overall loss function of the present invention is λ1Loss MH +λ2Loss KL +λ3Loss CE , where λ1, λ2, and λ3 are three hyperparameters.
[0139] Experimental results:
[0140] All experiments of the present invention are implemented in PyTorch 1.7 using a single NVIDIA GeForce RTX 3090 GPU (24G). In terms of image features, each image contains 36 most salient regions, and 2048 dimensional features are extracted from each region. The present invention sets the word embedding size to 300 and the dimension of the joint embedding space d to 1024. The present invention trains the proposed network on the training set and verifies it at each epoch of the validation set, and selects the model with the highest rSum for testing. The present invention uses the Adam optimizer and trains 30 epochs on both the Flickr30K and MS-COCO datasets with a mini-batch size of 128. For Flickr30K and MS-COCO, the initial learning rate is set to 0.0002 and decays by 10% every 15 epochs. For all experiments, the present invention sets γ to 0.2. The present invention spent about 26 hours training the model on Flickr30K, and the loss function converged after about 14 hours (15 epochs), and the training loss curve is as follows Figure 2 (a) shows. The present invention took about 92 hours to train the model on MS-COCO, and the loss function converged after about 39 hours (12 epochs). The training loss curve is shown in Figure 2 (b) as shown.
[0141] Table 1 shows the quantitative evaluation results of the present invention and mainstream cross-modal retrieval methods in the MS-COCO dataset using the evaluation criteria R@1, R@5, and R@10. For a more comprehensive comparison, the present invention uses two settings (1K and 5K) of the test set on MS-COCO. It can be seen that the present invention achieves the best performance in most indicators in both image retrieval and sentence retrieval tasks. In particular, under the 5K setting, the present invention has achieved significant improvements over previous methods.
[0142] Table 1 Comparison of experimental results with the current mainstream cross-modal retrieval results on the MS-COCO database
[0143]
[0144] Table 2 shows the comparison results of the present invention on the Flickr30K dataset. It can be found that under most evaluation indicators, the present invention is better than other methods, which shows the superiority of the present invention.
[0145] Table 2 Comparison of experimental results with the current best cross-modal retrieval results on the Flickr30K database
[0146]
[0147] Figure 3The visualized visual results of the text retrieval of the present invention for a given image query on the Flickr30K dataset are shown, where the truly matched samples are marked as light colors, and the incorrectly matched samples are marked as black. Figure 4 The visualization result of image retrieval given a text query on the Flickr30K dataset of the present invention is shown. Here, the real matching picture samples are added with borders.
Claims
1. A cross-modal retrieval method with latent space semantic supervision based on knowledge distillation, Features The method comprises the following steps: Step 1: For the image part in the image-text pair, use BUA as the basic image network of the image branch, select the image in the image-text pair as the input of the image branch, and output a set of salient area features for each image to represent the image V = {v 1 ,...,v j ,...,v n }, n is the number of detection regions, and d represents the dimension of the image region features; Step 2: For the text part of the image-text pair, use word encoding to encode each token into a word vector, and then use bidirectional GRU as the basic text network of the text branch to convert the word sequence into text representation u i represents the features of the i-th text word, and m is the number of input words; Step 3: Construct a fine-grained similarity matrix between image region features and text word features, and use the attention mechanism to represent the contextualized word features U of the image region with the weighted sum of all image region features. c , using the weighted sum of all text words to represent the word feature contextualized image region feature V c , according to V and V c Define the image latent space, according to U and U c Define text hidden space; Step 4: Introduce the target classifier and attribute classifier of BUA into the image latent space. Through knowledge distillation, transfer the semantic knowledge in BUA to the image latent space, so as to perform semantic supervision on the image region features and the corresponding image context features, as shown in the following formula: In the formula, and The target classifier representing the image region features and the corresponding image context features, o v and vc Respectively represent the target classification information of the image region features and the corresponding image context features, and are the attribute classifiers of image region features and corresponding image context features, a v and a vc Attribute classification information representing image region features and corresponding image context features; Step 5: Introduce target classifiers and attribute classifiers into the text latent space, and perform target classification and attribute classification on each word feature and the corresponding word context feature, as shown in the following formula: in, and The target classifier representing the word features and the corresponding word context features, o u and uc Represents the target classification information of word features and corresponding word context features respectively, and are attribute classifiers for word features and corresponding word context features, respectively. u and a uc Attribute classification information representing image region features and corresponding image context features; Step 6: Perform fine-grained consistency matching of image regions and fine-grained consistency matching of words in the image latent space and text latent space respectively. The specific steps are as follows: Step 61: Fine-grained consistency matching of image regions: First, calculate the image region feature V and the corresponding image context feature V c Then t fully connected layers are applied to learn the correspondence between each image region, as shown in the following formula: In the formula, "||" means concate, and diag(·) returns the diagonal elements of the matrix as a vector. and is the parameter to be learned in the kth fully connected layer, σ represents the corresponding activation function, Represents the matching features of the image latent space; The fine-grained consistency matching score of the image region is calculated as follows: S v =σ(W v V s +b v ); Where W v 、b v are the parameters of MLP; Step 62: Fine-grained word consistency matching: First, calculate the word feature U and the corresponding word context feature U c The word-by-word similarity between them is then calculated, and then t fully connected layers are applied to learn the correspondence between each word, as shown in the formula: in, and is the parameter to be learned by the kth fully connected layer, Represents the text latent space matching features; The word fine-grained consistency matching score is calculated as follows: S u =σ(W u U s +b u ); Among them, W u 、b u are the parameters of MLP; Step 7: Optimization goal: Step 71: Use hinge loss function with hard negative sample mining for fine-grained similarity matching supervision; Step 72: Use KL divergence loss function to supervise semantic consistency in image latent space; Step 7.3: Use the cross entropy loss function to supervise the semantic consistency in the text latent space.
2. According to claim 1, the cross-modal retrieval method based on latent space semantic supervision based on knowledge distillation, Features In the step 1, v j =W x x j +b x , where v j represents the feature of the jth image region, W x and b x represents the learnable parameters of the fully connected layer, x j represents the intermediate features of the j-th image region in BUA.
3. According to the cross-modal retrieval method based on latent space semantic supervision of knowledge distillation in claim 1, Features In the step 2, x i =W e w i ; In the formula, and denote the forward and reverse hidden states respectively, m is the number of input words, W e is the learnable parameter matrix, w i Represents the one-hot encoding of the i-th text word.
4. The cross-modal retrieval method based on latent space semantic supervision of knowledge distillation according to claim 1, Features In step 3, the fine-grained similarity matrix between the image region features and the text word features is shown in the following formula: Among them, s ij Indicates the similarity between the i-th word and the j-th region; Word feature contextualized image region feature V c As shown below: In the formula, λ 1 is the hyperparameter of the softmax function, represents the result of row-normalization of the fine-grained similarity matrix, represents the weight of all words in constituting the context information of the jth image region, Represents the context information of the jth image region; Image region contextualized word features U c As shown below: In the formula, represents the result of column-normalization of the fine-grained similarity matrix, represents the weight of all image regions in constituting the context information of the i-th word, Represents the context information of the i-th word.
5. The cross-modal retrieval method based on latent space semantic supervision of knowledge distillation according to claim 1, Features In step 7, the hinge loss function is as follows: In the formula, I′, T′ are negative samples, and the function [·] + It is equivalent to max[·,0], s(·) is the similarity between image-text pairs, and γ represents the gap between matching samples and non-matching samples.
6. The cross-modal retrieval method based on latent space semantic supervision of knowledge distillation according to claim 1, Features In step 7, the KL divergence loss function is as follows: In the formula, and Represents a classification softmax vector.
7. The cross-modal retrieval method based on latent space semantic supervision of knowledge distillation according to claim 1, Features In step 7, the cross entropy loss function is as follows: In the formula, c o and c a is a one-hot vector of the target / attribute vocabulary defined by BUA.
