Video text retrieval method and device, electronic equipment and storage medium

By calculating the attention weight of video and text and performing information interaction, and adjusting features to improve similarity matching, the problem of inaccurate video text retrieval in the existing technology is solved, and higher retrieval accuracy is achieved.

CN118779478APending Publication Date: 2024-10-15TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202310398254.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-04-04
Publication Date
2024-10-15

AI Technical Summary

Technical Problem

In the existing video text cross-modal retrieval technology, the text description content does not completely match the retrieved real video content, resulting in inaccurate retrieval.

Method used

By obtaining the characteristics of the video to be retrieved and the requested text, the attention weight of the video and text is calculated, information interaction is performed, the features are adjusted to improve similarity matching, and it is determined whether the video is the retrieval result of the requested text.

Benefits of technology

It improves the accuracy of video text retrieval, solves the problem of unstable video slicing methods, and enables text fragments to accurately retrieve relevant video fragments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118779478A_ABST
    Figure CN118779478A_ABST
Patent Text Reader

Abstract

The invention discloses a video text retrieval method and device, electronic equipment and a storage medium. The method relates to a computer vision direction in the field of artificial intelligence, and comprises the following steps: acquiring a to-be-retrieved video and a request text, and acquiring video features and text features; determining a first video attention weight and a second video attention weight, and determining a first text attention weight and a second text attention weight; adjusting the text features through the first video attention weight, and adjusting the video features through the second video attention weight to obtain video features after information interaction; adjusting the video features through the first text attention weight, and adjusting the text features through the second text attention weight to obtain text features after information interaction; and determining whether the to-be-retrieved video is a retrieval result corresponding to the request text based on the video feature after information interaction and the text feature after information interaction. According to the method, the accuracy degree of video text retrieval can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence, and specifically to a video text retrieval method, device, electronic device and storage medium. Background Art

[0002] With the development of Internet technology, people can use the Internet to store and obtain extremely rich video data. However, the huge amount of data storage will bring about the problem of difficult retrieval. Due to the huge amount of data, it becomes increasingly difficult to determine the data you want to obtain from the huge data storage. Often, due to the imperfect retrieval system, it is impossible to obtain accurate information from the stored data.

[0003] Rich information needs to be accurately screened and presented to users. For retrieval systems, accurate retrieval and services need to be provided. Therefore, cross-modal retrieval systems have become a hot topic today. For example, video text cross-modal retrieval is an important and challenging classic computer vision task. However, using current technical solutions for video text cross-modal retrieval will result in the problem that the text description content does not completely match the retrieved real video content, making video text cross-modal retrieval inaccurate. Summary of the invention

[0004] The embodiments of the present application provide a video text retrieval method, device, electronic device and storage medium, which can improve the accuracy of video text retrieval.

[0005] The present application embodiment provides a video text retrieval method, including:

[0006] Obtaining a video to be retrieved and a request text, and obtaining video features corresponding to the video to be retrieved and text features corresponding to the request text;

[0007] Determine a first video attention weight and a second video attention weight corresponding to the video to be retrieved, and determine a first text attention weight and a second text attention weight corresponding to the request text;

[0008] Adjusting the text feature by the first video attention weight, and adjusting the video feature by the second video attention weight to obtain a video feature after information interaction;

[0009] Adjusting the video feature by the first text attention weight, and adjusting the text feature by the second text attention weight to obtain a text feature after information interaction;

[0010] Based on the similarity between the video features after the information interaction and the text features after the information interaction, it is determined whether the video to be retrieved is a retrieval result corresponding to the request text.

[0011] Accordingly, the embodiment of the present application provides a video text retrieval device, comprising:

[0012] An acquisition unit, used to acquire a video to be retrieved and a request text, and acquire video features corresponding to the video to be retrieved and text features corresponding to the request text;

[0013] A determination unit, configured to determine a first video attention weight and a second video attention weight corresponding to the video to be retrieved, and to determine a first text attention weight and a second text attention weight corresponding to the request text;

[0014] A first adjustment unit, configured to adjust the text feature by using the first video attention weight, and adjust the video feature by using the second video attention weight, to obtain a video feature after information interaction;

[0015] A second adjustment unit, configured to adjust the video feature by using the first text attention weight, and adjust the text feature by using the second text attention weight, to obtain a text feature after information interaction;

[0016] The retrieval unit is used to determine whether the video to be retrieved is a retrieval result corresponding to the request text based on the similarity between the video features after the information interaction and the text features after the information interaction.

[0017] Optionally, in some embodiments of the present application, the determination unit is used to determine the first video attention weight on the query dimension, the video key attention weight on the key dimension, and the video value attention weight on the value dimension corresponding to the video to be retrieved, wherein the second video attention weight includes the video key attention weight and the video value attention weight; determine the first text attention weight on the query dimension, the text key attention weight on the key dimension, and the text value attention weight on the value dimension corresponding to the request text, wherein the second text attention weight includes the text key attention weight and the text value attention weight.

[0018] Optionally, in some embodiments of the present application, the first adjustment unit is used to adjust the text features through the first video attention weight to obtain a first text feature matrix; adjust the video features through the video key attention weight to obtain a second video feature matrix; adjust the video features through the video value attention weight to obtain a third video feature matrix; and interact information between the first text feature matrix, the second video feature matrix, and the third video feature matrix to obtain video features after information interaction.

[0019] Optionally, in some embodiments of the present application, the second adjustment unit is used to adjust the video features through the first text attention weights to obtain a first video feature matrix; adjust the text features through the text key attention weights to obtain a second text feature matrix; adjust the text features through the text value attention weights to obtain a third text feature matrix; and perform information interaction among the first video feature matrix, the second text feature matrix, and the third text feature matrix to obtain text features after information interaction.

[0020] Optionally, in some embodiments of the present application, the acquisition unit includes an acquisition subunit, an input subunit, and an adjustment subunit, as follows:

[0021] An acquisition subunit, used for acquiring a video frame of a video to be retrieved;

[0022] An input subunit, used for inputting the video frame into an image encoder to obtain initial video features corresponding to the video frame;

[0023] The adjustment subunit is used to calculate the self-attention weight based on the initial video feature to obtain the self-attention video weight, and adjust the initial video feature by the self-attention video weight to obtain the video feature.

[0024] Optionally, in some embodiments of the present application, the input subunit is used to perform image segmentation on the video frame to obtain a number of image blocks; perform feature extraction on each of the image blocks to obtain initial image block features corresponding to each of the image blocks; add position coding information to the initial image block features corresponding to each of the image blocks to obtain initial video features corresponding to the video to be retrieved.

[0025] Optionally, in some embodiments of the present application, the adjustment subunit is used to determine the self-attention video weight corresponding to each feature element in the initial video feature; based on the self-attention video weight, determine the first feature matrix on the query dimension, the second feature matrix on the key dimension, and the third feature matrix on the value dimension corresponding to the feature element; based on the first feature matrix and the second feature matrix, obtain a self-attention feature matrix, the self-attention feature matrix expresses the degree of correlation between different feature elements in the video frame; based on the feature correlation and the third feature matrix, obtain video features.

