A human motion prediction method based on adversarial training attention mechanism
By introducing a deformable attention mechanism and an adversarial training mechanism into the Transformer model, the first frame discontinuity and computing resource consumption problems in human action prediction are solved, and efficient and accurate long-term human action prediction and more stable are achieved. training process.
Patent Information
- Application Number
- CN202210047220.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-17
- Publication Date
- 2024-09-10
- Estimated Expiration
- 2042-01-17
AI Technical Summary
The existing technology has the problem of discontinuity in the first frame and the high consumption of computing resources of the Transformer model in human action prediction, making it difficult to predict human actions in a long-term range efficiently and accurately.
A deformable Transformer attention mechanism based on adversarial training is designed. By introducing non-negative similarity calculation function and kernel function, the computational complexity is reduced, and the continuity discriminator and authenticity discriminator are introduced to alleviate the discontinuity of the first frame. The problem transforms human motion prediction into a generation problem.
It achieves efficient and accurate human movement prediction over a long period of time, reduces computational complexity, generates more realistic and continuous human movement sequences, and improves the stability of the training process.
Smart Images

Figure CN114386582B
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of human-computer interaction, and relates to the prediction of human body motion in human-computer interaction, and specifically is a human body motion prediction method based on adversarial training attention mechanism. Background Art
[0002] In recent years, with the rapid development of artificial intelligence technology in the computer field, the research on human-computer interaction has attracted the attention of more and more researchers. Humans have the ability to predict the surrounding dynamic environment in real time. How to make robots imitate human prediction ability has become one of the research hotspots in the field of human-computer interaction. In a natural and efficient human-computer interaction process, robots can only complete the interaction safely and plan and execute subsequent tasks if they perceive the surrounding environment in time. Therefore, accurate prediction of human motion is of great significance to ensure efficient human-computer interaction. So far, due to the complexity of human motion structure and the uncertainty of human subjective intention, there is still a lot of room for improvement in human motion prediction. The following will introduce the research progress of human motion prediction in detail.
[0003] (1) Human motion prediction based on recurrent neural network
[0004] Methods based on recurrent neural networks (RNNs) have achieved phased success in the field of human motion prediction in recent years. RNNs-based methods aggregate the contextual information of human motion over a long period of time by iterating multiple hidden states, thereby modeling the interdependence between human motion information over a long period of time and completing the prediction. However, human motion information / data itself has the attributes of time and space dimensions. RNNs pay more attention to the dependency of human motion in the time dimension, while ignoring the modeling of information dependency in the space dimension. The prediction error of this type of method for motion will continue to increase over time, and the results of long-term motion prediction often converge to static postures.
[0005] (2) Human motion prediction based on graph neural network
[0006] Graph neural networks (GCNs) have been applied to the field of human motion prediction due to their high generalization and interpretability. This type of method captures the spatial dimension of human motion by representing human skeleton points as a graph, thereby alleviating the problems of RNNs in human motion prediction to a certain extent from the perspective of increasing the information observation dimension. GCNs explore the global dependencies between all joints by adding auxiliary spatial correlations to the temporal dimension dependency, and regard the entire skeleton point sequence as an implicit, unrestricted graph structure. However, most existing GCNs-based methods cannot represent the prior topological relationship between human joints. Therefore, when predicting human motion over a long period of time, they usually encounter a large difference between the last frame of observed data and the first frame of predicted data, that is, the first frame discontinuity problem.
[0007] (3) Human motion prediction based on Transformer
[0008] Transformer is a network model based on the attention mechanism proposed by the Google team in 2017. It is widely used in various fields due to its excellent long-term dependency modeling capabilities. Transformer aims to connect different positions in a sequence, calculate the correlation between each position in the sequence, and then express a wider range of dependencies. At present, Transformer has been successfully used in the field / problem of human motion prediction. However, since the attention mechanism of the Transformer model needs to calculate the similarity between any two positions in the form of dot product, when the input data dimension is large and the interaction / dependency is complex, the computational efficiency of the entire model will decrease exponentially and occupy a large amount of memory.
[0009] Based on the above information, it can be seen that how to efficiently and accurately predict human motion over a long period of time is still a very challenging problem that requires further research and improvement. Summary of the invention
[0010] The purpose of the present invention is to solve the problem of discontinuity of the first frame when predicting human motion, as well as the problem of computational resource consumption and discontinuity of the first frame in the attention mechanism in the Transformer model when predicting human motion. The present invention provides a new attention mechanism for the spatiotemporal feature extraction of human motion, and introduces a generative adversarial training mechanism to transform the human motion prediction problem into a generation problem. Specifically, based on the original Transformer model, the present invention transforms and optimizes the attention calculation mechanism inside the Transformer, and designs a Transformer model called a deformable Transformer model for extracting the temporal and spatial features of human motion, thereby capturing the interdependence between various joints in a long time range, thereby efficiently predicting human motion in a long time range. Secondly, the present invention introduces the proposed network model for training the adversarial training mechanism, uses the above-mentioned process of generating motion prediction as a generator, and introduces a continuity discriminator and a authenticity discriminator to verify the temporal smoothness and continuity of the generated sequence, so as to alleviate the problem of discontinuity of the first frame.
[0011] The technical solution of the present invention:
[0012] A human motion prediction method based on adversarial training attention mechanism specifically includes the following steps:
[0013] Step S1: Human motion data preprocessing: First, read all 3D skeleton point data in the human motion posture data set, decompose all human skeletons into joint points and embed them as features for representation; the details are as follows:
[0014] Assume that the input human action sequence is X, project the human action sequence into the high-dimensional feature space E through a linear layer n (For example, 64 or 128), n represents the number of frames in the human body sequence, and each frame represents a specific action at a certain moment; and the sinusoidal position encoding of the joint points is embedded in the feature space to determine the relative position of each human body joint point.
[0015] Step S2: The preprocessed human motion data is divided into time dimension and space dimension, and the temporal and spatial characteristics of human motion are obtained through the deformable Transformer-based spatiotemporal attention mechanism; the details are as follows:
[0016] Due to the great potential of the Transformer model in acquiring long-term dependencies, the present invention considers introducing the Transformer model into the field of human motion prediction. The advantage of the Transformer model lies in the self-attention mechanism, which uses the softmax function to calculate the matching between any two positions, thereby calculating the degree of association between each position. Assuming that the input sequence is X, X is projected into three matrices Q, K and V, and the attention calculation formula is as follows:
[0017]
[0018] Among them, QK T It is used to calculate the information matching between any two positions. d represents the dimension of the matrix. Softmax will output the final matching situation. However, its calculation mechanism will also cause the complexity of the calculation and storage cost to be the quadratic term of the input sequence length. As the input sequence length and the complexity of the input data increase, the calculation complexity and cost of the model will also increase significantly.
[0019] Taking the above problems into consideration, the present invention designs a deformable Transformer-based attention mechanism, aiming to solve the problem of high computational complexity caused by the attention mechanism in the original Transformer model when predicting human motions, and removes the softmax function on which the attention mechanism in the original Transformer depends.
[0020] The specific process of the deformable Transformer attention mechanism proposed in this invention is as follows:
[0021] First, generalize the attention calculation formula into the following representation:
[0022]
[0023] Wherein, sim() refers to the similarity calculation function, M represents the spatial scale N or the time range T. i and j represent different positions. It should be noted that the similarity calculation function sim() must be a non-negative value to be used to define the attention function. Based on this limitation, the present invention introduces a new kernel function From this formula (2) can be further expressed as:
[0024]
[0025] Furthermore, the numerator of formula (3) is vectorized, and the associative law of matrix multiplication is used. The calculation order of the numerator of formula (3) can be expressed as follows:
[0026]
[0027] Note that the feature function corresponding to softmax is infinite-dimensional, which makes the softmax function impossible to linearize. In order to ensure that formula (4) is also applicable to other attention calculations, it is necessary to ensure that the calculation result of formula (4) still has distribution characteristics. Therefore, the present invention introduces a positive similarity function as a specific implementation of the kernel function. Kernel function The expression is as follows:
[0028]
[0029] The kernel function is chosen because it can largely avoid the non-zero loss caused by other functions. After that, the projection matrices Q and K are transformed by the kernel function respectively, and the order of attention calculation is changed. First, the matrix K and V are calculated to obtain the global feature vector, and then multiplied with Q to obtain the final attention distribution. The above operation splits the softmax function and replaces the kernel function based on Transformer, which reduces the computational complexity of the overall model from O(n 2 ) is reduced to O(n). The present invention refers to the above process as a deformable Transformer-based attention mechanism.
[0030] In terms of attention calculation in the time dimension, the present invention obtains the time dependency of the same joint point through the above-designed deformable Transformer attention mechanism, and uses it to update the embedding information of the current joint point. First, the input X sequence is embedded into the high-dimensional space in, represents the temporal feature representation of each input frame, n represents the number of input frames, T represents the length of the time series, and D represents the projection dimension. In order to more accurately capture the characteristics of human motion, the present invention refers to the original Transformer processing mechanism and adopts a multi-head attention mechanism, aiming to obtain more input feature information through different projection processes. Specifically, E t Projection to multiple matrices represents Q (n,i) , K (n,i) , V (n,i) , head i =Attention(Q (n,i) ,K (n,i) ,V (n,i) ), where i represents the number of heads. Then the information of multiple heads is aggregated to obtain the feature information of the time dimension. Where W (n,O) Represents the weight matrix when aggregating time features. By calculating the time dependency of each joint point, the information of all time steps of the same joint point is finally aggregated and updated.
[0031] In terms of attention calculation in the spatial dimension, the present invention focuses on the spatial dependencies between different joints in the same frame based on the deformable Transformer attention mechanism, that is, obtains the degree of attention of a certain joint to other joints, and explicitly learns the human body dynamic pattern and the spatial interdependence between the joint positions from the data. First, the input X sequence is embedded into a high-dimensional space in represents the spatial feature representation of each input frame, n represents the number of input frames, and T represents the length of the time series. Similar to the temporal attention mechanism, the spatial attention mechanism also adopts a multi-head attention mechanism. Specifically, E t Projection to multiple matrices represents Q (i) , K (i) , V (i) , Where i represents the number of heads. Then the information of multiple heads is aggregated to obtain the feature information of the spatial dimension W (O) Represents the weight matrix when aggregating spatial features, and performs feature aggregation on all joint information at the same time.
[0032] Step S3: Aggregate the temporal information and spatial information of the human body motion to predict the next frame of human body motion; the details are as follows:
[0033] Through step S2, the temporal and spatial features of human motion are extracted, and the temporal information and spatial information are collected respectively. The full-dimensional information of human motion is obtained by adding and fusing the two, and the joint points of the next frame are constructed to form the overall skeleton, that is, the human motion at the next moment. The above steps are repeated in sequence to generate a human motion sequence.
[0034] Step S4: Using the generated human motion sequence process as a generator, an adversarial training mechanism is introduced to generate more realistic human motions; the details are as follows:
[0035] In order to alleviate the first frame discontinuity problem in the prediction process, the present invention introduces an improved adversarial training mechanism (Wasserstein Generative Adversarial Networks-gradient penalty, WGAN-GP). Specifically, the human action generation sequence process in step S3 is used as a generator (Generator, G), and a authenticity discriminator (D f ) and a continuity discriminator (D c ). The authenticity discriminator aims to minimize the generated human action sequence distribution P through the loss function g and the distribution of the actual action sequence P r The purpose of the continuity discriminator is to make the connection between the generated sequence and the historical observation sequence smoother to solve the problem of first frame discontinuity. Assume that the generated sequence is The real sequence is X, is the expected value of the data distribution, For the interpolation between the generated sequence and the actual data, the training method of WGAN-GP optimization network is through the following loss function L adv conduct:
[0036]
[0037] Among them, λ is the penalty coefficient. This mechanism can generate reliable motion sequences over a long period of time, making the training process more stable.
[0038] Compared with the prior art, the present invention has the following advantages:
[0039] The human motion prediction method based on adversarial training attention mechanism provided by the present invention designs a deformable attention mechanism based on Transformer, which is used for temporal and spatial feature extraction of human motion, fuses the captured temporal and spatial information, predicts human motion sequences and can capture the motion dependencies of human motions over a long period of time; the improved adversarial training mechanism, authenticity discriminator and continuity discriminator provided by the present invention can generate more realistic and continuous human motion sequences over a long period of time, making the training process more stable. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] Figure 1 It is a schematic diagram of the overall process structure of the human motion prediction method based on adversarial training attention mechanism provided by the present invention.
[0041] Figure 2 It is a schematic diagram of the Transformer-based deformable spatiotemporal attention mechanism provided by the present invention. DETAILED DESCRIPTION
[0042] The present invention is further described in detail below in conjunction with specific implementation methods. The specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0043] This embodiment discloses a method for predicting human motion based on adversarial training attention mechanism, and its detailed network structure principle diagram is as follows: Figure 1 The specific steps are as follows:
[0044] (1) Human body motion joint data processing
[0045] In this example, the Human3.6m dataset is used. This dataset contains 15 actions. To read all the data from the dataset, for example, to run, you need to traverse all the files and read the data by file. The human body is divided into 32 joints and the sequence X = {x 1 ,x 2 ,…,x t}∈R T×NFIndicated by, where T represents the time range; N is the number of human joints; F represents the dimension of the human joint representation method. There are many methods for representing human joints, such as: three-dimensional position, rotation matrix, angle axis or quaternion. In this embodiment, the rotation matrix is used for representation; Indicates human posture; Represents the representation of joint N at time t. In this embodiment, all human joints are projected into d-dimensional space through a linear projection layer. In this embodiment, d=128 is set. At the same time, in order to mark the relative positions of different joints of human movements, sinusoidal position coding is injected, and finally the joint embedding representation E is output.
[0046] The length of the observation frame for training is specified, which is set to 50 in this embodiment. The data is trained according to the specified batches, each batch has 32 sets of training data, and a total of 500 iterations. For short-term prediction, the input observation sequence is 2 seconds (50 frames in total) and the future prediction sequence is 400 milliseconds (10 frames in total). For long-term prediction, the input observation sequence is the same 2 seconds and the future prediction sequence is 1000 milliseconds.
[0047] (2) The spatiotemporal characteristics of human movements are obtained through the spatiotemporal attention mechanism, and the features of the input human skeleton are learned to obtain the features of the input skeleton.
[0048] The data processed in step S1 is input into the Transformer-based deformable spatiotemporal attention mechanism in batches for temporal and spatial feature extraction. This embodiment adopts a multi-head attention mechanism to divide the input information into 8 heads and stack 4 deformable transformer spatiotemporal attention mechanisms. The detailed network structure principle diagram is as follows: Figure 2 shown.
[0049] Specifically, a linear layer is used to project the input information into a representation space with a dimension of 128. The feature space is then divided and features are extracted using the time module and the space module. The time module obtains the changing trend of 32 body joints over time, and uses the time-deformable Transformer attention mechanism to focus on the changing trend of different joints of the human body over time. The embedding of each joint is updated through the dependency between historical frames of the same joint. At the same time, the d-dimensional representation is projected into the subspace by using a multi-head mechanism to aggregate the action information of the same joint in different human actions. n represents a certain joint point.
[0050]
[0051] Among them, W (n,O) Represents the weight matrix when aggregating time features. head 1 ,…,head HThey represent different attention heads respectively, and H represents the number of attention heads, which is set to 8 in this embodiment.
[0052] The spatial module captures the interaction between 22 joints in the same frame. The spatially deformable Transformer attention mechanism focuses on the interdependence of human joints and updates the joint embedding representation. The multi-head mechanism aggregates all joint information at time t and calculates the sum of spatial joints.
[0053]
[0054] Among them, W (O) Represents the weight matrix when aggregating spatial features, head 1 ,…,head H They represent different attention heads respectively, and H represents the number of attention heads, which is set to 8 in this embodiment.
[0055] In addition, a position-based feedforward network (FFN) is placed in each spatiotemporal attention module. FFN introduces nonlinear changes (ReLu activation function), thereby increasing the performance of the model. Layer normalization can prevent the numerical scale within the layer from changing too much, which is conducive to keeping the gradient sensible, thereby speeding up training and improving generalization performance. At the same time, a normalization (Layer Norm) layer with residual connections is added after each multi-head attention mechanism and FFN layer to standardize the data.
[0056] (3) Aggregate temporal and spatial information features to predict the next human action
[0057] Based on the deformable Transformer spatiotemporal attention mechanism in the above steps, the temporal characteristics of human movements are obtained and spatial characteristics By calculating the time characteristics and spatial characteristics The global information is obtained by summing up. Then the global information is used to predict the next human action. This step is repeated until 10 frames of human actions are generated.
[0058] (4) Use the improved adversarial training mechanism to train the overall network
[0059] In order to solve the problem of discontinuity in the first frame of the generated sequence, this paper introduces the WGAN-GP adversarial training mechanism to solve this problem, and solves the discontinuity problem by designing an adversarial loss function. Specifically, the above action prediction process is used as the generator G, and a authenticity discriminator (D f ) and a continuity discriminator (D c) to verify the authenticity and continuity of the generated sequence. The authenticity discriminator aims to minimize the generated human pose and the true value X gt The distance between them makes the generated human posture more realistic; the purpose of the continuity discriminator is to promote the generated sequence With the real sequence {X,X gt} to solve the problem of discontinuity in the first frame. This mechanism can generate reliable motion sequences over a long period of time, making the training process more stable. Assume that the generated sequence is The true sequence is X, E(·) is the expected value of the data distribution, For interpolation between the generated sequence and the actual data, the WGAN-GP optimizes the training network as follows:
[0060]
[0061] Among them, λ is the penalty coefficient. The human action sequence generated by the loss function is continuously optimized, and the Adam optimizer is used in this process.
[0062] This mechanism can generate reliable motion sequences over a long period of time, making the training process more stable.
Claims
1. A human motion prediction method based on adversarial training attention mechanism, characterized in that: The specific steps include: Step S1: Human motion data preprocessing: First, read all 3D bone point data in the human motion posture data set, decompose all human bones into joint points and embed them as features for representation; the details are as follows: Assuming that the input human action sequence is X, in order to extract better features, the human action sequence is projected into a high-dimensional feature space E through a linear layer n , n represents the number of frames in the human body sequence, and each frame represents a specific action at a certain moment; and the sinusoidal position encoding of the joint points is embedded in the feature space to determine the relative position of each human body joint point; Step S2: The preprocessed human motion data is divided into time dimension and space dimension, and the temporal and spatial characteristics of human motion are obtained through the deformable Transformer-based spatiotemporal attention mechanism; the details are as follows: The process of the deformable Transformer attention mechanism is as follows: First, generalize the attention calculation formula into the following representation: Among them, sim() refers to the similarity calculation function, M represents the spatial scale N or the time range T; i and j represent different positions respectively; the similarity calculation function sim() is a non-negative value, so a new kernel function is introduced From this formula (2) can be further expressed as: Furthermore, the numerator of formula (3) is vectorized, and the associative law of matrix multiplication is used. The calculation order of the numerator of formula (3) is expressed as follows: In order to ensure that formula (4) is also applicable to the calculation of other attentions, it is necessary to ensure that the calculation result of formula (4) still has distribution characteristics. Therefore, a positive similarity function is introduced as the specific implementation of the kernel function. The kernel function The expression is as follows: Afterwards, assuming the input sequence is X, X is projected into three matrices Q, K, and V. The projection matrices Q and K are transformed by the kernel function respectively, and the previous attention calculation order is changed. K and V are first calculated by matrix to obtain the global eigenvector, and then multiplied with Q to obtain the final attention distribution. In the attention calculation of the time dimension, the time dependency of the same joint point is obtained through the deformable Transformer attention mechanism, and the embedding information of the current joint point is updated accordingly. Specifically, the input X sequence is first embedded into the high-dimensional space in represents the temporal feature representation of each input frame, n represents the number of input frames, T represents the length of the time series, and D represents the projection dimension; and a multi-head attention mechanism is used to obtain more input feature information through different projection processes, specifically: n Projection to multiple matrices represents Q (n,i) , K (n,i) , V (n,i) , head i =Attention(Q (n,i) ,K (n,i) ,V (n,i) ), where i represents the number of heads; then the information of multiple heads is aggregated to obtain the feature information of the time dimension, W (n,O) Represents the weight matrix when aggregating time features; by calculating the time dependency of each joint point, the information of all time steps of the same joint point is finally aggregated and updated; In the attention calculation of the spatial dimension, the attention mechanism based on the deformable Transformer focuses on the spatial dependency between different joints in the same frame, that is, obtains the degree of attention of a joint to other joints, and explicitly learns the spatial interdependence between the human body dynamic pattern and the joint positions from the data. Specifically, the input X sequence is first embedded into the high-dimensional space in represents the spatial feature representation of each input frame, n represents the number of input frames, and T represents the length of the time series; and a multi-head attention mechanism is adopted, specifically: E t Projection to multiple matrices represents Q (i) , K (i) , V (i) , Where i represents the number of heads; then the information of multiple heads is aggregated to obtain the feature information of the spatial dimension W (O) Represents the weight matrix when aggregating spatial features, and performs feature aggregation on all joint information at the same time; Step S3: Aggregate the temporal information and spatial information of the human body motion to predict the next frame of human body motion; the details are as follows: The temporal and spatial features of human motion are extracted through step S2, and the temporal information and spatial information are collected respectively. The full-dimensional information of human motion is obtained by adding and fusing the two, and the joint points of the next frame are constructed to form the overall skeleton, that is, the human motion at the next moment; repeat in sequence to generate a human motion sequence; Step S4: Using the generated human motion sequence process as a generator, an adversarial training mechanism is introduced to generate more realistic human motions; the details are as follows: The human action sequence generation process in step S3 is used as a generator, and a authenticity discriminator and a continuity discriminator are designed; the authenticity discriminator minimizes the generated human action sequence distribution P by the loss function g and the distribution of the actual action sequence P r The distance makes the generated human posture more realistic; the continuity discriminator makes the connection between the generated sequence and the historical observation sequence smoother to solve the problem of first frame discontinuity; assuming that the generated sequence is The real sequence is X, is the expected value of the data distribution, For the interpolation between the generated sequence and the actual data, the adversarial training mechanism optimizes the training network through the following loss function L adv conduct: Among them, λ is the penalty coefficient.
