Audio and video scene collaboration method and device based on twin network and medium
Through the audio and video scene collaboration method based on twin networks, the problems of high labor costs and poor generalization of the existing technology audio and video scene perception and prediction methods are solved, and the accurate switching and prediction of audio and video scenes are realized, and the scene adaptability is improved. Coordination and prediction accuracy.
Patent Information
- Application Number
- CN202411121249.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-15
- Publication Date
- 2024-11-22
AI Technical Summary
The existing audio and video scene perception and prediction methods have high labor costs, poor generalization and poor iterability, resulting in scene switching that cannot adapt to actual scenarios or is inaccurate.
Using the audio and video scene collaboration method based on the twin network, by adjusting the twin network to make the audio and video data samples similar in the feature space, causal convolution processing and global context information capture are carried out, and paired twin data are generated to achieve accurate prediction of scene information. and switch.
It improves the accuracy and flexibility of audio and video scene prediction, ensures the accuracy and adaptability of scene switching, reduces labor costs, and enhances the learning and understanding ability of scenes.
Smart Images

Figure CN119004135A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of audio and video recognition technology, and in particular to a twin network-based audio and video scene collaboration method, device and medium. Background Art
[0002] In the current audio and video industry, through audio and video scene perception, the system can capture emotional elements in the scene, such as sadness, joy, tension, etc., so as to enhance the expressiveness of the scene by adjusting the audio and video parameters, making the audience more engaged and immersed. At present, the perception prediction of scenes is mainly concentrated in two directions. One is to achieve audio and video scene switching through manual operation of the console. This method has the advantages of being intuitive and flexible and can cope with some complex and changeable scene changes; the other is to perceive and switch scenes through pre-set feature rules. This method has the advantages of high automation, fast response speed and good consistency.
[0003] Since traditional audio and video scene perception and prediction methods require continuous monitoring by dedicated operators, the requirements for operators are also high, and they need to have an in-depth understanding of the application scenarios and accurately formulate feature rules that can effectively reflect scene changes. Therefore, these two methods have high labor costs and strong personal subjective influence factors, so they are prone to poor generalization, poor iterability, and poor scene subtle perception capabilities, resulting in scene switching that cannot adapt to the actual scene or inaccurate switching. Summary of the invention
[0004] The present invention provides an audio and video scene collaboration method, device and medium based on a twin network to solve the problem that it is difficult to flexibly predict audio and video scenes to achieve accurate scene switching.
[0005] Acquire audio and video data of the environment where the audio and video equipment is located;
[0006] Adjusting the network of the twin network according to the loss function so that the sample similarities of the audio and video data are close to each other in the feature space, thereby obtaining feature data;
[0007] Performing causal convolution processing on the audio and video data to obtain time series data;
[0008] Generate paired twin data according to the feature data and the time series data, and obtain actual scene information of the audio and video data by capturing global context information at each position of the paired twin data;
[0009] The audio and video equipment is controlled to perform scene switching according to the actual scene information.
[0010] The present invention adjusts the network of the twin network according to the loss function, so that the sample similarities of the audio and video data are close to each other in the feature space, which helps to better capture the intrinsic characteristics of the audio and video data; and the adjusted twin network can generate more distinguishing and representative feature data, which are crucial for subsequent audio and video processing tasks. The causal convolution layer ensures that at any point in time, the output of the model only depends on the input data at that time point and before. Therefore, through the causal convolution processing, the obtained time series data can effectively reflect the local dependencies in the audio and video data. By capturing global contextual information at various positions in paired twin data, the association and dependency between audio and video data can be established, so as to more accurately understand the actual scene. This global perspective helps to consider not only the characteristics of the current scene when making scene predictions, but also the historical scenes and possible future changes. Trends, thereby ensuring the prediction accuracy and flexibility of the actual scene information, and achieving accurate switching of scenes.
[0011] Compared with the prior art, the present invention obtains feature data by amplifying the feature representation of paired audio and video data, and obtains time series data by amplifying the time series granularity, thereby ensuring the validity of paired twin data; and captures global dependencies through a preset mechanism, thereby enhancing the learning, understanding and prediction capabilities of the scene, and ensuring the accuracy and flexibility of the prediction of actual scene information. Therefore, it can solve the problem of difficulty in flexibly predicting audio and video scenes to achieve accurate scene switching.
[0012] As a preferred solution, the audio and video data of the environment where the audio and video equipment is located is obtained, specifically:
[0013] Acquire initial audio and video data of the environment where the audio and video equipment is located; wherein the initial audio and video data includes audio data and video data;
[0014] Classify and annotate different scenes in the initial audio and video data, and detect and annotate occurrence nodes of preset events in the initial audio and video data to obtain annotated data;
[0015] The audio data in the labeled data is two-dimensionally matrixed, and corresponding standardized matrix data is generated according to the video data in the labeled data to obtain paired two-dimensional matrix data;
[0016] The paired two-dimensional matrix data is defined as the audio and video data.
[0017] This preferred solution classifies and annotates different scenes in the initial audio and video data, and annotates the occurrence nodes of preset specific events, so that the data has structured information, which is convenient for computer understanding and processing. In addition, the converted paired two-dimensional matrix data reduces the data complexity during model processing, so that subsequent models can process audio and video data more efficiently; at the same time, since the data has been preprocessed and standardized, the subsequent data training process will also be more stable and faster.
[0018] As a preferred solution, the network of the twin network is adjusted according to the loss function so that the sample similarities of the audio and video data are close to each other in the feature space, and feature data is obtained, specifically:
[0019] Inputting the audio and video data into the twin sub-network of the twin network to generate positive sample pairs and negative sample pairs;
[0020] Extracting features from the positive sample pair and the negative sample pair to obtain a feature vector for the positive sample pair and a feature vector for the negative sample pair;
[0021] The network of the twin network is adjusted by the loss function so that the sample similarities between the feature vectors of the positive sample pair and the feature vectors of the negative sample pair are close to each other in the feature space, thereby obtaining the feature data.
[0022] In this preferred solution, since the twin networks have the same structure and share weights, they can process different input data in the same way and extract feature information that is useful for distinguishing positive and negative sample pairs. Therefore, the obtained positive sample pair feature vectors and negative sample pair feature vectors can reflect the essential properties and mutual relationships of the input data. The network parameters of the twin network are adjusted through the loss function so that the distances of the feature vectors of the positive sample pair in the feature space are close to each other, that is, the similarity increases. This learning method enables the twin network to learn and extract useful feature data, which is conducive to the accurate classification and recognition of audio and video data.
[0023] As a preferred solution, the loss function is specifically:
[0024]
[0025] Among them, y is a binary label, taking the value of 0 or 1; v1 is the feature vector of the positive sample pair, v2 is the feature vector of the negative sample pair, and m is the boundary interval.
[0026] As a preferred solution, causal convolution processing is performed on the audio and video data to obtain time series data, specifically:
[0027] Input the audio and video data into the TCN model;
[0028] The audio and video data are processed layer by layer through the causal convolution layer of the TCN model, and a time embedding vector is used to give a time series label to the audio and video data. The time embedding vector is combined with the convolution operation of the TCN model to predict future data points to obtain the time series features of the audio and video data.
[0029] In this preferred solution, the causal convolution layer ensures that at any point in time, the output of the model depends only on the input data at that point in time and before. Therefore, by stacking the causal convolution layer, the TCN model can gradually increase the perception, thereby effectively capturing the local dependencies in the audio and video data. In addition, by combining the time embedding vector with the original audio and video data, the TCN model can learn richer time series features, thereby showing better performance when predicting future data points, ensuring the effectiveness of the time series features.
[0030] As a preferred solution, the actual scene information of the audio and video data is obtained by capturing the global context information at each position of the paired twin data, specifically:
[0031] Input the paired twin data into the Transformer model;
[0032] Transforming the first element in the paired twin data into a query vector, a key vector, and a value vector through a multi-layer self-attention mechanism of the Transformer model;
[0033] Calculate the dot product between the query vector and the key vector to obtain a similarity matrix between the first element and other elements in the paired twin data;
[0034] Using the similarity matrix as a weight, performing weighted summation on the value vector to obtain an output representation of a position corresponding to the first element;
[0035] The elements in the twin data are traversed, and combined with a preset optimizer strategy, actual scene information of the audio and video data composed of several output representations is obtained.
[0036] This preferred solution calculates the similarity matrix, which can provide the Transformer model with a quantitative index of the interaction between elements, so that the model can distinguish which elements are important to the current element and which are not. The similarity matrix is used as a weight to perform a weighted summation on the value vector to obtain the output representation of the position corresponding to the first element. This process is actually a new representation of the first element based on the integration of all relevant information. The result of the weighted summation is a vector representation that takes global information into account. It contains the complex relationship between the first element and other elements. This representation method helps the model to more accurately understand the actual scene information in the audio and video data.
[0037] As a preferred solution, the optimizer strategy is specifically:
[0038] Introducing a multi-task learning framework into the Transformer model, so that the Transformer model can simultaneously learn preset tasks about audio, video and timing;
[0039] A shared representation layer is established in the Transformer model based on time sequence, so that the preset layers of different data tasks can capture features related to the preset tasks.
[0040] In this preferred solution, multi-task learning allows the Transformer model to share knowledge between different tasks, which means that when the model learns different tasks such as audio, video, and timing, it can use the knowledge learned from one task to help improve the learning of another task. This cross-task knowledge transfer helps the model learn more generalized and robust feature representations. Through the shared representation layer, different data tasks can share and learn each other's temporal features and patterns. This sharing mechanism promotes cross-task knowledge transfer, allowing the model to make better use of data and information from different tasks; and the shared representation layer encourages the model to learn more generalized and generalized temporal features, rather than being limited to specific tasks, which helps the model show stronger adaptability and generalization when dealing with new or unseen tasks.
[0041] The present invention also provides an audio and video scene collaboration device based on a twin network, comprising a data module, a feature module, a timing module, a scene module and a control module;
[0042] Wherein, the data module is used to obtain audio and video data of the environment where the audio and video equipment is located;
[0043] The feature module is used to adjust the network of the twin network according to the loss function so that the sample similarities of the audio and video data are close to each other in the feature space to obtain feature data;
[0044] The timing module is used to perform causal convolution processing on the audio and video data to obtain timing data;
[0045] The scene module is used to generate paired twin data according to the feature data and the time series data, and obtain actual scene information of the audio and video data by capturing global context information at each position of the paired twin data;
[0046] The control module is used to control the audio and video equipment to switch scenes according to the actual scene information.
[0047] As a preferred solution, the data module includes a data unit, a labeling unit, a matrix unit and a definition unit;
[0048] Wherein, the data unit is used to obtain the initial audio and video data of the environment where the audio and video equipment is located; wherein the initial audio and video data includes audio data and video data;
[0049] The labeling unit is used to classify and label different scenes in the initial audio and video data, and detect and label the occurrence nodes of preset events in the initial audio and video data to obtain labeling data;
[0050] The matrix unit is used to two-dimensionally matrix the audio data in the annotated data, and generate corresponding standardized matrix data according to the video data in the annotated data to obtain paired two-dimensional matrix data;
[0051] The definition unit is used to define the paired two-dimensional matrix data as the audio and video data.
[0052] As a preferred solution, the feature module includes a sample unit, a vector unit and a feature unit;
[0053] Wherein, the sample unit is used to input the audio and video data into the twin sub-network of the twin network to generate positive sample pairs and negative sample pairs;
[0054] The vector unit is used to extract features from the positive sample pair and the negative sample pair to obtain a feature vector of the positive sample pair and a feature vector of the negative sample pair;
[0055] The feature unit is used to adjust the network of the twin network through the loss function so that the sample similarities between the feature vectors of the positive sample pair and the feature vectors of the negative sample pair are close to each other in the feature space to obtain the feature data.
[0056] As a preferred solution, the loss function is specifically:
[0057]
[0058] Among them, y is a binary label, taking the value of 0 or 1; v1 is the feature vector of the positive sample pair, v2 is the feature vector of the negative sample pair, and m is the boundary interval.
[0059] As a preferred solution, the timing module includes a first input unit and a timing unit;
[0060] Wherein, the first input unit is used to input the audio and video data into the TCN model;
[0061] The timing unit is used to process the audio and video data layer by layer through the causal convolution layer of the TCN model, and use the time embedding vector to give the audio and video data a timing label, and combine the time embedding vector with the convolution operation of the TCN model to predict future data points to obtain the timing features of the audio and video data.
[0062] As a preferred solution, the scene module includes a second input unit, a conversion unit, a similarity unit, a representation unit and an information unit;
[0063] Wherein, the second input unit is used to input the paired twin data into the Transformer model;
[0064] The conversion unit is used to convert the first element in the paired twin data into a query vector, a key vector and a value vector through the multi-layer self-attention mechanism of the Transformer model;
[0065] The similarity unit is used to calculate the dot product between the query vector and the key vector to obtain a similarity matrix between the first element and other elements in the paired twin data;
[0066] The representation unit is used to use the similarity matrix as a weight to perform weighted summation on the value vector to obtain an output representation of a position corresponding to the first element;
[0067] The information unit is used to traverse the elements in the twin data, and in combination with a preset optimizer strategy, obtain the actual scene information of the audio and video data composed of several output representations.
[0068] As a preferred solution, the optimizer strategy is specifically:
[0069] Introducing a multi-task learning framework into the Transformer model, so that the Transformer model can simultaneously learn preset tasks about audio, video and timing;
[0070] A shared representation layer is established in the Transformer model based on time sequence, so that the preset layers of different data tasks can capture features related to the preset tasks.
[0071] The present application also provides a storage medium, on which a computer program is stored. The computer program is called and executed by a computer to implement the audio and video scene collaboration method based on a twin network as described above. BRIEF DESCRIPTION OF THE DRAWINGS
[0072] Figure 1 It is a flowchart of an audio and video scene collaboration method based on a twin network provided in an embodiment of the present application;
[0073] Figure 2 It is a model training and optimization flow chart provided in the embodiment of the present application;
[0074] Figure 3 It is a practical operation flow chart provided by the embodiment of the present application;
[0075] Figure 4 It is a structural diagram of an audio and video scene collaboration device based on a twin network provided in an embodiment of the present application. DETAILED DESCRIPTION
[0076] 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 ordinary technicians in this field without creative work are within the scope of protection of this application.
[0077] In the description of this application, it should be understood that the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of this application, unless otherwise specified, "several" means two or more.
[0078] The embodiment of the present application provides an audio and video scene collaboration method based on a twin network, which is mainly used to overcome the problems of poor generalization, poor iterability, and poor scene subtle perception ability in audio and video scene perception and prediction, and to flexibly predict audio and video scenes to achieve accurate scene switching.
[0079] Embodiment 1:
[0080] See also Figure 1 , the embodiment of the present application provides an audio and video scene collaboration method based on a twin network, including S1 to S5, and the specific implementation steps are as follows:
[0081] S1. Acquire audio and video data of the environment where the audio and video equipment is located.
[0082] Step S1 of the embodiment of the present application is specifically as follows:
[0083] In the environment where the audio and video equipment is located, the initial audio and video data is obtained through high-quality audio and video capture equipment, and the clarity and stability of the data are ensured; wherein the initial audio and video data includes audio data and video data, and the audio data includes audio signals, voices, music, and environmental sounds, etc.; the video data includes scene visual information, such as color, motion, and behavior;
[0084] Classify and annotate different scenes in the initial audio and video data, and detect and annotate occurrence nodes of preset specific events in the initial audio and video data to obtain annotated data;
[0085] Remove noise from the annotated data, specifically: delete the meaningless noise pre-defined in the annotated data, and delete the sound and image that are invalid for the scene;
[0086] The audio data in the annotated data is two-dimensionally matrixed, and the video data in the annotated data is processed in RGB grayscale and the corresponding standardized matrix data is generated to obtain paired two-dimensional matrix data; and in the process of data processing, the frame rate of the data needs to be adjusted to avoid excessive frame rate that will generate too much repeated data, thereby causing model overfitting;
[0087] Pairs of two-dimensional matrix data are defined as audio and video data.
[0088] In this embodiment S1, different scenes in the initial audio and video data are classified and labeled, and the occurrence nodes of preset specific events are labeled, so that the data has structured information, which is convenient for computer understanding and processing, and provides supervision signals for subsequent model training. In addition, the converted paired two-dimensional matrix data reduces the data complexity during model processing, so that the subsequent model can process audio and video data more efficiently; at the same time, since the data has been preprocessed and standardized, the subsequent data training process will also be more stable and faster.
[0089] S2. Adjust the network of the twin network according to the loss function so that the sample similarities of the audio and video data are close to each other in the feature space to obtain feature data.
[0090] Step S2 of the embodiment of the present application is specifically as follows:
[0091] The audio data and video data in the audio and video data are respectively input into the twin sub-network of the twin network to generate positive sample pairs L1 and negative sample pairs L2; wherein the twin sub-networks share the same weights; the positive sample pair L1 represents similar samples, and the negative sample pair L2 represents dissimilar samples;
[0092] Perform feature extraction on the positive sample pair and the negative sample pair to obtain the positive sample pair feature vector v1 and the negative sample pair feature vector v2;
[0093] Make the sample similarity between the feature vector v1 of the positive sample pair and the feature vector v2 of the negative sample pair close to each other in the feature space, make the dissimilar sample pairs farther away, and use gradient descent or a preset optimization algorithm to minimize the loss function, and then adjust the network of the twin network to better distinguish the positive sample pair L1 and the negative sample pair L2, and obtain feature data; wherein, the sample similarity can be expressed by cosine similarity or Euclidean distance;
[0094] Among them, the feature vector of the positive sample pair is:
[0095] v1=f(L1)v2=f(L2)
[0096] The loss function is:
[0097]
[0098] The cosine similarity is:
[0099]
[0100] The Euclidean distance is:
[0101] d(v1,v2)=∥v1-v2∥2
[0102] Among them, f in f(L1) and f(L2) represents the parameterization function of the sub-network, which is composed of a series of convolutional layers, pooling layers and activation functions. The specific number of convolutional layers needs to be determined based on the model verification feedback. The activation function here is Relu.
[0103] y is a binary label, which takes the value of 0 or 1; v1 is the feature vector of the positive sample pair, v2 is the feature vector of the negative sample pair, and m is the boundary interval.
[0104] In the present embodiment S2, since the twin networks have the same structure and share weights, they can process different input data in the same way and extract feature information useful for distinguishing positive and negative sample pairs, so the obtained positive sample pair feature vectors and negative sample pair feature vectors can reflect the essential properties and mutual relationships of the input data. The network parameters of the twin network are adjusted through the loss function, so that the distance between the feature vectors of the positive sample pair in the feature space is close to each other, that is, the similarity increases; while the distance between the feature vectors of the negative sample pair is relatively far, that is, the similarity decreases; this learning method enables the twin network to learn and extract useful feature data, which is conducive to the accurate classification and recognition of audio and video data.
[0105] S3. Perform causal convolution processing on the audio and video data to obtain time series data.
[0106] Step S3 of the embodiment of the present application is specifically as follows:
[0107] Input the audio and video data into the TCN model; TCN is a convolutional neural network suitable for time series data, which captures temporal dynamics by applying convolution operations on the time dimension;
[0108] The audio and video data is processed layer by layer through the causal convolution layer of the TCN model, and the time embedding vector is used to give the audio and video data a time series label. The time embedding vector is combined with the convolution operation of the TCN model to predict future data points, and the time series characteristics of the audio and video data are obtained.
[0109] Among them, the causal convolution formula used by the causal convolution layer layer by layer is:
[0110] o t =f(TCN,i t ,i t-1 ,...,i t-k+1 )
[0111] The time embedding vector is:
[0112] i t ′ =i t +e t
[0113] For parameter e t have:
[0114] e t =Embedding(t)
[0115] Among them, t is the output at time t, i t is the input at time t, k is the overall time length covered by the convolution kernel, and f is the convolution function; Embedding(t) means converting discrete data (such as words, characters, category labels, etc.) into a continuous, dense vector representation.
[0116] In this embodiment S3, the causal convolution layer ensures that at any time point, the output of the model depends only on the input data at that time point and before. Therefore, by stacking the causal convolution layer, the TCN model can gradually increase the perception, thereby effectively capturing the local dependencies in the audio and video data. In addition, by combining the time embedding vector with the original audio and video data, the TCN model can learn richer time series features, thereby showing better performance when predicting future data points, ensuring the effectiveness of the time series features.
[0117] S4. Generate paired twin data based on feature data and time series data, and obtain actual scene information of the audio and video data by capturing global context information at each position of the paired twin data.
[0118] Step S4 of the embodiment of the present application is specifically as follows:
[0119] Generate paired twin data based on feature data and time series data;
[0120] Input paired twin data into the Transformer model;
[0121] Through the multi-layer self-attention mechanism of the Transformer model, the first element in the paired twin data is transformed into a query vector, a key vector, and a value vector;
[0122] Calculate the dot product between the query vector and the key vector to obtain the similarity matrix between the first element and other elements in the paired twin data;
[0123] Using the similarity matrix as the weight, perform weighted summation on the value vector to obtain the output representation of the position corresponding to the first element;
[0124] Traverse the elements in the twin data, and combine the preset optimizer strategy and feedback tuning strategy to obtain the actual scene information of the audio and video data composed of several output representations;
[0125] Among them, the formula of the multi-layer self-attention mechanism is:
[0126]
[0127] Among them, Q, K and V are the matrices of query vector, key vector and value vector respectively; d k is the dimension of the key vector, and this operation calculates the attention weights of each element in the sequence for all other elements and performs a weighted sum operation on the value vector V according to these weights.
[0128] Among them, the optimizer strategy is to construct a cross entropy loss function, then verify the data reconstruction loss, and then use the AdamW (Adam with Weight Decay) optimizer to optimize and update the parameters of the entire model;
[0129] In addition, the optimizer strategy can also be implemented through multi-task learning optimization combined with data enhancement strategy, specifically:
[0130] Introducing a multi-task learning framework into the Transformer model, enabling the Transformer model to simultaneously learn classification tasks, detection tasks, and prediction tasks for audio, video, and time series;
[0131] Establish a shared representation layer in the Transformer model based on time sequence, so that the preset specific layers of different data tasks can capture the features related to the preset tasks, that is, optimize the preset specific layers of different data tasks;
[0132] In the process of data input, elastic deformation of time series and audio noise injection are added, the number of video frame rate cuts is increased, etc., so as to increase the robustness of the model to data changes by increasing the dimension and quantity of data input.
[0133] Among them, the feedback tuning strategy is specifically as follows:
[0134] Use the positive feedback of the Transformer model training results to verify the feasibility of the Transformer model, and control the negative feedback of the Transformer model training results to tune the Transformer model with the help of the optimizer strategy.
[0135] To apply the embodiments of this application, please refer to Figure 2 , Figure 2 It is a model training and optimization flowchart provided in an embodiment of the present application, which represents the general process of generating actual scene information.
[0136] In this embodiment S4, by calculating the similarity matrix, it can provide the Transformer model with a quantitative index of the interaction between elements, so that the model can distinguish which elements are important to the current element and which are not. The similarity matrix is used as a weight to perform a weighted summation on the value vector to obtain the output representation of the position corresponding to the first element. This process is actually a new representation of the first element based on the integration of all relevant information. The result of the weighted summation is a vector representation that takes global information into account. It contains the complex relationship between the first element and other elements. This representation method helps the model to more accurately understand the actual scene information in the audio and video data;
[0137] Moreover, for the optimizer strategy, multi-task learning allows the Transformer model to share knowledge between different tasks, which means that when the model learns different tasks such as audio, video and time series, it can use the knowledge learned from one task to help improve the learning of another task. This cross-task knowledge transfer helps the model learn more generalized and robust feature representations, improves the generalization ability and training efficiency of the model, and can effectively avoid the model's feature loss and gradient vanishing phenomenon. Through the shared representation layer, different data tasks can share and learn each other's temporal features and patterns. This sharing mechanism promotes cross-task knowledge transfer, allowing the model to make better use of data and information from different tasks; and the shared representation layer encourages the model to learn more generalized and generalized temporal features, rather than being limited to specific tasks, which helps the model show stronger adaptability and generalization when dealing with new or unseen tasks.
[0138] S5. Control the audio and video equipment to switch scenes according to the actual scene information.
[0139] Step S5 of the embodiment of the present application is specifically as follows:
[0140] The actual scene information is transmitted to the preset server, and the debugging strategy of subsequent audio and video equipment is analyzed by the server;
[0141] The audio and video equipment remote operation module controls the audio and video equipment to switch scenes according to the debugging strategy parsed by the server, and in this process allows the user to perform real-time calibration according to the current scene;
[0142] Get the user's positive and negative feedback about the current scene switch, and return the user's positive and negative feedback to the server and Transformer model. If it is positive feedback, record the operation and continue to execute according to the debugging strategy. If it is negative feedback, return to the Transformer model for secondary training and adjustment to obtain a more accurate debugging strategy.
[0143] To apply the embodiments of this application, please refer to Figure 3 , Figure 3 This is a practical operation flow chart provided by an embodiment of the present application, which shows the general process of controlling audio and video equipment, specifically:
[0144] Acquire initial audio and video data in a real-time actual scene where the audio and video equipment is located, and pre-process the initial audio and video data to obtain audio and video data;
[0145] The audio and video data are translated and processed through the twin network and TCN model to obtain paired twin data;
[0146] Use the Transformer model to predict the actual scene of the paired twin data and obtain the actual scene information;
[0147] Based on the actual scene information, use the server to generate debugging strategies for audio and video equipment;
[0148] According to the debugging strategy, the audio and video equipment is controlled by the audio and video equipment remote operation module to switch scenes;
[0149] The user's positive and negative feedback on the current scene switch is returned to the server and Transformer model. If it is positive feedback, the operation is recorded and continued to be executed according to the strategy. If it is negative feedback, it is returned to the Transformer model for secondary training and adjustment.
[0150] Overall, this embodiment has the following beneficial effects:
[0151] The present invention adjusts the network of the twin network according to the loss function, so that the sample similarities of the audio and video data are close to each other in the feature space, which helps to better capture the intrinsic characteristics of the audio and video data; and the adjusted twin network can generate more distinguishing and representative feature data, which are crucial for subsequent audio and video processing tasks. The causal convolution layer ensures that at any point in time, the output of the model only depends on the input data at that time point and before. Therefore, by stacking the causal convolution layer, the obtained time series data can effectively reflect the local dependencies in the audio and video data. By capturing global contextual information at various positions in paired twin data, the association and dependency between audio and video data can be established, so as to more accurately understand the actual scene. This global perspective helps to consider not only the characteristics of the current scene when making scene predictions, but also the historical scenes and possible future changes. Trends, thereby ensuring the prediction accuracy and flexibility of the actual scene information, and achieving accurate switching of scenes.
[0152] In addition, the present invention can ensure the validity of paired twin data by amplifying the feature representation of paired audio and video data to obtain feature data, and by amplifying the time series granularity to obtain time series data; and then capture global dependencies through a preset mechanism to enhance the learning, understanding and prediction capabilities of the scene, thereby ensuring the accuracy and flexibility of the prediction of actual scene information, thereby solving the problem of difficulty in flexibly predicting audio and video scenes to achieve accurate scene switching.
[0153] Embodiment 2:
[0154] See also Figure 4 , the embodiment of the present application provides an audio and video scene collaboration device based on a twin network, including a data module 10, a feature module 20, a timing module 30, a scene module 40 and a control module 50;
[0155] Wherein, the data module 10 is used to obtain audio and video data through audio and video equipment;
[0156] A feature module 20 is used to adjust the network of the twin network according to the loss function so that the sample similarities of the audio and video data are close to each other in the feature space to obtain feature data;
[0157] A timing module 30, for performing causal convolution processing on the audio and video data to obtain timing data;
[0158] A scene module 40 is used to generate paired twin data based on feature data and time series data, and obtain actual scene information of audio and video data by capturing global context information at various positions of the paired twin data;
[0159] The control module 50 is used to control the audio and video equipment to switch scenes according to the actual scene information.
[0160] In one embodiment, the data module 10 includes a data unit, a labeling unit, a matrix unit, and a definition unit;
[0161] The data unit is used to obtain initial audio and video data through high-quality audio and video capture equipment in the environment where the audio and video equipment is located, and ensure the clarity and stability of the data; the initial audio and video data includes audio data and video data, and the audio data includes audio signals, voices, music, and environmental sounds, etc.; the video data includes scene visual information, such as color, motion, and behavior;
[0162] A labeling unit, used to classify and label different scenes in the initial audio and video data, and to detect and label occurrence nodes of preset specific events in the initial audio and video data to obtain labeling data;
[0163] The matrix unit is used to remove noise from the annotated data, specifically: deleting the meaningless noise pre-defined in the annotated data, and deleting the sound and image that are invalid for the scene;
[0164] The matrix unit is also used to two-dimensionally matrix the audio data in the annotated data, and perform RGB grayscale processing on the video data in the annotated data and generate corresponding standardized matrix data to obtain paired two-dimensional matrix data; and in the process of data processing, the frame rate of the data needs to be adjusted to avoid excessive frame rate that will generate too much repeated data, thereby causing overfitting of the model;
[0165] A definition unit is used to define paired two-dimensional matrix data as audio and video data.
[0166] The data module 10 of this embodiment classifies and annotates different scenes in the initial audio and video data, and annotates the occurrence nodes of preset specific events, so that the data has structured information, which is convenient for computer understanding and processing, and provides supervision signals for subsequent model training. In addition, the converted paired two-dimensional matrix data reduces the data complexity during model processing, so that the subsequent model can process audio and video data more efficiently; at the same time, since the data has been preprocessed and standardized, the subsequent data training process will also be more stable and faster.
[0167] In one embodiment, the feature module 20 includes a sample unit, a vector unit, and a feature unit;
[0168] The sample unit is used to input the audio data and the video data in the audio and video data into the twin sub-network of the twin network respectively, to generate a positive sample pair L1 and a negative sample pair L2; wherein the twin sub-networks share the same weight; the positive sample pair L1 represents similar samples, and the negative sample pair L2 represents dissimilar samples;
[0169] The vector unit is used to extract features from the positive sample pair and the negative sample pair to obtain the feature vector v1 of the positive sample pair and the feature vector v2 of the negative sample pair;
[0170] The feature unit is used to make the sample similarities between the feature vector v1 of the positive sample pair and the feature vector v2 of the negative sample pair close to each other in the feature space, and make the dissimilar sample pairs farther away, and use gradient descent or a preset optimization algorithm to minimize the loss function, thereby adjusting the network of the twin network to better distinguish the positive sample pair L1 and the negative sample pair L2, and obtain feature data; wherein the sample similarity can be represented by cosine similarity or Euclidean distance;
[0171] Among them, the feature vector of the positive sample pair is:
[0172] v1=f(L1)v2=f(L2)
[0173] The loss function is:
[0174]
[0175] The cosine similarity is:
[0176]
[0177] The Euclidean distance is:
[0178] d(v1,v2)=∥v1-v2∥2
[0179] Among them, f in f(L1) and f(L2) represents the parameterization function of the sub-network, which is composed of a series of convolutional layers, pooling layers and activation functions. The specific number of convolutional layers needs to be determined based on the model verification feedback. The activation function here is Relu.
[0180] y is a binary label, which takes the value of 0 or 1; v1 is the feature vector of the positive sample pair, v2 is the feature vector of the negative sample pair, and m is the boundary interval.
[0181] In the feature module 20 of this embodiment, since the twin networks have the same structure and share weights, they can process different input data in the same way and extract feature information useful for distinguishing positive and negative sample pairs, so the obtained positive sample pair feature vectors and negative sample pair feature vectors can reflect the essential properties and relationships of the input data. The network parameters of the twin network are adjusted through the loss function so that the distance between the feature vectors of the positive sample pair in the feature space is close to each other, that is, the similarity increases; while the distance between the feature vectors of the negative sample pair is relatively far, that is, the similarity decreases; this learning method enables the twin network to learn and extract useful feature data, which is conducive to the accurate classification and recognition of audio and video data.
[0182] In one embodiment, the timing module 30 includes a first input unit and a timing unit;
[0183] The first input unit is used to input audio and video data into the TCN model; wherein TCN is a convolutional neural network suitable for time series data, which captures time dynamics by applying convolution operations on the time dimension;
[0184] The timing unit is used to process the audio and video data layer by layer through the causal convolution layer of the TCN model, and use the time embedding vector to give the audio and video data a time series label, and combine the time embedding vector with the convolution operation of the TCN model to predict future data points to obtain the time series features of the audio and video data;
[0185] Among them, the causal convolution formula used by the causal convolution layer layer by layer is:
[0186] o t =f(TCN,i t ,i t-1 ,...,i t-k+1 )
[0187] The time embedding vector is:
[0188] i′ t =i t +e t
[0189] For parameter e t have:
[0190] e t =Embedding(t)
[0191] Among them, t is the output at time t, i t is the input at time t, k is the overall time length covered by the convolution kernel, and f is the convolution function; Embedding(t) means converting discrete data (such as words, characters, category labels, etc.) into a continuous, dense vector representation.
[0192] In the timing module 30 of this embodiment, the causal convolution layer ensures that at any time point, the output of the model depends only on the input data at that time point and before. Therefore, by stacking the causal convolution layer, the TCN model can gradually increase the perception, thereby effectively capturing the local dependencies in the audio and video data. In addition, by combining the time embedding vector with the original audio and video data, the TCN model can learn richer timing features, thereby showing better performance when predicting future data points, ensuring the effectiveness of the timing features.
[0193] In one embodiment, the scene module 40 includes a second input unit, a conversion unit, a similarity unit, a representation unit, and an information unit;
[0194] Wherein, the second input unit is used to generate paired twin data according to the feature data and the time series data;
[0195] The second input unit is also used to input paired twin data into the Transformer model;
[0196] The conversion unit is used to convert the first element in the paired twin data into a query vector, a key vector, and a value vector through the multi-layer self-attention mechanism of the Transformer model;
[0197] The similarity unit is used to calculate the dot product between the query vector and the key vector to obtain the similarity matrix between the first element and other elements in the paired twin data;
[0198] A representation unit, used to perform weighted summation on the value vector using the similarity matrix as a weight, to obtain an output representation of the position corresponding to the first element;
[0199] The information unit is used to traverse the elements in the twin data and obtain the actual scene information of the audio and video data composed of several output representations in combination with the preset optimizer strategy and feedback tuning strategy;
[0200] Among them, the formula of the multi-layer self-attention mechanism is:
[0201]
[0202] Among them, Q, K and V are the matrices of query vector, key vector and value vector respectively; d k is the dimension of the key vector, and this operation calculates the attention weights of each element in the sequence for all other elements and performs a weighted sum operation on the value vector V according to these weights.
[0203] Among them, the optimizer strategy is to construct a cross entropy loss function, then verify the data reconstruction loss, and then use the AdamW (Adam with Weight Decay) optimizer to optimize and update the parameters of the entire model;
[0204] In addition, the optimizer strategy can also be implemented through multi-task learning optimization combined with data enhancement strategy, specifically:
[0205] Introducing a multi-task learning framework into the Transformer model, enabling the Transformer model to simultaneously learn classification tasks, detection tasks, and prediction tasks for audio, video, and time series;
[0206] Establish a shared representation layer in the Transformer model based on time sequence, so that the preset specific layers of different data tasks can capture the features related to the preset tasks, that is, optimize the preset specific layers of different data tasks;
[0207] In the process of data input, elastic deformation of time series and audio noise injection are added, the number of video frame rate cuts is increased, etc., so as to increase the robustness of the model to data changes by increasing the dimension and quantity of data input.
[0208] Among them, the feedback tuning strategy is specifically as follows:
[0209] Use the positive feedback of the Transformer model training results to verify the feasibility of the Transformer model, and control the negative feedback of the Transformer model training results to tune the Transformer model with the help of the optimizer strategy.
[0210] To apply the embodiments of this application, please refer to Figure 2 , Figure 2 It is a model training and optimization flowchart provided in an embodiment of the present application, which represents the general process of generating actual scene information.
[0211] The scene module 40 of this embodiment calculates the similarity matrix, which can provide the Transformer model with a quantitative index of the interaction between elements, so that the model can distinguish which elements are important to the current element and which are not. The similarity matrix is used as a weight to perform a weighted summation on the value vector to obtain the output representation of the position corresponding to the first element. This process is actually a new representation of the first element based on the integration of all relevant information. The result of the weighted summation is a vector representation that takes global information into account, which contains the complex relationship between the first element and other elements. This representation method helps the model to more accurately understand the actual scene information in the audio and video data;
[0212] Moreover, for the optimizer strategy, multi-task learning allows the Transformer model to share knowledge between different tasks, which means that when the model learns different tasks such as audio, video and time series, it can use the knowledge learned from one task to help improve the learning of another task. This cross-task knowledge transfer helps the model learn more generalized and robust feature representations, improves the generalization ability and training efficiency of the model, and can effectively avoid the model's feature loss and gradient vanishing phenomenon. Through the shared representation layer, different data tasks can share and learn each other's temporal features and patterns. This sharing mechanism promotes cross-task knowledge transfer, allowing the model to make better use of data and information from different tasks; and the shared representation layer encourages the model to learn more generalized and generalized temporal features, rather than being limited to specific tasks, which helps the model show stronger adaptability and generalization when dealing with new or unseen tasks.
[0213] In one embodiment, the control module 50 is specifically:
[0214] The actual scene information is transmitted to the preset server, and the debugging strategy of subsequent audio and video equipment is analyzed by the server;
[0215] The audio and video equipment remote operation module controls the audio and video equipment to switch scenes according to the debugging strategy parsed by the server, and in this process allows the user to perform real-time calibration according to the current scene;
[0216] Get the user's positive and negative feedback about the current scene switch, and return the user's positive and negative feedback to the server and Transformer model. If it is positive feedback, record the operation and continue to execute according to the debugging strategy. If it is negative feedback, return to the Transformer model for secondary training and adjustment to obtain a more accurate debugging strategy.
[0217] To apply the embodiments of this application, please refer to Figure 3 , Figure 3 This is a practical operation flow chart provided by an embodiment of the present application, which shows the general process of controlling audio and video equipment, specifically:
[0218] Acquire initial audio and video data in a real-time actual scene where the audio and video equipment is located, and pre-process the initial audio and video data to obtain audio and video data;
[0219] The audio and video data are translated and processed through the twin network and TCN model to obtain paired twin data;
[0220] Use the Transformer model to predict the actual scene of the paired twin data and obtain the actual scene information;
[0221] Based on the actual scene information, use the server to generate debugging strategies for audio and video equipment;
[0222] According to the debugging strategy, the audio and video equipment is controlled by the audio and video equipment remote operation module to switch scenes;
[0223] The user's positive and negative feedback on the current scene switch is returned to the server and Transformer model. If it is positive feedback, the operation is recorded and continued to be executed according to the strategy. If it is negative feedback, it is returned to the Transformer model for secondary training and adjustment.
[0224] Overall, this embodiment has the following beneficial effects:
[0225] The present invention adjusts the network of the twin network according to the loss function, so that the sample similarities of the audio and video data are close to each other in the feature space, which helps to better capture the intrinsic characteristics of the audio and video data; and the adjusted twin network can generate more distinguishing and representative feature data, which are crucial for subsequent audio and video processing tasks. The causal convolution layer ensures that at any point in time, the output of the model only depends on the input data at that time point and before. Therefore, by stacking the causal convolution layer, the obtained time series data can effectively reflect the local dependencies in the audio and video data. By capturing global contextual information at various positions in paired twin data, the association and dependency between audio and video data can be established, so as to more accurately understand the actual scene. This global perspective helps to consider not only the characteristics of the current scene when making scene predictions, but also the historical scenes and possible future changes. Trends, thereby ensuring the prediction accuracy and flexibility of the actual scene information, and achieving accurate switching of scenes.
[0226] In addition, the present invention can ensure the validity of paired twin data by amplifying the feature representation of paired audio and video data to obtain feature data, and by amplifying the time series granularity to obtain time series data; and then capture global dependencies through a preset mechanism to enhance the learning, understanding and prediction capabilities of the scene, thereby ensuring the accuracy and flexibility of the prediction of actual scene information, thereby solving the problem of difficulty in flexibly predicting audio and video scenes to achieve accurate scene switching.
[0227] Embodiment three:
[0228] An embodiment of the present application provides a computer-readable storage medium, the computer-readable storage medium including a stored computer program, wherein when the computer program is running, the device where the computer-readable storage medium is located is controlled to execute the audio and video scene collaboration method based on a twin network;
[0229] Among them, the audio and video scene collaboration method based on the twin network, if implemented in the form of a software functional unit and used as an independent product, can be stored in a computer-readable storage medium. Based on this understanding, the present invention implements all or part of the process in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electrical carrier signal, telecommunication signal and software distribution medium, etc.
[0230] The above are preferred embodiments of the present invention. It should be noted that, for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications are also considered to be within the scope of protection of the present invention.
Claims
1. A method for audio and video scene collaboration based on twin networks, characterized in that: include: Acquire audio and video data of the environment where the audio and video equipment is located; Adjusting the network of the twin network according to the loss function so that the sample similarities of the audio and video data are close to each other in the feature space, thereby obtaining feature data; Performing causal convolution processing on the audio and video data to obtain time series data; Generate paired twin data according to the feature data and the time series data, and obtain actual scene information of the audio and video data by capturing global context information at each position of the paired twin data; The audio and video equipment is controlled to perform scene switching according to the actual scene information.
2. The audio and video scene collaboration method based on a twin network as claimed in claim 1, characterized in that: Get the audio and video data of the environment where the audio and video equipment is located, specifically: Acquire initial audio and video data of the environment where the audio and video equipment is located; wherein the initial audio and video data includes audio data and video data; Classify and annotate different scenes in the initial audio and video data, and detect and annotate occurrence nodes of preset events in the initial audio and video data to obtain annotated data; The audio data in the labeled data is two-dimensionally matrixed, and corresponding standardized matrix data is generated according to the video data in the labeled data to obtain paired two-dimensional matrix data; The paired two-dimensional matrix data is defined as the audio and video data.
3. The audio and video scene collaboration method based on twin network as claimed in claim 1, characterized in that: The network of the twin network is adjusted according to the loss function so that the sample similarities of the audio and video data are close to each other in the feature space, and feature data is obtained, specifically: Inputting the audio and video data into the twin sub-network of the twin network to generate positive sample pairs and negative sample pairs; Extracting features from the positive sample pair and the negative sample pair to obtain a feature vector for the positive sample pair and a feature vector for the negative sample pair; The network of the twin network is adjusted by the loss function so that the sample similarities between the feature vectors of the positive sample pair and the feature vectors of the negative sample pair are close to each other in the feature space, thereby obtaining the feature data.
4. The audio and video scene collaboration method based on twin network as claimed in claim 3 is characterized in that: The loss function is specifically: Among them, y is a binary label, taking the value of 0 or 1; v1 is the feature vector of the positive sample pair, v2 is the feature vector of the negative sample pair, and m is the boundary interval.
5. The audio and video scene collaboration method based on a twin network as claimed in claim 1, characterized in that: The audio and video data are subjected to causal convolution processing to obtain time series data, specifically: Input the audio and video data into the TCN model; The audio and video data are processed layer by layer through the causal convolution layer of the TCN model, and a time embedding vector is used to give a time series label to the audio and video data. The time embedding vector is combined with the convolution operation of the TCN model to predict future data points to obtain the time series features of the audio and video data.
6. The audio and video scene collaboration method based on twin network according to claim 1, characterized in that: By capturing global context information at each position of the paired twin data, the actual scene information of the audio and video data is obtained, specifically: Input the paired twin data into the Transformer model; Transforming the first element in the paired twin data into a query vector, a key vector, and a value vector through a multi-layer self-attention mechanism of the Transformer model; Calculate the dot product between the query vector and the key vector to obtain a similarity matrix between the first element and other elements in the paired twin data; Using the similarity matrix as a weight, performing weighted summation on the value vector to obtain an output representation of a position corresponding to the first element; The elements in the twin data are traversed, and combined with a preset optimizer strategy, actual scene information of the audio and video data composed of several output representations is obtained.
7. The audio and video scene collaboration method based on twin network as claimed in claim 6, characterized in that: The optimizer strategy is specifically: Introducing a multi-task learning framework into the Transformer model, so that the Transformer model can simultaneously learn preset tasks about audio, video and timing; A shared representation layer is established in the Transformer model based on time sequence, so that the preset layers of different data tasks can capture features related to the preset tasks.
8. An audio and video scene collaboration device based on a twin network, characterized in that: Includes data module, feature module, timing module, scenario module and control module; Wherein, the data module is used to obtain audio and video data of the environment where the audio and video equipment is located; The feature module is used to adjust the network of the twin network according to the loss function so that the sample similarities of the audio and video data are close to each other in the feature space to obtain feature data; The timing module is used to perform causal convolution processing on the audio and video data to obtain timing data; The scene module is used to generate paired twin data according to the feature data and the time series data, and obtain actual scene information of the audio and video data by capturing global context information at each position of the paired twin data; The control module is used to control the audio and video equipment to switch scenes according to the actual scene information.
9. The audio and video scene collaboration device based on twin network as claimed in claim 8, characterized in that: The data module includes a data unit, a labeling unit, a matrix unit and a definition unit; Wherein, the data unit is used to obtain the initial audio and video data of the environment where the audio and video equipment is located; wherein the initial audio and video data includes audio data and video data; The labeling unit is used to classify and label different scenes in the initial audio and video data, and detect and label the occurrence nodes of preset events in the initial audio and video data to obtain labeling data; The matrix unit is used to two-dimensionally matrix the audio data in the annotated data, and generate corresponding standardized matrix data according to the video data in the annotated data to obtain paired two-dimensional matrix data; The definition unit is used to define the paired two-dimensional matrix data as the audio and video data.
10. A storage medium, characterized in that: The storage medium stores a computer program, which is called and executed by a computer to implement an audio and video scene collaboration method based on a twin network as described in any one of claims 1 to 7 above.
Citation Information
Cited By
Green construction decision-making method for railway tunnel in mountainous area based on CBR
CN120910119A
A CBR-based green construction decision method for mountain railway tunnels
CN120910119B