[0026] Optionally, in some embodiments of the present application, the acquisition unit is used to obtain a request text; input the request text into a text encoder to obtain initial text features corresponding to the request text; perform self-attention weight calculation based on the initial text features to obtain self-attention text weights, and adjust the initial text features by the self-attention text weights to obtain text features.

[0027] An electronic device provided in an embodiment of the present application includes a processor and a memory, wherein the memory stores a plurality of instructions, and the processor loads the instructions to execute the steps in the video text retrieval method provided in the embodiment of the present application.

[0028] In addition, an embodiment of the present application further provides a storage medium on which a computer program is stored, wherein when the computer program is executed by a processor, the steps in the video text retrieval method provided in the embodiment of the present application are implemented.

[0029] The embodiment of the present application provides a video text retrieval method, device, electronic device and storage medium, which can obtain the video to be retrieved and the request text, and obtain the video features and text features; determine the first video attention weight and the second video attention weight, and determine the first text attention weight and the second text attention weight; adjust the text features by the first video attention weight, and adjust the video features by the second video attention weight to obtain the video features after information interaction; adjust the video features by the first text attention weight, and adjust the text features by the second text attention weight to obtain the text features after information interaction; based on the video features after information interaction and the text features after information interaction, determine whether the video to be retrieved is the retrieval result corresponding to the request text. The present application can improve the accuracy of video text retrieval. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0031] Figure 1 Schematic diagram of a video text retrieval method according to an embodiment of the present application;

[0032] Figure 2 is a first flow chart of the video text retrieval method provided by an embodiment of the present application;

[0033] Figure 3 is a second flow chart of the video text retrieval method provided in an embodiment of the present application;

[0034] Figure 4 is a third flow chart of the video text retrieval method provided in an embodiment of the present application;

[0035] Figure 5 It is a schematic diagram of video feature extraction provided by an embodiment of the present application;

[0036] Figure 6 is a structural diagram of a video text retrieval device provided in an embodiment of the present application;

[0037] Figure 7 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0038] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of this application.

[0039] The embodiments of the present application provide a video text retrieval method, device, electronic device and storage medium. The business information processing device can be integrated in an electronic device, which can be a terminal or a server. It is understandable that the video text retrieval method of the present embodiment can be executed on a terminal, on a server, or jointly by a terminal and a server. The above examples should not be construed as limitations on the present application.

[0040] The terminal may include a mobile phone, an intelligent voice interaction device, an intelligent home appliance, a vehicle-mounted terminal, an aircraft, a tablet computer, a notebook computer, or a personal computer (PC), etc. A client may also be set on the terminal, and the client may be an application client or a browser client, etc.

[0041] The server may be an independent physical server, a server cluster or a distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. In the business information processing method or device disclosed in the present application, multiple servers may be composed of a blockchain, and the server is a node on the blockchain.

[0042] The video text retrieval method provided in the embodiment of the present application relates to the field of computer vision (CV) in the field of artificial intelligence (AI). The embodiment of the present application can improve the retrieval accuracy by combining computer vision with natural language processing.

[0043] Among them, artificial intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology in computer science. It attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence. Artificial intelligence is to study the design principles and implementation methods of various intelligent machines so that machines have the functions of perception, reasoning and decision-making. Artificial intelligence technology is a comprehensive discipline that covers a wide range of fields, including both hardware-level technology and software-level technology. Basic artificial intelligence technologies generally include technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, and mechatronics. Artificial intelligence software technology mainly includes computer vision technology, speech processing technology, natural language processing technology, and machine learning / deep learning.

[0044] Among them, computer vision technology (CV) is a science that studies how to make machines "see". To put it more specifically, it refers to machine vision that uses computers to replace human eyes to identify and measure targets, and further processes images so that the images are processed by computers to become more suitable for human eye observation or transmission to instruments for detection. As a scientific discipline, computer vision studies related theories and technologies, and attempts to establish an artificial intelligence system that can obtain information from images or multidimensional data. Computer vision technology usually includes image processing, image recognition, three-dimensional object reconstruction, virtual reality, augmented reality and other technologies, as well as common biometric recognition technologies such as face recognition and human posture recognition.

[0045] For example, see Figure 1 The electronic device can obtain the video to be retrieved and the requested text, and obtain the video features and the text features; determine the first video attention weight and the second video attention weight, and determine the first text attention weight and the second text attention weight; adjust the text features by the first video attention weight, and adjust the video features by the second video attention weight to obtain the video features after information interaction; adjust the video features by the first text attention weight, and adjust the text features by the second text attention weight to obtain the text features after information interaction; based on the video features after information interaction and the text features after information interaction, determine whether the video to be retrieved is the retrieval result corresponding to the requested text.

[0046] The following are detailed descriptions. It should be noted that the order of the following embodiments is not intended to limit the preferred order of the embodiments. Figure 2As shown, the specific process of the video text retrieval method can be as follows:

[0047] 201. Obtain a video to be retrieved and a request text, and obtain video features corresponding to the video to be retrieved and text features corresponding to the request text.

[0048] In one embodiment, the present application can be applied to a video retrieval task, that is, a task of retrieving relevant video clips using a request text. For example, the present application can be applied to a script video retrieval task, the request text can be a scene-by-scene script used when shooting a TV series, and the video to be retrieved can be a TV series video. First, the video to be retrieved and the request text can be obtained, and then the video features corresponding to the video to be retrieved and the text features corresponding to the request text can be obtained.

[0049] In one embodiment, for example, Figure 4 As shown, the technical solution of the present application can establish a cross-modal retrieval model, and use the cross-modal retrieval model to complete the retrieval task between video texts. The cross-modal retrieval model as a whole is composed of a video encoding module, a text encoding module, and a similarity calculation module (similarity matrix). During the training process, a loss module (MSE Loss) is added to adjust the parameters. Among them, the video encoding module includes an information interaction submodule (crossinfo block), and the text encoding module also includes an information interaction submodule (cross info block). Among them, the video encoding module can be used to implement the steps of obtaining the video to be retrieved and the video features.

[0050] In one embodiment, since the self-attention mechanism can obtain features with richer information, the technical solution of the present application can use the self-attention mechanism to obtain the video features corresponding to the video to be retrieved. The step of "obtaining the video to be retrieved and obtaining the video features corresponding to the video to be retrieved" may include:

[0051] Get the video frame of the video to be retrieved;

[0052] Input the video frame into the image encoder to obtain the initial video features corresponding to the video frame;

[0053] The self-attention weights are calculated based on the initial video features to obtain the self-attention video weights, and the initial video features are adjusted by the self-attention video weights to obtain the video features.

[0054] Among them, the self-attention mechanism is an attention mechanism that can link different positions of a single sequence to calculate the sequence representation. It reduces the dependence on external information and is better at capturing the internal correlation of data or features. The self-attention mechanism can be applied to reading comprehension, summary and other scenarios. Therefore, the present application can use the self-attention mechanism to obtain features with richer information.

