Human motion recognition method and device
By performing multi-head attention calculations and tree-structured expressions of joint point relationships in the Transformer model, combined with convolutional network extraction of features, the problem of large amounts of calculation and low recognition accuracy in the existing technology is solved, and the amount of calculation in human action recognition is reduced. and improved accuracy.
Patent Information
- Application Number
- CN202411038403.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-31
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2044-07-31
AI Technical Summary
Existing human action recognition methods based on deep learning cannot balance the amount of calculation and recognition accuracy. The graph neural network requires more parameters, resulting in a large amount of calculation, while the Transformer-based method ignores the physical connection between human bones, resulting in low recognition accuracy. Low.
The Transformer model is used to calculate multi-head attention, and is combined with a tree structure to express the adjacency relationship of human body joint points. The convolutional network is used to extract time-depth features, reduce model parameters, and express soft and hard connections, thereby improving action recognition accuracy.
By reducing the parameters of the deep network model, the amount of calculation is reduced, while the accuracy of action recognition is improved, achieving both calculation amount and recognition accuracy.
Smart Images

Figure CN118570880B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computers, and more specifically, to a method and device for human motion recognition. Background Art
[0002] There have been many studies on behavior recognition based on human skeleton action sequences. In related studies, human skeleton behavior consists of limb positions in space and limb changes in time. When identifying behavior, it is often necessary to obtain spatial information and temporal information, that is, to extract the temporal and spatial features of human skeleton data. Among the behavior recognition methods for human skeleton action sequences, there are mainly traditional methods and behavior recognition methods based on deep learning. Among them, traditional methods use manually designed methods to extract spatiotemporal features of skeleton data, such as the length and angle between joints and bones, and then classify and recognize them through pattern recognition methods. Since manually designed features rely on human cognition of behavior and action, it is difficult to extract hidden information of behavior by directly using manually designed features for classification. The method based on deep learning can extract features containing rich information from a large amount of data, and has achieved quite good results in tasks such as classification and recognition. In recent years, deep learning methods based on graph neural networks (GNN) and Transformer have achieved remarkable results in human skeleton action recognition.
[0003] The method based on graph neural network uses the graph data structure to represent the temporal and spatial adjacency relationship between the joints and bones of the human skeleton, and then extracts the features of the human action sequence by convolution of the adjacent joints or bones. The classic algorithm is Spatial Temporal Graph Convolutional Networks (ST-GCN). At present, the method based on spatiotemporal graph convolutional network and its improved method have achieved a high action recognition rate on public data sets (such as NTU-RGB+D 60, etc.). However, the method based on graph neural network needs to consider the physical connection between the joints or bones of the human body and the dynamic connection relationship between the joints or bones in the action sequence, so more parameters need to be introduced in the network structure, and the amount of calculation will be greater.
[0004] The Transformer-based deep learning method abandons the traditional neural network structure. The entire network is completely composed of the attention mechanism, which can greatly reduce the amount of model calculations and make the model lightweight. In terms of human skeletal action representation, the attention mechanism directly obtains the connection (soft connection) between human joints through calculation. Although it alleviates the disadvantage of the GNN-based method that can only capture local features, it ignores the inherent physical connection (hard connection) between human bones. Therefore, its action recognition accuracy is lower than that of the GNN-based method.
[0005] Therefore, existing behavior recognition methods based on deep learning cannot balance computational complexity and recognition accuracy. Summary of the invention
[0006] In view of this, the embodiments of the present application are committed to providing a method and device for human motion recognition to solve the problem that the behavior recognition method based on deep learning cannot take into account both the amount of calculation and the recognition accuracy.
[0007] In a first aspect, this specification provides a method for human motion recognition, comprising:
[0008] Preprocessing the sample containing the target object to obtain a preprocessed sample;
[0009] Based on the deep learning model Transformer, multi-head attention calculation is performed on the preprocessed samples to obtain attention samples;
[0010] Based on the tree structure, the attention samples are aggregated in the spatial dimension to obtain spatial samples containing spatial depth features. The spatial samples represent the adjacency relationship of multiple joints of the human skeleton.
[0011] Based on the convolutional network, spatial samples are aggregated in the time dimension to obtain spatiotemporal samples containing temporal depth features;
[0012] The spatiotemporal samples are input into the action classification model and the action of the target object is output.
[0013] According to the first aspect, in a possible implementation, information aggregation is performed on the attention samples in the spatial dimension based on the tree structure, including:
[0014] Based on the learnable weight matrix, the attention sample is updated to generate the learned attention sample, where the learnable weight matrix is a set of connections between one of the multiple joint points and any one of the multiple joint points;
[0015] Based on the node relationship matrix, the learned attention samples are updated to generate associated attention samples. The node relationship matrix is a collection of parent-child information of multiple joints.
[0016] Based on the relevance constraint matrix, the associated attention samples are updated to generate spatial samples. The relevance constraint matrix is a set of cosine similarity coefficients between one of multiple joint points and any one of the multiple joint points.
[0017] According to the first aspect, in a possible implementation, preprocessing a sample containing a target object includes:
[0018] Perform high-dimensional embedding on the samples to obtain high-dimensional embedded samples;
[0019] Position-encode multiple joint points in the sample in time and space to obtain position-encoded samples;
[0020] The high-dimensional embedded samples are added to the position-encoded samples to obtain the preprocessed samples.
[0021] According to the first aspect, in a possible implementation, position encoding is performed on multiple joint points in the sample in time and space, including:
[0022] Based on the binary group, multiple joint points are encoded in position, and the binary group contains the time frame and multiple joint points;
[0023] Multiple joint points are encoded according to the following formula:
[0024]
[0025] in, PE () represents the feature matrix after position encoding, v Indicates multiple joint points, t represents the time frame, i represents the coding dimension; C pos Represents the sine and cosine code length.
[0026] According to the first aspect, in a possible implementation, based on the deep learning model Transformer, multi-head attention calculation is performed on the preprocessed samples, including:
[0027] Perform convolution operation on the preprocessed samples to generate Q weight matrix, K weight matrix and V weight matrix;
[0028] Calculate the similarity between the Q weight matrix and the transpose of the K weight matrix, and use the similarity as the weight;
[0029] Use Tanh function to normalize weights;
[0030] The normalized weights and the corresponding V weight matrix are weighted and summed to obtain the attention sample.
[0031] In a second aspect, this specification provides a human motion recognition device, comprising:
[0032] A preprocessing unit, used to preprocess the sample containing the target object to obtain a preprocessed sample;
[0033] Spatial information aggregation unit, including:
[0034] The multi-head attention calculation module is used to perform multi-head attention calculation on the preprocessed samples based on the deep learning model Transformer to obtain attention samples;
[0035] The tree topology building module is used to aggregate the information of the attention samples in the spatial dimension based on the tree structure to obtain spatial samples containing spatial depth features. The spatial samples represent the adjacency relationship of multiple joints of the human skeleton.
[0036] The time information aggregation unit is used to aggregate the spatial samples in the time dimension based on the convolutional network to obtain the spatiotemporal samples containing time depth features;
[0037] The classification and recognition unit is used to input the spatiotemporal samples into the action classification model and output the action of the target object.
[0038] According to the second aspect, in a possible implementation manner, the tree topology building module is specifically used to:
[0039] Based on the learnable weight matrix, the attention sample is updated to generate the learned attention sample, where the learnable weight matrix is a set of connections between one of the multiple joint points and any one of the multiple joint points;
[0040] Based on the node relationship matrix, the learned attention samples are updated to generate associated attention samples. The node relationship matrix is a collection of parent-child information of multiple joints.
[0041] Based on the relevance constraint matrix, the associated attention samples are updated to generate spatial samples. The relevance constraint matrix is a set of cosine similarity coefficients between one of multiple joint points and any one of the multiple joint points.
[0042] According to the second aspect, in a possible implementation manner, the preprocessing unit includes:
[0043] A high-dimensional embedding module is used to perform high-dimensional embedding on samples to obtain samples after high-dimensional embedding;
[0044] A position encoding module is used to perform position encoding on multiple joint points in the sample in time and space to obtain position-encoded samples;
[0045] The sum processing module is used to add the high-dimensional embedded samples and the position-encoded samples to obtain preprocessed samples.
[0046] According to the second aspect, in a possible implementation manner, the position encoding module is specifically used to:
[0047] Based on the binary group, multiple joint points are encoded in position, and the binary group contains the time frame and multiple joint points;
[0048] Multiple joint points are encoded according to the following formula:
[0049]
[0050] in, PE () represents the feature matrix after position encoding, v Indicates multiple joint points, t represents the time frame, i represents the coding dimension; C pos Represents the sine and cosine code length.
[0051] According to the second aspect, in one possible implementation, the multi-head attention calculation module is specifically used for:
[0052] Perform convolution operation on the preprocessed samples to generate Q weight matrix, K weight matrix and V weight matrix;
[0053] Calculate the similarity between the Q weight matrix and the transpose of the K weight matrix, and use the similarity as the weight;
[0054] Use Tanh function to normalize weights;
[0055] The normalized weights and the corresponding V weight matrix are weighted and summed to obtain the attention sample.
[0056] In a third aspect, this specification provides an electronic device comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can perform each step in any one of the described methods.
[0057] In a fourth aspect, the present specification provides a computer-readable storage medium, the computer-readable storage medium comprising a stored program, wherein the program executes each step in any one of the described methods.
[0058] Compared with the prior art, the beneficial effects of the present invention are:
[0059] Different from the prior art, the human action recognition method provided by the present invention obtains preprocessed samples by preprocessing samples containing target objects; performs multi-head attention calculation on the preprocessed samples based on the deep learning model Transformer to obtain attention samples; performs information aggregation on the attention samples in the spatial dimension based on the tree structure to obtain spatial samples containing spatial depth features, and the spatial samples represent the adjacency relationship of multiple joints of the human skeleton; performs information aggregation on the spatial samples in the time dimension based on the convolutional network to obtain spatiotemporal samples containing temporal depth features; inputs the spatiotemporal samples into the action classification model to output the action of the target object. The present invention reduces the amount of calculation by reducing the parameters of the deep network model through the multi-head attention obtained by the deep learning model Transformer, and simultaneously expresses hard connections through the multi-head attention expression of soft connections and the adjacency relationship of human joints represented by the tree structure, thereby improving the accuracy of action recognition. BRIEF DESCRIPTION OF THE DRAWINGS
[0060] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.
[0061] Figure 1 A schematic diagram of a human body motion recognition method according to an embodiment of the present invention;
[0062] Figure 2 A schematic diagram of the hierarchical relationship of human joints before and after processing based on a tree structure provided in an embodiment of the present application;
[0063] Figure 3 A schematic diagram of a model framework based on a human motion recognition method provided in an embodiment of the present application;
[0064] Figure 4 A schematic diagram of a human motion recognition device provided in an embodiment of the present application;
[0065] Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0066] Unless otherwise defined, the technical terms or scientific terms used in the embodiments of this specification shall have the common meanings understood by persons with ordinary skills in the field to which this specification belongs. The words "first", "second" and similar words used in the embodiments of this specification do not indicate any order, quantity or importance, but are only used to avoid confusion of constituent elements.
[0067] Unless the context requires otherwise, throughout the specification, "plurality" means "at least two", and "including" is interpreted as an open, inclusive meaning, that is, "including, but not limited to". In the description of the specification, the terms "one embodiment", "some embodiments", "exemplary embodiments", "examples", "specific examples" or "some examples" are intended to indicate that a particular feature, structure, material or characteristic associated with the embodiment or example is included in at least one embodiment or example of the specification. The schematic representation of the above terms does not necessarily refer to the same embodiment or example.
[0068] The following will be combined with the drawings in the embodiments of this specification to clearly and completely describe the technical solutions in the embodiments of this specification. Obviously, the described embodiments are only part of the embodiments of this specification, not all of the embodiments. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this specification.
[0069] As mentioned above, although the Transformer-based deep learning method greatly reduces the amount of computation of the model, making the model lightweight and reducing the amount of computation, the recognition accuracy is low because it only obtains the connection between the human joints (soft connection) through calculation and ignores the inherent physical connection (hard connection) between the human bones. Therefore, this application considers making improvements based on the Transformer model, only using the Transformer model self-attention layer for attention calculation, and then combining the tree structure to express the adjacency relationship of the human joints. That is, for the human skeletal joint sequence obtained based on motion capture technology, the connection relationship and degree of connection between the human joints are represented and calculated by combining the tree structure representation with the attention mechanism in the Transformer, and then the recognition of human movements is realized through classification recognition.
[0070] like Figure 1 As shown, it is a flow chart of a human motion recognition method provided by an embodiment of the present invention, and the method may specifically include the following steps.
[0071] S110: Preprocessing the sample containing the target object to obtain a preprocessed sample, wherein the sample information includes the number of action sequence frames, the number of human skeleton joints, and the number of channels of each joint;
[0072] S120: Based on the deep learning model Transformer, multi-head attention calculation is performed on the preprocessed samples to obtain attention samples;
[0073] S130: Based on the tree structure, information aggregation is performed on the attention samples in the spatial dimension to obtain spatial samples containing spatial depth features, wherein the spatial samples represent the adjacency relationship of multiple joints of the human skeleton;
[0074] S140: Based on the convolutional network, information aggregation is performed on the spatial samples in the time dimension to obtain spatiotemporal samples containing time depth features;
[0075] S150: Input the spatiotemporal samples into the action classification model, and output the action of the target object.
[0076] In the above method, first, the depth camera can be used to pre-process the sample (i.e., video data) containing the target object, so as to convert the sample data into three-dimensional data located in the x, y, and z spaces for subsequent processing. Then, the attention layer of the encoding component in the Transformer model is used to perform multi-head attention calculations. Next, based on the tree structure, information of the sample is aggregated in the spatial dimension to extract spatial depth features. Then, based on the convolutional network, information of the sample is aggregated in the temporal dimension to extract temporal depth features. Finally, the sample is input into the action classification model to obtain the action of the identified target object.
[0077] The target object can be set as needed, and in this application it is a human body. The video data obtained by the depth camera can be multi-dimensional (for example, twelve dimensions), and the video data can be processed into three-dimensional data for subsequent recognition and processing through the camera's own algorithm. Transformer is essentially an Encoder-Decoder architecture. Therefore, the middle part of the Transformer can be divided into two parts: an encoding component and a decoding component. Among them, the encoding component consists of multiple layers of encoders (Encoders). The decoding component is also composed of decoders (Decoders) with the same number of layers. The structure of each encoder is the same, but they use different weight parameters (the architecture of all encoders is the same, but the parameters are different). This application uses the Self-Attention layer in the encoding component to perform multi-head self-attention calculations to obtain soft connections.
[0078] A tree structure is a very basic and widely used data structure that simulates the hierarchical and branching structure of trees in nature. In a tree structure, there is a hierarchical relationship between data elements (called nodes). Each node can have zero or more child nodes, but each non-root node has only one parent node (except the root node, which has no parent node). Tree structures have many applications in computer science, such as the directory structure of file systems, the DOM tree of HTML documents, decision trees, syntax analysis trees, etc. They provide an effective way to organize and represent data with hierarchical relationships. A tree graph is a graph structure used to represent hierarchical or classified data. It represents information in a graph data that introduces a tree structure, where each node represents an entity (such as an item, category, concept, etc.), and the lines or edges connecting these nodes represent the relationship or hierarchical structure between these entities. Based on the skeleton graph, this application uses a tree structure to represent the adjacency relationship of human joints, thereby forming hard connections. For example Figure 2 As shown in FIG. 1 , it is a schematic diagram of the hierarchical relationship of human joints before and after processing based on the tree structure. In the figure, 1 to 25 represent various bone joints.
[0079] Information aggregation in the time dimension, specifically using convolution to aggregate inter-frame features of the same joint point, thereby completing temporal depth feature extraction. Finally, the sample is input into the action classification model for action classification, thereby completing action recognition.
[0080] In at least one embodiment of the present application, in order to obtain a stable and reliable hard connection, the information aggregation of the attention samples in the spatial dimension based on the tree structure can be designed to include:
[0081] Based on the learnable weight matrix, the attention sample is updated to generate the learned attention sample, where the learnable weight matrix is a set of connections between one of the multiple joint points and any one of the multiple joint points;
[0082] Based on the node relationship matrix, the learned attention samples are updated to generate associated attention samples. The node relationship matrix is a collection of parent-child information of multiple joints.
[0083] Based on the relevance constraint matrix, the associated attention samples are updated to generate spatial samples. The relevance constraint matrix is a set of cosine similarity coefficients between one of multiple joint points and any one of the multiple joint points.
[0084] The introduced learnable weight matrix can be updated by back propagation during the training process of the entire deep learning model (i.e., the Tree-Graph Transformer in this paper). Its goal is to update the value of the current joint point by calculating the connection between the current joint point and other joint points. When training a deep learning model, forward propagation and back propagation are interdependent. On the one hand, the calculation of forward propagation may depend on the current values of the model parameters, which are iterated by the optimization algorithm after the gradient calculation of back propagation. On the other hand, the gradient calculation of back propagation may depend on the current values of each variable, which is obtained by forward propagation. Forward propagation calculates and stores the intermediate variables of the neural network in sequence from the input layer to the output layer. Back propagation calculates and stores the gradients of the intermediate variables and parameters of the neural network in sequence from the output layer to the input layer. Considering the inherent physical connection relationship between joints, a node relationship matrix is introduced, which is used to establish the hierarchical relationship between joints. The correlation constraint matrix uses the cosine similarity coefficient to reflect the constraints on the strength of the correlation between joints. Through the above three matrix designs, a stable and reliable hard connection that reflects the adjacency relationship of joints is achieved.
[0085] In at least one embodiment of the present application, preprocessing a sample containing a target object includes:
[0086] Perform high-dimensional embedding on the samples to obtain high-dimensional embedded samples;
[0087] Position-encode multiple joint points in the sample in time and space to obtain position-encoded samples;
[0088] The high-dimensional embedded samples are added to the position-encoded samples to obtain the preprocessed samples.
[0089] High-dimensional embedding is used to change the sample dimension to encode the position of the joint points of the input sample; the position of the joint points at different times and positions is encoded to correspond the joint points to the position for subsequent recognition processing. All of the above processing can be completed by the depth camera itself.
[0090] In at least one embodiment of the present application, in order to better perform position encoding, the position encoding of multiple joint points in the sample in time and space can be designed to include:
[0091] Based on the binary group, multiple joint points are encoded in position, and the binary group contains the time frame and multiple joint points;
[0092] Multiple joint points are encoded according to the following formula:
[0093]
[0094] in, PE () represents the feature matrix after position encoding, v Indicates multiple joint points, t represents the time frame, i represents the coding dimension; C pos Represents the sine and cosine code length.
[0095] Generally, position encoding adopts a one-dimensional method. The present application combines the time and space positions of the joints into a binary group, which can retain the spatial position information of the joint points, and maps the binary group to a higher-dimensional space through sine and cosine transforms, which can better retain the high-frequency information that reflects the changes in the time and space positions.
[0096] In at least one embodiment of the present application, in order to perform multi-head attention calculation, the multi-head attention calculation of the preprocessed samples based on the deep learning model Transformer can be designed to include:
[0097] Perform convolution operation on the preprocessed samples to generate Q weight matrix, K weight matrix and V weight matrix;
[0098] Calculate the similarity between the Q weight matrix and the transpose of the K weight matrix, and use the similarity as the weight;
[0099] Use Tanh function to normalize weights;
[0100] The normalized weights and the corresponding V weight matrix are weighted and summed to obtain the attention sample.
[0101] This application obtains the Q, K and V weight matrices through convolution operations, then calculates the similarity between Q and K to obtain the weights, then uses the Tanh function to normalize the weights, and finally adds the normalized weights and the corresponding V weight matrix to obtain the attention sample.
[0102] The following is an example of a human action recognition method.
[0103] like Figure 3 As shown in the figure, it is a schematic diagram of the model framework provided by an embodiment of the present invention. As shown in the figure, the sample is first preprocessed (such as high-dimensional embedding, position encoding), and then sent to a multi-layer feature extraction module. Each layer completes the spatial information aggregation represented by attention calculation and tree structure and the temporal information aggregation realized by convolution, and finally connected to the linear layer for classification and recognition.
[0104] 1. Data Preprocessing
[0105] Assume that the human skeleton action sequence obtained by motion capture technology is X ( ), that is, a sequence X represents a sample, where T Indicates the number of action sequence frames, V is the number of human skeleton joints, C Represents the number of channels of each joint point, that is, the feature dimension of the joint point.
[0106] 1.1 High-dimensional embedding
[0107] pass The convolution kernel input X Perform high-dimensional embedding, and the embedding dimension is consistent with the preset dimension of the first feature extraction layer. Its mathematical expression is:
[0108] (1)
[0109] express After high-dimensional embedding, the input sample becomes , here C in This is the number of dimensions after high-dimensional embedding. Change the sample dimension order to It is convenient to use sine and cosine functions of different frequencies to encode the joint point positions of the input samples to obtain the position encoding of the joint points.
[0110] 1.2 Positional Encoding
[0111] The present invention uses a binary group to identify the position of the joint points in the human action sequence. p Encode ( t , v )(0≤ t < T , 0≤ v < V ),( t , v ) represents the joint point v In the t The position of the frame. t , v ) performs two-dimensional sine and cosine function position encoding, and its expression is shown in formula (2):
[0112] (2)
[0113] In the formula, i represents the coding dimension; C pos Represents the sine and cosine code lengths. To be consistent with the high-dimensional embedding sample dimensions, C pos = Cin / 4.
[0114] The samples after high-dimensional embedding X inq The corresponding spatiotemporal position codes are added and marked as X in , the pre-processed samples , and the position encoding ends here.
[0115] At this point, the human skeleton joint data preprocessing process is completed.
[0116] 2. Deep feature extraction of human skeleton joint data
[0117] After pre-processing, the samples After that, the sample is sent to the feature extraction layer for processing. Specifically, it includes the following steps.
[0118] 2.1 Using Transformer’s encoding component for multi-head attention calculation
[0119] This section uses the attention mechanism to model the relationship between the inputs. Specifically, the input X in use Convolution kernel generation Q (Query), K (key), V (value) three different weight matrices, as shown in formula (3):
[0120] (3)
[0121] Then, calculate Q and K The similarity between the transposes of and uses the similarity as the weight. As in the standard Transformer process, the dot product is used as the query Q With key K The similarity calculation function is then used to normalize the obtained weights using the Tanh function, and then the weights and corresponding values are V The weighted sum is used to obtain the final attention, as shown in formula (4):
[0122] (4)
[0123] in, C Represents the scaling factor, usually K The square root of the single vector dimension of the matrix is used for scaling and avoidance X att Too large, so that the gradient during training is more stable.
[0124] Based on the above description of the attention mechanism, a multi-head attention mechanism is introduced, which allows the model to learn relevant information in different subspaces, and then concatenate the information of each subspace and send it to subsequent processing, as shown in formula (5):
[0125] (5)
[0126] in, express n The number of attention heads, that is n A diverse group of learnable Q , K , V Combination of matrices.
[0127] This completes the calculation of the multi-head attention mechanism.
[0128] 2.2 Spatial Information Aggregation of Node Dependencies Based on Tree Structure Representation
[0129] This section is for samples that have been calculated using multi-head attention. X att Information aggregation in the spatial dimension is mainly divided into three parts. The specific steps are as follows:
[0130] 2.2.1 Learnable Weight Matrix W
[0131] Introducing learnable weight matrix W The goal is to update the value of the current joint point by calculating the connection between the current joint point and other joint points. Taking a single frame as an example, its mathematical principle is shown in the following formula (6):
[0132] (6)
[0133] In the above formula x Att_i Representative i Joint points, Representative i The joints and j The weights between the joint points are obtained through training, and their matrix form is shown in formula (7):
[0134] (7)
[0135] In the above formula X new This represents the updated input matrix (i.e., the attention sample after learning) X att , W That is The learnable weight matrix composed of
[0136] 2.2.2 Node Relationship Matrix G
[0137] After the weight matrix is introduced, the inherent physical connection relationship between the joints is considered. Figure 2 The tree structure shown builds a relationship matrix between joint points, and the relationship matrix is used to establish the hierarchical relationship between the joint points.
[0138] In order to fully consider the contribution of the joint point itself and its child nodes in the tree structure, according to the attached Figure 2 The node-level relationship can construct a relationship matrix containing parent-child information G , which is expressed as shown in formula (8):
[0139] (8)
[0140] In the above formula v Represents the number of joint points, G The elements in each column of represent the dependency of the child node on the parent node, such as G Middle i Columns, indicating other nodes and nodes i The dependencies, G The values of the elements are:
[0141] (9)
[0142] In the above formula Representation Node j With its upper node i There is a hierarchical connection relationship. Representation Node j With its upper node i There is no hierarchical connection.
[0143] Then formula (6) can be further expressed as formula (10):
[0144] (10)
[0145] in g ij Representative i The joints and j The parent-child hierarchical relationship between the joint points is expressed in matrix form (i.e., the associated attention samples), then formula (7) is modified to the following formula (11):
[0146] (11)
[0147] Figure 2The 25 joint points are generated according to preset rules. It can be understood that other numbers of skeleton graph joint points can also be generated according to other preset rules.
[0148] 2.2.3 Correlation Constraint Matrix
[0149] The correlation constraint matrix uses the cosine similarity coefficient to reflect the correlation strength constraints between joint points. α ij That means i The joints and j The cosine similarity coefficient (correlation strength) of the joint points is calculated as follows:
[0150] (13)
[0151] Constrain the strength of the correlation α ij Introduced into formula (10), formula (10) can be expressed as:
[0152] (12)
[0153] Then formula (11) is finally expressed as formula (14):
[0154] (14)
[0155] in, A is constrained by the correlation strength between joint points α ij The matrix composed of.
[0156] At this point, spatial samples are generated and spatial information aggregation based on the tree structure and node relationship matrix is completed.
[0157] 2.3 Using Convolutional Networks to Aggregate Information in the Time Dimension
[0158] This part is used as a feature aggregation layer on a time dimension in the model. The convolution kernel aggregates the spatial information aggregation result into inter-frame feature aggregation of the same joint point (i.e., obtains spatiotemporal samples), as shown in formula (15):
[0159] (15)
[0160] At this point, the processing of spatial depth feature extraction and temporal depth feature extraction is completed. The more detailed processing process includes operations such as residual connection to make its training more stable.
[0161] At this point, the spatiotemporal depth feature extraction of human skeletal joint data is completed.
[0162] 3. Action Recognition
[0163] After completing the spatiotemporal and deep feature extraction of human skeleton joint data, the aggregated information X out After layer normalization, a fully connected layer is connected ( FC Layer) directly performs action classification tasks, and its mathematical expression is:
[0164] (16)
[0165] In the above formula, FC Represents fully connected layers, whose input is the aggregate information normalized by the layer X out , the output dimension is composed of the total number of categories in the classification task Classes Decide; y is the predicted value.
[0166] Action classification model uses cross entropy as loss function Loss For training, the mathematical expression is:
[0167] (17)
[0168] In the above formula, is the actual value, i.e., the label.
[0169] Finally, a prediction vector is output , classes Represents the total number of action categories, each component is the probability corresponding to each action category, and the category represented by the maximum probability is taken as the predicted action category.
[0170] This completes the action recognition task.
[0171] This application improves on the Transformer model, uses the self-attention layer to perform multi-head attention calculations, builds the human joint adjacency relationship based on the tree structure, uses the convolutional network to extract time-depth features, and performs action recognition through the action classification model. Therefore, the model parameters are reduced to reduce the amount of calculation, and the expression of soft connections and hard connections is realized at the same time, thereby improving the recognition accuracy, achieving both reduced calculation and improved recognition accuracy in action recognition.
[0172] like Figure 4 As shown, a human motion recognition device 400 provided by an embodiment of the present invention includes:
[0173] A preprocessing unit 410 is used to preprocess the sample containing the target object to obtain the preprocessed sample, wherein the sample information includes the number of action sequence frames, the number of human skeleton joints and the number of channels of each joint;
[0174] The spatial information aggregation unit 420 includes:
[0175] A multi-head attention calculation module (not shown) is used to perform multi-head attention calculation on the preprocessed samples based on the deep learning model Transformer to obtain attention samples;
[0176] A tree topology building module (not shown) is used to aggregate information of attention samples in the spatial dimension based on the tree structure to obtain spatial samples containing spatial depth features, and the spatial samples represent the adjacency relationship of multiple joints of the human skeleton;
[0177] The time information aggregation unit 430 is used to aggregate the spatial samples in the time dimension based on the convolutional network to obtain the spatiotemporal samples containing time depth features;
[0178] The classification and identification unit 440 is used to input the spatiotemporal samples into the action classification model and output the action of the target object.
[0179] In the above-mentioned device, first, a preprocessing unit (such as a depth camera) can be used to preprocess samples containing the target object (i.e., video data), so as to convert the sample data into three-dimensional data located in the x, y, and z spaces for subsequent processing. Then, the multi-head attention calculation module of the spatial information aggregation unit is used to perform multi-head attention calculations by the attention layer of the encoding component in the Transformer model. Then, a tree topology construction module is used to aggregate information on the samples in the spatial dimension, so as to extract spatial depth features. Then, a temporal information aggregation unit is used to aggregate information on the samples in the temporal dimension, so as to extract temporal depth features. Finally, the classification and recognition unit outputs the input spatiotemporal samples as the identified actions of the target object.
[0180] The target object can be set as needed, and in this application it is a human body. The video data obtained by the depth camera can be multi-dimensional (for example, twelve dimensions), and the camera's own algorithm can be used to process the video data into three-dimensional data for subsequent recognition and processing. Transformer is essentially an Encoder-Decoder architecture. Therefore, the middle part of the Transformer can be divided into two parts: an encoding component and a decoding component. This application uses the Self-Attention layer in the encoding component to perform multi-head self-attention calculations to obtain soft connections.
[0181] A tree structure is a very basic and widely used data structure that simulates the hierarchical and branching structure of trees in nature. In a tree structure, there is a hierarchical relationship between data elements (called nodes). Each node can have zero or more child nodes, but each non-root node has only one parent node (except the root node, which has no parent node). They provide an effective way to organize and represent data with hierarchical relationships. A tree graph is a graph structure used to represent hierarchical or classified data. It represents information in a graph data that introduces a tree structure, in which each node represents an entity (such as an item, category, concept, etc.), and the lines or edges connecting these nodes represent the relationship or hierarchical structure between these entities. Based on the skeleton graph, this application uses a tree structure to represent the adjacency relationship of human joints, thereby forming hard connections. For example Figure 2 The figure shows the hierarchical relationship of human joints before and after tree structure processing.
[0182] Information aggregation in the time dimension, specifically using convolution to aggregate inter-frame features of the same joint point, thereby completing temporal depth feature extraction. Finally, the sample is input into the action classification model for action classification, thereby completing action recognition.
[0183] In at least one embodiment of the present application, in order to obtain a stable and reliable hard connection, the tree topology building module may be designed to be specifically used for:
[0184] Based on the learnable weight matrix, the attention sample is updated to generate the learned attention sample, where the learnable weight matrix is a set of connections between one of the multiple joint points and any one of the multiple joint points;
[0185] Based on the node relationship matrix, the learned attention samples are updated to generate associated attention samples. The node relationship matrix is a collection of parent-child information of multiple joints.
[0186] Based on the relevance constraint matrix, the associated attention samples are updated to generate spatial samples. The relevance constraint matrix is a set of cosine similarity coefficients between one of multiple joint points and any one of the multiple joint points.
[0187] The introduced learnable weight matrix can be updated by back propagation during model training. Its goal is to update the value of the current joint point by calculating the connection between the current joint point and other joint points. When training deep learning models, forward propagation and back propagation are interdependent. On the one hand, the calculation of forward propagation may depend on the current values of model parameters, which are iterated by the optimization algorithm after the gradient calculation of back propagation. On the other hand, the gradient calculation of back propagation may depend on the current values of each variable, which is obtained by forward propagation. Forward propagation calculates and stores the intermediate variables of the neural network in sequence from the input layer to the output layer. Back propagation calculates and stores the gradients of the intermediate variables and parameters of the neural network in sequence from the output layer to the input layer. Considering the inherent physical connection relationship between joints, a node relationship matrix is introduced, which is used to establish the hierarchical relationship between joints. The correlation constraint matrix uses the cosine similarity coefficient to reflect the constraints on the strength of the correlation between joints. Through the above three designs, a stable and reliable hard connection that reflects the adjacency relationship of joints is achieved.
[0188] In at least one embodiment of the present application, the pre-processing unit 410 may be designed to include:
[0189] A high-dimensional embedding module is used to perform high-dimensional embedding on samples to obtain samples after high-dimensional embedding;
[0190] A position encoding module is used to perform position encoding on multiple joint points in the sample in time and space to obtain position-encoded samples;
[0191] The sum processing module is used to add the high-dimensional embedded samples and the position-encoded samples to obtain preprocessed samples.
[0192] High-dimensional embedding is used to change the sample dimension to encode the position of the joint points of the input sample; the position of the joint points at different times and positions is encoded to correspond the joint points to the position for subsequent recognition processing. All of the above processing can be completed by the depth camera itself.
[0193] In at least one embodiment of the present application, in order to better perform position encoding, the position encoding module may be designed to be specifically used for:
[0194] Based on the binary group, multiple joint points are encoded in position, and the binary group contains the time frame and multiple joint points;
[0195] Multiple joint points are encoded according to the following formula:
[0196]
[0197] in, PE () represents the feature matrix after position encoding, v Indicates multiple joint points, t represents the time frame, i represents the coding dimension; C pos Represents the sine and cosine code length.
[0198] Generally, position encoding adopts a one-dimensional method. The present application combines the time and space positions of the joints into a binary group, which can retain the spatial position information of the joint points, and maps the binary group to a higher-dimensional space through sine and cosine transforms, which can better retain the high-frequency information that reflects the changes in the time and space positions.
[0199] In at least one embodiment of the present application, in order to perform multi-head attention calculation, the multi-head attention calculation module can be designed to be specifically used for:
[0200] Perform convolution operation on the preprocessed samples to generate Q weight matrix, K weight matrix and V weight matrix;
[0201] Calculate the similarity between the Q weight matrix and the transpose of the K weight matrix, and use the similarity as the weight;
[0202] Use Tanh function to normalize weights;
[0203] The normalized weights and the corresponding V weight matrix are weighted and summed to obtain the attention sample.
[0204] This application obtains the Q, K and V weight matrices through convolution operations, then calculates the similarity between Q and K to obtain the weights, then uses the Tanh function to normalize the weights, and finally adds the normalized weights and the corresponding V weight matrix to obtain the attention sample.
[0205] like Figure 5 , which is a schematic diagram of the structure of an electronic device according to an embodiment of the present application. As shown in the figure, the electronic device 50 includes one or more processors 51 and a memory 52.
[0206] The processor 51 may be a central processing unit (CPU) or other forms of processing units having data processing capabilities and / or instruction execution capabilities, and may control other components in the electronic device 50 to perform desired functions.
[0207] The memory 52 may include one or more computer program products, and the memory may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. The volatile memory may include, for example, a random access memory (RAM) and / or a cache memory (cache), etc. The non-volatile memory may include, for example, a read-only memory (ROM), a hard disk, a flash memory, etc. One or more computer program instructions may be stored on the computer-readable storage medium, and the processor 51 may run the program instructions to implement the human motion recognition method of each embodiment of the present application described above and / or other desired functions. Various contents such as input signals, signal components, noise components, etc. may also be stored in the computer-readable storage medium.
[0208] In one example, the electronic device 50 may further include: an input device 53 and an output device 54 , and these components are interconnected via a bus system and / or other forms of connection mechanisms (not shown).
[0209] Of course, to simplify, Figure 5 Only some of the components related to the present application in the electronic device 50 are shown, and components such as a bus, an input / output interface, etc. are omitted. In addition, according to specific application conditions, the electronic device 50 may also include any other appropriate components.
[0210] Based on the embodiments of the present application, the present application also provides a computer-readable storage medium, wherein computer instructions are used to enable a computer to execute each step in the human motion recognition method of the aforementioned technical solution.
[0211] Based on the embodiments of the present application, the present application also provides a processor, which is used to run a program, wherein the program executes each step in the human motion recognition method of the aforementioned technical solution when it is run.
[0212] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, segment or portion of code comprising one or more executable instructions for implementing the steps of a custom logical function or process, and the scope of the preferred embodiments of the present invention includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in reverse order depending on the functions involved, which should be understood by technicians in the technical field to which the embodiments of the present invention belong.
[0213] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute instructions), or in combination with these instruction execution systems, devices or apparatuses. For the purposes of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in combination with these instruction execution systems, devices or apparatuses. More specific examples (non-exhaustive list) of computer-readable media include the following: an electrical connection with one or more wires (electronic device), a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), a fiber optic device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium and then editing, interpreting or processing in other suitable ways if necessary, and then stored in a computer memory.
[0214] It should be understood that each part of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the described embodiment, a plurality of steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system.
[0215] In addition, each functional unit in each embodiment of the present invention may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into one module. The integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium.
[0216] The above is only a specific implementation of this specification, but the protection scope of this specification is not limited to this. Any technician familiar with this technical field can easily think of changes or replacements within the technical scope disclosed in this specification, which should be included in the protection scope of this specification. Therefore, the protection scope of this specification should be based on the protection scope of the claims.
Claims
1. A human motion recognition method, characterized in that: include: Preprocessing the sample containing the target object to obtain a preprocessed sample; Based on the deep learning model Transformer, multi-head attention calculation is performed on the preprocessed samples to obtain attention samples; Based on the tree structure, information aggregation is performed on the attention samples in the spatial dimension to obtain spatial samples containing spatial depth features, wherein the spatial samples represent the adjacency relationship between multiple joints of the human skeleton; Based on a convolutional network, information aggregation is performed on the spatial samples in the time dimension to obtain spatiotemporal samples containing time depth features; Inputting the spatiotemporal samples into an action classification model, and outputting the action of the target object; The step of aggregating information of the attention samples in a spatial dimension based on a tree structure includes: Based on a learnable weight matrix, updating the attention sample to generate a learned attention sample, wherein the learnable weight matrix is a set of connections between one of the plurality of joint points and any one of the plurality of joint points; Based on a node relationship matrix, updating the learned attention samples to generate associated attention samples, wherein the node relationship matrix is a set of parent-child information of the plurality of joint points; Based on a correlation constraint matrix, updating the associated attention sample to generate the spatial sample, wherein the correlation constraint matrix is a set of cosine similarity coefficients between one of the multiple joint points and any one of the multiple joint points; Wherein, the node relationship matrix is constructed according to the hierarchical relationship of the human body joints.
2. The method according to claim 1, characterized in that The preprocessing of the sample containing the target object comprises: Performing high-dimensional embedding on the sample to obtain a high-dimensional embedded sample; Position-encoding the multiple joint points in the sample in time and space to obtain position-encoded samples; The high-dimensional embedded samples are added to the position-encoded samples to obtain the preprocessed samples.
3. The method according to claim 2, characterized in that The step of encoding the positions of the plurality of joint points in the sample in time and space comprises: Based on a binary group, position encoding is performed on the plurality of joint points, wherein the binary group includes a time frame and the plurality of joint points; The multiple joint points are position-encoded according to the following formula: ; in, PE () represents the feature matrix after position encoding, v represents the multiple joint points, t represents the time frame, i represents the coding dimension; C pos Represents the sine and cosine code length.
4. The method according to claim 1, characterized in that: The multi-head attention calculation is performed on the preprocessed samples based on the deep learning model Transformer, including: Performing convolution operation on the preprocessed samples to generate a Q weight matrix, a K weight matrix and a V weight matrix; Calculate the similarity between the Q weight matrix and the transpose of the K weight matrix, and use the similarity as the weight; Normalizing the weights using a Tanh function; The normalized weight and the corresponding V weight matrix are weighted and summed to obtain the attention sample.
5. A human motion recognition device, characterized in that: include: A preprocessing unit, used to preprocess the sample containing the target object to obtain a preprocessed sample; Spatial information aggregation unit, including: A multi-head attention calculation module is used to perform multi-head attention calculation on the preprocessed samples based on the deep learning model Transformer to obtain attention samples; A tree topology building module, which is used to aggregate the information of the attention samples in the spatial dimension based on the tree structure to obtain spatial samples containing spatial depth features, wherein the spatial samples represent the adjacency relationship of multiple joints of the human skeleton; A time information aggregation unit, used to aggregate the spatial samples in the time dimension based on a convolutional network to obtain spatiotemporal samples containing time depth features; A classification and recognition unit, used for inputting the spatiotemporal samples into an action classification model and outputting the action of the target object; The tree topology building module is specifically used for: Based on a learnable weight matrix, updating the attention sample to generate a learned attention sample, wherein the learnable weight matrix is a set of connections between one of the plurality of joint points and any one of the plurality of joint points; Based on a node relationship matrix, updating the learned attention samples to generate associated attention samples, wherein the node relationship matrix is a set of parent-child information of the plurality of joint points; Based on a correlation constraint matrix, updating the associated attention sample to generate the spatial sample, wherein the correlation constraint matrix is a set of cosine similarity coefficients between one of the multiple joint points and any one of the multiple joint points; Wherein, the node relationship matrix is constructed according to the hierarchical relationship of the human body joints.
6. The device according to claim 5, characterized in that The pre-processing unit comprises: A high-dimensional embedding module, used to perform high-dimensional embedding on the sample to obtain the high-dimensional embedded sample; A position encoding module, used for performing position encoding on the multiple joint points in the sample in time and space to obtain a position-encoded sample; The sum processing module is used to add the high-dimensional embedded samples and the position-encoded samples to obtain the preprocessed samples.
7. The device according to claim 6, characterized in that The position encoding module is specifically used for: Based on a binary group, position encoding is performed on the plurality of joint points, wherein the binary group includes a time frame and the plurality of joint points; The multiple joint points are position-encoded according to the following formula: ; in, PE () represents the feature matrix after position encoding, v represents the multiple joint points, t represents the time frame, i represents the coding dimension; C pos Represents the sine and cosine code length.
8. The device according to claim 5, characterized in that The multi-head attention calculation module is specifically used for: Performing convolution operation on the preprocessed samples to generate a Q weight matrix, a K weight matrix and a V weight matrix; Calculate the similarity between the Q weight matrix and the transpose of the K weight matrix, and use the similarity as the weight; Normalizing the weights using a Tanh function; The normalized weight and the corresponding V weight matrix are weighted and summed to obtain the attention sample.
Citation Information
Patent Citations
End-to-end human behavior recognition method and model based on skeleton nodes
CN114613013A
Video action recognition method, device and equipment and computer readable storage medium
CN114926770A
Motion behavior recognition method based on multi-mode collaborative self-attention network
CN114944012A
Three-dimensional human body behavior recognition method under small sample condition
CN115188068A
Action recognition method based on space-time information of human skeleton sequence
CN116682180A
