Identification methods, model training, systems and equipment
By using the attention mechanism in the neural network model to weight the video frame features, the problem of low video recognition accuracy in the existing technology is solved and higher recognition accuracy is achieved.
Patent Information
- Application Number
- CN201910963072.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-10-11
- Publication Date
- 2024-09-27
- Estimated Expiration
- 2039-10-11
AI Technical Summary
In the existing technology, video recognition methods based on neural network models have the problem of low recognition accuracy, and there is noise interference in the feature extraction process, which affects the recognition efficiency.
By introducing the attention mechanism into the neural network model, the attention weight in the video frame features is extracted, and the frame features are weighted to suppress noise, enhance effective features, and improve recognition accuracy.
It effectively suppresses noise in frame features, enhances the accuracy of video recognition, and improves the accuracy of time series data and data recognition.
Smart Images

Figure CN112651267B
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a recognition method, model training, system and device. Background Art
[0002] Currently, many terminal devices have the functions of taking pictures, shooting and / or recording. In some application scenarios, it is necessary to identify the pictures, videos and / or audio data taken by the terminal device, for example, to classify the pictures, videos or audio.
[0003] Taking a smart surveillance camera as an example, a user can set up the smart surveillance camera at home to realize the function of guarding the house or capturing the wonderful moments of pets. The amount of data of the video or picture taken by the smart surveillance camera is very huge, so it is necessary to analyze the video or image taken by the smart surveillance camera and filter out the data that the user is not interested in.
[0004] In the prior art, there are technical solutions that use artificial intelligence algorithms (such as neural network models) to recognize pictures, videos or audios, but the recognition accuracy of these algorithms is relatively poor. Summary of the invention
[0005] In view of the above problems, the present application is proposed to provide an identification method, model training, system and device that solve the above problems or at least partially solve the above problems.
[0006] Therefore, in one embodiment of the present application, a video recognition method is provided. The method comprises:
[0007] Acquire a video to be identified; wherein the video to be identified includes multiple frames of images;
[0008] Inputting the video to be recognized into a trained neural network model to obtain a recognition result;
[0009] Among them, the neural network model is used to: extract features from the multiple frame images respectively to obtain multiple frame features; determine the attention weight corresponding to each element in the multiple frame features based on the multiple frame features; multiply each element in the multiple frame features by its corresponding attention weight to obtain multiple weighted frame features; and combine the multiple weighted frame features to obtain the recognition result.
[0010] In another embodiment of the present application, a model training method is provided. The method comprises:
[0011] Acquire a sample video; wherein the sample video includes multiple frames of images;
[0012] Inputting the sample video into a neural network model to obtain a prediction recognition result;
[0013] Optimizing parameters of the neural network model according to the predicted recognition result and the expected recognition result corresponding to the sample video;
[0014] Among them, the neural network model is used to: extract features from the multiple frame images respectively to obtain multiple frame features; determine the attention weight corresponding to each element in the multiple frame features based on the multiple frame features; multiply each element in the multiple frame features by its corresponding attention weight to obtain multiple weighted frame features; and combine the multiple weighted frame features to obtain the predicted recognition result.
[0015] In another embodiment of the present application, a neural network system is provided. The system comprises: at least one first network layer, at least one second network layer and at least one third network layer; wherein:
[0016] The at least one first network layer is used to extract features from multiple frames of the video to be identified, respectively, to obtain multiple frame features;
[0017] The at least one second network layer is used to determine, based on the multiple frame features, an attention weight corresponding to each element in the multiple frame features; and is also used to multiply each element in the multiple frame features by its corresponding attention weight to obtain a plurality of weighted frame features;
[0018] The at least one third network layer is used to integrate the multiple weighted frame features to obtain a recognition result.
[0019] In another embodiment of the present application, a time series data identification method is provided. The method comprises:
[0020] Acquire time series data to be identified; wherein the time series data to be identified includes multiple frames of data;
[0021] Inputting the time series data to be identified into a trained neural network model to obtain a recognition result;
[0022] Among them, the neural network model is used to: extract features from the multiple frames of data respectively to obtain multiple frame features; determine the attention weight corresponding to each element in the multiple frame features based on the multiple frame features; multiply each element in the multiple frame features by its corresponding attention weight to obtain multiple weighted frame features; and combine the multiple weighted frame features to obtain the recognition result.
[0023] In another embodiment of the present application, a time series data identification method is provided. The method comprises:
[0024] Feature extraction is performed on multiple frames of time series data to be identified respectively to obtain multiple frame features;
[0025] Determining, according to the multiple frame features, an attention weight corresponding to each element in the multiple frame features;
[0026] Multiplying each element in the plurality of frame features by its corresponding attention weight to obtain a plurality of weighted frame features;
[0027] The multiple weighted frame features are combined to obtain a recognition result.
[0028] In another embodiment of the present application, a data identification method is provided. The method comprises:
[0029] Obtaining data to be identified;
[0030] Inputting the data to be identified into a trained neural network model to obtain a recognition result;
[0031] Among them, the neural network model is used to: extract features of the data to be identified to obtain data features; determine the attention weights corresponding to each element in the data features based on the data features; multiply each element in the data features by its corresponding attention weight to obtain weighted data features; and obtain the recognition result based on the weighted data features.
[0032] In another embodiment of the present application, a data identification method is provided. The method comprises:
[0033] Extract features from the data to be identified to obtain data features;
[0034] According to the data feature, determining the attention weight corresponding to each element in the data feature;
[0035] Multiply each element in the data feature by its corresponding attention weight to obtain a weighted data feature;
[0036] The recognition result is obtained according to the weighted data features.
[0037] In one embodiment of the present application, an electronic device is provided. The electronic device includes: a memory and a processor, wherein:
[0038] The memory is used to store programs;
[0039] The processor is coupled to the memory and is configured to execute the program stored in the memory to:
[0040] Acquire a video to be identified; wherein the video to be identified includes multiple frames of images;
[0041] Inputting the video to be recognized into a trained neural network model to obtain a recognition result;
[0042] Among them, the neural network model is used to: extract features from the multiple frame images respectively to obtain multiple frame features; determine the attention weight corresponding to each element in the multiple frame features based on the multiple frame features; multiply each element in the multiple frame features by its corresponding attention weight to obtain multiple weighted frame features; and combine the multiple weighted frame features to obtain the recognition result.
[0043] In another embodiment of the present application, an electronic device is provided. The electronic device includes: a memory and a processor, wherein:
[0044] The memory is used to store programs;
[0045] The processor is coupled to the memory and is configured to execute the program stored in the memory to:
[0046] Acquire a sample video; wherein the sample video includes multiple frames of images;
[0047] Inputting the sample video into a neural network model to obtain a prediction recognition result;
[0048] Optimizing parameters of the neural network model according to the predicted recognition result and the expected recognition result corresponding to the sample video;
[0049] Among them, the neural network model is used to: extract features from the multiple frame images respectively to obtain multiple frame features; determine the attention weight corresponding to each element in the multiple frame features based on the multiple frame features; multiply each element in the multiple frame features by its corresponding attention weight to obtain multiple weighted frame features; and combine the multiple weighted frame features to obtain the predicted recognition result.
[0050] In another embodiment of the present application, an electronic device is provided. The electronic device includes: a memory and a processor, wherein:
[0051] The memory is used to store programs;
[0052] The processor is coupled to the memory and is configured to execute the program stored in the memory to:
[0053] Acquire time series data to be identified; wherein the time series data to be identified includes multiple frames of data;
[0054] Inputting the time series data to be identified into a trained neural network model to obtain a recognition result;
[0055] Among them, the neural network model is used to: extract features from the multiple frames of data respectively to obtain multiple frame features; determine the attention weight corresponding to each element in the multiple frame features based on the multiple frame features; multiply each element in the multiple frame features by its corresponding attention weight to obtain multiple weighted frame features; and combine the multiple weighted frame features to obtain the recognition result.
[0056] In another embodiment of the present application, an electronic device is provided. The electronic device includes: a memory and a processor, wherein:
[0057] The memory is used to store programs;
[0058] The processor is coupled to the memory and is configured to execute the program stored in the memory to:
[0059] Feature extraction is performed on multiple frames of time series data to be identified respectively to obtain multiple frame features;
[0060] Determining, according to the multiple frame features, an attention weight corresponding to each element in the multiple frame features;
[0061] Multiplying each element in the plurality of frame features by its corresponding attention weight to obtain a plurality of weighted frame features;
[0062] The multiple weighted frame features are combined to obtain a recognition result.
[0063] In another embodiment of the present application, an electronic device is provided. The electronic device includes: a memory and a processor, wherein:
[0064] The memory is used to store programs;
[0065] The processor is coupled to the memory and is configured to execute the program stored in the memory to:
[0066] Obtaining data to be identified;
[0067] Inputting the data to be identified into a trained neural network model to obtain a recognition result;
[0068] Among them, the neural network model is used to: extract features of the data to be identified to obtain data features; determine the attention weights corresponding to each element in the data features based on the data features; multiply each element in the data features by its corresponding attention weight to obtain weighted data features; and obtain the recognition result based on the weighted data features.
[0069] In another embodiment of the present application, an electronic device is provided. The electronic device includes: a memory and a processor, wherein:
[0070] The memory is used to store programs;
[0071] The processor is coupled to the memory and is configured to execute the program stored in the memory to:
[0072] Extract features from the data to be identified to obtain data features;
[0073] According to the data feature, determining the attention weight corresponding to each element in the data feature;
[0074] Multiply each element in the data feature by its corresponding attention weight to obtain a weighted data feature;
[0075] The recognition result is obtained according to the weighted data features.
[0076] In the technical solution provided by the embodiment of the present application, the attention weight corresponding to each element in the multiple frame features of the video to be identified is obtained through the attention mechanism, and each element in the multiple frame features is weighted to obtain multiple weighted frame features. In this way, the noise in the multiple frame features can be effectively suppressed, the effective features can be enhanced, and the accuracy of video recognition can be effectively improved.
[0077] In the technical solution provided by the embodiment of the present application, the attention weight corresponding to each element in the multiple frame features of the time series data to be identified is obtained through the attention mechanism, and each element in the multiple frame features is weighted to obtain multiple weighted frame features. In this way, the noise in the multiple frame features can be effectively suppressed, the effective features can be enhanced, and the accuracy of time series data recognition can be effectively improved.
[0078] In the technical solution provided by the embodiment of the present application, the attention weight corresponding to each element in the data feature of the data to be identified is obtained through the attention mechanism, and each element in the data feature is weighted to obtain the weighted data feature. In this way, the noise in the data feature can be effectively suppressed, the effective features can be enhanced, and the accuracy of data recognition can be effectively improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0079] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, a brief introduction will be given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are 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.
[0080] Figure 1a A schematic diagram of data processing of an intelligent surveillance camera provided in one embodiment of the present application;
[0081] Figure 1b A flowchart of a video recognition method provided by another embodiment of the present application;
[0082] Figure 1c A flowchart of a time series data identification method provided in an embodiment of the present application;
[0083] Figure 2 A flowchart of a time series data identification method provided in yet another embodiment of the present application;
[0084] Figure 3 A flowchart of a video recognition method provided in an embodiment of the present application;
[0085] Figure 4 A flowchart of a model training method provided in an embodiment of the present application;
[0086] Figure 5 A flowchart of a data identification method provided in yet another embodiment of the present application;
[0087] Figure 6 A flowchart of a data identification method provided in yet another embodiment of the present application;
[0088] Figure 7 A structural block diagram of an identification device provided in an embodiment of the present application;
[0089] Figure 8 A structural block diagram of a model training device provided in yet another embodiment of the present application;
[0090] Fig. 9 A structural block diagram of an identification device provided in another embodiment of the present application;
[0091] Fig.10 A structural block diagram of an electronic device provided in yet another embodiment of the present application. DETAILED DESCRIPTION
[0092] In the prior art, there are video recognition methods based on neural network models, and the existing neural network models usually use CNN (Convolutional Neural Networks) to extract features corresponding to different frames of the video, and then input all the features corresponding to different frames into the fully connected layer, so that the fully connected layer performs feature fusion to obtain the final recognition result. This method directly fuses the features corresponding to different frames through the fully connected layer and then performs recognition, which has poor effect and affects the recognition accuracy.
[0093] In the process of studying the technical solution provided by the embodiment of the present application, the inventor found that there is a lot of noise in the features extracted by the feature extraction sub-network, which is not only useless for the final recognition, but also has interference problems. Therefore, the inventor proposed this application to suppress the noise in the features to effectively improve the recognition efficiency.
[0094] In order to enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without making creative work are within the scope of protection of the present application.
[0095] In addition, some of the processes described in the specification, claims and the above-mentioned figures of the present application include multiple operations that appear in a specific order, and these operations may not be executed in the order in which they appear in this article or may be executed in parallel. The serial numbers of the operations, such as 101, 102, etc., are only used to distinguish between different operations, and the serial numbers themselves do not represent any execution order. In addition, these processes may include more or fewer operations, and these operations may be executed in sequence or in parallel. It should be noted that the descriptions of "first", "second", etc. in this article are used to distinguish different messages, devices, modules, etc., do not represent the order of precedence, and do not limit the "first" and "second" to be different types.
[0096] Figure 1c A flow chart of a method for identifying time series data provided in an embodiment of the present application is shown. The execution subject of the method provided in the embodiment of the present application may be a server or a client. The server may be a general server, a cloud or a virtual server, etc., which is not specifically limited in the embodiment of the present application. The client may be a hardware with an embedded program integrated in the terminal, or an application software installed in the terminal, or a tool software embedded in the terminal operating system, etc., which is not limited in the embodiment of the present application. The terminal may be any terminal device including a mobile phone, a tablet computer, a smart wearable device, a surveillance camera, etc. Figure 1c As shown, the method includes:
[0097] 101. Obtain time series data to be identified.
[0098] Wherein, the time series data to be identified includes multiple frames of data.
[0099] 102. Input the time series data to be identified into a trained neural network model to obtain a recognition result.
[0100] Among them, the neural network model is used to: extract features from the multiple frames of data respectively to obtain multiple frame features; determine the attention weight corresponding to each element in the multiple frame features based on the multiple frame features; multiply each element in the multiple frame features by its corresponding attention weight to obtain multiple weighted frame features; and combine the multiple weighted frame features to obtain the recognition result.
[0101] In the above 101, the time series data to be identified may be input or uploaded by a user, or read from a database.
[0102] The time series data to be identified may be a video to be identified or an audio to be identified, etc. When the time series data to be identified is a video to be identified, the multi-frame data is a multi-frame image of the video to be identified. When the time series data to be identified is an audio to be identified, the multi-frame data is a multi-frame audio of the audio to be identified.
[0103] It should be added that: in practical applications, the audio to be recognized can be sampled to obtain multiple frames of audio, for example: the audio to be recognized can be sampled at equal time intervals or unequal time intervals to obtain multiple frames of audio. The specific sampling technology can be found in the prior art and will not be described in detail here.
[0104] In addition, in one example, when the time series data to be recognized is audio to be recognized, before the audio to be recognized is input into the trained neural network model, speech signal analysis can be performed on each frame of the audio to be recognized to obtain the time spectrum corresponding to each frame of the audio. The time spectrum corresponding to multiple frames of the audio to be recognized is input into the neural network model, so that the neural network model processes the time spectrum as a frame image.
[0105] In the above 102, the neural network model can be obtained by training the sample time series data and the expected recognition results corresponding to the sample time series data, wherein the number of sample time series data can be set according to actual needs, and this embodiment does not specifically limit this. Among them, the backbone network of the neural network model can be CNN.
[0106] The time series data to be identified is used as the input of the trained neural network model to obtain the recognition result using the trained neural network model.
[0107] In the above step of "extracting features from the multiple frames of data to obtain multiple frame features", the frame feature may be a frame feature map having a three-dimensional data structure of H*W*C, wherein H and W are the length and width of the frame feature map, respectively, and C is the number of channels of the frame feature map. Since feature extraction is performed on each frame of data, two-dimensional convolution (i.e., 2D convolution) may be used to extract features from each frame of data.
[0108] In the above step of "determining the attention weight corresponding to each element in the multiple frame features based on the multiple frame features", each frame feature is composed of multiple elements. For example, when the frame feature is a frame feature map with a three-dimensional data structure of H*W*C, the frame feature is composed of H*W*C elements.
[0109] In an achievable solution, the attention weight corresponding to each element in each frame feature can be obtained according to each frame feature. Specifically, the first weight feature including the attention weight corresponding to each element in each frame feature can be obtained by convolving each frame feature.
[0110] In one feasible solution, the above step of "combining the plurality of weighted frame features to obtain the recognition result" can be specifically implemented by the following steps:
[0111] S11, performing intra-frame and inter-frame summing pooling processing on the weighted time series data features formed by stacking the multiple weighted frame features to obtain fused features.
[0112] S12. Obtain the recognition result according to the fusion feature.
[0113] In the above S11, since the weighted time series data feature is formed by stacking multiple weighted frame features, the dimension of the weighted time series data is one dimension higher than the dimension of the weighted frame feature. The specific implementation of stacking can refer to the tensor stacking method in the prior art, which will not be described in detail here.
[0114] For example: each weighted frame feature has a three-dimensional data structure of H*W*C, and the number of the weighted frame features is N, then the weighted time series data feature has a four-dimensional data structure of N*H*W*C.
[0115] Among them, the weighted frame feature can specifically be a weighted frame feature map with a three-dimensional data structure of H*W*C; the weighted time series data feature can specifically be a weighted time series data feature map with a four-dimensional data structure of N*H*W*C.
[0116] In one example, the weighted temporal data features are subjected to intra-frame and inter-frame summing pooling processing, and the summing pooling processing window is a three-dimensional window, and the size of the summing pooling window is n1*h1*w1. Among them, n1 is less than or equal to the above N, h1 is less than or equal to the above H, and w1 is less than or equal to the above W. The specific size of the summing pooling window can be set according to actual needs, and this application does not make specific restrictions on this.
[0117] In a feasible solution, the above-mentioned summed pooling may be global summed pooling. Continuing with the above example, the size of the summed pooling window is N*H*W.
[0118] Among them, summed pooling refers to the summation of all elements in each summed pooling window.
[0119] In this embodiment, through intra-frame and inter-frame summing pooling processing, the fusion within each weighted frame feature and the fusion between different weighted frame features are achieved.
[0120] It should be supplemented that when the time series data to be identified is a video to be identified, since each weighted frame feature only contains the spatial dimension, different weighted frame features contain the time dimension. In this way, the feature fusion in the time dimension and the spatial dimension is achieved through the summed pooling processing within and between frames. Therefore, the above-mentioned summed pooling processing within and between frames can also be called summed pooling processing in time and space.
[0121] When the time series data to be identified is a video to be identified, the weighted time series data features are also weighted video features.
[0122] In one feasible solution, in the above S12, the fused features can be used as input of at least one fully connected layer in the neural network model to obtain a fully connected result; and the recognition result is determined based on the fully connected result.
[0123] The number of at least one fully connected layer can be two. The fully connected result can be used as the input of the output layer in the above neural network model to obtain the recognition result output by the output layer.
[0124] The output layer may be a normalized exponential Softmax layer or a Sigmoid layer. For example, when the neural network model is used for single classification, the output layer may be a Softmax layer; when the neural network model is used for multi-class classification, the output layer may be a Sigmoid layer.
[0125] Among them, the output layer can be understood as a classifier. In addition to the above two classifiers, it can also be other classifiers, such as: Support Vector Machine (SVM).
[0126] In the technical solution provided by the embodiment of the present application, the attention weight corresponding to each element in the multiple frame features of the time series data to be identified is obtained through the attention mechanism, and each element in the multiple frame features is weighted to obtain multiple weighted frame features. In this way, the noise in the multiple frame features can be effectively suppressed, the effective features can be enhanced, and the accuracy of time series data recognition can be effectively improved.
[0127] In the above embodiment, a method for calculating the attention weight is provided, that is, according to each frame feature, the attention weight corresponding to each element in each frame feature is obtained. In this method, the size of the attention weight corresponding to each element in each frame feature is independent of other frame features, and is only related to the adjacent elements in the frame feature in which it is located, that is, this method ignores the mutual influence between adjacent frames. In the problem of time series data recognition, the information between frames is very important information. For example: in the process of video-based action recognition, the recognition of an action usually requires the integration of multiple frames of images to determine. In order to further improve the recognition accuracy, the above step of "determining the attention weight corresponding to each element in the multiple frame features according to the multiple frame features" can be specifically implemented by the following steps:
[0128] S21. Perform intra-frame and inter-frame convolution processing on the time series data features formed by stacking the multiple frame features to obtain convolution features.
[0129] S22. Determine the attention weight corresponding to each element in the time series data feature based on the convolution feature.
[0130] In the above S21, multiple frame features can be stacked into a time series data feature, and the dimension of the time series data feature is one dimension higher than the dimension of each frame feature. The specific implementation of stacking can refer to the tensor stacking method in the prior art, which will not be described in detail here.
[0131] For example: each frame feature has a three-dimensional data structure of H*W*C, and the number of multiple frame features is N, then the time series data feature has a four-dimensional data structure of N*H*W*C.
[0132] Among them, the frame feature can specifically be a frame feature map with a three-dimensional data structure of H*W*C; the time series data feature can specifically be a time series data feature map with a four-dimensional data structure of N*H*W*C.
[0133] The time series data features are convolved within and between frames to achieve the fusion within each frame feature and the fusion between different frame features. When the time series data to be identified is a video to be identified, since each frame feature only contains the spatial dimension, the different frame features contain the temporal dimension. In this way, the convolution processing within and between frames realizes the convolution processing in the temporal and spatial dimensions. Therefore, the convolution processing within and between frames can also be called spatiotemporal convolution processing.
[0134] When the time series data to be identified is a video to be identified, the time series data feature is also the video feature; the convolution feature can also be called spatiotemporal feature.
[0135] In one example, three-dimensional convolution (i.e., 3D convolution) processing can be performed on the time series data features to achieve intra-frame and inter-frame convolution processing of the time series data features. The specific implementation method can be found in the prior art C3D (Convolutional 3D) and I3D (Inflated 3D) derived from C3D, which will not be described in detail here.
[0136] The size of the convolution kernel used in the 3D convolution process is n2*h2*w2, where n2 is smaller than the above N, h2 is smaller than the above H, and w2 is smaller than the above W. The specific size of the convolution window can be set according to actual needs, and this application does not make specific restrictions on this. In one example, the size of the convolution kernel used in the 3D convolution process can be 3*3*3.
[0137] Considering that the amount of calculation for 3D convolution processing is large, in order to reduce the amount of calculation, in another feasible solution, the above S21 "performing intra-frame and inter-frame convolution processing on the temporal data features formed by stacking the multiple frame features to obtain convolution features" can be implemented by the following steps:
[0138] a. Using a combination of two-dimensional convolution within a frame and one-dimensional convolution between frames, the time series data features are convolved within and between frames to obtain initial convolution features.
[0139] b. Determine the convolution feature according to the initial convolution feature.
[0140] In the above a, a combination of two-dimensional convolution within a frame and one-dimensional convolution between frames is used to replace 3D convolution, which can not only reduce the amount of calculation, but also obtain better recognition accuracy than 3D convolution. Specifically, the following methods can be used to implement the above a:
[0141] Method 1: Perform two-dimensional convolution processing on the time series data features within a frame to obtain a first time series data feature; perform one-dimensional convolution processing on the first time series data features between frames to obtain an initial convolution feature.
[0142] Method 2: Perform two-dimensional convolution processing on the time series data features within the frame to obtain the first time series data features; perform one-dimensional convolution processing on the time series data between frames to obtain the second time series data features; the initial convolution feature is obtained by element-wise addition of the first time series data features and the second time series data features.
[0143] It should be noted that element-wise addition means adding the elements at the same position in the first time series data feature and the second time series data feature, that is, adding the elements with the same subscript.
[0144] Method three: perform two-dimensional convolution processing on the time series data feature within the frame to obtain a first time series data feature; perform one-dimensional convolution processing on the first time series data feature between frames to obtain a third time series data feature; the initial convolution feature is obtained by element-wise addition of the first time series data feature and the third time series data feature.
[0145] In practical applications, when the time series data to be identified is a video to be identified, the two-dimensional convolution within a frame is also a two-dimensional spatial convolution, and the one-dimensional convolution between frames is also a one-dimensional temporal convolution. The initial convolution feature is also the initial spatiotemporal feature. The specific implementation of the above methods 1, 2 and 3 can refer to P3D (pseudo-3D, pseudo-convolution 3D) derived from C3D in the prior art.
[0146] In the above step b, the initial convolution feature can be directly used as the convolution feature. Alternatively, the time series data feature and the initial convolution feature are element-wise added to obtain the convolution feature, which can effectively avoid the loss of detail information and improve recognition accuracy.
[0147] In an implementable scheme, in the above step S22, the data structure of the above convolution feature is consistent with the data structure of the time series data feature. Specifically, the time series data feature can be a time series data feature map with a four-dimensional data structure of N*H*W*C; the convolution feature is also a convolution feature map with a four-dimensional data structure of N*H*W*C.
[0148] The element value at a certain position in the convolution feature can be directly used as the attention weight of the element at the corresponding position in the time series data feature. The elements at the corresponding positions can be understood as elements with the same subscript. Correspondingly, the above step of "multiplying each element in the multiple frame features with its corresponding attention weight to obtain multiple weighted frame features" is specifically: multiplying the time series data feature formed by stacking the multiple frame features with the convolution feature element by element to obtain the weighted time series data feature, wherein the weighted time series data feature can be regarded as a stack of the above multiple weighted frame features.
[0149] It should be noted that element-wise multiplication means multiplying the elements at the same position in the time series data features and the convolution features, that is, multiplying the elements with the same subscript.
[0150] In another feasible solution, the convolution features can be normalized exponentially so that the attention weight corresponding to each element in the time series data feature is between 0 and 1, which is helpful to reduce the model complexity and speed up the convergence of the neural network model.
[0151] Specifically, in the above step S22, "determine the attention weight corresponding to each element in the time series data feature according to the convolution feature", specifically: perform normalized exponential processing on each element in the above-mentioned summed pooling window in the convolution feature to obtain a weight feature containing the attention weight corresponding to each element in the time series data feature. The weight feature can specifically be a weight feature map, which has a four-dimensional data structure of N*H*W*C and has the same data structure as the time series data feature. The element value at a certain position in the weight feature is the attention weight of the element at the corresponding position in the time series data feature.
[0152] The size of the summed pooling window can be found in the corresponding contents of the above embodiments, which will not be described here. Attention pooling is achieved through the above attention weight multiplication and summed pooling processing.
[0153] In order to further suppress noise and enhance features, the above step of "combining the multiple weighted post-frame features to obtain the recognition result" can be implemented by the following steps:
[0154] S31. Perform convolution processing on the multiple weighted frame features respectively to obtain multiple new frame features.
[0155] S32. Determine, based on the multiple new frame features, an attention weight corresponding to each element in the multiple new frame features.
[0156] S33, multiplying each element in the multiple new frame features by its corresponding attention weight to obtain multiple new weighted frame features.
[0157] S34, synthesizing the multiple new weighted frame features to obtain the recognition result.
[0158] In the above S31, the purpose of convolution processing on multiple weighted frame features is to change the meaning of each channel in each weighted frame feature, that is, the channel meaning contained in the multiple new frame features is different from the channel meaning contained in the multiple weighted frame features.
[0159] Through further convolution processing, the network can be deepened and the recognition accuracy can be improved.
[0160] The specific implementation of "determining the attention weight corresponding to each element of the multiple new frame features based on the multiple new frame features" in the above S32 can be similarly referred to the content of "determining the attention weight corresponding to each element of the multiple frame features based on the multiple frame features" in the above embodiments, which will not be described in detail here.
[0161] The specific implementation of "multiplying each element of the multiple new frame features by its corresponding attention weight to obtain multiple new weighted frame features" in the above S33 can also be similarly referred to the contents of "multiplying each element of the multiple frame features by its corresponding attention weight to obtain multiple weighted frame features" in the above embodiments, which will not be described in detail here.
[0162] In one feasible solution, the step of “combining the multiple new weighted post-frame features to obtain the recognition result” in S34 can be implemented by the following steps:
[0163] c. Performing spatiotemporal summing and pooling processing on the new weighted time series data features formed by stacking the multiple new weighted frame features to obtain new fusion features.
[0164] d. Obtain the recognition result based on the new fusion feature.
[0165] The specific implementation of "performing spatiotemporal aggregation and pooling processing on the new weighted time series data features formed by stacking the multiple new weighted frame features to obtain new fusion features" in the above step c can be similarly referred to the content of "performing spatiotemporal aggregation and pooling processing on the weighted video features formed by stacking the multiple weighted frame features to obtain fusion features" in the above embodiments, which will not be described in detail here.
[0166] The specific implementation of "obtaining the recognition result according to the new fusion feature" in the above step d can be similarly referred to the content of "obtaining the recognition result according to the fusion feature" in the above embodiments, which will not be described in detail here.
[0167] In this embodiment, two noise suppression operations are performed in total.
[0168] In another feasible scheme, in the above S34, "the multiple new weighted post-frame features are integrated to obtain the recognition result", in the specific implementation, the multiple new weighted post-frame features can also be brought into the above step S31 as convolution processing objects, and the above steps S31, S32, S33 and S34 can be repeated.
[0169] In this embodiment, the step of suppressing noise by the attention mechanism may be repeated multiple times to suppress the noise. The specific number of times of repetition can be set according to actual needs, and this embodiment does not make a specific limitation on this.
[0170] By repeatedly performing convolution operations that change the meaning of channels and noise suppression operations, the depth of the network is deepened, more complex features can be extracted, and better recognition results can be achieved through training.
[0171] A training method for the above neural network model is introduced below, which includes:
[0172] S41. Obtain sample time series data.
[0173] The sample video includes multiple frames of data.
[0174] S42: Input the sample data into a neural network model to obtain a prediction and recognition result.
[0175] S43. Optimize parameters of the neural network model according to the predicted recognition result and the expected recognition result corresponding to the sample time series data.
[0176] Among them, the neural network model is used to: extract features from the multiple frames of data respectively to obtain multiple frame features; determine the attention weight corresponding to each element in the multiple frame features based on the multiple frame features; multiply each element in the multiple frame features by its corresponding attention weight to obtain multiple weighted frame features; and combine the multiple weighted frame features to obtain the predicted recognition result.
[0177] In the above step S41, the sample time series data may be sample video or sample audio. When the sample time series data is sample video, the multi-frame data is a multi-frame image; when the sample time series data is sample audio, the multi-frame data is a multi-frame audio.
[0178] The sampling method of the frame audio can be similarly referred to the corresponding contents in the above embodiments, and will not be described in detail here.
[0179] In the above S42, the sample data is used as the input of the neural network model to obtain the prediction recognition result by using the neural network model. The specific implementation of the execution step of the neural network model in this embodiment can be similarly referred to the corresponding content in the above embodiments, and will not be described in detail here.
[0180] Among them, the initial value of each network parameter in the neural network model can be a random value.
[0181] In the above S43, the parameters of the neural network model are optimized according to the predicted recognition result and the expected recognition result corresponding to the sample time series data.
[0182] After being trained, the neural network model is used to identify time series data to be identified.
[0183] Among them, according to the predicted recognition result and the expected recognition result corresponding to the sample time series data, the parameter optimization of the neural network model can be specifically achieved by using a loss function. The loss function is used to estimate the degree of inconsistency between the predicted recognition result and the expected recognition result of the model, and is usually a non-negative real-valued function.
[0184] Optionally, the loss function may be specifically a cross entropy loss.
[0185] Each time the parameters of the neural network model are optimized, the adjustment coefficients of the various model parameters in the neural network model can be obtained, and the model parameters of the neural network model can be obtained by numerically adjusting the various model parameters using the adjustment coefficients of the various model parameters.
[0186] The method of using the loss function to optimize parameters is the same as the prior art and will not be described in detail here.
[0187] In a practical application, the expected recognition result can be the training label of the time series data, for example, in a video-based action recognition scenario, the training labels can be playing basketball, swimming, playing badminton, etc. The training samples for model training are the same as those in the prior art, and the main difference lies in the different processing process of the training samples by the neural network model provided in the embodiment of the present application.
[0188] It should be noted that the attention mechanism in the embodiment of the present application is different from the attention mechanism in the prior art. In the embodiment of the present application, the attention weight for each element in the feature is obtained by convolution and multiplied element by element. The convolution processing in the neural network model is a nonlinear processing with strong generalization ability, and can obtain a relatively accurate calculation of the attention weight of each element in the feature.
[0189] The attention mechanism in the prior art usually obtains an attention weight matrix by linear matrix multiplication, and then linearly multiplies the attention weight matrix with the feature to obtain the attention feature. It can be seen that the scheme is completely different from this scheme, the calculation amount of the scheme is higher than that of this scheme, and the linear matrix multiplication has many redundant elements, so it is difficult to obtain a reasonable attention weight matrix, which affects the recognition accuracy.
[0190] For ease of understanding, the following will be combined Figure 1b The schematic diagram shown describes the method provided in the embodiment of the present application:
[0191] 1. Input multiple frames of video images into the trained neural network model.
[0192] 2. The backbone network (backbone CNN) in the neural network model extracts features from multiple frames of images to obtain multi-frame features.
[0193] 3. Stack multiple frame features to obtain video features.
[0194] 4. Input the video features into the P3D network in the neural network model for convolution to obtain spatiotemporal features.
[0195] 5. Perform spatiotemporal normalized exponential (softmax) processing on the spatiotemporal features to obtain weighted features.
[0196] Specifically, each element in the summed pooling window in each step 8 of the spatiotemporal feature may be subjected to normalized exponential processing to obtain a weight feature, wherein the size of each element in the weight feature is less than 1, and the sum of all elements in the summed pooling window in each step 8 is 1.
[0197] 6. Multiply the video features and weight features element by element to obtain the weighted video features.
[0198] 7. Perform spatiotemporal summing and pooling processing on the weighted video features to obtain fused features.
[0199] The data structure of the fused feature is a C-dimensional vector, that is, the data structure is 1*1*1*C.
[0200] 8. Based on the fusion features, the recognition results are obtained through two fully connected layers and the output layer.
[0201] The recognition result includes: the probability that the video to be recognized belongs to K candidate categories.
[0202] It should be noted here that: for the contents of each step not fully described in detail in the method provided in the embodiment of the present application, please refer to the corresponding contents in the above embodiment, which will not be repeated here. In addition, in addition to the above steps, the method provided in the embodiment of the present application may also include other parts or all of the steps in the above embodiments, which can be specifically referred to the corresponding contents in the above embodiments, which will not be repeated here.
[0203] The following will be combined Figure 1a, taking the smart surveillance camera as an example, the solution provided by the embodiment of the present application is introduced: the smart surveillance camera inputs the multi-frame images of the captured video into the locally deployed trained neural network model, and extracts features from the multi-frame images respectively through the feature extraction network in the neural network model (i.e., the backbone CNN mentioned above) to obtain multi-frame features. The multi-frame features are input into the attention pooling network to obtain fused features. The fused features are input into the classifier to obtain recognition results. Based on the recognition results, it is determined whether the video needs to be uploaded, that is, whether the video is of interest to the user. The video of interest to the user is uploaded to the server for backup. Among them, the specific implementation of the attention pooling network can be found in the corresponding contents in the above embodiments, which will not be repeated here.
[0204] In one example, the method may further include: receiving preset time period information configured by a user. The obtaining of the video to be identified includes: obtaining, from all videos monitored by the smart surveillance camera, a video whose shooting time is within the preset time period as the video to be identified.
[0205] Taking the wonderful moment capture of pets as an example, users can determine the reasonable preset time period information according to the pet's daily routine. For example, if a pet is more active during the day and quieter at night, the user can configure the preset time period to be from 8 am to 8 pm every day.
[0206] In this way, users can design according to their own needs, which is more humane.
[0207] In another example, the first smart surveillance camera may send configuration information of a trained neural network model running thereon to a second smart surveillance camera; the second smart surveillance camera may locally configure the trained neural network model according to the sent configuration information to perform video recognition.
[0208] Specifically, the above method may further include: receiving configuration information of a trained neural network model running on the first intelligent surveillance camera and sending it; and completing the local configuration of the trained neural network model according to the configuration information. The configuration information may include the number of various types of network layers in the neural network model, the trained parameters of each network layer, and the relationship between network layers.
[0209] In this way, the video to be identified can be identified locally.
[0210] For example, when visiting a friend's house, user A sets up smart camera B at home to monitor pet cat C and capture the wonderful moments of pet cat C. One day, user A brings his pet cat C to visit his friend's house, hoping to monitor pet cat C at his friend's house and capture the wonderful moments of pet cat C. At this time, user A can remotely trigger smart camera B at home to send the configuration information of the trained neural network model running on it to smart camera D at his friend's home. After receiving the configuration information, smart camera D completes the configuration, thereby realizing the function of capturing the wonderful moments of pet cat C.
[0211] It should be noted that the above video recognition method can not only identify pets of different species at home, but also distinguish multiple pets of the same species at home. For example, user A has two cats at home: a big cat and a small cat. As long as the neural network model is trained based on the relevant labeled samples of the big cat and the small cat, the trained neural network model can: distinguish videos about big cats and videos about small cats when recognizing videos taken by smart cameras.
[0212] It should be noted that the technical solutions provided by the above-mentioned embodiments of the present application can be applied to the fields of shopping mall replenishment, smart transportation, smart logistics, and city brain in addition to being applied to the fields of smart home. For example: a smart camera can be set up in a shopping mall, and the smart camera can be used to shoot, and the trained neural network model running on it can be used to identify the captured video, so as to determine whether there is a shortage of stock; if so, the shopping mall staff can be reminded to replenish the stock. Another example: a smart camera can be set up at an intersection, and the smart camera can be used to shoot, and the trained neural network model running on it can be used to identify the captured video, so as to determine whether there is congestion at the current intersection; if so, the corresponding strategy can be used for scheduling.
[0213] Figure 2 A flow chart of a method for identifying time series data provided in an embodiment of the present application is shown. The execution subject of the method provided in the embodiment of the present application may be a server or a client. The server may be a general server, a cloud or a virtual server, etc., which is not specifically limited in the embodiment of the present application. The client may be a hardware with an embedded program integrated in the terminal, or an application software installed in the terminal, or a tool software embedded in the terminal operating system, etc., which is not limited in the embodiment of the present application. The terminal may be any terminal device including a mobile phone, a tablet computer, a smart wearable device, a surveillance camera, etc. Figure 2 As shown, the method includes:
[0214] 201. Perform feature extraction on multiple frames of time series data to be identified respectively to obtain multiple frame features.
[0215] 202. Determine, based on the multiple frame features, an attention weight corresponding to each element in the multiple frame features.
[0216] 203. Multiply each element in the multiple frame features by its corresponding attention weight to obtain multiple weighted frame features.
[0217] 204. Combining the multiple weighted frame features to obtain a recognition result.
[0218] In this embodiment, at least one trained machine learning model may be used to perform the above steps 201, 202, 203 and 204. The machine learning model may be a neural network model.
[0219] In order to obtain a better prediction accuracy, the at least one machine learning model needs to be trained together. In an achievable solution, the number of the at least one machine learning model is one, and the one machine learning model is specifically a neural network model trained in the above corresponding embodiment.
[0220] The specific implementation of the above steps 201, 202, 203 and 204 can refer to the corresponding contents in the above embodiments, which will not be repeated here.
[0221] In the technical solution provided by the embodiment of the present application, the attention weight corresponding to each element in the multiple frame features of the time series data to be identified is obtained through the attention mechanism, and each element in the multiple frame features is weighted to obtain multiple weighted frame features. In this way, the noise in the multiple frame features can be effectively suppressed, the effective features can be enhanced, and the accuracy of time series data recognition can be effectively improved.
[0222] Furthermore, in the above 202, “determining, according to the multiple frame features, the attention weight corresponding to each element in the multiple frame features” can be implemented by the following steps:
[0223] Performing intra-frame and inter-frame convolution processing on the time series data features formed by stacking the multiple frame features to obtain convolution features;
[0224] According to the convolution feature, the attention weight corresponding to each element in the time series data feature is determined.
[0225] Furthermore, the above-mentioned “combining the plurality of weighted frame features to obtain a recognition result” in 204 can be implemented by the following steps:
[0226] Performing intra-frame and inter-frame summing pooling processing on the weighted time series data features formed by stacking the multiple weighted frame features to obtain fused features;
[0227] The recognition result is obtained according to the fusion feature.
[0228] It should be noted here that: for the contents of each step not fully described in detail in the method provided in the embodiment of the present application, please refer to the corresponding contents in the above embodiment, which will not be repeated here. In addition, in addition to the above steps, the method provided in the embodiment of the present application may also include other parts or all of the steps in the above embodiments, which can be specifically referred to the corresponding contents in the above embodiments, which will not be repeated here.
[0229] Figure 3 A flow chart of a video recognition method provided by an embodiment of the present application is shown. The execution subject of the method provided by the embodiment of the present application may be a server or a client. The server may be a general server, a cloud or a virtual server, etc., which is not specifically limited by the embodiment of the present application. The client may be a hardware with an embedded program integrated on the terminal, or an application software installed in the terminal, or a tool software embedded in the terminal operating system, etc., which is not limited by the embodiment of the present application. The terminal may be any terminal device including a mobile phone, a tablet computer, a smart wearable device, a surveillance camera, etc. Figure 3 As shown, the method includes:
[0230] 301. Obtain a video to be identified.
[0231] The video to be identified includes multiple frames of images.
[0232] 302. Input the video to be recognized into a trained neural network model to obtain a recognition result.
[0233] Among them, the neural network model is used to: extract features from the multiple frame images respectively to obtain multiple frame features; determine the attention weight corresponding to each element in the multiple frame features based on the multiple frame features; multiply each element in the multiple frame features by its corresponding attention weight to obtain multiple weighted frame features; and combine the multiple weighted frame features to obtain the recognition result.
[0234] The specific implementation of the above steps 301 and 302 can refer to the corresponding content in the above embodiments, which will not be repeated here.
[0235] In the technical solution provided by the embodiment of the present application, the attention weight corresponding to each element in the multiple frame features of the video to be identified is obtained through the attention mechanism, and each element in the multiple frame features is weighted to obtain multiple weighted frame features. In this way, the noise in the multiple frame features can be effectively suppressed, the effective features can be enhanced, and the accuracy of video recognition can be effectively improved.
[0236] Furthermore, the above-mentioned “determining, according to the multiple frame features, the attention weight corresponding to each element in the multiple frame features” can be specifically implemented by the following steps:
[0237] Performing spatiotemporal convolution on the video features formed by stacking the multiple frame features to obtain spatiotemporal features;
[0238] According to the spatiotemporal features, an attention weight corresponding to each element in the video features is determined.
[0239] Furthermore, the above-mentioned “performing spatiotemporal convolution on the video features formed by stacking the multiple frame features to obtain spatiotemporal features” can be implemented by the following steps:
[0240] Using a combination of two-dimensional spatial convolution and one-dimensional temporal convolution, the video features are subjected to spatiotemporal convolution to obtain initial spatiotemporal features;
[0241] The spatiotemporal features are determined according to the initial spatiotemporal features.
[0242] Furthermore, the above-mentioned “determining the spatiotemporal features according to the initial spatiotemporal features” is specifically: adding the video features and the initial spatiotemporal features element by element to obtain the spatiotemporal features.
[0243] Furthermore, the above “combining the plurality of weighted frame features to obtain the recognition result” can be implemented by the following steps:
[0244] Performing a spatiotemporal summing pooling process on the weighted video features formed by stacking the plurality of weighted frame features to obtain a fusion feature;
[0245] The recognition result is obtained according to the fusion feature.
[0246] Furthermore, the above-mentioned "determining the attention weight corresponding to each element in the video feature based on the spatiotemporal feature" is specifically: performing normalized exponential processing on each element in each of the summed pooling windows in the spatiotemporal feature to obtain a weight feature containing the attention weight corresponding to each element in the video feature.
[0247] Furthermore, the summed pooling is global summed pooling.
[0248] Furthermore, the above “obtaining the recognition result according to the fusion feature” can be implemented by the following steps:
[0249] Using the fused features as input of at least one fully connected layer in the neural network model to obtain a fully connected result;
[0250] The recognition result is determined according to the full connection result.
[0251] Furthermore, the above “combining the plurality of weighted frame features to obtain the recognition result” can be implemented by the following steps:
[0252] Performing convolution processing on the multiple weighted frame features respectively to obtain multiple new frame features;
[0253] Determining, according to the multiple new frame features, an attention weight corresponding to each element in the multiple new frame features;
[0254] Multiplying each element of the multiple new frame features by its corresponding attention weight to obtain multiple new weighted frame features;
[0255] The recognition result is obtained by combining the multiple new weighted frame features.
[0256] It should be noted here that: for the contents of each step not fully described in detail in the method provided in the embodiment of the present application, please refer to the corresponding contents in the above embodiment, which will not be repeated here. In addition, in addition to the above steps, the method provided in the embodiment of the present application may also include other parts or all of the steps in the above embodiments, which can be specifically referred to the corresponding contents in the above embodiments, which will not be repeated here.
[0257] In summary, the technical solution provided in the embodiment of the present application only utilizes the attention mechanism to solve the video understanding problem (for example: single-class, multi-class classification or recognition) in the feature fusion stage. Compared with the previous C3D series models (i.e., C3D model, P3D model, I3D model) and sequence model methods, it can simultaneously improve the operation speed and accuracy and reduce the number of model parameters. In addition, the number of parameters that need to be learned is small, which can avoid overfitting in training and effectively provide recognition accuracy.
[0258] Taking smart surveillance cameras as an example, this solution can significantly reduce the amount of video that needs to be transmitted back by identifying and filtering out data that users are not interested in, avoiding occupying user network bandwidth, saving cloud storage space, and saving server computing requirements; secondly, the computing power on smart terminals is usually insufficient and there is a need to save power. The calculation required by this solution is 1 / 6 of the previous C3D series model or sequence model, which is in line with the power consumption and computing power occupation that the hardware can bear; finally, this solution has a high recall rate and a low false recognition rate.
[0259] Figure 4A flow chart of a model training method for the above-mentioned neural network model is shown. The execution subject of the method provided in the embodiment of the present application can be a server or a client. Among them, the server can be a general server, a cloud or a virtual server, etc., which is not specifically limited in the embodiment of the present application. The client can be a hardware with an embedded program integrated on the terminal, or it can be an application software installed in the terminal, or it can be a tool software embedded in the terminal operating system, etc., which is not limited in the embodiment of the present application. The terminal can be any terminal device including a mobile phone, a tablet computer, a smart wearable device, a surveillance camera, etc. Figure 4 As shown, the method includes:
[0260] 401. Get sample video.
[0261] Wherein, the sample video includes multiple frames of images;
[0262] 402. Input the sample video into a neural network model to obtain a prediction recognition result.
[0263] 403. Optimize parameters of the neural network model according to the predicted recognition result and the expected recognition result corresponding to the sample video.
[0264] Among them, the neural network model is used to: extract features from the multiple frame images respectively to obtain multiple frame features; determine the attention weight corresponding to each element in the multiple frame features based on the multiple frame features; multiply each element in the multiple frame features by its corresponding attention weight to obtain multiple weighted frame features; and combine the multiple weighted frame features to obtain the predicted recognition result.
[0265] In the above 402, the sample video is used as the input of the neural network model to obtain the prediction recognition result by using the neural network model. The specific implementation of the execution step of the neural network model in this embodiment can be similarly referred to the corresponding content in the above embodiments, and will not be described in detail here.
[0266] Among them, the initial value of each network parameter in the neural network model can be a random value.
[0267] In the above 403, the parameters of the neural network model are optimized according to the predicted recognition result and the expected recognition result corresponding to the sample time series data.
[0268] After being trained, the neural network model is used to identify time series data to be identified.
[0269] Among them, according to the predicted recognition result and the expected recognition result corresponding to the sample time series data, the parameter optimization of the neural network model can be specifically achieved by using a loss function. The loss function is used to estimate the degree of inconsistency between the predicted recognition result and the expected recognition result of the model, and is usually a non-negative real-valued function.
[0270] Optionally, the loss function may be specifically a cross entropy loss.
[0271] Each time the parameters of the neural network model are optimized, the adjustment coefficients of the various model parameters in the neural network model can be obtained, and the model parameters of the neural network model can be obtained by numerically adjusting the various model parameters using the adjustment coefficients of the various model parameters.
[0272] The method of using the loss function to optimize parameters is the same as the prior art and will not be described in detail here.
[0273] In a practical application, the expected recognition result can be the training label of the video, for example, in a video-based action recognition scenario, the training labels can be playing basketball, swimming, playing badminton, etc. The training samples for model training are the same as those in the prior art, and the main difference is that the neural network model provided in the embodiment of the present application has a different processing process for the training samples.
[0274] Another embodiment of the present application also provides a neural network system. The system includes: at least one first network layer, at least one second network layer and at least one third network layer; wherein,
[0275] The at least one first network layer is used to extract features from multiple frames of the video to be identified, respectively, to obtain multiple frame features;
[0276] The at least one second network layer is used to determine, based on the multiple frame features, an attention weight corresponding to each element in the multiple frame features; and is also used to multiply each element in the multiple frame features by its corresponding attention weight to obtain a plurality of weighted frame features;
[0277] The at least one third network layer is used to integrate the multiple weighted frame features to obtain a recognition result.
[0278] The at least one first network layer constitutes the backbone network and can constitute a CNN.
[0279] In the technical solution provided by the embodiment of the present application, the attention weight corresponding to each element in the multiple frame features of the video to be identified is obtained through the attention mechanism, and each element in the multiple frame features is weighted to obtain multiple weighted frame features. In this way, the noise in the multiple frame features can be effectively suppressed, the effective features can be enhanced, and the accuracy of video recognition can be effectively improved.
[0280] Further, the at least one third network layer includes a pooling layer;
[0281] The pooling layer is used to perform a temporal and spatial summing pooling process on the weighted video features formed by stacking the multiple weighted frame features to obtain a fused feature;
[0282] The other network layers in the at least one fourth network layer except the pooling layer are used to obtain the recognition result according to the fusion feature.
[0283] Furthermore, the other network layers include at least one fully connected layer and an output layer.
[0284] The specific implementation and principle of the processing performed by each network layer in the neural network system in this application can be found in the corresponding contents of the above embodiments, which will not be repeated here.
[0285] Figure 5 A flow chart of a data identification method provided by another embodiment of the present application is shown. The execution subject of the method provided in the embodiment of the present application can be a server or a client. Among them, the server can be a general server, a cloud or a virtual server, etc., which is not specifically limited in the embodiment of the present application. The client can be a hardware with an embedded program integrated in the terminal, or it can be an application software installed in the terminal, or it can be a tool software embedded in the terminal operating system, etc., which is not limited in the embodiment of the present application. The terminal can be any terminal device including a mobile phone, a tablet computer, a smart wearable device, etc. Figure 5 As shown, the method comprises:
[0286] 501. Obtain data to be identified.
[0287] 502. Input the data to be recognized into a trained neural network model to obtain a recognition result.
[0288] Among them, the neural network model is used to: extract features of the data to be identified to obtain data features; determine the attention weights corresponding to each element in the data features based on the data features; multiply each element in the data features by its corresponding attention weight to obtain weighted data features; and obtain the recognition result based on the weighted data features.
[0289] In the above 501, the data to be identified may include one or more of an image to be identified, a video to be identified, an audio to be identified, and odor information.
[0290] Among them, the odor information is generated by the odor sensor through detection.
[0291] In the above 502, the data to be recognized is input into a trained neural network model to obtain a recognition result using the neural network model.
[0292] The neural network model can be trained based on the sample data and the expected recognition results corresponding to the sample data. The amount of sample data can be set according to actual needs, and the embodiment of the present application does not specifically limit this.
[0293] In an achievable solution, when the data to be identified is an image to be identified, the neural network model can use 2D convolution to extract features from the data to be identified to obtain data features. When the data to be identified is time series data to be identified, 3D convolution or pseudo 3D convolution can be used to extract features from the data to be identified to obtain data features. 3D convolution or pseudo 3D convolution can be used to extract features within and between frames.
[0294] Among them, the specific implementation of 3D convolution can refer to C3D in the prior art and I3D (Inflated3D) derived from C3D; among them, the pseudo 3D convolution can specifically refer to P3D derived from C3D in the prior art.
[0295] The above-mentioned "determine the attention weight corresponding to each element in the data feature according to the data feature" can be specifically: perform convolution processing on the data feature to obtain a convolution feature; determine the attention weight corresponding to each element in the data feature according to the convolution feature. When the data to be identified is an image to be identified, the convolution processing can be 2D convolution; when the data to be identified is time series data to be identified, the convolution processing can be: 3D convolution or pseudo 3D convolution, so that the rationality of the calculated attention weight can be improved by combining the features within and between frames.
[0296] The above-mentioned "obtaining the recognition result according to the weighted data features" can be specifically: performing summing and pooling processing on the weighted data features to obtain fusion features; and obtaining the recognition result according to the fusion features. When the data to be recognized is an image to be recognized, the summing and pooling processing can be 2D pooling; when the data to be recognized is time series data to be recognized, the convolution processing can be: 3D pooling, and 3D pooling can realize feature fusion within and between frames.
[0297] The window size of the summed pooling process can be set according to actual needs, and this embodiment does not specifically limit this. In one example, the summed pooling is global pooling.
[0298] Attention pooling is achieved through the above-mentioned attention weight multiplication and summing pooling processing.
[0299] In order to accelerate the convergence of the neural network model, the above-mentioned "determining the attention weight corresponding to each element in the data feature according to the convolution feature" is specifically: performing normalized exponential processing on each element in each of the summed pooling windows in the convolution feature to obtain a weight feature containing the attention weight corresponding to each element in the data feature.
[0300] The attention pooling in this embodiment can replace the pooling operation in any neural network model in the prior art, such as maximum pooling or average pooling, which can effectively suppress noise, enhance features, and improve accuracy.
[0301] In another feasible solution, the data to be identified is time series data to be identified. The time series data to be identified includes multiple frames of data; accordingly, the above-mentioned “extracting features from the data to be identified to obtain data features” is specifically: extracting features from the multiple frames of data respectively to obtain multiple frame features; wherein the data features include the multiple frame features.
[0302] Correspondingly, the above-mentioned “determining the attention weight corresponding to each element in the data feature according to the data feature” is specifically: determining the attention weight corresponding to each element in the multiple frame features according to the multiple frame features.
[0303] Correspondingly, the above-mentioned "multiplying each element in the data feature by its corresponding attention weight to obtain a weighted data feature" is specifically: multiplying each element in the multiple frame features by its corresponding attention weight to obtain multiple weighted frame features.
[0304] Correspondingly, the above-mentioned “obtaining the recognition result according to the weighted data features” is specifically: obtaining the recognition result according to multiple weighted frame features.
[0305] The specific implementation of the above steps can refer to the corresponding contents in the above embodiments, which will not be repeated here.
[0306] In the technical solution provided by the embodiment of the present application, the attention weight corresponding to each element in the data feature of the data to be identified is obtained through the attention mechanism, and each element in the data feature is weighted to obtain the weighted data feature. In this way, the noise in the data feature can be effectively suppressed, the effective features can be enhanced, and the accuracy of data recognition can be effectively improved.
[0307] A training method for a neural network model in this embodiment is described below. The method includes:
[0308] S51. Obtain sample data.
[0309] S52: Input the sample data into a neural network model to obtain a prediction and recognition result.
[0310] S53: Perform parameter training on the neural network model according to the predicted recognition result and the expected recognition result corresponding to the sample data.
[0311] Among them, the neural network model is used to: extract features from the sample data to obtain data features; determine the attention weight corresponding to each element in the data features based on the data features; multiply each element in the data features by its corresponding attention weight to obtain weighted data features; and obtain the recognition result based on the weighted data features.
[0312] In the above S52, the sample data is used as the input of the neural network model to obtain the prediction recognition result by using the neural network model. The specific implementation of the execution step of the neural network model in this embodiment can refer to the corresponding content in the above embodiments, and will not be described in detail here.
[0313] Among them, the initial value of each network parameter in the neural network model can be a random value.
[0314] In the above S43, the parameters of the neural network model are optimized according to the predicted recognition result and the expected recognition result corresponding to the sample data.
[0315] After being trained, the neural network model is used to identify data to be identified.
[0316] Among them, according to the predicted recognition result and the expected recognition result corresponding to the sample data, the parameter optimization of the neural network model can be specifically achieved by using a loss function. The loss function is used to estimate the degree of inconsistency between the predicted recognition result and the expected recognition result of the model, and is usually a non-negative real-valued function.
[0317] Optionally, the loss function may be specifically a cross entropy loss.
[0318] Each time the parameters of the neural network model are optimized, the adjustment coefficients of the various model parameters in the neural network model can be obtained, and the model parameters of the neural network model can be obtained by numerically adjusting the various model parameters using the adjustment coefficients of the various model parameters.
[0319] The method of using the loss function to optimize parameters is the same as the prior art and will not be described in detail here.
[0320] In a practical application, the expected recognition result can be the training label of the sample data, for example, in an image classification scenario, the training labels can be cats, dogs, birds, backgrounds, etc. The training samples for model training are the same as those in the prior art, and the main difference is that the neural network model provided in the embodiment of the present application has a different processing process for the training samples.
[0321] It should be noted here that: for the contents of each step not fully described in detail in the method provided in the embodiment of the present application, please refer to the corresponding contents in the above embodiment, which will not be repeated here. In addition, in addition to the above steps, the method provided in the embodiment of the present application may also include other parts or all of the steps in the above embodiments, which can be specifically referred to the corresponding contents in the above embodiments, which will not be repeated here.
[0322] Figure 6 A flow chart of a data identification method provided by an embodiment of the present application is shown. The execution subject of the method provided by the embodiment of the present application can be a server or a client. The server can be a general server, a cloud or a virtual server, etc., which is not specifically limited by the embodiment of the present application. The client can be a hardware with an embedded program integrated on the terminal, or an application software installed in the terminal, or a tool software embedded in the terminal operating system, etc., which is not limited by the embodiment of the present application. The terminal can be any terminal device including a mobile phone, a tablet computer, a smart wearable device, etc. Figure 6 As shown, the method includes:
[0323] 601. Perform feature extraction on the data to be identified to obtain data features.
[0324] 602. Determine, based on the data feature, an attention weight corresponding to each element in the data feature.
[0325] 603. Multiply each element in the data feature by its corresponding attention weight to obtain a weighted data feature.
[0326] 604. Obtain the recognition result according to the weighted data features.
[0327] In this embodiment, at least one trained machine learning model may be used to perform the above steps 601, 602, 603 and 604. The machine learning model may be a neural network model.
[0328] In order to obtain a better prediction accuracy, the at least one machine learning model needs to be trained together. In an achievable solution, the number of the at least one machine learning model is one, and the one machine learning model is specifically a neural network model trained in the above corresponding embodiment.
[0329] The specific implementation of the above steps 601, 602, 603 and 604 can refer to the corresponding contents in the above embodiments, which will not be repeated here.
[0330] In the technical solution provided by the embodiment of the present application, the attention weight corresponding to each element in the multiple frame features of the data to be identified is obtained through the attention mechanism, and each element in the multiple frame features is weighted to obtain multiple weighted frame features. In this way, the noise in the multiple frame features can be effectively suppressed, the effective features can be enhanced, and the accuracy of data recognition can be effectively improved.
[0331] It should be noted here that: for the contents of each step not fully described in detail in the method provided in the embodiment of the present application, please refer to the corresponding contents in the above embodiment, which will not be repeated here. In addition, in addition to the above steps, the method provided in the embodiment of the present application may also include other parts or all of the steps in the above embodiments, which can be specifically referred to the corresponding contents in the above embodiments, which will not be repeated here.
[0332] Figure 7 FIG. 1 is a schematic diagram showing the structure of an identification device provided by an embodiment of the present application. Figure 7 As shown, the device includes: a first acquisition module 701 and a first input module 702. Among them,
[0333] The first acquisition module 701 is used to acquire a video to be identified; wherein the video to be identified includes multiple frames of images;
[0334] The first input module 702 is used to input the video to be recognized into the trained neural network model to obtain a recognition result;
[0335] Among them, the neural network model is used to: extract features from the multiple frame images respectively to obtain multiple frame features; determine the attention weight corresponding to each element in the multiple frame features based on the multiple frame features; multiply each element in the multiple frame features by its corresponding attention weight to obtain multiple weighted frame features; and combine the multiple weighted frame features to obtain the recognition result.
[0336] It should be noted here that: the recognition device provided in the above embodiment can realize the technical solutions and technical effects described in the above corresponding method embodiments. The specific implementation and principles of the above modules and neural network models can refer to the corresponding contents in the above method embodiments, which will not be repeated here.
[0337] Figure 8 FIG. 1 is a schematic diagram showing the structure of a model training device provided in an embodiment of the present application. Figure 8 As shown, the device includes: a second acquisition module 801, a second input module 802 and a first optimization module 803.
[0338] The second acquisition module 801 is used to acquire a sample video; wherein the sample video includes multiple frames of images;
[0339] The second input module 802 is used to input the sample video into the neural network model to obtain a prediction recognition result;
[0340] A first optimization module 803, configured to optimize parameters of the neural network model according to the predicted recognition result and the expected recognition result corresponding to the sample video;
[0341] Among them, the neural network model is used to: extract features from the multiple frame images respectively to obtain multiple frame features; determine the attention weight corresponding to each element in the multiple frame features based on the multiple frame features; multiply each element in the multiple frame features by its corresponding attention weight to obtain multiple weighted frame features; and combine the multiple weighted frame features to obtain the predicted recognition result.
[0342] It should be noted here that the model training device provided in the above embodiments can realize the technical solutions and technical effects described in the above corresponding method embodiments. The specific implementation and principles of the above modules and neural network models can refer to the corresponding contents in the above method embodiments, which will not be repeated here.
[0343] Figure 7 FIG. 1 is a schematic diagram showing the structure of an identification device provided by an embodiment of the present application. Figure 7 As shown, the device includes: a first acquisition module 701 and a first input module 702. Among them,
[0344] A first acquisition module 701 is used to acquire time series data to be identified; wherein the time series data to be identified includes multiple frames of data;
[0345] The first input module 702 is used to input the time series data to be identified into a trained neural network model to obtain a recognition result;
[0346] Among them, the neural network model is used to: extract features from the multiple frames of data respectively to obtain multiple frame features; determine the attention weight corresponding to each element in the multiple frame features based on the multiple frame features; multiply each element in the multiple frame features by its corresponding attention weight to obtain multiple weighted frame features; and combine the multiple weighted frame features to obtain the recognition result.
[0347] It should be noted here that: the recognition device provided in the above embodiment can realize the technical solutions and technical effects described in the above corresponding method embodiments. The specific implementation and principles of the above modules and neural network models can refer to the corresponding contents in the above method embodiments, which will not be repeated here.
[0348] Fig. 9 FIG. 1 is a schematic diagram showing the structure of an identification device provided by an embodiment of the present application. Fig. 9 As shown, the device includes: a first feature extraction module 901, a first determination module 902, a first calculation module 903 and a second calculation module 904.
[0349] A first feature extraction module 901 is used to extract features from multiple frames of time series data to be identified, and obtain multiple frame features;
[0350] A first determination module 902 is used to determine the attention weight corresponding to each element in the multiple frame features according to the multiple frame features;
[0351] A first calculation module 903 is used to multiply each element of the plurality of frame features by its corresponding attention weight to obtain a plurality of weighted frame features;
[0352] The second calculation module 904 is used to synthesize the multiple weighted frame features to obtain a recognition result.
[0353] Furthermore, the first determining module 902 is specifically configured to:
[0354] Performing intra-frame and inter-frame convolution processing on the time series data features formed by stacking the multiple frame features to obtain convolution features;
[0355] According to the convolution feature, the attention weight corresponding to each element in the time series data feature is determined.
[0356] Furthermore, the second calculation module 904 is specifically configured to:
[0357] Performing intra-frame and inter-frame summing pooling processing on the weighted time series data features formed by stacking the multiple weighted frame features to obtain fused features;
[0358] The recognition result is obtained according to the fusion feature.
[0359] It should be noted here that: the recognition device provided in the above embodiment can realize the technical solutions and technical effects described in the above corresponding method embodiments. The specific implementation and principles of the above modules and neural network models can refer to the corresponding contents in the above method embodiments, which will not be repeated here.
[0360] Figure 7FIG. 1 is a schematic diagram showing the structure of an identification device provided by an embodiment of the present application. Figure 7 As shown, the device includes: a first acquisition module 701 and a first input module 702. Among them,
[0361] The first acquisition module 701 is used to acquire data to be identified;
[0362] The first input module 702 is used to input the data to be recognized into the trained neural network model to obtain a recognition result;
[0363] Among them, the neural network model is used to: extract features of the data to be identified to obtain data features; determine the attention weights corresponding to each element in the data features based on the data features; multiply each element in the data features by its corresponding attention weight to obtain weighted data features; and obtain the recognition result based on the weighted data features.
[0364] It should be noted here that: the recognition device provided in the above embodiment can realize the technical solutions and technical effects described in the above corresponding method embodiments. The specific implementation and principles of the above modules and neural network models can refer to the corresponding contents in the above method embodiments, which will not be repeated here.
[0365] Fig. 9 FIG. 1 is a schematic diagram showing the structure of an identification device provided by an embodiment of the present application. Fig. 9 As shown, the device includes: a first feature extraction module 901, a first determination module 902, a first calculation module 903 and a second calculation module 904.
[0366] The first feature extraction module 901 is used to extract features from the data to be identified to obtain data features;
[0367] A first determination module 902 is used to determine the attention weight corresponding to each element in the data feature according to the data feature;
[0368] A first calculation module 903 is used to multiply each element in the data feature by its corresponding attention weight to obtain a weighted data feature;
[0369] The second calculation module 904 is used to obtain the recognition result according to the weighted data features.
[0370] It should be noted here that: the recognition device provided in the above embodiment can realize the technical solutions and technical effects described in the above corresponding method embodiments. The specific implementation and principles of the above modules and neural network models can refer to the corresponding contents in the above method embodiments, which will not be repeated here.
[0371] Fig.10FIG. 1 is a schematic diagram showing the structure of an electronic device provided by an embodiment of the present application. Fig.10 As shown, the electronic device includes a memory 1101 and a processor 1102. The memory 1101 can be configured to store various other data to support operations on the electronic device. Examples of these data include instructions for any application or method for operating on the electronic device. The memory 1101 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as a static random access memory (SRAM), an electrically erasable programmable read-only memory (EEPROM), an erasable programmable read-only memory (EPROM), a programmable read-only memory (PROM), a read-only memory (ROM), a magnetic memory, a flash memory, a magnetic disk or an optical disk.
[0372] The memory 1101 is used to store programs;
[0373] The processor 1102 is coupled to the memory 1101 and is used to execute the program stored in the memory 1101 to implement the video recognition method, model training method, time series data recognition method or data recognition method provided by the above-mentioned method embodiments.
[0374] Further, if Fig.10 As shown, the electronic device also includes: a communication component 1103, a display 1104, a power component 1105, an audio component 1106 and other components. Fig.10 Only some components are shown schematically, which does not mean that the electronic device only includes Fig.10 Components shown.
[0375] Accordingly, an embodiment of the present application also provides a computer-readable storage medium storing a computer program, which, when executed by a computer, can implement the steps or functions of each method in the video recognition method, model training method, time series data recognition method, and data recognition method provided in the above-mentioned method embodiments.
[0376] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0377] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0378] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A video recognition method, characterized in that: include: Acquire a video to be identified; wherein the video to be identified includes multiple frames of images; Inputting the video to be recognized into a trained neural network model to obtain a recognition result; Among them, the neural network model is used to: extract features from the multiple frame images respectively to obtain multiple frame features; determine the attention weight corresponding to each element in the multiple frame features based on the multiple frame features, including: perform spatiotemporal convolution on the video features stacked by the multiple frame features to obtain spatiotemporal features; determine the attention weight corresponding to each element in the video features based on the spatiotemporal features; multiply each element in the multiple frame features by its corresponding attention weight to obtain multiple weighted frame features; and obtain the recognition result by combining the multiple weighted frame features.
2. The method according to claim 1, characterized in that Performing spatiotemporal convolution on the video features formed by stacking the multiple frame features to obtain spatiotemporal features, including: Using a combination of two-dimensional spatial convolution and one-dimensional temporal convolution, the video features are subjected to spatiotemporal convolution to obtain initial spatiotemporal features; The spatiotemporal features are determined according to the initial spatiotemporal features.
3. The method according to claim 2, characterized in that Determining the space-time feature according to the initial space-time feature includes: The video feature and the initial spatiotemporal feature are added element by element to obtain the spatiotemporal feature.
4. The method according to any one of claims 1 to 3, characterized in that Combining the plurality of weighted frame features to obtain the recognition result includes: Performing a spatiotemporal summing pooling process on the weighted video features formed by stacking the plurality of weighted frame features to obtain a fusion feature; The recognition result is obtained according to the fusion feature.
5. The method according to claim 4, characterized in that Determining the attention weight corresponding to each element in the video feature according to the spatiotemporal feature includes: Normalized exponential processing is performed on each element in each of the summed pooling windows in the spatiotemporal features to obtain a weighted feature containing the attention weight corresponding to each element in the video features.
6. The method according to claim 4, characterized in that The summed pooling is global summed pooling.
7. The method according to claim 4, characterized in that The recognition result is obtained according to the fusion feature, including: Using the fused features as input of at least one fully connected layer in the neural network model to obtain a fully connected result; The recognition result is determined according to the full connection result.
8. The method according to any one of claims 1 to 3, characterized in that Combining the plurality of weighted frame features to obtain the recognition result includes: Performing convolution processing on the multiple weighted frame features respectively to obtain multiple new frame features; Determining, according to the multiple new frame features, an attention weight corresponding to each element in the multiple new frame features; Multiplying each element of the multiple new frame features by its corresponding attention weight to obtain multiple new weighted frame features; The recognition result is obtained by combining the multiple new weighted frame features.
9. A model training method, characterized in that: include: Acquire a sample video; wherein the sample video includes multiple frames of images; Inputting the sample video into a neural network model to obtain a prediction recognition result; Optimizing parameters of the neural network model according to the predicted recognition result and the expected recognition result corresponding to the sample video; Among them, the neural network model is used to: extract features from the multiple frame images respectively to obtain multiple frame features; determine the attention weight corresponding to each element in the multiple frame features based on the multiple frame features, including: perform spatiotemporal convolution on the video features stacked by the multiple frame features to obtain spatiotemporal features; determine the attention weight corresponding to each element in the video features based on the spatiotemporal features; multiply each element in the multiple frame features by its corresponding attention weight to obtain multiple weighted frame features; and combine the multiple weighted frame features to obtain the predicted recognition result.
10. A neural network system, characterized in that: include: at least one first network layer, at least one second network layer, and at least one third network layer; wherein, The at least one first network layer is used to extract features from multiple frames of the video to be identified, respectively, to obtain multiple frame features; The at least one second network layer is used to determine the attention weight corresponding to each element in the multiple frame features according to the multiple frame features, including: performing spatiotemporal convolution on the video features formed by stacking the multiple frame features to obtain spatiotemporal features; determining the attention weight corresponding to each element in the video features according to the spatiotemporal features; and multiplying each element in the multiple frame features with its corresponding attention weight to obtain multiple weighted frame features; The at least one third network layer is used to integrate the multiple weighted frame features to obtain a recognition result.
11. The system according to claim 10, characterized in that The at least one third network layer comprises a pooling layer; The pooling layer is used to perform a temporal and spatial summing pooling process on the weighted video features formed by stacking the multiple weighted frame features to obtain a fused feature; The other network layers in the at least one third network layer except the pooling layer are used to obtain the recognition result according to the fusion feature.
12. The system according to claim 11, characterized in that The other network layers include at least one fully connected layer and an output layer.
13. An electronic device, characterized in that: include: A memory and a processor, wherein The memory is used to store programs; The processor is coupled to the memory and is configured to execute the program stored in the memory to: Acquire a video to be identified; wherein the video to be identified includes multiple frames of images; Inputting the video to be recognized into a trained neural network model to obtain a recognition result; Among them, the neural network model is used to: extract features from the multiple frame images respectively to obtain multiple frame features; determine the attention weight corresponding to each element in the multiple frame features based on the multiple frame features, including: perform spatiotemporal convolution on the video features stacked by the multiple frame features to obtain spatiotemporal features; determine the attention weight corresponding to each element in the video features based on the spatiotemporal features; multiply each element in the multiple frame features by its corresponding attention weight to obtain multiple weighted frame features; and obtain the recognition result by combining the multiple weighted frame features.
14. An electronic device, characterized in that: include: A memory and a processor, wherein The memory is used to store programs; The processor is coupled to the memory and is configured to execute the program stored in the memory to: Acquire a sample video; wherein the sample video includes multiple frames of images; Inputting the sample video into a neural network model to obtain a prediction recognition result; Optimizing parameters of the neural network model according to the predicted recognition result and the expected recognition result corresponding to the sample video; Among them, the neural network model is used to: extract features from the multiple frame images respectively to obtain multiple frame features; determine the attention weight corresponding to each element in the multiple frame features based on the multiple frame features, including: perform spatiotemporal convolution on the video features stacked by the multiple frame features to obtain spatiotemporal features; determine the attention weight corresponding to each element in the video features based on the spatiotemporal features; multiply each element in the multiple frame features by its corresponding attention weight to obtain multiple weighted frame features; and combine the multiple weighted frame features to obtain the predicted recognition result.