[0055] For example, the obtained video to be retrieved includes bv video clips, each video clip contains nv video frames, and each video frame is an RGB image with a width of w and a height of h, that is, the video frame can be represented as x video ∈R bv×nv×3×h×w First, the video frame of the video to be retrieved can be obtained, and the video frame can be input into the image encoder for feature extraction to obtain the initial video feature corresponding to the video frame. Then, the self-attention mechanism is used to determine the self-attention video weight corresponding to the initial video feature, and the initial video feature is adjusted by the self-attention video weight to obtain the video feature.

[0056] In one embodiment, since the application of the Transformer architecture in the field of computer vision can not only obtain accurate results but also require less training resources, the technical solution of the present application can use the VIT method for feature extraction, and the step of "inputting the video frame into the image encoder to obtain the initial video features corresponding to the video frame" may include:

[0057] Perform image segmentation on the video frame to obtain several image blocks;

[0058] Perform feature extraction on each image block to obtain the initial image block features corresponding to each image block;

[0059] Position coding information is added to the initial image block features corresponding to each image block to obtain the initial video features corresponding to the video to be retrieved.

[0060] Among them, the VIT network model (Vision Transformer, self-attention visual model) is an image classification model that combines computer vision and natural language processing (NLP) fields.

[0061] In one embodiment, the image encoder in the embodiment of the present application may apply the VIT-B / 32 network model and load Imagenet pre-trained weights, where Imagenet is a database used for image recognition.

[0062] For example, Figure 5As shown, first, the video frame can be segmented into several image blocks of the same size, and different image blocks carry different image information. Then, feature extraction is performed on each image block obtained by segmentation to obtain the initial image block features corresponding to each image block, wherein, optionally, each image block can be linearly transformed to obtain the initial image block features corresponding to each image block, that is, the image block is transformed into a linear embedding as the input of the transformer, and its processing method is the same as the token in natural language processing.

[0063] In addition, it is necessary to add position coding information to the initial image block features corresponding to each image block to obtain the initial video features corresponding to the video to be retrieved, that is, to encode each image block into a token with position information, and then input the initial video features corresponding to the video to be retrieved into the transformer for processing. Among them, this module can encode the video frame into a cv-dimensional feature vector, so the initial video features can be expressed as F enc ∈R bv×nv×cv .

[0064] In one embodiment, since the multi-head attention mechanism can focus on information at different positions in the image, the technical solution of the present application can use the multi-head attention mechanism to extract video features. The step of "calculating self-attention weights based on initial video features to obtain self-attention video weights, and adjusting the initial video features by the self-attention video weights to obtain video features" may include:

[0065] Determine the self-attention video weight corresponding to each feature element in the initial video feature;

[0066] Based on the self-attention video weights, determining a first feature matrix on the query dimension, a second feature matrix on the key dimension, and a third feature matrix on the value dimension corresponding to the feature elements;

[0067] Based on the first feature matrix and the second feature matrix, a self-attention feature matrix is ​​obtained, where the self-attention feature matrix expresses the correlation between different feature elements in the video frame;

[0068] Based on the feature correlation and the third feature matrix, video features are obtained.

[0069] For example, the multi-head attention mechanism can be used to extract video features and determine the self-attention video weight corresponding to each feature element in the initial video features, where the self-attention video weight can include the weight W on the query dimension Q , the weight W on the key dimension K , weight W on the value dimension V Then use the weight W on the query dimensionQ Adjust the corresponding feature elements in the initial video features to obtain the first feature matrix Q on the query dimension; use the weight W on the key dimension K Adjust the corresponding feature elements in the initial video features to obtain the second feature matrix K on the key dimension; use the weight W on the value dimension V The corresponding feature elements in the initial video features are adjusted to obtain a third feature matrix V in the value dimension.

[0070] Then, based on the first feature matrix Q and the second feature matrix K, a self-attention feature matrix is ​​obtained, and the self-attention feature matrix expresses the correlation between different feature elements in the video frame; based on the feature correlation and the third feature matrix V, the video features are obtained, wherein the formula for calculating the video features based on the first feature matrix Q, the second feature matrix K, and the third feature matrix V can be as follows:

[0071]

[0072] in, is the scale factor.

[0073] In one embodiment, the self-attention module (self-attention) can be composed of a multi-head attention module (MHA) and a feed-forward module (FF) connected in series, wherein the feed-forward module can adopt a unidirectional multi-layer structure, wherein each layer contains a number of neurons, and each neuron can receive a signal from a neuron in the previous layer and generate an output to the next layer.

[0074] In addition, the technical solution of this application can also use shortcuts at the same time, wherein shortcuts can solve the problem of gradient divergence and difficulty in training in deep networks. The calculation formula of video features can be as follows:

[0075] F att =F enc +MHA(LN(F enc ),LN(F enc ),LN(F enc ))

[0076] F att =F att +FF(LN(F att ))

[0077] F att ∈R bv×nv×cv

[0078] In one embodiment, since the self-attention mechanism can obtain features with richer information, the technical solution of the present application can use the self-attention mechanism to obtain text features corresponding to the request text. The step of "obtaining the request text and obtaining the text features corresponding to the request text" may include:

[0079] Get the request text;

[0080] Input the request text into the text encoder to obtain the initial text features corresponding to the request text;

[0081] The self-attention weight is calculated based on the initial text features to obtain the self-attention text weight, and the initial text features are adjusted by the self-attention text weight to obtain the text features.

[0082] For example, the request text may be bt text segments or sentences, each of which contains nt elements, wherein if the request text language is Chinese, the element may be a single word; if the request text language is English, the element may be a word. The text encoder used in the embodiment of the present application may be a Roberta-base pre-trained network model, which may encode each element in the request text into a ct-dimensional feature vector, so the initial text feature corresponding to the request text may be represented as F enc ∈R bt×nt×ct .

[0083] Then, the self-attention module can be used to calculate the text features, where the self-attention module (self-attention) can be composed of a multi-head attention module (MHA) and a feed forward module (FF) in series, and a shortcut can be used at the same time, where the shortcut can solve the problem of gradient divergence and difficulty in training in deep networks. The self-attention weight is calculated based on the initial text features to obtain the self-attention text weight, and the initial text features are adjusted by the self-attention text weight to obtain the text features, where the calculation formula of the text features can be as follows:

[0084] F att =F enc +MHA(LN(F enc ),LN(F enc ),LN(F enc ))

[0085] F att =F att +FF(LN(F att ))

[0086] F att ∈R bt×nt×ct

[0087] 202. Determine a first video attention weight and a second video attention weight corresponding to the video to be retrieved, and determine a first text attention weight and a second text attention weight corresponding to the request text.

[0088] In order to make the overall retrieval results more accurate, therefore, in the multimodal retrieval task, the other party's modal information can be used to adjust the information representation of its own modality. For example, in the technical solution of the present application, the information representation of the video modality can be adjusted using the text modality information, and the information representation of the text modality can be adjusted using the video modality information. Therefore, it is necessary to determine the first video attention weight and the second video attention weight corresponding to the video to be retrieved, and determine the first text attention weight and the second text attention weight corresponding to the request text.

[0089] In one embodiment, the step of “determining a first video attention weight and a second video attention weight corresponding to the video to be retrieved, and determining a first text attention weight and a second text attention weight corresponding to the request text” may include:

