A cross-modal retrieval method based on multi-granularity feature interaction
By introducing multi-granularity feature interaction in cross-modal representation learning, combined with the collaborative attention mechanism, the problem of lack of local feature and global visual information interaction in the existing technology is solved, achieving more efficient video and text matching performance, and reducing Model complexity.
Patent Information
- Application Number
- CN202111506944.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-10
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2041-12-10
AI Technical Summary
Existing cross-modal representation learning methods lack fine-grained local features in semantic similarity calculation between video and text, resulting in performance bottlenecks, and multi-branch methods lack effective interaction between global visual information and local visual information.
Using a cross-modal retrieval method based on multi-granularity feature interaction, by extracting global visual features and local visual features at the video frame level, combined with the collaborative attention mechanism for feature fusion, the final feature representation at the video level is obtained, and combined with text features Map to the same embedding space, calculate similarity for cross-modal matching.
It improves the matching performance between video and text, enriches feature representation, reduces model complexity, and achieves better cross-modal retrieval effects.
Smart Images

Figure CN114037945B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of video-text cross-modal retrieval, and in particular to a method for realizing cross-modal retrieval between video and text based on multi-granularity feature interaction. Background Art
[0002] Due to the rapid development of network technology, a large amount of video data has begun to appear on the Internet. How to find the video data we want in a large amount of video data, specifically how to use text data to find the corresponding video data or use video data to find text data. The goal of the present invention is to achieve mutual matching retrieval between video and text, find text that matches the video content from a large amount of video, and find video content that matches the sentence semantics from a large amount of text data.
[0003] In order to achieve the goal of the present invention, it is crucial to calculate the semantic similarity between the two modalities (video and text). Since early video retrieval methods are all based on concepts, they use predefined concept spaces to measure the spatial distance between video and text queries, and use spatial distances to calculate the similarity between video and text queries through concept matching. However, since this method of using predefined methods limits performance, methods based on cross-modal representation learning have gradually become popular. It breaks through the constraints of the concept space and learns the joint embedding space in a concept-free way to measure the similarity between video and text queries, showing a more superior performance than the former.
[0004] The most basic method in cross-modal representation learning is to extract visual features from the video through a pre-trained feature extraction model, then obtain a global visual feature representation through simple pooling or aggregation operations, and finally map the features to the joint embedding space through a fully connected layer. However, while this representation learning obtains a large amount of global visual information, it lacks fine-grained local features, which leads to performance bottlenecks. Therefore, most current cross-modal representation learning uses a multi-branch method to make up for the lack of local information. This method does promote the learning ability of the model to a certain extent. However, there is no interaction between global visual information and local visual information. Multiple branches simply learn from their own directions without good complementary learning. Therefore, we believe that this simple use of independent multi-branch methods is not optimal. Summary of the invention
[0005] In order to alleviate the above limitations, the present invention proposes a cross-modal retrieval method based on multi-granularity feature interaction. Based on the cross-modal representation learning method, the present invention focuses on the relationship between multi-granularity features to mine richer global and local information. Usually, people only focus on the frame level for video feature extraction, and do not pay attention to the importance of objects in each frame of the video to help the model understand. Based on this idea, the present invention first pre-processes the video to extract the objects in each frame of the video and the category to which it belongs. Then, a pre-trained model is used to extract local visual features and local semantic features, and local visual semantic features are obtained after interaction. The local semantic features are weighted and aggregated to obtain global semantic features. Then, global visual features are extracted through a global visual information extraction branch, and the global visual semantic features obtained after the interaction of global semantic features and global visual features are used to guide the local visual semantic features to eliminate invalid information that affects the model. Then, the local visual semantic features and global visual semantic features are fused by the collaborative attention mechanism to obtain a video-level representation. The video-level features are mapped to the same embedding space together with the text features, the similarity between the text features and the video features is calculated, and the obtained similarity is used as the ranking basis for text-video retrieval.
[0006] The object of the present invention is achieved through the following technical solution: a cross-modal retrieval method based on multi-granularity feature interaction, which comprises the following steps:
[0007] (1) Extract global visual features at the video frame level and detect objects and object categories in each frame, and then extract local visual features and local semantic features at the object level;
[0008] (2) weighting and aggregating the local semantic features extracted in step (1) to obtain global semantic features; using a gating mechanism to interact the global semantic features with the global visual features to obtain global visual semantic features, and interacting the local semantic features with the local visual features to obtain local visual semantic features; based on an attention mechanism, using the global visual semantic features to guide the local visual semantic features to eliminate invalid information;
[0009] (3) Construct the contextual relationship between global visual semantic features and local visual semantic features respectively, and use the collaborative attention mechanism to fuse the local visual semantic features and the global visual semantic features to obtain the final feature representation at the video level;
[0010] (4) Extract text features, map the video-level features and text features obtained in step (3) into the same embedding space, calculate the similarity between the two modalities through the embedding space, use the similarity to perform cross-modal matching, and train the model in an end-to-end manner;
[0011] (5) Input the video and text into the model trained in step (4) respectively to achieve mutual retrieval between text and video.
[0012] Furthermore, in step (1), pre-trained 2D CNNs are used to extract global visual features at the video frame level; pre-trained Faster-RCNN is used to detect objects, pre-trained Resnet-101 is used to extract local visual features at the object level, and pre-trained GloVe is used to extract local semantic features at the object level.
[0013] Furthermore, in the step (2), a deduplication operation is performed on the local semantic features, that is, repeated categories in each frame are deduplicated, and then the local semantic features are weighted and aggregated to obtain the global semantic features.
[0014] Furthermore, in step (2), a weighted aggregation operation is performed on all local semantic features extracted from each frame, and a global semantic feature is obtained by using the frequency of occurrence of each category as the weight of the category.
[0015] Furthermore, in step (2), the acquisition of the global visual semantic features includes: after splicing the global semantic features to the global visual features, controlling the flow of information through a gating mechanism, guiding the global visual features to perform scaling modulation with the global semantic features, absorbing the global semantic information of the video, and thereby obtaining global visual semantic features that can better match the text.
[0016] Furthermore, in the step (2), the acquisition of the local visual semantic features includes: linearly transforming the local visual features and the local semantic features into a feature space, and then obtaining the local visual semantic features through a gating mechanism.
[0017] Furthermore, in step (2), the global visual semantic features are used to guide the local visual semantic features to eliminate invalid information, including: for the local visual semantic features of each frame, under the guidance of the corresponding global visual semantic features, the local visual semantic features are aggregated using an interactive network based on an attention mechanism, so that the dimensions of the two features are aligned to obtain the final local visual semantic features.
[0018] Furthermore, in the step (3), two different bidirectional GRUs are used to respectively construct the contextual relationship between the global visual semantic features and the local visual semantic features, and the interaction network based on the collaborative attention mechanism is used to realize the global-driven interaction and the local-driven interaction; in the global-driven interaction, the local visual semantic features are used as the query, and the global visual semantic features are used as the key and value; in the local-driven interaction, the global visual semantic features are used as the query, and the local visual semantic features are used as the key and value; finally, the maximum pooling layer is used to extract the global visual semantic features and the local visual semantic features, and the extracted global visual semantic features and the local visual semantic features are concatenated as the final feature representation at the video level.
[0019] Furthermore, in the step (4), text features are extracted through the BERT model, and the video-level features and text features are respectively mapped to the same embedding space through a fully connected layer and a batch normalization layer for matching. The cosine similarity between the text and the video is calculated through the embedding space, and cross-modal matching is performed using the cosine similarity. The global visual semantic features and the local visual semantic features are aligned in similarity, and a cross-modal retrieval model based on a neural network is trained in an end-to-end manner. The model is jointly trained using a cross-modal loss function and a cross-feature loss function.
[0020] Furthermore, in step (5), the text and video are mapped into the embedding space together, the similarity between all video-text pairs is calculated, and all candidate videos and texts are sorted based on this, and finally the video-text pair with the highest similarity is used as the retrieval result to achieve the cross-modal retrieval task.
[0021] The beneficial effects of the present invention are: in order to enrich the video representation features, the present invention proposes a cross-modal retrieval method based on multi-granularity feature interaction to handle text-video retrieval tasks. The method of the present invention learns from different perspectives through the global visual semantic features and local visual semantic features of the video. The method of the present invention achieves a relatively good level of performance, and the model complexity is relatively low relative to the performance. For multi-branch cross-modal visual representation learning, the present invention demonstrates the potential to mine deep information by utilizing the interaction of global visual semantic features and local visual semantic features. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Figure 1 It is a schematic diagram of the structure of the cross-modal retrieval method based on multi-granularity feature interaction of the present invention;
[0023] Figure 2 It is a schematic diagram of the global visual semantic interaction structure of the present invention;
[0024] Figure 3 It is a schematic diagram of the local visual semantic interaction structure of the present invention. DETAILED DESCRIPTION
[0025] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the specific embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0026] In the following description, many specific details are set forth to facilitate a full understanding of the present invention, but the present invention may also be implemented in other ways different from those described herein, and those skilled in the art may make similar generalizations without violating the connotation of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below.
[0027] In cross-modal retrieval, how to obtain more refined features is crucial for matching different modalities, so how to encode is of utmost importance. The implementation process of the method of the present invention is described in detail below.
[0028] The present invention proposes a cross-modal retrieval method based on multi-granularity feature interaction, and the specific steps include:
[0029] (1) Extract global visual features at the video frame level and detect objects and object categories in each frame, and then extract local visual features and local semantic features at the object level.
[0030] To be specific, after a video is given, a video frame sequence with a pre-specified interval of 0.5 seconds is first extracted. In this embodiment, on the one hand, 2D CNNs pre-trained on ImageNet are used to extract global visual features at the video frame level; on the other hand, Faster-RCNN pre-trained on the COCO dataset is used to detect objects with top-10 confidence levels, and then the pre-trained Resnet-101 is used to extract local visual features at the object level. For category information, the pre-trained GloVe is used to map the categories of the top-10 objects detected in each video frame with confidence levels to the embedding space to obtain local semantic features.
[0031] Through the above steps, we can get the global visual feature V g = {v g 1, v g 2, ..., v g T}, local visual feature V l = {v l 1, v l 2, ..., v l T} and local semantic features S l ={s l 1,s l 2, ..., s l T}.
[0032] (2) Aggregate local visual features and local semantic features to obtain local visual semantic features. Since local semantic information may be redundant and will affect the learning of the model, it is necessary to deduplicate local semantic features to prevent redundant information from interfering with the model. Specifically, duplicate categories in each frame are deduplicated to ensure that there is only one feature for each category. Then, all local semantic features extracted from each frame are weighted aggregated, that is, the frequency of occurrence of each category is used as the weight of the category to obtain global semantic features. Then, the global semantic features are aggregated with the global visual features extracted in step (1) to obtain global visual semantic features. Then, the global visual semantic features and local visual semantic features are subjected to visual semantic interaction, and the global visual semantic features are used to guide the learning of local visual semantic features. The specific steps are as follows:
[0033] (2-1) Figure 2 As shown, the global semantic feature S g Spliced to the global visual feature V g = {v g 1, v g 2, ..., v g T}, a gating mechanism is then used to control the flow of information, through which the global visual semantic feature F can be obtained. g ={f g 1, f g 2, ..., f g T}, the formula is as follows:
[0034]
[0035]
[0036] Where [;] represents the concatenation operation, ⊙ represents the element-wise multiplication, σ represents the Bigmoid activation function, and W g and b g Represents a learnable parameter. Through the above method, the global semantic features are used to guide the global visual features to perform scaling modulation, absorb the global semantic information of the video, and thus obtain the global visual semantic features that can better match the text.
[0037] (2-2) Since the features extracted from local areas are usually richer than those extracted from global areas, a more sophisticated interaction mechanism is needed to construct the relationship between local visual features and local semantic features. Figure 3 As shown, firstly, the local visual feature V l and local semantic features S lLinearly transform into a feature space, and then further use a gating mechanism similar to the global visual semantic interaction to obtain local visual semantic features. The formula is as follows:
[0038]
[0039]
[0040] Where W v , b v , W s , b s , W f , b f These are all learnable parameters.
[0041] Considering the global visual semantic feature F g It can guide local visual semantic features to aggregate better, so global visual semantic features are used to guide local visual semantic features. Aggregation is performed, that is, using global visual semantic features to guide the model to aggregate local visual semantic features. Specifically, given the local visual semantic features of the i-th frame and the global visual semantic feature f g i , using the interaction network based on the attention mechanism for aggregation, the specific formula is as follows:
[0042]
[0043]
[0044]
[0045] Among them, LN represents layer normalization, MHSA is a multi-head self-attention layer, MLP is a two-layer fully connected layer plus a ReLU nonlinear activation function, and P is a mean pooling operation. Then we get the local visual semantic feature f that considers the visual and semantic interaction at time i. l i , the f of all moments l Combined together to obtain the final local visual semantic feature F l ={f l 1, f l 2, ..., f l T}, where T represents the number of frames in a video.
[0046] (3) Given the global visual semantic feature F obtained through visual semantic interaction in step (2), g and local visual semantic features F l , further exploiting cross-feature interactions to enhance each other.
[0047] First, two different bidirectional GRUs are used to construct the contextual relationship between global visual semantic features and local visual semantic features. Then, an interaction network based on the collaborative attention mechanism is used to realize the global driven interaction and the local driven interaction. In the global driven interaction, F l As its query, and F g As its key and value. Therefore, the global driven interaction is to use the local visual semantic features to enrich the global visual semantic features. Similarly, the local driven interaction is to transform F g As its query, and F l As its key and value. The global visual semantic features are used to enhance the local features through local drive interaction. In addition, this embodiment further uses the maximum pooling layer to extract the global visual semantic features and the local visual semantic features, specifically as shown in the following formula:
[0048] h l =P(Trans(G(F g ), G(F l ), G(F l ))),
[0049] h g =P(Trans(G(F l ), G(F g ), G(F g ))),
[0050] Where G represents bidirectional GRU, Trans represents interactive network, and P represents the maximum pooling operation. l and h g The final feature h of the video is obtained by splicing.
[0051] (4) Extract text features, map the video-level features and text features obtained in step (3) into the same embedding space, calculate the similarity between the two modalities through the embedding space, use the similarity to perform cross-modal matching, and train the model in an end-to-end manner; the specific steps are as follows:
[0052] (4-1) Due to the popularity of the BERT model and the rapid development of the natural language processing field in recent years, this embodiment uses a pre-trained BERT model to encode the text to obtain a text feature vector c.
[0053] (4-2) Then, the video feature h obtained in step (3) and the text feature obtained in step (4-1) are mapped to the same embedding space through a fully connected layer and a batch normalization layer for matching. The formula is as follows:
[0054] v=BN(W vc h+bvc )
[0055] t=BN(W t c+b t )
[0056] Where W vc , W t , b vc , b t They are all learnable parameters, and BN is a batch normalization layer.
[0057] (4-3) Since in the embedding space, we hope to shorten the distance between related video text pairs and extend the distance between unrelated video text pairs, this embodiment uses the three-state loss L tri , the formula is as follows:
[0058] L tri =max[0,s(v,t - )-s(v,t)+m]+max[0,s(v - ,t)-s(v,t)+m]
[0059] where t - and v - They represent the negative text samples and negative video samples in a batch, respectively, m is the margin, s(·) is the cosine similarity function, and max means using the most difficult sample.
[0060] The h obtained from step (3) l and h g First, they are mapped to a new feature alignment space through the batch normalization layer and the ReLU activation mapping transformation to obtain the new mapping feature m g and m l In addition to the three-state loss, this embodiment further utilizes the cross-feature alignment loss to make the distance between features extracted from the same video shorter than that between features extracted from different videos. The formula of the cross-feature alignment loss is as follows:
[0061] L align =max[0,s(m g , m l- )-s(m g , m l )+m]+max[0,s(m g- , m l )-s(m g , m l )+m]
[0062] Finally, the three-state loss L is used together tri and cross-feature alignment loss L align Train the model as follows:
[0063] L=L tri +λ·L align
[0064] Where L is the total loss function of the model and λ is an adjustable parameter.
[0065] Then, in this embodiment, the SGD optimizer with an initial learning rate of 0.003, a weight decay of 0.005, and a momentum update weight of 0.99 is used to train the model with 64 video-text pairs per batch. During the training process, the learning rate will become 0.99 times that of the previous cycle, and an early stop training strategy is set. If the verification accuracy does not increase within 20 consecutive cycles, the learning rate will be directly reduced to half of the current learning rate. If it does not increase within 50 cycles, the model training will be terminated.
[0066] (5) Map the text and video together into the embedding space, use the cosine similarity function to calculate the cosine similarity between all video-text pairs, and use this to sort all candidate videos and texts. Finally, take the video-text pair with the highest similarity as the retrieval result to achieve the cross-modal retrieval task.
[0067] The above is only a preferred embodiment of the present invention. Although the present invention has been disclosed as a preferred embodiment, it is not intended to limit the present invention. Any technician familiar with the art can make many possible changes and modifications to the technical solution of the present invention by using the above disclosed methods and technical contents without departing from the scope of the technical solution of the present invention, or modify it into an equivalent embodiment of equivalent changes. Therefore, any simple modification, equivalent change and modification made to the above embodiments according to the technical essence of the present invention without departing from the content of the technical solution of the present invention still falls within the scope of protection of the technical solution of the present invention.
Claims
1. A cross-modal retrieval method based on multi-granularity feature interaction, characterized in that: The following steps are involved: (1) Extract global visual features at the video frame level and detect objects and object categories in each frame, and then extract local visual features and local semantic features at the object level; (2) weighting and aggregating the local semantic features extracted in step (1) to obtain global semantic features; using a gating mechanism to interact the global semantic features with the global visual features to obtain global visual semantic features, and to interact the local semantic features with the local visual features to obtain local visual semantic features; Based on the attention mechanism, the global visual semantic features are used to guide the local visual semantic features to eliminate invalid information; (3) Construct the contextual relationship between global visual semantic features and local visual semantic features respectively, and use the collaborative attention mechanism to fuse the local visual semantic features and the global visual semantic features to obtain the final feature representation at the video level; (4) Extract text features, map the video-level features and text features obtained in step (3) into the same embedding space, calculate the similarity between the two modalities through the embedding space, use the similarity to perform cross-modal matching, and train the model in an end-to-end manner; (5) Input the video and text into the model trained in step (4) respectively to achieve mutual retrieval between text and video.
2. According to claim 1, a cross-modal retrieval method based on multi-granularity feature interaction is characterized in that: In the step (1), a pre-trained 2D CNNs is used to extract global visual features at the video frame level; a pre-trained Faster-RCNN is used to detect objects, a pre-trained Resnet-101 is used to extract local visual features at the object level, and a pre-trained GloVe is used to extract local semantic features at the object level.
3. According to claim 1, a cross-modal retrieval method based on multi-granularity feature interaction is characterized in that: In the step (2), a deduplication operation is performed on the local semantic features, that is, repeated categories in each frame are deduplicated, and then the local semantic features are weighted and aggregated to obtain the global semantic features.
4. The cross-modal retrieval method based on multi-granularity feature interaction according to claim 1, characterized in that: In the step (2), a weighted aggregation operation is performed on all local semantic features extracted from each frame, and a global semantic feature is obtained based on the frequency of occurrence of each category as the weight of the category.
5. The cross-modal retrieval method based on multi-granularity feature interaction according to claim 1, characterized in that: In the step (2), the acquisition of the global visual semantic features includes: splicing the global semantic features to the global visual features, controlling the flow of information through a gating mechanism, guiding the global visual features to perform scaling modulation with the global semantic features, absorbing the global semantic information of the video, and thereby obtaining global visual semantic features that can better match the text.
6. A cross-modal retrieval method based on multi-granularity feature interaction according to claim 1, characterized in that: In the step (2), the acquisition of the local visual semantic features includes: linearly transforming the local visual features and the local semantic features into a feature space, and then obtaining the local visual semantic features through a gating mechanism.
7. The cross-modal retrieval method based on multi-granularity feature interaction according to claim 1, characterized in that: In the step (2), the global visual semantic features are used to guide the local visual semantic features to eliminate invalid information, including: for the local visual semantic features of each frame, under the guidance of the corresponding global visual semantic features, the local visual semantic features are aggregated using an interactive network based on an attention mechanism, so that the dimensions of the two features are aligned to obtain the final local visual semantic features.
8. The cross-modal retrieval method based on multi-granularity feature interaction according to claim 1, characterized in that: In the step (3), two different bidirectional GRUs are used to respectively construct the contextual relationship between the global visual semantic features and the local visual semantic features, and an interactive network based on a collaborative attention mechanism is used to realize the global-driven interaction and the local-driven interaction; in the globally-driven interaction, the local visual semantic features are used as queries, and the global visual semantic features are used as keys and values; in the locally-driven interaction, the global visual semantic features are used as queries, and the local visual semantic features are used as keys and values; finally, the maximum pooling layer is used to extract the global visual semantic features and the local visual semantic features, and the extracted global visual semantic features and the local visual semantic features are concatenated as the final feature representation at the video level.
9. The cross-modal retrieval method based on multi-granularity feature interaction according to claim 1, characterized in that: In the step (4), text features are extracted through the BERT model, video-level features and text features are mapped to the same embedding space through a fully connected layer and a batch normalization layer for matching, the cosine similarity between the text and the video is calculated through the embedding space, cross-modal matching is performed using the cosine similarity, similarity alignment is performed on global visual semantic features and local visual semantic features, and a cross-modal retrieval model based on a neural network is trained in an end-to-end manner, and the model is jointly trained using a cross-modal loss function and a cross-feature loss function.
10. A cross-modal retrieval method based on multi-granularity feature interaction according to claim 1, characterized in that: In step (5), the text and video are mapped into the embedding space together, the similarity between all video-text pairs is calculated, and all candidate videos and texts are sorted based on this, and finally the video-text pair with the highest similarity is used as the retrieval result to achieve the cross-modal retrieval task.
