Video retrieval method based on scene information
Video and frame-level scene information is extracted through the scene selection module and cross-attention mechanism, and integrated with video frame information, which solves the problem of low video retrieval accuracy in the existing technology, achieves efficient video retrieval effects, and simplifies the model structure. .
Patent Information
- Application Number
- PCT/CN2023/108662
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-03-20
- Filing Date
- 2023-07-21
- Publication Date
- 2024-09-26
AI Technical Summary
Existing video retrieval methods are difficult to effectively utilize scene information in videos, resulting in low retrieval accuracy, and multi-modal methods introduce complex network structures.
By designing a scene selection module and a cross-attention mechanism, video-level scenes and frame-level scenes are extracted respectively and fused with video frame information. Cosine distance and contrast loss are used for supervised training to achieve video feature fusion and similarity measurement.
The accuracy of video retrieval is significantly improved, the model structure is simplified, and the introduction of additional expert models is avoided.
Smart Images

Figure CN2023108662_26092024_PF_FP
Abstract
Description
A video retrieval method based on scene information Technical Field
[0001] The present invention relates to the field of computer vision, and in particular to a video retrieval method based on scene information. Background Art
[0002] Text-Video Retrieval (TVR) aims to solve the problem of finding semantically consistent videos from a large pool of unlabeled videos, given a natural language query. This technology allows for rapid text-based retrieval of relevant videos from the internet. However, due to the significant differences between video and natural language data, accurately finding the corresponding video based on a query is challenging.
[0003] There are currently two main approaches for video retrieval: bimodal and multimodal. The former uses only frame and text information from the video, directly calculating similarity using these two features. This results in a significant amount of scene information not being utilized, preventing optimal accuracy. The latter typically uses multiple expert models to extract various information from the video and text, such as pose, appearance, semantics, and sound. This integration of multiple forms of information often yields better results. However, the use of multiple expert models complicates the overall network structure.
[0004] Summary of the Invention
[0005] Without introducing additional expert models, the present invention fully considers the scene information of the video, obtains the video-level scene and frame-level scene respectively through the scene selection module and the cross-attention mechanism, and integrates the scene information with the video frame information, which greatly improves the accuracy of video retrieval.
[0006] To achieve the above object, the technical solution of the present invention is as follows:
[0007] A video retrieval method based on scene information includes the following steps:
[0008] (1) Video-level scene acquisition stage: The scene information in the video is represented using the designed scene selection module;
[0009] (2) Frame-level scene acquisition stage: Based on the video-level scene obtained in the previous step, the cross-attention mechanism is used to extract the corresponding frame-level scene information for each frame;
[0010] (3) Feature fusion module: Combine the frame features obtained in (1) with the frame-level scene information obtained in (2), and use the feature fusion module to fuse video features according to the corresponding semantic information;
[0011] (4) Similarity measurement module: Use cosine distance to measure the similarity between text and video, and use contrastive loss to supervise model training.
[0012] In the above scheme, the specific method of step (1) is as follows:
[0013] This stage is used to obtain video-level scene information. After taking n video frames from a video using uniform sampling, the image encoder and text encoder in CLIP-ViT-Base-Patch32 are used to obtain the semantic features of the video frames. and the semantic features of the corresponding text f t .
[0014] (1.1) The average value of video frame features is used as the video-level scene, and the scene selection module is used to aggregate the features of each frame and generate its mean.
[0015] Here W and b are the mapping matrix and offset vector, respectively, used to transform the features Projected into another space, is a normalization function used to scale the results to the same range, f s is the obtained video-level scene; in the normalization function In it, E(x) and D(x) represent the expectation and variance respectively, ε is a very small positive number used to ensure that the denominator is not zero, β and γ are two learnable parameters used to control the range of normalization.
[0016] In the above scheme, the specific method of step (2) is as follows:
[0017] (2.1) The video frame feature f v Mapped to query, video-level scene features are mapped to key and value to obtain the corresponding vector representation;
[0018] Here W q1 , W k1 , W v1 Represents the mapping matrix of video query, scene key and scene value, Q v , K s , V s are the corresponding mapping results respectively;
[0019] (2.2) Use the cross-attention mechanism to generate corresponding scene weights for each video frame;
[0020] Df Represents the dimension of the mapping matrix and is related to Q v , K s The second dimension has the same size, Attention(Q v ,K s ,V s ) represents the scene weight corresponding to each frame; ρ is used to normalize a matrix so that each row in the matrix satisfies the following conditions: each element ranges between 0 and 1, and the sum of the elements is 1. The specific calculation method is as follows,
[0021] Here r,t1 is the element in the rth row and t1th column of the matrix z, and C is the number of columns in the matrix z;
[0022] (2.3) According to the scene weight in (2.2), the corresponding frame-level scene information is obtained.
[0023] Here f p represents the frame-level scene information, W o1 It is a mapping matrix for scene information.
[0024] In the above scheme, the specific method of step (3) is as follows:
[0025] (3.1) The video frame feature f obtained in step (1) v And the frame-level scene feature f obtained in step (3) p Fusion, get the video frame feature f with scene information m , f m =αf v +(1-α)f p
[0026] Here α is a learnable parameter between 0 and 1, with an initial value of 0.5.
[0027] (3.2) The text feature f t As query, the video frame features with scene information are used as key and value, and the corresponding vector is obtained using the mapping matrix.
[0028] Here W q2 , W k2 , W v2 Represents the mapping matrix of text query, video key and video value, Q t , K v , V v are the corresponding mapping results,
[0029] (3.3) Use the cross attention mechanism again to generate corresponding weights for each video frame based on the text.
[0030] D a Represents the dimension of the mapping matrix and is related to Q t , K v The second dimension is consistent with Attention(Q t ,K v ,V v ) represents the video frame weight corresponding to each text;
[0031] (3.4) According to the weights of each frame obtained in the previous step, each frame is weighted to obtain the overall characteristics of a video.
[0032] Here f a represents the overall video features, W o2 It is a mapping matrix for the overall video features.
[0033] In the above scheme, the specific method of step (4) is as follows:
[0034] (4.1) For the text feature f obtained in step (1) t And the overall video feature f obtained in step (3) a , use the cosine distance to find the similarity between the two. sim(f t ,f a )=1-cos(f t ,f a )
[0035] (4.2) Use contrast loss to supervise the training process of the network model. Specifically, for a dataset containing N text and video pairs In each pair, the text t i It's video v i Corresponding description. Use cross entropy to supervise model training, where matching video-text pairs are used as positive samples and mismatched ones as negative samples; L=L t2v +L v2t
[0036] Here L t2v and L v2t The cross entropy loss of text to video and video to text respectively, L is the overall loss function, ω is a learnable parameter, and B is the size of a batch.
[0037] Through the above technical solution, the video retrieval model based on scene information proposed by the present invention has the following effects:
[0038] (1) The present invention fully considers the scene information in the video and designs a scene selection module and a cross-attention module to extract video-level scenes and frame-level scenes respectively, which significantly improves the accuracy of video retrieval.
[0039] (2) The present invention does not introduce other expert models while using scene information, which ensures that the model is simple and easy to use. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for describing the embodiments or the prior art.
[0041] FIG1 is an overall schematic diagram of a video retrieval model based on scene information disclosed in an embodiment of the present invention. DETAILED DESCRIPTION
[0042] The technical solutions in the embodiments of the present invention will be described clearly and completely below with reference to the accompanying drawings in the embodiments of the present invention.
[0043] The present invention provides a video retrieval method based on scene information, as shown in FIG1 . The model adds scene features to the video, so that the video contains richer information, thereby greatly improving the accuracy of video retrieval.
[0044] The specific embodiments are as follows:
[0045] A video retrieval model based on scene information includes the following steps:
[0046] (1) Video-level scene acquisition stage:
[0047] This stage is used to obtain video-level scene information. After taking n video frames from a video using uniform sampling, the image encoder and text encoder in CLIP-ViT-Base-Patch32 are used to obtain video frame features respectively. and the semantic features of the corresponding text f t .
[0048] (1.1) The average value of each frame feature is used as the video-level scene, and the scene selection module is used to aggregate the features of each frame and generate its mean.
[0049] Here W and b are the mapping matrix and offset vector, respectively, used to transform the features Projected into another space, is a normalization function used to scale the results to the same range, f sis the obtained video level scene. In the normalization function In it, E(x) and D(x) represent the expectation and variance respectively, ε is a very small positive number used to ensure that the denominator is not zero, β and γ are two learnable parameters used to control the range of normalization.
[0050] (2) Frame-level scene acquisition stage:
[0051] (2.1) The video frame feature f v The map is mapped to query, and the video-level scene features are mapped to key and value to obtain the corresponding vector representation.
[0052] Here W q1 , W k1 , W v1 Represents the mapping matrix of video query, scene key and scene value, Q v , K s , V s are the corresponding mapping results respectively.
[0053] (2.2) Use the cross-attention mechanism to generate corresponding scene weights for each video frame.
[0054] Here D f Indicates the dimension of the mapping matrix, Q in this application v and K s The dimensions are the same, so either one will do. v and K s If the dimensions are different, D f Should be with Q v , and K s The second dimension is consistent, such as Q v The dimension is m1*n, K s The dimension is m2*n, then D f It should be n; so D f Equal to Q v , K s The size of the second dimension. Attention(Q v ,K s ,V s ) represents the scene weight corresponding to each frame. ρ is used to normalize a matrix so that each row in the matrix satisfies the following conditions: each element ranges between 0 and 1, and the sum of the elements is 1. It is calculated as follows.
[0055] Here r,t1is the element in the rth row and t1th column of the matrix z, where C is the number of columns in the matrix z.
[0056] (2.3) According to the scene weight in (2.2), the corresponding frame-level scene information is obtained.
[0057] Here f p represents the frame-level scene information, W o1 It is a mapping matrix for scene information.
[0058] (3) Feature fusion module:
[0059] (3.1) The video frame feature f obtained in step (1) v And the frame-level scene feature f obtained in step (3) p Fusion, get the video frame feature f with scene information m .f m =αf v +(1-α)f p
[0060] Here α is a learnable parameter between 0 and 1, with an initial value of 0.5.
[0061] (3.2) The text feature f t As the query, the video frame features with scene information are used as the key and value, and the corresponding vector is obtained using the mapping matrix.
[0062] Here W q2 , W k2 , W v2 Represents the mapping matrix of text query, video key and video value, Q t , K v , V v are the corresponding mapping results respectively.
[0063] (3.3) Use the cross attention mechanism again to generate corresponding weights for each video frame based on the text.
[0064] Q of this application t and K v When the dimensions are the same, D a Indicates Q t or K v The dimension of any mapping matrix is , so either one can be chosen. t and K v If the dimensions are different, D a Should and Qt and K v The second dimension is consistent, such as Q t The dimension is m1*n, K v The dimension is m2*n, then D f It should be n. So D a Equal to Q t , K v The size of the second dimension, Attention(Q t ,K v ,V v ) represents the video frame weight corresponding to each text.
[0065] (3.4) According to the weights of each frame obtained in the previous step, each frame is weighted to obtain the overall characteristics of a video.
[0066] Here f a represents the overall video features, W o2 It is a mapping matrix for the overall video features.
[0067] (4) Similarity measurement module:
[0068] (4.1) For the text feature f obtained in step (1) t And the overall video feature f obtained in step (4) a , use cosine distance to find their similarity. sim(f t ,f a )=1-cos(f t ,f a )
[0069] (4.2) Use contrast loss to supervise the training process of the network model. Specifically, for a dataset containing N text and video pairs In each pair, the text t i It's video v i Corresponding description. Cross entropy is used to supervise model training, where matching video-text pairs are used as positive samples and mismatched ones as negative samples. L=L t2v +L v2t
[0070] Here L t2v and L v2t The cross entropy loss of text to video and video to text respectively, L is the overall loss function, ω is a learnable parameter, and B is the size of a batch. Here, when j is not equal to i, it means t j and v i Not relevant. L t2vThe whole becomes smaller, so the denominator becomes smaller and the numerator becomes larger, so the relevant (t i ,v i ) will become larger, and the similarity of irrelevant (tj,vi) will become smaller.
[0071] To verify the effectiveness of the proposed model, the following experiments are conducted: The experimental dataset uses MSRVTT, which contains 10,000 videos. Each video has 20 sentence descriptions and each video lasts 10-32 seconds. In the experiment, we selected 9,000 videos for training and 1,000 videos for testing.
[0072] In the experiment, Rank K (R@K) is used to evaluate the performance of the model. This is the most commonly used evaluation metric in video retrieval. The experimental results are shown in Table 1.
[0073] In the table, CLIP4Clip is the most commonly used method for video retrieval. Baseline is essentially the same as our model, but it does not utilize scene information. The results in the table show that our model significantly outperforms the other two methods in video retrieval, fully demonstrating the effectiveness of our proposed model and the powerful auxiliary role of scene information in video retrieval.
[0074] Table 1 Experimental results
[0075] The above description of the disclosed embodiments is intended to enable one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be readily apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention is not limited to the embodiments shown herein but is intended to conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A video retrieval method based on scene information, It is characterized in that The following steps are involved: (1) Video-level scene acquisition stage: The scene information in the video is represented using the designed scene selection module; (1.1) After taking n video frames from a video using uniform sampling, the image encoder and text encoder are used to obtain the video frame features respectively. and the corresponding text feature f t ; (2) Frame-level scene acquisition stage: Based on the video-level scene obtained in the previous step, the cross-attention mechanism is used to extract the corresponding frame-level scene information for each frame; (2.1) The video frame feature f v Mapped to query, video-level scene features are mapped to key and value to obtain the corresponding vector representation; Here W q1 , W k1 , W v1 Represents the mapping matrix of video query, scene key and scene value, Q v , K s , V s are the corresponding mapping results respectively; (2.2) Use the cross-attention mechanism to generate corresponding scene weights for each video frame. D f represents the dimension of the mapping matrix and is related to Q v , K s The second dimension has the same size, Attention(Q v ,K s ,V s ) represents the scene weight corresponding to each frame; ρ is used to normalize a matrix so that each row in the matrix satisfies the following conditions: each element ranges between 0 and 1, and the sum of the elements is 1. The specific calculation method is as follows: z r,y1 is the element in the rth row and y1th column of the matrix z, and C is the number of columns in the matrix z; (2.3) According to the scene weight in (2.2), the corresponding frame-level scene information is obtained; f p represents the frame-level scene information, W o1 It is a mapping matrix for scene information; (3) Feature fusion module: Combine the video frame features obtained in (1) with the frame-level scene information obtained in (2), and use the feature fusion module to fuse the video features according to the corresponding semantic information; (4) Similarity measurement module: Cosine distance is used to measure the similarity between text and video, and contrastive loss is used to supervise the training of the model.
2. A video retrieval method based on scene information according to claim 1, It is characterized in that In step (1), the video-level scene is obtained as follows: (1.2) Using the average value of the video frame features as the video-level scene, the scene selection module is used to aggregate the video frame features and generate their mean. Here W and b are the mapping matrix and offset vector, respectively, used to transform the features Projected into another space, is a normalization function used to scale the results to the same range, f s is the obtained video-level scene; in the normalization function In it, E(x) and D(x) represent the expectation and variance respectively, ε is a very small positive number used to ensure that the denominator is not zero, β and γ are two learnable parameters used to control the range of normalization.
3. A video retrieval method based on scene information according to claim 1, It is characterized in that The specific method of step (3) is as follows: (3.1) The video frame feature f obtained in step (1) v The frame-level scene feature f obtained in step (2) p Fusion, get the video frame feature f with scene information m , f m =αf v +(1-a)f p α is a learnable parameter between 0 and 1; (3.2) The text feature f t As query, the video frame features with scene information are used as key and value, and the corresponding vector is obtained using the mapping matrix; W q2 , W k2 , W v2 Represents the mapping matrix of text query, video key and video value, Q t , K v , V v are the corresponding mapping results respectively; (3.3) Use the cross attention mechanism again to generate corresponding weights for each video frame based on the text. D a represents the dimension of the mapping matrix and is related to Q t , K v The second dimension is consistent with Attention (Q t ,K v ,V v ) represents the video frame weight corresponding to each text; (3.4) According to the weights of each frame obtained in the previous step, each frame is weighted to obtain the overall characteristics of a video. f a represents the overall video feature, W o2 It is a mapping matrix for the overall video features.
4. The video retrieval method based on scene information according to claim 1, It is characterized in that The specific method of step (4) is as follows: (4.1) For the text feature f obtained in step (1) t and the overall video feature f obtained in step (3) a , use the cosine distance to find the similarity between the two, sim(f t ,f a )=1-cos(f t ,f a ) (4.2) Use contrastive loss to supervise the training process of the network model.
5. A video retrieval method based on scene information according to claim 4, It is characterized in that The specific method of step (4.2) is as follows: For a dataset containing N text and video pairs In each pair, the text t i It's video v i Corresponding description, cross entropy is used to supervise model training, and matching video-text pairs are used as positive samples, and mismatched ones are used as negative samples; L=L t2v +L v2t L t2v and L v2t The cross entropy losses for text to video and video to text are respectively, L is the overall loss function, ω is a learnable parameter, and B is the size of a batch.
Citation Information
Patent Citations
Video text matching model training method and device and video text matching method and device
CN115204301A
Video retrieval method based on attention segment prompt
CN115269913A
Long video retrieval method and device based on multi-scale multi-example similarity learning
CN115408558A
Video retrieval model based on scene information
CN116089653A
Method of processing video, method of querying video, and method of training model
EP4138047A2
Cited By
Video content detection method
CN120356136A