[0090] Determine a first video attention weight on the query dimension, a video key attention weight on the key dimension, and a video value attention weight on the value dimension corresponding to the video to be retrieved, wherein the second video attention weight includes the video key attention weight and the video value attention weight;

[0091] Determine a first text attention weight on the query dimension, a text key attention weight on the key dimension, and a text value attention weight on the value dimension corresponding to the request text, wherein the second text attention weight includes the text key attention weight and the text value attention weight.

[0092] For example, the first video attention weight W corresponding to the video to be retrieved on the query dimension can be determined Q1 , video key attention weight W on key dimension K1 , and the video value attention weight W on the value dimension V1 , where the second video attention weight includes the video key attention weight W K1 , and the video value attention weight W V1 .

[0093] At the same time, determine the first text attention weight W corresponding to the request text in the query dimension Q2 , the text key attention weight W on the key dimension K2 , and the text value attention weight W on the value dimension V2 , where the second text attention weight includes the text key attention weight W K2 , and the text value attention weight W V2 .

[0094] 203. Adjust the text feature by using the first video attention weight, and adjust the video feature by using the second video attention weight, to obtain the video feature after information interaction.

[0095] In one embodiment, for example, Figure 4 As shown in the figure, the data of the two modalities in the information interaction submodule can calculate the attention features of each other through the Cartesian product method. Therefore, the operation of copying in the batch dimension is added in the model design, and the feature dimension of the video modality is increased from (bv, nv, cv) to (bv, bt, nv, cv), and the feature dimension of the text modality is increased from (bt, nt, ct) to (bt, bt, nt, ct). Then, the features of each (nv, cv) and (nt, ct) are fused using an operation similar to the self-attention module, where the query in the input of the attention module is the feature F of the other modality. y , key and value are the features of their own mode F x After the output features are passed through the feedforward module (FF) and shortcut, the final information interaction feature F is obtained out , F out The calculation formula can be as follows:

[0096] F out =FF(F x +MHA(F y ,F x ,F x ))

[0097] In one embodiment, the step of “adjusting text features by the first video attention weight and adjusting video features by the second video attention weight to obtain video features after information interaction” may include:

[0098] Adjusting the text features by the first video attention weights to obtain a first text feature matrix;

[0099] Adjust the video features by using the video key attention weights to obtain a second video feature matrix;

[0100] Adjust the video features by using the video value attention weights to obtain a third video feature matrix;

[0101] The first text feature matrix, the second video feature matrix, and the third video feature matrix are subjected to information interaction to obtain video features after the information interaction.

[0102] For example, the first video attention weight W Q1 Adjust the text features to get the first text feature matrix Q2, and use the video key attention weight W K1Adjust the video features to obtain the second video feature matrix K1, and use the video value attention weight W V1 The video features are adjusted to obtain a third video feature matrix V1, and then the first text feature matrix Q2, the second video feature matrix K1, and the third video feature matrix V1 are interacted with each other to obtain video features after the interaction.

[0103] 204. Adjust the video feature by using the first text attention weight, and adjust the text feature by using the second text attention weight to obtain the text feature after information interaction.

[0104] In one embodiment, the step of “adjusting the video feature by the first text attention weight and adjusting the text feature by the second text attention weight to obtain the text feature after information interaction” may include:

[0105] Adjusting the video features by the first text attention weights to obtain a first video feature matrix;

[0106] Adjust the text features by the text key attention weights to obtain a second text feature matrix;

[0107] Adjust the text features by using the text value attention weights to obtain a third text feature matrix;

[0108] The first video feature matrix, the second text feature matrix, and the third text feature matrix are subjected to information interaction to obtain text features after information interaction.

[0109] For example, the first text attention weight W Q2 Adjust the video features to get the first video feature matrix Q1, and use the text key attention weight W K2 Adjust the text features to get the second text feature matrix K2, and use the video value attention weight W V2 The text features are adjusted to obtain a third text feature matrix V2. Then, the first video feature matrix Q1, the second text feature matrix K2, and the third text feature matrix V2 are subjected to information interaction to obtain text features after information interaction.

[0110] 205. Based on the similarity between the video features after the information interaction and the text features after the information interaction, determine whether the video to be retrieved is a retrieval result corresponding to the requested text.

[0111] For example, after obtaining the video features after information interaction and the text features after information interaction, the linear layer (FC) can be used to perform linear projection on the video features after information interaction and the text features after information interaction, and then the linear projection of the video features after information interaction and the linear projection of the text features after information interaction are used to calculate the similarity between the video features after information interaction and the text features after information interaction, wherein the similarity calculation formula can be as follows:

[0112]

[0113] M sim ∈R bv×bt

[0114] According to the similarity between the video features after information interaction and the text features after information interaction, it can be determined whether the retrieval result of the requested text is the video to be retrieved.

[0115] In one embodiment, for example, the present application can be applied to a script video retrieval task, the request text can be a scene-by-scene script used when shooting a TV series, and the video to be retrieved can be a TV series video. The technical solution of the present application can be used to obtain the similarity between the video to be retrieved and the request text, and it can be determined based on the similarity value whether the video to be retrieved matches the request text. If they match, it means that the correlation between the video to be retrieved and the request text is very strong, and the video to be retrieved can be retrieved using the request text; if they match, it means that the correlation between the video to be retrieved and the request text is not strong, and the video to be retrieved cannot be retrieved using the request text.

[0116] After the search results are determined, the search results can also be stored. For example, the text segment sequence can be arranged in chronological order, and the video segment sequence can also be arranged in chronological order. According to the matching relationship between the text segment and the video segment, the mapping relationship between the text segment sequence and the video segment sequence can be determined. Then, the user can use the known text to quickly find the video segment corresponding to its content from the storage.

[0117] In one embodiment, the technical solution of the present application mainly uses the information of the features to be retrieved to adjust the representation of its own features, and then performs feature retrieval. Among them, the multi-head attention mechanism can be used to adjust the self-representation, and other methods can also be used to adjust the self-representation, which is not limited to the method provided in the embodiment of the present application.

[0118] In one embodiment, before obtaining the video to be retrieved and the requested text, a model training step may also be included. For example, a sample video and a sample text may be obtained, wherein the sample video includes a sample video identifier and the sample text includes a sample text identifier. nv sample videos and nt sample texts may be input into the cross-modal retrieval model constructed by the present application for processing. When the sample video identifier matches the sample text identifier, it indicates that the sample video and the sample text match, and the true value is 1 at this time; if the sample video identifier does not match the sample text identifier, it indicates that the sample video and the sample text do not match, and the true value is 0 at this time, wherein the situation where the sample video identifier and the sample text identifier are the same can be determined as the sample video identifier and the sample text identifier match, and the situation where the sample video identifier and the sample text identifier are different can be determined as the sample video identifier and the sample text identifier do not match. Then a matrix of the true value may be constructed, and this value may be obtained using MSELoss regression, and the formula is as follows:

[0119] M gt ∈R bv×bt

[0120]

