Video processing method and device based on hybrid expert model, equipment and medium
Through the video processing method of hybrid expert model, combining the temporal expert model and multiple expert models, the temporal features and candidate features of the video frames are extracted, which solves the problem of poor understanding of temporal features of multi-modal large models in video processing, and improves the quality of video processing. Content crawling and temporal visual understanding capabilities.
Patent Information
- Application Number
- CN202410854723.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-28
- Publication Date
- 2024-10-15
AI Technical Summary
Existing multi-modal large models have poor understanding of temporal features during video processing, resulting in insufficient video content capture capabilities and temporal visual understanding capabilities.
A video processing method based on a hybrid expert model is adopted, combining the temporal expert model and multiple expert models. Through embedding processing and vector fusion, the temporal feature vectors and candidate feature vectors of the video frames are extracted and input into the large language model to generate Text information of the target video.
It significantly improves video content capture capabilities and temporal visual understanding capabilities, improves the modeling and interpretation of complex video data, and provides flexibility and efficiency in adapting to different task scenarios.
Smart Images

Figure CN118781518A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a video processing method, device, equipment and medium based on a hybrid expert model. Background Art
[0002] The development of large multimodal models has reached a bottleneck period. With the actual needs of different application scenarios, the parameters of large multimodal models will become larger and larger, and the complexity and scale will continue to increase.
[0003] Currently, when multimodal large models are performing video understanding, they basically use position encoding between frames to enable the multimodal large models to understand the temporal features. This encoding method is simple and crude. The understanding of temporal features is not only the understanding of sequence, but also the relationship between the state changes of events over time. Currently, when performing video processing based on multimodal large models, the understanding of the temporal features of the video is poor. Summary of the invention
[0004] The present application provides a video processing method, apparatus, device and medium based on a hybrid expert model to solve the problem in the prior art of poor understanding of the temporal characteristics of a video when performing video processing based on a multimodal large model.
[0005] In a first aspect, an embodiment of the present application provides a video processing method based on a hybrid expert model, wherein the hybrid expert model includes a time series expert model and multiple expert models, and the method includes:
[0006] Each video frame in the target video is embedded respectively to obtain each initial feature vector corresponding to each video frame and a first classification vector corresponding to the target video; wherein the initial feature vector carries a second classification vector of the video frame;
[0007] Inputting the first classification vector and the second classification vector of each video frame into the time series expert model to obtain a time series feature vector output by the time series expert model;
[0008] Inputting each of the initial feature vectors into the multiple expert models, obtaining each candidate feature vector output by the multiple expert models, and fusing the time series feature vector with each candidate feature vector respectively according to a preset vector fusion method to determine each target feature vector;
[0009] Each target feature vector is input into the language model to obtain the target text information corresponding to the target video output by the language model.
[0010] In a second aspect, an embodiment of the present application further provides a video processing device based on a hybrid expert model, wherein the hybrid expert model includes a time series expert model and multiple expert models, and the device includes:
[0011] A processing module, used to perform embedding processing on each video frame in the target video, to obtain each initial feature vector corresponding to each video frame and a first classification vector corresponding to the target video; wherein the initial feature vector carries a second classification vector of the video frame; input the first classification vector and the second classification vector of each video frame into the time series expert model, to obtain the time series feature vector output by the time series expert model; input each initial feature vector into the multiple expert models, to obtain each candidate feature vector output by the multiple expert models, and according to a preset vector fusion method, fuse the time series feature vector with each candidate feature vector, to determine each target feature vector;
[0012] The recognition module is used to input each target feature vector into the language model to obtain the target text information corresponding to the target video output by the language model.
[0013] In a third aspect, an embodiment of the present application further provides an electronic device, which includes at least a processor and a memory, and the processor is used to implement the steps of the video processing method based on the hybrid expert model as described above when executing a computer program stored in the memory.
[0014] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the video processing method based on the hybrid expert model as described above.
[0015] In an embodiment of the present application, the hybrid expert model includes a temporal expert model and multiple expert models, including: embedding each video frame in the target video separately to obtain each initial feature vector corresponding to each video frame and a first classification vector corresponding to the target video; wherein the initial feature vector carries the second classification vector of the video frame; inputting the first classification vector and the second classification vector of each video frame into the temporal expert model to obtain the temporal feature vector output by the temporal expert model; inputting each initial feature vector into multiple expert models to obtain each candidate feature vector output by the multiple expert models, and according to a preset vector fusion method, fusing the temporal feature vector with each candidate feature vector separately to determine each target feature vector; inputting each target feature vector into the language large model to obtain the target text information corresponding to the target video output by the language large model. In an embodiment of the present application, the electronic device extracts the temporal feature vector in the target video based on the temporal expert model in the hybrid expert model, extracts the candidate feature vector in the target video based on multiple expert models in the hybrid expert model, and fuses each candidate feature vector with the temporal feature vector to obtain each target feature vector. Then, based on the language large model, each target feature vector is understood to obtain the target text information of the target video, which can effectively improve the ability to capture video content and the temporal visual understanding ability. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the technical solution 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 ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0017] Figure 1 A schematic diagram of a video processing process based on a hybrid expert model provided in an embodiment of the present application;
[0018] Figure 2 A schematic diagram of a hybrid expert model provided in an embodiment of the present application;
[0019] Figure 3 A schematic diagram of a visual text adapter provided by an embodiment of the present application;
[0020] Figure 4 A schematic diagram of the structure of a video processing device based on a hybrid expert model provided in an embodiment of the present application;
[0021] Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0022] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application.
[0023] In order to improve the ability to capture video content and the ability to understand temporal visual information, the embodiments of the present application provide a video processing method, device, equipment and medium based on a hybrid expert model.
[0024] In an embodiment of the present application, the hybrid expert model includes a time series expert model and multiple expert models, and the method includes: embedding each video frame in the target video separately to obtain each initial feature vector corresponding to each video frame and a first classification vector corresponding to the target video; wherein the initial feature vector carries the second classification vector of the video frame; inputting the first classification vector and the second classification vector of each video frame into the time series expert model to obtain the time series feature vector output by the time series expert model; inputting each initial feature vector into multiple expert models to obtain each candidate feature vector output by the multiple expert models, and according to a preset vector fusion method, fusing the time series feature vector with each candidate feature vector separately to determine each target feature vector; inputting each target feature vector into the language large model to obtain the target text information corresponding to the target video output by the language large model.
[0025] Figure 1 A schematic diagram of a video processing process based on a hybrid expert model provided in an embodiment of the present application, wherein the hybrid expert model includes a time series expert model and multiple expert models, and the process includes:
[0026] S101: Perform embedding processing on each video frame in the target video respectively to obtain each initial feature vector corresponding to each video frame and a first classification vector corresponding to the target video; wherein the initial feature vector carries a second classification vector of the video frame; input the first classification vector and the second classification vector of each video frame into the timing expert model to obtain the timing feature vector output by the timing expert model.
[0027] A video processing method based on a hybrid expert model provided in an embodiment of the present application is applied to an electronic device, which may be a PC or a server.
[0028] At present, there are many problems with the multimodal large models in the field of transportation. 1. There seems to be a competitive dynamic between multimodality and language modality, which leads to catastrophic forgetting of language ability in the large language model (LLM). 2. The model is overly dependent on data of a certain modality due to the single training task. 3. Interference between different heterogeneous data. 4. Traffic scene events are complex and the development of events is changing rapidly. It is necessary to analyze the cause and effect relationship of the situation. Time series information plays a vital role in the judgment and accountability of traffic incidents.
[0029] In order to achieve efficient training and reasoning of large models, some methods start from the bottom of the model, such as directly changing the underlying model architecture, changing the original Transformer architecture to the recently released Mamba architecture based on the state space model (SSM); some methods start with pre-training and fine-tuning methods; and another method is the Mixture of Experts (MoE) to be introduced in the embodiments of this application. Advantages of the Mixture of Experts Model:
[0030] Task specificity: The use of hybrid expert models can effectively take advantage of the advantages of multiple expert models. Each expert can specialize in different tasks or different parts of the data, achieving better performance when dealing with complex tasks. Each expert model can model different data distributions and patterns, which significantly improves the accuracy and generalization ability of the model, so that the model can better adapt to the complexity of the task. This task specificity makes the hybrid expert model perform well when dealing with multimodal data and complex tasks.
[0031] Flexibility: The hybrid expert model exhibits excellent flexibility and can flexibly select and combine appropriate expert models according to the needs of the task. The structure of the model allows for dynamic selection of activated expert models according to the needs of the task, enabling flexible processing of input data. This enables the model to adapt to different input distributions and task scenarios, improving the flexibility of the model.
[0032] Efficiency: Since only a few expert models are activated and most models are inactive, the hybrid expert model has high sparsity. This sparsity improves computational efficiency because only specific expert models process the current input, reducing computational overhead.
[0033] Representational power: Each expert model can be designed to be more specialized and better able to capture patterns and relationships in the input data. The overall model improves the modeling ability of complex data structures by combining the outputs of these experts, thereby enhancing the performance of the model.
[0034] Interpretability: Since each expert model is relatively independent, the decision-making process of the model is easier to explain and understand, providing users with higher interpretability, which is very important for some application scenarios that have strong explanatory requirements for the model decision-making process.
[0035] Currently, a relatively effective method to solve the above problems is to construct a hybrid expert model for traffic scenarios. The embodiment of the present application proposes a hybrid expert model suitable for traffic scenarios, which can effectively solve the problems of multimodal data stacking, modal forgetting, single training task, over-reliance on a certain modality, and difficulty in accident judgment and accountability in traffic scenarios. The hybrid expert model can effectively improve the multimodal feature extraction capability and the visual understanding capability of adding time series information.
[0036] In the embodiment of the present application, different from the traditional hybrid expert model, the hybrid expert model proposed in the embodiment of the present application includes a timing expert model, and the electronic device can determine the timing feature vector of the target video according to the timing expert model.
[0037] Specifically, the electronic device performs embedding processing on each video frame in the target video to obtain each initial feature vector corresponding to each video frame and a first classification vector corresponding to the target video; wherein the initial feature vector carries a second classification vector of the video frame.
[0038] The electronic device inputs the first classification vector and the second classification vector of each video frame into the timing expert model, so that the timing expert model identifies the timing characteristics of the target video according to the first classification vector and the second classification vector, determines and outputs the timing feature vector, and the electronic device obtains the timing feature vector output by the timing expert model.
[0039] Specifically, in the embodiment of the present application, the time series expert model can determine the time series feature vector by the following formula:
[0040] E t (x cls )=λ3E t (x cls1 )+λ4E t (x cls2 )+…+λ n E t (x clsN )+E t (x cls0 )
[0041] E t (x cls ) is the time series feature vector, E t (x clsi ) is the first classification vector corresponding to the i-th video frame i≤N, E t (xcls0 ) is the second classification vector of the target video, λ m is the preset weight, the λ m It can be a training parameter or an experience value.
[0042] In this embodiment of the present application, the first classification vector of each video frame can reflect the overall characteristics of the video frame, and the second classification vector of the target video can reflect the overall characteristics of the target video.
[0043] S102: Input each of the initial feature vectors into the multiple expert models, obtain each candidate feature vector output by the multiple expert models, and fuse the time series feature vector with each candidate feature vector respectively according to a preset vector fusion method to determine each target feature vector.
[0044] In an embodiment of the present application, the hybrid expert model also includes multiple expert models, wherein the multiple is at least two.
[0045] The electronic device inputs the initial feature vector corresponding to each video frame into multiple expert models, and each expert model can focus on the initial feature vector input into the expert model, thereby improving the overall performance of the model. Each expert model determines and outputs a candidate feature vector, and the electronic device obtains each candidate feature vector output by multiple expert models, and fuses at least one candidate feature vector corresponding to an initial feature vector to obtain a target feature vector corresponding to the initial feature vector. The vector fusion method can be splicing and then dimensionality reduction, or summation, etc., which is not limited here.
[0046] Specifically, each expert model is usually a feedforward neural network, which can be expressed as:
[0047] E i (x) = f i (W i *x+b i )
[0048] Among them, E i (x) represents the output candidate feature vector, x is the input initial feature vector, f i (k) represents the classification process, W i and b i are preset parameters.
[0049] In an embodiment of the present application, a feedforward neural network (FFNN) is a basic artificial neural network structure, also known as a multi-layer perceptron (MLP). A feedforward neural network consists of three parts: an input layer, one or more hidden layers containing several neurons, and an output layer. In the hybrid expert model, the expert network usually uses a Transformer structure. A standard Transformer structure usually includes a multi-head self-attention layer (Multi-head Self-attention), a feedforward neural network layer, a residual connection, and a normalized LayerNorm. Using Transformer as an expert network can give full play to the advantages of Transformer in processing long-distance dependencies and parallel computing.
[0050] Among them, the multi-head self-attention layer includes:
[0051]
[0052] MultiHead(X)=Concat(head1,head2,...,head H )W O
[0053] Among them, Q, K, and V are query matrices, key matrices, and value matrices, respectively. K and V are consistent with the initial feature vector of the input, Q is the learnable weight, and d k is the dimension of the row vectors in the key matrix, W O It is the linear transformation matrix of the preset output.
[0054] The feedforward neural network layer includes: FFN(X)=max(0,XW1+b1)W2+b2, where X is the input, and W1, b1, W2 and b2 are preset parameters.
[0055] S103: Input each target feature vector into the language model to obtain target text information corresponding to the target video output by the language model.
[0056] In an embodiment of the present application, after the electronic device determines each target feature vector based on the hybrid expert model, the electronic device understands each target feature vector through a large language model to obtain text information corresponding to the target video.
[0057] Specifically, the electronic device inputs each target feature vector into the language model, and obtains the target text information corresponding to the target video output by the language model.
[0058] In addition, in order to improve the comprehension ability of the large language model, in an embodiment of the present application, before the electronic device inputs each target feature vector into the large language model, the electronic device may also use a visual text adapter to align and update each target feature vector, and then input each updated target feature vector into the large language model to obtain the target text information corresponding to the target video output by the large language model.
[0059] Among them, in the embodiments of the present application, there are currently many choices for language big models commonly used in traffic scenarios, such as domestic language big models or foreign language big models. Since domestic language big models have a much better understanding of Chinese than foreign language big models, it is recommended to use domestic language big models.
[0060] In the embodiments of the present application, a domestic language large model can be used as the base, and model fine-tuning methods such as the lora series, Adapter, Prefix-tuning, P-tuning, and Prompt-tuning can be added to construct a traffic field text dataset, and the model can be fine-tuned based on the traffic field text dataset to obtain a language large model.
[0061] Among them, the language big model can be TransGPT-7B. Different from the general multimodal traffic big model products, TransGPT-7B is mainly committed to playing a practical role in real traffic scenarios, including traffic situation prediction, intelligent consulting assistant, public transportation service, traffic planning and design, traffic safety education, assistance management, traffic accident reporting and analysis, automatic driving assistance system and other capabilities.
[0062] TransGPT trained the language model version of the comprehensive traffic model based on the chinese-alpaca-plus-7b-hf model framework, and implemented general domain pre-training, traffic domain pre-training, supervised fine-tuning, reward modeling, and reinforcement learning training.
[0063] In an embodiment of the present application, the electronic device extracts the temporal feature vector in the target video based on the temporal expert model in the hybrid expert model, extracts the candidate feature vector in the target video based on multiple expert models in the hybrid expert model, and fuses each candidate feature vector with the temporal feature vector to obtain each target feature vector. Then, based on the language large model, each target feature vector is understood to obtain the target text information of the target video, which can effectively improve the ability to capture video content and the temporal visual understanding ability.
[0064] In order to improve the ability to capture video content and the ability to understand temporal visual sequences, based on the above embodiments, in the embodiment of the present application, before embedding each video frame in the target video, the method further includes:
[0065] Dividing each video frame into a preset number of sub-images;
[0066] The embedding process is performed on each video frame in the target video to obtain each initial feature vector corresponding to each video frame, including:
[0067] Each sub-image is embedded separately to obtain the sub-feature vector corresponding to each sub-image;
[0068] For each video frame, each sub-feature vector corresponding to the video frame is determined as an initial feature vector of the video frame.
[0069] Input resolution is crucial for accurately interpreting text and detailed image features. Related research has shown that starting from a smaller resolution and gradually learning image features with a larger resolution can effectively improve the model effect. Based on this, in order to increase the image resolution that the model can process, in the embodiment of the present application, the electronic device will segment each video frame.
[0070] Specifically, in an embodiment of the present application, the electronic device divides each video frame into a preset number of sub-images; the electronic device performs embedding processing on each sub-image to obtain a sub-feature vector corresponding to each sub-image; for each video frame, each sub-feature vector corresponding to the video frame is determined as an initial feature vector of the video frame.
[0071] For example, a video frame is divided into three sub-images I∈R H×W×3 , using a sliding window W∈R Hv×Wv Divide the image into smaller, local parts. Among them, Hv and Wv represent the resolution supported by the original LLM, such as 448×448 for the qwen model. Electronic devices can also use fine-tuning methods (such as: LoRA series, etc.) in each video encoder to process various visual elements in different parts of the image. The purpose of this integrated fine-tuning method is to help the video encoder effectively identify and absorb detail-sensitive features of each image area, which enhances the understanding of spatial and contextual relationships without significantly increasing parameters or computational requirements.
[0072] In addition, in an embodiment of the present application, position coding is added to the sub-feature vector corresponding to each sub-image to retain spatial information, as well as timing coding of the video frame. Temporal information is also incorporated while acquiring spatial features, further strengthening the expression of temporal features. This allows the model to fully acquire spatial information while incorporating real and effective timing information into the judgment of events, and can efficiently and accurately hold accountable and punish events in traffic scenes.
[0073] The position coding is used to identify the position information of the sub-image in its corresponding video frame, and the timing coding is used to identify the timing information of the video frame where the sub-image is located in the target video.
[0074] In order to improve the ability to capture video content and the ability to understand temporal visual sequences, based on the above embodiments, in the embodiment of the present application, the hybrid expert model further includes a gating model;
[0075] Inputting each of the initial feature vectors into the multiple expert models to obtain each of the candidate feature vectors output by the multiple expert models comprises:
[0076] For each initial feature vector, the gating model determines at least one target expert model among the multiple expert models to process the initial feature vector; inputs the initial feature vector into the at least one target expert model, and obtains an intermediate feature vector output by the at least one target expert model; performs vector fusion on the intermediate feature vectors output by the at least one target expert model to obtain a candidate feature vector corresponding to the initial feature vector.
[0077] In the embodiment of the present application, the hybrid expert model also includes a gating model, which is used to determine which expert model should take over the processing of each initial feature vector.
[0078] Specifically, in an embodiment of the present application, for each initial feature vector, the gating model determines at least one target expert model among multiple expert models to process the initial feature vector; inputs the initial feature vector into at least one target expert model, and obtains an intermediate feature vector output by at least one target expert model; performs vector fusion on the intermediate feature vectors output by at least one target expert model to obtain a candidate feature vector corresponding to the initial feature vector.
[0079] In an embodiment of the present application, an initial feature vector can be processed by multiple expert models. After obtaining multiple intermediate feature vectors output by multiple expert models for an initial feature vector, the multiple intermediate feature vectors are fused to obtain a candidate feature vector, so that one initial feature vector corresponds to one candidate feature vector.
[0080] Among them, the gating model is a sparse gate network that receives a single data element as input and then outputs a weight that represents the contribution of each expert model to processing the input data. Generally, the probability distribution is modeled through the expert model or token through the softmax gating function, and the top K are selected. For example, if the hybrid model has three expert models, the output probabilities may be 0.5, 0.4, and 0.1, which means that the first expert model contributes 50% to processing this data, the second expert model 40%, and the second expert model 10%. At this time, K can be chosen to be 2. We believe that the suggestions of the first two expert models will be better and can be used for more precise answers, while the suggestions of the third expert model can be used for more creative answers.
[0081] Specifically, the gating model determines the target expert model through the following formula:
[0082] G(x)=Softmax(KeepTopK(H(x),k))
[0083] H(x) i =(x·W g ) i +StandardNormal()·Softplus((x·W noise ) i )
[0084]
[0085] Where i is the i-th sub-image (token), x is the input token sub-feature vector. K is the setting to obtain the top K targets; StandardNormal()·Softplus((x·W noise ) i ) is the noise injection. First, (x·W noise ) i is a fully connected layer operation, where W noise is a weight matrix. Then, this output is activated by the Softplus function, which is a smooth activation function in the form of softplus(x)=log(1+exp(x)). Finally, a standard normal distribution random number StandardNormal() is generated and multiplied by the output of softplus, thus generating a noise term. (x·W g ) i is a standard fully connected layer operation, where x is the input and W g is the weight matrix, i is the index, indicating that this is the output of the i-th token feature.
[0086] Figure 2 A schematic diagram of a hybrid expert model provided in an embodiment of the present application, such as the Figure 2 As shown, the first classification vector and the second classification vector cls are input into the time series expert model (FFN-time), and each initial feature vector is assigned to multiple expert models (FFN1, FFN2, FFN3, FFN4) through the gating model (routing) to obtain a candidate feature vector corresponding to each initial feature vector, and the time series feature vector output by the time series expert model is fused with multiple candidate feature vectors respectively to obtain multiple target feature vectors, and the multiple target feature vectors are aligned through the visual text adapter (image-text alignment module), and the aligned multiple target feature vectors are input into the language large model (LLM), and the text feature vector (embedding) corresponding to the question text (txt) is determined and input into the language large model to obtain the reply text output by the language large model.
[0087] In order to improve the ability to capture video content and the ability to understand temporal visual sequences, based on the above embodiments, in the embodiments of the present application,
[0088] After the gating model determines at least one target expert model among the multiple expert models for processing the initial feature vector, the method further includes:
[0089] The gating model determines the weights respectively corresponding to the at least one target expert model;
[0090] The intermediate feature vectors output by at least one target expert model are vector-fused to obtain candidate feature vectors corresponding to the initial feature vectors, including:
[0091] According to the weight corresponding to each target expert model and the intermediate feature vector output by each target expert, weighted summation processing is performed on each intermediate feature vector, and the obtained sum vector is determined as the candidate feature vector.
[0092] In an embodiment of the present application, the gating model will also assign a corresponding weight to each target expert model. The gating model will assign a weight to each target expert model based on the ability of each target expert model to process the initial feature vector.
[0093] The target expert model selected by the gating model will generate corresponding outputs, namely intermediate feature vectors, for the input data. Multiple intermediate feature vectors corresponding to an initial feature vector will finally be weighted and combined with the weights assigned by the gating model according to the ability of each target expert model to process the feature, forming a candidate feature vector corresponding to the initial feature vector.
[0094] Specifically, the hybrid expert model can determine the candidate feature vector by the following formula:
[0095]
[0096] Among them, N is the number of expert models included in the hybrid expert model, E i (x) is the intermediate feature vector output by the i-th target expert network, g i (x) is the weight of the i-th target expert model determined by the gating network, satisfying
[0097] In order to improve the ability to capture video content and the ability to understand temporal visuals, based on the above embodiments, in the embodiment of the present application, according to the preset vector fusion method, the temporal feature vector is fused with each candidate feature vector respectively, and each target feature vector is determined to include:
[0098] Obtaining a first weight corresponding to a preconfigured time series feature vector and a second weight corresponding to the candidate feature vector;
[0099] Determine each sum vector of the time series feature vector and each candidate feature vector according to the first weight and the second weight;
[0100] Each of the sum vectors is determined as each of the target feature vectors.
[0101] In order to further improve the comprehension ability of the large language model, in an embodiment of the present application, the electronic device can fuse the time series feature vector with each candidate feature vector respectively, and then input each fused target feature vector into the large language model.
[0102] Specifically, in an embodiment of the present application, the electronic device obtains a first weight corresponding to a pre-configured timing feature vector and a second weight corresponding to a candidate feature vector; the electronic device performs weighted summation of the timing feature vector and each candidate feature vector respectively based on the first weight and the second weight, determines each sum vector of the timing feature vector and each candidate feature vector respectively, and determines each sum vector as each target feature vector.
[0103] In this embodiment of the present application, the sum vector can be determined by the following formula:
[0104]
[0105] in, is the candidate feature vector corresponding to the i-th initial feature vector, where the meaning of each parameter is consistent with that in the above embodiment, E t (x cls) is the time series feature vector, λ1 is the second weight, λ2 is the first weight, and the λ1 and λ2 can be training parameters or empirical values.
[0106] In order to improve the ability to capture video content and the ability to understand temporal visuals, based on the above embodiments, in the embodiment of the present application, according to the preset vector fusion method, the temporal feature vector is fused with each candidate feature vector respectively, and after each target feature vector is determined, the method further includes:
[0107] Obtaining an input question text and determining a text feature vector corresponding to the question text;
[0108] The text feature vector and each target feature vector are input into the language model to obtain a reply text corresponding to the question text of the language model.
[0109] In an embodiment of the present application, after determining each target feature vector of the target video, the electronic device may also conduct question and answer based on each target feature vector.
[0110] Specifically, the input question text is obtained, and the text feature vector corresponding to the question text is determined; the electronic device inputs the text feature vector and each target feature vector into the language model to obtain the reply text corresponding to the question text of the language model.
[0111] In order to improve the ability to capture video content and the ability to understand temporal visual sequences, based on the above embodiments, in an embodiment of the present application, the training method of the hybrid expert model includes:
[0112] Get sample videos and sample texts from the dataset;
[0113] Determine each sample feature vector corresponding to the sample video using the hybrid expert model;
[0114] Using a preconfigured visual text adapter, aligning each sample feature vector with the sample text;
[0115] Inputting each aligned sample feature vector into a large language model to obtain a predicted text output by the large language model;
[0116] The parameters of the hybrid expert model are adjusted according to the predicted text and the sample text.
[0117] In the embodiment of the present application, a visual text adapter is introduced in the training process of the hybrid expert model to effectively align the visual and text features. This alignment can not only improve the performance of the model, but also enable the model to understand the relationship between the image and the text. There are many ways to design a visual text adapter, including but not limited to:
[0118] MLP: MLP is a fully connected neural network that can be used to learn complex mapping relationships between image and text features.
[0119] Q-former structure: The Q-former structure is a Transformer-based model that uses a new self-attention mechanism to process image and text data more effectively.
[0120] Cross Attention: CrossAttention is an attention mechanism that can handle two different types of inputs, such as source language and target language in the Transformer model. By calculating the matching degree between Query and Key, we can get an attention score, and then use this score to perform weighted summation on Value to get the final output.
[0121] In an embodiment of the present application, an electronic device obtains a sample video and a sample text from a data set; uses a hybrid expert model to determine each sample feature vector corresponding to the sample video; uses a pre-configured visual text adapter to align each sample feature vector and sample text; inputs each aligned sample time series feature vector and sample feature vector into a large language model to obtain a predicted text output by the large language model; and adjusts the parameters of the hybrid expert model according to the predicted text and the sample text.
[0122] The process of the hybrid expert model determining each sample feature vector corresponding to the sample video is consistent with the process of the hybrid expert model determining each target feature vector of the target video in the above embodiment, and will not be described in detail here.
[0123] Figure 3 A schematic diagram of a visual text adapter provided in an embodiment of the present application, such as the Figure 3 As shown, the sample time series feature vector and the sample and vector (Image Encoder) of the sample feature vector, the sample text (text) and the sample question text (Queries) are input into the visual text adapter, and the output of the visual text adapter is input into the language large model (LLM), and the language large model outputs the predicted text.
[0124] In multimodal complex scenes, fine-grained correspondence between images and text is a challenge, especially in complex environments where there are multiple images and the order, absolute position, and relative position of the images are crucial. In order to accurately indicate the image position and distinguish between image representation and text representation, in addition to conventional generation description tasks, question-answering tasks, etc., this application also proposes a method to refine the alignment relationship between modalities, and through the construction of two data formats, the following special training tasks are achieved:
[0125] 1. Fine-grained referential expression understanding task
[0126] Referential expression understanding enables the model to identify the object referred to in an image by understanding referential expressions in natural language (e.g., “black BYD sedan”).
[0127] Image tokens are used, and the model allows multiple image inputs (<im_start> ,<im_end> )For example:
[0128] Label image format:
[0129] <im1_start> picture_1.jpg<im1_end> \n<im2_start> picture_2.jpg<im2_end> \n<im3_start> picture_3.jpg<im3_end> \n;
[0130] Event id:<id_start> 1<id_end> ;
[0131] The text description and the coordinate information of the location can be entered together with the text:<txt_start> tell me Figure 1 Black BYD car in Figure 2 The answer format is: [xmin, ymin, xmax, ymax], the answer is:<txt_end> .
[0132] The answer is: [523,621,816,937].
[0133] 2. Fine-grained designation expression generation task
[0134] Referential expression generation allows the model to understand a specific object in an image and generate a natural language referential expression that describes that object (e.g. given the coordinates of a target, let the model identify the content of that area: “a fire broke out on the road”).
[0135] Label image format:
[0136] <im1_start>picture_1.jpg<im1_end> \n<im2_start> picture_2.jpg<im2_end> \n<im3_start> picture_3.jpg<im3_end> \n;
[0137] Event id:<id_start> 2<id_end> ;
[0138] Label text format:<txt_start> tell me Figure 1 and Figure 2 What happened in this area [131,238,675,578]?
[0139] Using the given picture and coordinate information to answer, the answer is:<txt_end> .
[0140] The answer is: There was a fire at the intersection.
[0141] 3. Contrastive learning tasks
[0142] The way contrastive learning achieves the goal of learning better representations is to ensure that similar data samples are close to each other in the feature space, while dissimilar data samples are far away from each other. When the model performs well on such tasks, it has learned the key features that distinguish the data. This feature representation provides a favorable starting point for subsequent supervised learning tasks (such as classification, regression, etc.).
[0143] Label image format:
[0144] <im1_start> picture_1.jpg<im1_end> \n<im2_start> picture_2.jpg<im2_end> \n<im3_start> picture_3.jpg<im3_end> \nWhich of the three pictures above has a higher traffic accident response level? \nWe divide traffic incidents into:
[0145] Level 1: Emergency response events; fires, landslides, etc. that require emergency handling.
[0146] Level 2: Severe response incidents; snowy roads, foggy weather, accidents with major casualties, etc.
[0147] Level 3: More serious response incidents; serial traffic accidents, etc.
[0148] Level 4: General response incidents; traffic violations, etc.
[0149] Answer: In the second picture, there is a fire that requires an emergency response.
[0150] In order to fully utilize the advantages of LLM, the researchers used a powerful LLM (Vicuna) as the backbone. During the training process, the parameters of the language model (LLM) and the visual encoder were frozen, the parameters of the connection module (Q-former) between the LLM and the visual encoder were unfrozen, and they were fine-tuned on the traffic field dataset. This allows the pre-trained knowledge of LLM and visual encoder to be utilized while adapting it to the specific needs of traffic multimodal scenarios.
[0151] 4. Multimodal data ratio
[0152] Performance comparison results of different modal fusion ratios. Too large a proportion of multimodal data (multimodal: language = 100%: 0%) will cause the language ability of LLM to be significantly reduced. The appropriate ratio (language: multimodal = 70%: 30%) can effectively alleviate the problem of language forgetting while enhancing the multimodal ability of the model. The performance of different modalities is strongly related to their proportion in the training data set, and related papers have confirmed the game relationship between the two modalities. Among them, a training ratio of about 7:3 language: multimodal data can be selected. This ratio enables the model to achieve better multimodal data pre-training while maintaining language ability, effectively balancing the dual development of language and multimodal capabilities.
[0153] In the embodiment of the present application, the training of the multimodal large model includes three steps:
[0154] (1) Pre-training of large language models: Use professional traffic knowledge to conduct supervised training on large language models. (Or use large language models in the traffic field)
[0155] (2) Visual-language instruction fine-tuning training: The pre-trained visual encoder and LLM remain frozen, and only the visual-language adapter needs to learn the visual representation most relevant to the text and perform multimodal instruction fine-tuning to improve the performance of the VLM. It mainly focuses on learning the detailed features of the image, and adopts two training tasks: referring expression understanding task, referring expression generation and contrastive learning task to achieve this.
[0156] (3) Visual-Text Supervised Instruction Fine-tuning: Further multimodal contextual instruction fine-tuning is performed in the dataset to activate the ability to process multi-image inputs of the VLM. This stage enables it to fully stimulate the reasoning potential of the LLM in a multimodal environment.
[0157] A diverse and large dataset is the most important factor in visual language model training. The data types required by the present application embodiment are various and can be divided into the following categories:
[0158] (1) Traffic field text dataset
[0159] Government websites and public databases: Many government websites and public databases provide information on traffic laws, policies, and regulations. You can download relevant documents from these websites or use web crawlers to collect data.
[0160] Open data platforms: Some open data platforms may provide text datasets in the field of transportation.
[0161] Transportation departments and agencies: You can contact local or national transportation departments and agencies directly and ask them if they can provide relevant data.
[0162] Academic research: Some academic research may publish their datasets, which can be found in academic journals and scientific literature.
[0163] Self-collection: Obtain through cooperative units of the transportation department.
[0164] (2) Visual-Text Dataset in the Traffic Field
[0165] The visual-language pre-training data consists of visual-text data from various sources, aiming to enhance the model's cross-modal understanding ability; while the visual-language supervised fine-tuning data is relatively small and aims to teach the model to complete specific downstream tasks.
[0166] Open Source Datasets: There are some open source datasets that may contain visual-textual data in the field of transportation. For example, the Cityscapes dataset contains images of urban street scenes and associated semantic labels. Another example is the BDD100K dataset, which contains 100,000 videos, each with traffic labels and attributes associated with it.
[0167] Government and public institutions: Some governments and public institutions cooperate to provide traffic video surveillance data. Using real scene data is more suitable for actual application scenarios.
[0168] Self-collection and annotation: If you cannot find a ready-made dataset, you may need to collect data and annotate it yourself. This may include obtaining videos from public webcams and then annotating them using annotation tools such as Labelbox, VGGImageAnnotator, etc.
[0169] (3) Other traffic-related data
[0170] Historical traffic flow data: This is the most basic data, including the number of vehicles in each time period (for example, every 5 minutes, every 15 minutes, every hour, etc.).
[0171] Time information: including date, day of the week, whether it is a holiday, etc., as these factors may affect traffic flow.
[0172] Weather information: Weather conditions (such as sunny, rainy, snowy, etc.) may affect road traffic flow.
[0173] Road information: including road type (such as expressway, main road, secondary road, etc.), road capacity, whether there is construction and other information.
[0174] Special event information: Large events such as sporting events, concerts, etc. may cause sudden increases or decreases in traffic volume.
[0175] Geographic information: including road type, road length, road width, road direction, road slope and other information.
[0176] The visual-language pre-training data consists of visual-text data from various sources, aiming to enhance the model's cross-modal understanding ability; while the visual-language supervised fine-tuning data is relatively small and aims to teach the model to complete specific downstream tasks.
[0177] Based on the above embodiments, Figure 4 A schematic diagram of the structure of a video processing device based on a hybrid expert model provided in an embodiment of the present application, the device comprising:
[0178] The processing module 401 is used to perform embedding processing on each video frame in the target video, and obtain each initial feature vector corresponding to each video frame and the first classification vector corresponding to the target video; wherein the initial feature vector carries the second classification vector of the video frame; input the first classification vector and the second classification vector of each video frame into the time series expert model, and obtain the time series feature vector output by the time series expert model; input each initial feature vector into the multiple expert models, and obtain each candidate feature vector output by the multiple expert models, and fuse the time series feature vector with each candidate feature vector according to a preset vector fusion method, and determine each target feature vector;
[0179] The recognition module 402 is used to input the temporal feature vector and the target feature vector into the language model to obtain the target text information corresponding to the target video output by the language model.
[0180] In a possible implementation, the processing module 401 is further used to divide each of the video frames into a preset number of sub-images; perform embedding processing on each sub-image to obtain a sub-feature vector corresponding to each sub-image; and for each video frame, determine each sub-feature vector corresponding to the video frame as an initial feature vector of the video frame.
[0181] In a possible implementation, the hybrid expert model further includes a gating model;
[0182] The processing module 401 is specifically used to determine, for each initial feature vector, at least one target expert model among the multiple expert models that processes the initial feature vector; input the initial feature vector into the at least one target expert model, and obtain an intermediate feature vector output by the at least one target expert model; and perform vector fusion on the intermediate feature vectors output by the at least one target expert model to obtain a candidate feature vector corresponding to the initial feature vector.
[0183] In a possible implementation, the processing module 401 is also used by the gating model to determine the weights corresponding to the at least one target expert model; based on the weight corresponding to each target expert model and the intermediate feature vectors output by each target expert, weighted summation is performed on each intermediate feature vector, and the obtained sum vector is determined as the candidate feature vector.
[0184] In a possible implementation, the identification module 402 is specifically used to obtain a first weight corresponding to a pre-configured time series feature vector and a second weight corresponding to the candidate feature vector; determine each sum vector of the time series feature vector and each candidate feature vector based on the first weight and the second weight; and determine each sum vector as each target feature vector.
[0185] In a possible implementation, the recognition module 402 is also used to obtain an input question text and determine a text feature vector corresponding to the question text; input the text feature vector and each target feature vector into the language model to obtain a reply text corresponding to the question text of the language model.
[0186] In a possible implementation, the device further includes:
[0187] The training module 403 is used to obtain sample videos and sample texts from the data set; use the hybrid expert model to determine each sample feature vector corresponding to the sample video; use a pre-configured visual text adapter to align each sample feature vector and the sample text; input each aligned sample feature vector into the language model to obtain the predicted text output by the language model; and adjust the parameters of the hybrid expert model according to the predicted text and the sample text.
[0188] Based on the above embodiments, the present application also provides an electronic device, Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application is shown in FIG. Figure 5As shown, it includes: a processor 501, a communication interface 502, a memory 503 and a communication bus 504, wherein the processor 501, the communication interface 502, and the memory 503 communicate with each other through the communication bus 504;
[0189] The memory 503 stores a computer program. When the program is executed by the processor 501, the processor 501 executes the steps of the video processing method based on the hybrid expert model provided in the above embodiments.
[0190] Since the principle of solving the problem by the above electronic device is similar to the video processing method based on the hybrid expert model, the implementation of the above electronic device can refer to the embodiment of the method, and the repeated parts will not be repeated.
[0191] The communication bus mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus. The communication interface 502 is used for communication between the above electronic device and other devices. The memory may include a random access memory (RAM) and may also include a non-volatile memory (NVM), such as at least one disk storage. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0192] The above-mentioned processor can be a general-purpose processor, including a central processing unit, a network processor (Network Processor, NP), etc.; it can also be a digital signal processing processor (Digital Signal Processing, DSP), an application-specific integrated circuit, a field programmable gate array or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component, etc.
[0193] On the basis of the above embodiments, an embodiment of the present invention further provides a computer-readable storage medium, which stores a computer program executable by a processor. When the program runs on the processor, the processor implements the steps of the video processing method based on the hybrid expert model provided in the above embodiments.
[0194] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0195] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0196] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0197] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0198] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
Claims
1. A video processing method based on a hybrid expert model, characterized in that: The hybrid expert model includes a time series expert model and multiple expert models, and the method includes: Each video frame in the target video is embedded respectively to obtain each initial feature vector corresponding to each video frame and a first classification vector corresponding to the target video; wherein the initial feature vector carries a second classification vector of the video frame; Inputting the first classification vector and the second classification vector of each video frame into the time series expert model to obtain a time series feature vector output by the time series expert model; Inputting each of the initial feature vectors into the multiple expert models, obtaining each candidate feature vector output by the multiple expert models, and fusing the time series feature vector with each candidate feature vector respectively according to a preset vector fusion method to determine each target feature vector; Each target feature vector is input into the language model to obtain the target text information corresponding to the target video output by the language model.
2. The method according to claim 1, characterized in that Before embedding each video frame in the target video, the method further includes: Dividing each video frame into a preset number of sub-images; The embedding process is performed on each video frame in the target video to obtain each initial feature vector corresponding to each video frame, including: Each sub-image is embedded separately to obtain the sub-feature vector corresponding to each sub-image; For each video frame, each sub-feature vector corresponding to the video frame is determined as an initial feature vector of the video frame.
3. The method according to claim 1, characterized in that: The hybrid expert model also includes a gating model; Inputting each of the initial feature vectors into the multiple expert models to obtain each candidate feature vector output by the multiple expert models comprises: For each initial feature vector, the gating model determines at least one target expert model among the multiple expert models to process the initial feature vector; inputs the initial feature vector into the at least one target expert model, and obtains an intermediate feature vector output by the at least one target expert model; performs vector fusion on the intermediate feature vectors output by the at least one target expert model to obtain a candidate feature vector corresponding to the initial feature vector.
4. The method according to claim 3, characterized in that After the gating model determines at least one target expert model among the multiple expert models for processing the initial feature vector, the method further includes: The gating model determines the weights respectively corresponding to the at least one target expert model; The intermediate feature vectors output by at least one target expert model are vector-fused to obtain candidate feature vectors corresponding to the initial feature vectors, including: According to the weight corresponding to each target expert model and the intermediate feature vector output by each target expert, weighted summation processing is performed on each intermediate feature vector, and the obtained sum vector is determined as the candidate feature vector.
5. The method according to claim 1, characterized in that According to the preset vector fusion method, the time series feature vector is fused with each candidate feature vector respectively to determine each target feature vector, which includes: Obtaining a first weight corresponding to a preconfigured time series feature vector and a second weight corresponding to the candidate feature vector; Determine each sum vector of the time series feature vector and each candidate feature vector according to the first weight and the second weight; Each of the sum vectors is determined as each of the target feature vectors.
6. The method according to claim 1, characterized in that According to the preset vector fusion method, the time series feature vector is fused with each candidate feature vector respectively, and after each target feature vector is determined, the method further includes: Obtaining an input question text and determining a text feature vector corresponding to the question text; The text feature vector and each target feature vector are input into the language model to obtain a reply text corresponding to the question text of the language model.
7. The method according to claim 1, characterized in that The training method of the hybrid expert model includes: Get sample videos and sample texts from the dataset; Determine each sample feature vector corresponding to the sample video using the hybrid expert model; Using a preconfigured visual text adapter, aligning each sample feature vector with the sample text; Inputting each aligned sample feature vector into a large language model to obtain a predicted text output by the large language model; The parameters of the hybrid expert model are adjusted according to the predicted text and the sample text.
8. A video processing device based on a hybrid expert model, characterized in that: The hybrid expert model includes a time series expert model and a plurality of expert models, and the device includes: A processing module, used to perform embedding processing on each video frame in the target video, to obtain each initial feature vector corresponding to each video frame and a first classification vector corresponding to the target video; wherein the initial feature vector carries a second classification vector of the video frame; input the first classification vector and the second classification vector of each video frame into the time series expert model, to obtain the time series feature vector output by the time series expert model; input each initial feature vector into the multiple expert models, to obtain each candidate feature vector output by the multiple expert models, and according to a preset vector fusion method, fuse the time series feature vector with each candidate feature vector, to determine each target feature vector; The recognition module is used to input each target feature vector into the language model to obtain the target text information corresponding to the target video output by the language model.
9. An electronic device, characterized in that: The electronic device comprises at least a processor and a memory, and the processor is used to implement the steps of the video processing method based on the hybrid expert model as claimed in any one of claims 1 to 7 when executing the computer program stored in the memory.
10. A computer-readable storage medium, characterized in that: It stores a computer program, which, when executed by a processor, implements the steps of the video processing method based on a hybrid expert model as claimed in any one of claims 1 to 7.
Citation Information
Cited By
Video understanding method and device based on double-layer hybrid expert model
CN119964043A
Video classification method for carrying out adaptive adjustment on image basic model based on Mangbar network
CN120388315A
Video understanding method, video understanding system and computer equipment
CN120492863A
Video understanding method, video understanding system and computer device
CN120492863B
Multi-modal large model expansion method fusing multi-head cross attention mechanism and Q-former
CN120524987A