[0121] In order to verify the effectiveness of the technical solution of this application, the following experiment was conducted on the public dataset VaTEX. The experimental evaluation indicator is the recall rate of k candidates (R@k). The experimental results are shown in the following table:

[0122] R@1 R@5 R@10 R@50 ts2-vit+roberta 14.9 37.4 48.8 73.3 CrossInfo-vit+roberta 23.35 60.45 74.16 90.97

[0123] Among them, ts2-vit+roberta is the current technical solution, and CrossInfo-vit+roberta is the technical solution of this application. According to the experimental results, after adding the mutual information mechanism, the recall rate of the model has been greatly improved.

[0124] Videos can be divided into four layers according to semantic concepts, from fine to coarse granularity: frame, shot, scene, and video. A frame is each image that makes up a video. Under the same shot, the visual difference between consecutive frame images is very small. Multiple shots make up a scene. A scene clip can usually fully describe a plot. Finally, a complete video composed of all scenes tells a story.

[0125] In the prior art, video clips at different levels are encoded and stored in the library according to business requirements. When a search request occurs, the known search request is used to match the video clips in the library to find the required video. However, different methods used in the video slicing process will result in different features corresponding to the stored video clips, which will lead to different search results.

[0126] In addition, since the image encoder and text encoder map video clips and text clips into a high-dimensional latent space, they are represented by high-dimensional arrays, i.e., features. However, this feature cannot clearly indicate the direction and weight of each semantic entity in the space. In this case, entities with a high proportion in the training data may naturally obtain higher weights and thus be easier to retrieve, while some long-tail entities may not be easily retrieved due to their low weights.

[0127] The technical solution of this application changes the setting that each video clip or text clip in the storage has only one encoding feature, and instead uses the attention mechanism to encode each pair of video clips and text clips into a pair of corresponding features, and then calculates the similarity of this pair of video text clips. In this way, the weight of the corresponding entity can be improved by using the other party's information, so that the related entities can be normalized to the same level as much as possible during similar matching, thereby improving the accuracy of retrieval.

[0128] For example, suppose there are action entities "biking" and "running", of which "biking" accounts for 90% and "running" accounts for 10% in the training set. We assume that the weight of "biking" in the feature embedding generated by the general retrieval model is 90%, and the weight of "running" is 10%. Now there is a video clip with the content of "a person riding a bicycle to the park and then running". For the request text clip "biking", the similarity of this video is about 0.9, while for the request text clip "running", the similarity is only 0.1, which will undoubtedly reduce the accuracy of retrieval.

[0129] The technical solution of this application proposes a high-precision video text retrieval method. Using the technical solution of this application, the similarity Sim between the video clip and the text clip "riding a bicycle" can be calculated respectively. A , A = (Video ("A person rides a bike to the park, then runs"), Text ("ride a bike")), and the similarity between the video segment and the text segment "running" Sim B , B = (Video ("A person rides a bike to the park, then runs"), Text ("Running")). Since the video segment shares the expected entity information of the text segment during the calculation process, video feature A will increase the weight of "riding a bike", and video feature B will increase the weight of "running", thus obtaining Sim A and Sim B The results are close to 1.

[0130] The technical solution of the present application solves the problem that the text description content is not completely consistent with the actual video content in the retrieval task, so that even when the video slicing method is unstable, the correct video segment can also be retrieved using the text segment, thereby achieving the purpose of improving the retrieval accuracy.

[0131] As can be seen from the above, this embodiment can obtain the video to be retrieved and the request text, and obtain video features and text features; determine the first video attention weight and the second video attention weight, and determine the first text attention weight and the second text attention weight; adjust the text features by the first video attention weight, and adjust the video features by the second video attention weight, and obtain the video features after information interaction; adjust the video features by the first text attention weight, and adjust the text features by the second text attention weight, and obtain the text features after information interaction; based on the video features after information interaction and the text features after information interaction, determine whether the video to be retrieved is the retrieval result corresponding to the request text. This application can use text modality information to adjust the information representation of the video modality, and use video modality information to adjust the information representation of the text modality, which solves the problem that the text description content is not completely consistent with the real video content in the retrieval task, so that when the video slicing method is unstable, the text fragment can also be used to retrieve the correct video fragment, thereby achieving the purpose of improving the retrieval accuracy.

[0132] According to the method described in the previous embodiment, the video text retrieval device will be further described in detail below by taking the example of being specifically integrated into an electronic device.

[0133] like Figure 3 As shown, the video text retrieval method provided in the embodiment of the present application is specifically described by the following embodiments:

[0134] 301. Training cross-modal retrieval models through electronic devices.

[0135] Video can be roughly divided into four layers according to semantic concepts, and their granularity from fine to coarse is: frame, shot, scene, and video. A frame is each frame of the video. Under the same shot, the visual difference between consecutive frame images is very small. Multiple shots make up a scene. A scene clip can usually describe a plot. Finally, a complete video composed of all scenes tells a story. In the prior art, video clips at different levels are encoded and stored in the library according to business requirements. When a search request appears, the encoded search request is similarly matched with the features in the library to find the corresponding video in the library.

[0136] However, using this method will lead to the following problems: First, the video slicing problem. Different methods used in the video slicing process will lead to different features of the video segments, which in turn lead to different retrieval results. Second, the problem of entity representation in the latent space. The video and text encoders will map each video and text segment to a high-dimensional latent space, represented by a high-dimensional array, namely the feature. This feature cannot clearly indicate the direction and weight of each semantic entity in the space. In this case, entities with a high proportion in the training data may naturally obtain higher weights, making them easier to retrieve. Conversely, some long-tail entities may be difficult to retrieve due to their low weights.

[0137] The technical solution of this application starts from the task of aligning the timeline of the script with the finished film, and proposes a high-precision cross-modal retrieval method for script-video. This method solves the problem that the text description content is not exactly the same as the real video content in the retrieval task, so that when the video slicing method is unstable, the correct video can also be retrieved using the script. The method proposed in this application changes the setting that each video / text has only one encoding feature, and instead uses the attention mechanism to encode each pair of video text segments into a pair of corresponding features, and then calculates the similarity of this pair of video text segments. In this way, the information of the other party can be used to enhance the weight of the corresponding entity, so that the related entities are normalized to the same level as much as possible during similar matching, thereby improving the accuracy of retrieval.

[0138] For example, Figure 4 As shown, a cross-modal retrieval model is constructed, which includes a video encoding module, a text encoding module, a similarity calculation module, and a loss module. Sample videos and sample texts can be obtained, each sample video corresponds to a sample video id, and each sample text corresponds to a sample text id.

[0139] The image encoder in the video encoding module and the self-attention module can be used to extract features from the sample video to obtain sample video features corresponding to the sample video, and the text encoder in the text encoding module and the self-attention module can be used to extract features from the sample text to obtain sample text features corresponding to the sample text.

[0140] In order to perform information interaction, it is necessary to upgrade the dimensions of video features and text features. Therefore, the dimensionality upgrade module can be used to upgrade the dimensions of video features and text features respectively to obtain upgraded video features and upgraded text features. Then the attention module can be used to perform information interaction operations. In the input of the attention module corresponding to the sample video, qurey is the upgraded text feature, key and value are the upgraded video feature, and the sample attention video feature is output after passing through the attention module; similarly, in the input of the attention module corresponding to the sample text, qurey is the upgraded video feature, key and value are the upgraded text feature, and the sample attention text feature is output after passing through the attention module.

[0141] After linear transformation of the sample attention video features and the sample attention text features, the similarity between the two is calculated using the similarity calculation module, and then the loss is calculated through the loss module. Among them, when the sample video id and the sample text id are the same, it means that the video and the text match, and the true value is 1; when the sample video id and the sample text id are different, it means that the video and the text do not match, and the true value is 0. In this way, the matrix of the true value can be constructed:

[0142] M gt ∈R bv×bt

[0143] And use MSELoss regression to get this value, the formula is as follows:

[0144]

[0145] The loss calculated by the loss module is used to adjust the parameters of the cross-modal retrieval model until the cross-modal retrieval model is adjusted to a usable level.

[0146] 302. Obtain the video to be retrieved through the video encoding module, and obtain the video features corresponding to the video to be retrieved.

[0147] For example, after obtaining a trained cross-modal retrieval model, the cross-modal retrieval model can be used to perform a video retrieval task, that is, a task of retrieving relevant video clips using a request text. The request text can be a scene-by-scene script used when shooting a TV series, and the video to be retrieved can be a video clip of the TV series.

[0148] For example, the video to be retrieved can be obtained through the video encoding module. The obtained video to be retrieved includes bv video clips, each of which contains nv video frames. Each video frame is an RGB image with a width of w and a height of h. That is, the video frame can be represented as x. video ∈R bv×nv×3×h×wThe image encoder in the embodiment of the present application can apply the VIT-B / 32 network model and load the Imagenet pre-trained weights. The module can encode the video frame into a cv-dimensional feature vector, which can be represented by F enc ∈R bv×nv×cv The self-attention module can be composed of a multi-head attention module (MHA) and a feed forward module (FF) in series. Using shortcuts, the calculation formula of video features can be as follows:

[0149] F att =F enc +MHA(LN(F enc ),LN(F enc ),LN(F enc ))

[0150] F att =F att +FF(LN(F att ))

[0151] F att ∈R bv×nv×cv

[0152] 303. Obtain the request text through the text encoding module, and obtain the text features corresponding to the request text.

[0153] For example, the request text may be bt text segments or sentences, each of which contains nt elements. The text encoder used in the embodiment of the present application may be a Roberta-base pre-trained network model, which may encode each element in the request text into a ct-dimensional feature vector. Therefore, the initial text feature corresponding to the request text may be expressed as F enc ∈R bt×nt×ct .

[0154] Then, the self-attention module can be used to calculate the text features, where the self-attention module can be composed of a multi-head attention module (MHA) and a feed forward module (FF) in series, and a shortcut is used at the same time, where the calculation formula of the text features can be as follows:

[0155] F att =F enc +MHA(LN(F enc ),LN(F enc ),LN(F enc ))

[0156] F att =F att +FF(LN(F att ))

[0157] F att ∈R bt×nt×ct

[0158] 304. Obtain information interaction video features that are integrated with text features through the information interaction submodule.

[0159] In the multimodal matching task, the overall matching can be made more accurate by adjusting the representation of one’s own modal information using the other party’s modal information. Therefore, in the information interaction submodule, the video modality data and the text modality data can calculate each other’s attention features through the Cartesian product method. Therefore, the operation of copying in the batch dimension is added to the model design, and the feature dimension of the video modality is increased from (bv, nv, cv) to (bv, bt, nv, cv), and the feature dimension of the text modality is increased from (bt, nt, ct) to (bt, bt, nt, ct).

[0160] Then, an operation similar to the self-attention module is used to fuse the features of each (nv, cv) and (nt, ct), where the query in the input of the attention module corresponding to the video to be retrieved is the feature of the text modality, and the key and value are the features of the video modality. After the output features are passed through the feedforward module (FF) and shortcut, the video features after information interaction that fuses the text features are obtained.

[0161] 305. Obtain text features after information interaction that incorporate video features through the information interaction submodule.

[0162] Among them, the query in the input of the attention module corresponding to the request text is the feature of the video modality, the key and value are the features of the text modality, and the output features are passed through the feedforward module (FF) and shortcut to obtain the text features after information interaction that integrates the video features.

[0163] 306. Calculate the similarity between the video features after the information interaction and the text features after the information interaction through a similarity calculation module, and determine the retrieval result.

[0164] For example, after obtaining the video features after information interaction and the text features after information interaction, the linear layer (FC) can be used to perform linear projection on the video features after information interaction and the text features after information interaction, and then the similarity calculation module is used to calculate the similarity between the video features after information interaction and the text features after information interaction, wherein the similarity calculation formula can be as follows:

[0165]

[0166] M sim ∈R bv×bt

[0167] According to the similarity between the video features after information interaction and the text features after information interaction, it can be determined whether the retrieval result of the requested text is the video to be retrieved.

[0168] As can be seen from the above, this embodiment can train a cross-modal retrieval model through an electronic device, obtain the video to be retrieved through a video encoding module, and obtain the video features corresponding to the video to be retrieved, obtain the request text through a text encoding module, and obtain the text features corresponding to the request text, obtain the video features after information interaction that are integrated with the text features through the information interaction submodule, obtain the text features after information interaction that are integrated with the video features through the information interaction submodule, calculate the similarity between the video features after information interaction and the text features after information interaction through the similarity calculation module, and determine the retrieval results. The present application can use text modality information to adjust the information representation of the video modality, and use video modality information to adjust the information representation of the text modality, which solves the problem that the text description content is not completely consistent with the real video content in the retrieval task, so that when the video slicing method is unstable, the correct video segment can also be retrieved using the text segment, thereby achieving the purpose of improving the retrieval accuracy.

[0169] In order to better implement the above method, the embodiment of the present application further provides a video text retrieval device, wherein the video text retrieval device can be specifically integrated on an electronic device, such as Figure 6 As shown, the video text retrieval device may include an acquisition unit 601, a determination unit 602, a first adjustment unit 603, a second adjustment unit 604 and a retrieval unit 605, as follows:

[0170] The acquisition unit 601 is used to acquire the video to be retrieved and the request text, and acquire the video features corresponding to the video to be retrieved and the text features corresponding to the request text;

[0171] A determination unit 602 is used to determine a first video attention weight and a second video attention weight corresponding to the video to be retrieved, and to determine a first text attention weight and a second text attention weight corresponding to the request text;

[0172] A first adjustment unit 603 is used to adjust the text feature by the first video attention weight, and adjust the video feature by the second video attention weight to obtain a video feature after information interaction;

[0173] A second adjustment unit 604 is used to adjust the video feature by the first text attention weight, and adjust the text feature by the second text attention weight to obtain a text feature after information interaction;

[0174] The retrieval unit 605 is used to determine whether the video to be retrieved is a retrieval result corresponding to the request text based on the similarity between the video features after the information interaction and the text features after the information interaction.

[0175] Optionally, in some embodiments of the present application, the determination unit is used to determine the first video attention weight on the query dimension, the video key attention weight on the key dimension, and the video value attention weight on the value dimension corresponding to the video to be retrieved, wherein the second video attention weight includes the video key attention weight and the video value attention weight; determine the first text attention weight on the query dimension, the text key attention weight on the key dimension, and the text value attention weight on the value dimension corresponding to the request text, wherein the second text attention weight includes the text key attention weight and the text value attention weight.

[0176] Optionally, in some embodiments of the present application, the first adjustment unit is used to adjust the text features through the first video attention weight to obtain a first text feature matrix; adjust the video features through the video key attention weight to obtain a second video feature matrix; adjust the video features through the video value attention weight to obtain a third video feature matrix; and interact information between the first text feature matrix, the second video feature matrix, and the third video feature matrix to obtain video features after information interaction.

[0177] Optionally, in some embodiments of the present application, the second adjustment unit is used to adjust the video features through the first text attention weights to obtain a first video feature matrix; adjust the text features through the text key attention weights to obtain a second text feature matrix; adjust the text features through the text value attention weights to obtain a third text feature matrix; and perform information interaction among the first video feature matrix, the second text feature matrix, and the third text feature matrix to obtain text features after information interaction.

[0178] Optionally, in some embodiments of the present application, the acquisition unit includes an acquisition subunit, an input subunit, and an adjustment subunit, as follows:

[0179] An acquisition subunit, used for acquiring a video frame of a video to be retrieved;

[0180] An input subunit, used for inputting the video frame into an image encoder to obtain initial video features corresponding to the video frame;

[0181] The adjustment subunit is used to calculate the self-attention weight based on the initial video feature to obtain the self-attention video weight, and adjust the initial video feature by the self-attention video weight to obtain the video feature.

[0182] Optionally, in some embodiments of the present application, the input subunit is used to perform image segmentation on the video frame to obtain a number of image blocks; perform feature extraction on each of the image blocks to obtain initial image block features corresponding to each of the image blocks; add position coding information to the initial image block features corresponding to each of the image blocks to obtain initial video features corresponding to the video to be retrieved.

[0183] Optionally, in some embodiments of the present application, the adjustment subunit is used to determine the self-attention video weight corresponding to each feature element in the initial video feature; based on the self-attention video weight, determine the first feature matrix on the query dimension, the second feature matrix on the key dimension, and the third feature matrix on the value dimension corresponding to the feature element; based on the first feature matrix and the second feature matrix, obtain a self-attention feature matrix, the self-attention feature matrix expresses the degree of correlation between different feature elements in the video frame; based on the feature correlation and the third feature matrix, obtain video features.

[0184] Optionally, in some embodiments of the present application, the acquisition unit is used to obtain a request text; input the request text into a text encoder to obtain initial text features corresponding to the request text; perform self-attention weight calculation based on the initial text features to obtain self-attention text weights, and adjust the initial text features by the self-attention text weights to obtain text features.

[0185] As can be seen from the above, the embodiment of the present application can obtain the video to be retrieved and the request text by the acquisition unit 601, and obtain the video features and text features; the determination unit 602 determines the first video attention weight and the second video attention weight, and determines the first text attention weight and the second text attention weight; the first adjustment unit 603 adjusts the text features by the first video attention weight, and adjusts the video features by the second video attention weight to obtain the video features after information interaction; the second adjustment unit 604 adjusts the video features by the first text attention weight, and adjusts the text features by the second text attention weight to obtain the text features after information interaction; the retrieval unit 605 determines whether the video to be retrieved is the retrieval result corresponding to the request text based on the video features after information interaction and the text features after information interaction. The present application can use text modality information to adjust the information representation of the video modality, and use video modality information to adjust the information representation of the text modality, which solves the problem that the text description content is not completely consistent with the real video content in the retrieval task, so that in the case of unstable video slicing method, the correct video fragment can also be retrieved using the text fragment, thereby achieving the purpose of improving the retrieval accuracy.

[0186] The present application also provides an electronic device, such as Figure 7 As shown, it shows a schematic diagram of the structure of the electronic device involved in the embodiment of the present application, specifically:

[0187] The electronic device may include components such as a processor 701 with one or more processing cores, a memory 702 with one or more computer-readable storage media, a power supply 703, and an input unit 704. Those skilled in the art will appreciate that Figure 7 The electronic device structure shown in the figure does not constitute a limitation on the electronic device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.

[0188] The processor 701 is the control center of the electronic device. It uses various interfaces and lines to connect various parts of the entire electronic device. It executes various functions of the electronic device and processes data by running or executing software programs and / or modules stored in the memory 702, and calling data stored in the memory 702, thereby processing the electronic device as a whole. Optionally, the processor 701 may include one or more processing cores; preferably, the processor 701 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, etc., and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 701.

[0189] The memory 702 can be used to store software programs and modules. The processor 701 executes various functional applications and data processing by running the software programs and modules stored in the memory 702. The memory 702 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 702 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. Accordingly, the memory 702 may also include a memory controller to provide the processor 701 with access to the memory 702.

[0190] The electronic device also includes a power supply 703 for supplying power to each component. Preferably, the power supply 703 can be logically connected to the processor 701 through a power management system, so as to manage charging, discharging, and power consumption through the power management system. The power supply 703 can also include any components such as one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, and power status indicators.

[0191] The electronic device may further include an input unit 704, which may be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control.

[0192] Although not shown, the electronic device may further include a display unit, etc., which will not be described in detail herein. Specifically in this embodiment, the processor 701 in the electronic device will load the executable files corresponding to the processes of one or more application programs into the memory 702 according to the following instructions, and the processor 701 will run the application programs stored in the memory 702, thereby realizing various functions, as follows:

[0193] Obtain the video to be retrieved and the requested text, and obtain the video features and the text features; determine the first video attention weight and the second video attention weight, and determine the first text attention weight and the second text attention weight; adjust the text features by the first video attention weight, and adjust the video features by the second video attention weight, to obtain the video features after information interaction; adjust the video features by the first text attention weight, and adjust the text features by the second text attention weight, to obtain the text features after information interaction; based on the video features after information interaction and the text features after information interaction, determine whether the video to be retrieved is the retrieval result corresponding to the requested text.

[0194] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.

[0195] As can be seen from the above, this embodiment can obtain the video to be retrieved and the request text, and obtain video features and text features; determine the first video attention weight and the second video attention weight, and determine the first text attention weight and the second text attention weight; adjust the text features by the first video attention weight, and adjust the video features by the second video attention weight, and obtain the video features after information interaction; adjust the video features by the first text attention weight, and adjust the text features by the second text attention weight, and obtain the text features after information interaction; based on the video features after information interaction and the text features after information interaction, determine whether the video to be retrieved is the retrieval result corresponding to the request text. This application can use text modality information to adjust the information representation of the video modality, and use video modality information to adjust the information representation of the text modality, which solves the problem that the text description content is not completely consistent with the real video content in the retrieval task, so that when the video slicing method is unstable, the text fragment can also be used to retrieve the correct video fragment, thereby achieving the purpose of improving the retrieval accuracy.

[0196] A person of ordinary skill in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be completed by instructions, or by controlling related hardware through instructions. The instructions may be stored in a computer-readable storage medium and loaded and executed by a processor.

[0197] To this end, an embodiment of the present application provides a storage medium in which a plurality of instructions are stored, and the instructions can be loaded by a processor to execute the steps in any one of the video text retrieval methods provided in the embodiment of the present application. For example, the instructions can execute the following steps:

[0198] Obtain the video to be retrieved and the requested text, and obtain the video features and the text features; determine the first video attention weight and the second video attention weight, and determine the first text attention weight and the second text attention weight; adjust the text features by the first video attention weight, and adjust the video features by the second video attention weight, to obtain the video features after information interaction; adjust the video features by the first text attention weight, and adjust the text features by the second text attention weight, to obtain the text features after information interaction; based on the video features after information interaction and the text features after information interaction, determine whether the video to be retrieved is the retrieval result corresponding to the requested text.

[0199] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.

[0200] The storage medium may include: a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.

[0201] Since the instructions stored in the storage medium can execute the steps in any video text retrieval method provided in the embodiments of the present application, the beneficial effects that can be achieved by any video text retrieval method provided in the embodiments of the present application can be achieved. Please refer to the previous embodiments for details and will not be repeated here.

[0202] The above is a detailed introduction to a video text retrieval method, device, electronic device and storage medium provided in the embodiments of the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for technical personnel in this field, according to the ideas of the present application, there will be changes in the specific implementation methods and application scopes. In summary, the content of this specification should not be understood as a limitation on the present application.

Claims

1. A video text retrieval method, characterized in that: include: Obtaining a video to be retrieved and a request text, and obtaining video features corresponding to the video to be retrieved and text features corresponding to the request text; Determine a first video attention weight and a second video attention weight corresponding to the video to be retrieved, and determine a first text attention weight and a second text attention weight corresponding to the request text; Adjusting the text feature by the first video attention weight, and adjusting the video feature by the second video attention weight to obtain a video feature after information interaction; Adjusting the video feature by the first text attention weight, and adjusting the text feature by the second text attention weight to obtain a text feature after information interaction; Based on the similarity between the video features after the information interaction and the text features after the information interaction, it is determined whether the video to be retrieved is a retrieval result corresponding to the request text.

2. The method according to claim 1, characterized in that The determining of the first video attention weight and the second video attention weight corresponding to the video to be retrieved, and the determining of the first text attention weight and the second text attention weight corresponding to the request text, comprises: Determine a first video attention weight on the query dimension, a video key attention weight on the key dimension, and a video value attention weight on the value dimension corresponding to the video to be retrieved, wherein the second video attention weight includes the video key attention weight and the video value attention weight; Determine a first text attention weight on the query dimension, a text key attention weight on the key dimension, and a text value attention weight on the value dimension corresponding to the request text, wherein the second text attention weight includes the text key attention weight and the text value attention weight.

3. The method according to claim 2, characterized in that The step of adjusting the text feature by the first video attention weight and adjusting the video feature by the second video attention weight to obtain the video feature after information interaction includes: Adjusting the text features by using the first video attention weights to obtain a first text feature matrix; Adjusting the video features by the video key attention weights to obtain a second video feature matrix; Adjusting the video features by using the video value attention weights to obtain a third video feature matrix; The first text feature matrix, the second video feature matrix, and the third video feature matrix are subjected to information interaction to obtain video features after the information interaction.

4. The method according to claim 2, characterized in that: The step of adjusting the video feature by the first text attention weight and adjusting the text feature by the second text attention weight to obtain the text feature after information interaction includes: Adjusting the video features by using the first text attention weights to obtain a first video feature matrix; Adjusting the text features by the text key attention weights to obtain a second text feature matrix; Adjusting the text features by the text value attention weights to obtain a third text feature matrix; The first video feature matrix, the second text feature matrix, and the third text feature matrix are subjected to information interaction to obtain text features after the information interaction.

5. The method according to claim 1, characterized in that The step of obtaining the video to be retrieved and obtaining the video features corresponding to the video to be retrieved includes: Get the video frame of the video to be retrieved; Inputting the video frame into an image encoder to obtain initial video features corresponding to the video frame; A self-attention weight is calculated based on the initial video feature to obtain a self-attention video weight, and the initial video feature is adjusted by the self-attention video weight to obtain a video feature.

6. The method according to claim 5, characterized in that The step of inputting the video frame into an image encoder to obtain initial video features corresponding to the video frame includes: Performing image segmentation on the video frame to obtain a plurality of image blocks; Performing feature extraction on each of the image blocks to obtain initial image block features corresponding to each of the image blocks; Position coding information is added to the initial image block feature corresponding to each of the image blocks to obtain the initial video feature corresponding to the video to be retrieved.

7. The method according to claim 5, characterized in that The calculating of the self-attention weight based on the initial video feature to obtain the self-attention video weight, and adjusting the initial video feature by the self-attention video weight to obtain the video feature, includes: Determine the self-attention video weight corresponding to each feature element in the initial video feature; Based on the self-attention video weights, determining a first feature matrix on the query dimension, a second feature matrix on the key dimension, and a third feature matrix on the value dimension corresponding to the feature elements; Based on the first feature matrix and the second feature matrix, a self-attention feature matrix is ​​obtained, where the self-attention feature matrix expresses the correlation between different feature elements in the video frame; Video features are obtained based on the feature correlation and the third feature matrix.

8. The method according to claim 1, characterized in that: The obtaining of the request text and obtaining text features corresponding to the request text include: Get the request text; Inputting the request text into a text encoder to obtain initial text features corresponding to the request text; A self-attention weight is calculated based on the initial text feature to obtain a self-attention text weight, and the initial text feature is adjusted by the self-attention text weight to obtain a text feature.

9. A video text retrieval device, characterized in that: include: An acquisition unit, used to acquire a video to be retrieved and a request text, and acquire video features corresponding to the video to be retrieved and text features corresponding to the request text; A determination unit, configured to determine a first video attention weight and a second video attention weight corresponding to the video to be retrieved, and to determine a first text attention weight and a second text attention weight corresponding to the request text; A first adjustment unit, configured to adjust the text feature by using the first video attention weight, and adjust the video feature by using the second video attention weight, to obtain a video feature after information interaction; A second adjustment unit, configured to adjust the video feature by using the first text attention weight, and adjust the text feature by using the second text attention weight, to obtain a text feature after information interaction; The retrieval unit is used to determine whether the video to be retrieved is a retrieval result corresponding to the request text based on the similarity between the video features after the information interaction and the text features after the information interaction.

10. An electronic device, characterized in that: It comprises a memory and a processor; the memory stores an application program, and the processor is used to run the application program in the memory to execute the operations in the video text retrieval method according to any one of claims 1 to 8.

11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor to execute the steps in the video text retrieval method according to any one of claims 1 to 8.

12. A computer program product comprising a computer program or instructions, characterized in that When the computer program or instruction is executed by a processor, the steps in the video text retrieval method according to any one of claims 1 to 8 are implemented.

Citation Information

Cited By

  • Video clip retrieval method, video clip retrieval device and storage medium

    CN120316307A