{'fraction_non_alphanumeric': 0.029563621065514207, 'fraction_numerical': 0.012085516502849275, 'mean_word_length': 4.868043087971275, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Jointformer: Single-Frame Lifting Transformer with Error Prediction and Refinement for 3D Human Pose Estimation

Monocular 3D human pose estimation technologies have the potential to greatly increase the availability of human movement data. The best-performing models for single-image 2D-3D lifting use graph convolutional networks (GCNs) that typically require some manual input to define the relationships between different body joints. We propose a novel transformer-based approach that uses the more generalised self-attention mechanism to learn these relationships within a sequence of tokens representing joints. We find that the use of intermediate supervision, as well as residual connections between the stacked encoders benefits performance. We also suggest that using error prediction as part of a multi-task learning framework improves performance by allowing the network to compensate for its confidence level. We perform extensive ablation studies to show that each of our contributions increases performance. Furthermore, we show that our approach outperforms the recent state of the art for single-frame 3D human pose estimation by a large margin. Our code and trained models are made publicly available on Github.


I. INTRODUCTION
Movement analysis is vitally important for applications including mixed reality, human-computer interaction, sports biomechanics and physiotherapy. However, human motion is highly complex and subjective, and the high dimensionality and the variation between subjects means that much is still not understood. While motion capture systems have been used to quantify movement since the 1980s [1], the equipment is expensive, the datasets are largely constrained to laboratory settings and relatively few are publicly-available. At the same time, the internet has collected vast amounts of in-the-wild (unlabelled and unconstrained) images and videos of moving humans. The maturation of monocular 3D human pose estimation (HPE) technologies has the potential to create a stepincrease in data available and scenarios that can be assessed, which can ultimately be used to improve our understanding of human movement.
Monocular 3D human pose estimation involves the prediction of 3D joint positions from a single viewpoint. While video techniques can leverage temporal information to improve * denotes equal contribution accuracy, single-image estimators remain useful in their own right. For example, useful information about human movement can be learned from online image datasets or video datasets with low frame-rate. Furthermore, some video approaches opt to use a combination of single-frame spatial models along with a multi-frame temporal model [2]. Thus, strong single-image 3D pose lifters can also improve the performance on video data.
Direct estimation techniques aim to estimate 3D human pose directly from images [3]. However, diverse image datasets with 3D pose labels are sparse, and it is convenient to leverage the high accuracy of off-the-shelf 2D pose estimators [4], [5] that are well-suited for the pixel-processing task. Lifting approaches predict the 3D pose from 2D joint predictions provided from such estimators. The types of neural network architectures used to learn this mapping have progressively evolved. The original simple baseline [6] for pose lifting used a multi-layer perceptron to achieve surprising accuracy, even without information from image features. More recent works have highlighted that treating pose as a vector ignores the spatial relationships between joints, and that graph structures may be better-suited [7]. However, existing works on graph convolutions require a hand-crafted adjacency matrix to define the relationship between nodes. Also, standard graph convolutions model the relationships between neighboring joints with a shared weight matrix, which is sub-optimal for modelling articulated bodies since the relations between different body joints may be different [8]. Furthermore, stacking GCN layers may result in over-smoothing [9]. In contrast, the self-attention operator of the transformer model generalises the feed-forward layer to be dynamic to the input, and the relationship between joints can be learned rather than manually encoded.
Transformers first unseated recurrent neural networks as the predominant models in natural language processing (NLP) [10], and have recently gained success in replacing convolutional neural networks in vision tasks such as image classification [11], object detection [12], and action recognition [13]. However, very few studies have applied transformers to the task of 3D human pose estimation to date. Existing works have either used a direct estimation approach [14] or focused their studies on video-based 2D-3D lifting [2], [15]. To our knowledge, ours is the first method to adopt a transformer for single-image 2D-3D pose lifting. The input and output tokens of the sequence represent joints, and thus we refer to our method as the Jointformer.
Accordingly, our contributions are as follows: • We present a novel single-frame 2D-3D lifting Joint Transformer for human pose estimation. • We suggest that predicting the error associated with each of the joints improves accuracy, by enabling the network to compensate for its own uncertainty. • We propose a Refinement Transformer to refine the 3D pose predictions of the Joint Transformer, based on the 3D prediction themselves, the input 2D joints, and the predicted errors for each joint. •

II. RELATED WORKS
Human Pose Estimation: Due to its applicability in diverse areas such as action recognition, augmented and mixed reality etc., HPE has emerged as a very active problem in computer vision. We present the literature relevant to direct estimation and 2D-3D lifting methods. Direct estimation refers to estimating the 3D pose directly from raw images. Pavlakos et al. [16] use the ordinal depths of human joints to provide a weaker supervision signal. Sun et al. [17] exploit the joint connection structure and define a compositional loss function that encodes long range interactions of the pose. Martinez et al. [6] explored decoupling of the problem into 2D human pose estimation and 2D-3D lifting and used a vanilla neural network to learn the mapping. Zhao et al. [7] exploit the spatial relations of nodes (both local and global) in a semantic graph convolutional network (SemGCN) to improve performance. Ci et al. [18] introduced locally-connected networks to overcome the limited representation power of GCNs for estimating 3D pose. Xu et al. [19] use a graph stacked hourglass network to process graph-structured features across three different scales of human skeletal representations. Tekin et al. [20] design a network to combine the strengths and weaknesses of direct estimation and lifting. Yang et al. [21] propose a method for in-the-wild HPE using adversarial learning aided by a geometry-aware discriminator. Fang et al. [22] present a lifting framework based on bidirectional recurrent networks which explicitly models auxiliary information such as kinematics, symmetry and motor coordination. Sharma et al. [23] use variational autoencoder for predicting a set of candidate 3D poses and ranks them using an ordinal score or oracle. Liu et al. [8] -in a comprehensive review of HPE -study different weight sharing strategies for graph convolution based lifting methods. Zhou et al. [24] propose a two-stage method in which the 2D points are mapped to an intermediate latent space, followed by a volumetric regression to the 3D space.
Transformers for Vision: Convolutional neural networks (CNNs) [25] have remained the dominant model in computer vision for three decades. Since the convolution operates within small local neighbourhoods, deeply stacking convolutions becomes necessary to form large receptive fields and capture long-distance dependencies. Inspired by the self-attention mechanism in NLP [10], the non-local neural network [26] used a small number of non-local blocks between various stages of a CNN to better capture long-distance relationships for action recognition. Ramachandran et al. [27] explored using stand-alone self-attention within small windows as a basic building block (rather than an augmentation on top of convolutions) for image classification and object detection. Similarly, Zhao et al. [28] used a self-attention network with pairwise and patchwise self-attention for image recognition.
Rather than basing the structure of building blocks on ResNet-style architectures, the vision transformer (ViT) [11] directly applied a standard transformer (with as few modifications as possible) to classify images. Images were input as sequences of flattened patches, with patches treated similar to tokens (words) in NLP applications. Similar approaches have since been applied to video classification [29] and action recognition [13].
Despite showing significant promise in other vision tasks, few studies have applied transformers to the task of 3D human pose estimation. Liu et al. were the first to use an attention mechanism to adaptively identify significant frames in temporal windows of human motion videos. Lin et al. [14] used a transformer for direct estimation of 3D human pose and shape for a single input frame. The input tokens consisted of a feature vector extracted with a CNN that is concatenated with either randomly-initialised 3D joints or mesh vertices. The input input token dimensions were progressively reduced after each encoder. Zheng et al. [2] addressed the task of video-based 3D human pose estimation and incorporated a spatial transformer as a component within a larger temporal transformer, where the output tokens are encoded features rather than 3D joint positions. Thus, it cannot be applied to single-frame 2D-3D lifting and its performance was not evaluated on images. Li et al. [15] used a lifting transformer that replaced feed-forward layers in the encoder with strided temporal convolutions. It operated on a temporal sequence, where each input token was a whole skeleton. This means that useful information cannot be passed between joints in the skeleton.
Error Prediction, Refinement and Intermediate Supervision: The predictions from human pose estimation models inevitably contain errors. Ronchi et al. [30] performed a rigorous analysis of the prediction errors of 2D HPE estimators on the COCO dataset [31]. The relative frequency and impact to performance of different categories of errors (jitter, inversion, swap, and miss) was investigated, and it was found that the errors showed similar distributions independent of the type of 2D pose estimator used. Moon et al. [32] used these error statistics to generate synthetic poses, which were input to a refinement network. Similarly, Chang et al. [33] used specific error distributions to synthesise 2D poses to be used for 2D-3D pose lifting. Fieraru et al. [34] introduced a pose refinement network that takes as input both the image and a given pose estimate. Zhang et al. [35] constructed a pose graph to consider the relationship between different keypoints during refinement. Wang et al. [36] used a graph pose refinement (GPR) module to refine the visual features based on the relationship between keypoints.
Intermediate supervision is the practice of using additional loss terms at various stages of deep neural networks to improve performance. In 2D human pose estimation, Newell et al. [37] used repeated bottom-up/top-down processing with intermediate supervision with their stacked hourglass network. DETR [12] used intermediate supervision between the stacked transformer decoder blocks for object detection.

III. METHOD
In this section, we describe our proposed network architecture for 3D human pose estimation. Following previous 2D-3D pose lifting approaches [6], we use an off-the-shelf model to generate 2D poses from images, and use these predictions to estimate the corresponding 3D poses. The 3D poses are estimated in camera coordinates and centered on the pelvis joint. While most of the previous state of the art use multilayer perceptrons (MLPs) [6] or GCNs [7], we use transformers to predict and refine the 3D pose in two parts. First, our Joint Transformer estimates the 3D pose and the prediction error from the 2D pose of a single frame. Afterwards, our Refinement Transformer further improves this prediction by using the intermediate prediction and prediction error. This novel combination of networks allows us achieve state-of-theart performance in single frame 3D pose estimation.

A. Joint Transformer
Our Joint Transformer is designed to lift the input 2D pose to 3D for a single frame. Given a set of J 2D joint coordinates x, we consider each joint a token and first embed each into a higher dimension of size c: f embed (x) : R J×2 → R J×c . Traditionally in transformers, the embedding is followed by a positional encoding. In our case however, the order of joints is not changed during both training and testing, implicitly encoding the position in the input itself (i.e. the first joint in the input is always the hip joint). This makes the addition of an explicit positional encoding redundant, and in fact hurts our prediction performance as we show in Section IV-C. Following the embedding, we feed the joint tokens into a stack of transformer encoders where self-attention is applied to share information across each joint. We use the original implementation for the transformer encoder [10] and do not modify the hidden dimension further. Given L transformer encoders, the output of each encoder is z L ∈ R J×c . Finally, we regress the output of the last encoder z to predict the 3D pose using an MLP block consisting of layer normalization, dropout and a single linear layer f pred (z) : R J×c → R J×3 . 1) Intermediate supervision: By design, the transformer encoder layers share information between tokens and learns which tokens are important for prediction. This gives even the first transformer encoder in our stack the ability (though not necessarily the capacity) to learn how joint tokens interact and to predict the 3D pose. We leverage this by training our network using intermediate supervision. Compared to previous methods, we do not compute the loss at the end of the network alone, but introduce a loss term after each individual transformer encoder in the stack. This allows the network to learn initial estimates that get further refined by each transformer encoder in the stack. Subsequent transformer encoders get passed down highly discriminative features from previous encoders and can focus on increasingly fine-grained features to refine previous estimates. To further help with this, we add residual connections around every encoder. In our implementation, each encoder is followed by an MLP predicting the 3D pose, to which a loss can be applied. We add an additional linear layer to the predicted 3D pose to embed the prediction back to the hidden dimension of the transformer and add the embedding to the original transformer output, as can be seen in the upper right of Figure 1.
2) Pose embedding: The 2D input pose coordinates need to be expanded to the hidden dimension of our network. Previous methods used linear layers or graph convolutions for this task. In our method however, we use 1D convolutions with a kernel size of 1 across all joints. This is equivalent to a linear layer that expands the 2D coordinates to the hidden dimension individually for each joint with weight sharing between each joint. Since the embedding weights are shared for each joint, the layer can focus on finding the best way to expand the 2D coordinates regardless of the location of the joint. Traditionally, transformers also require a positional encoding of the embedded tokens. Since the input order of joints never changes, the position is implicitly already encoded and additional encodings are redundant. We show in Table III that our method works better without any explicit positional encoding and our convolutional embedding outperforms a linear layer.
3) Error prediction: Giving an estimate of the confidence in its prediction gives the network the ability to compensate. Since classification heads generate one prediction per class before a softmax layer, their prediction confidence can be directly inferred. In contrast, regression heads lack this ability out of the box. We add a second MLP mirroring the 3D pose prediction to the output of the transformer encoder, and force the network to implicitly learn its own uncertainty. Therefore, the error prediction will predict its own error per joint and per coordinate f error (z) : R J×c → R J×3 . We observe that the addition of the error prediction stabilizes the training and leads to better overall results (Section IV-C). It can also serve as important additional information when visualizing the pose or for practical application of the technology.

4) Loss function:
The loss function which we use to train our network consists of two terms: the 3D prediction loss L 3D and the error loss L error . For the 3D prediction loss, we use the mean-squared error between the predicted 3D poses y and the ground-truth posesŷ. For the error loss, we first define the true errorê as the absolute difference between the predicted and the ground-truth poseê = |y −ŷ|. This allows us to use the mean-squared error between the predicted error e and the true errorê as the error loss. Due to our intermediate supervision, we apply both of these loss terms after every transformer encoder in the stack. This leads to the combined loss: where L is the number of transformer encoders in the stack.

B. Refinement Transformer
In order to make further use of the error prediction and boost the accuracy of the pose prediction, we design an additional Refinement Transformer. This network is similar to our Joint Transformer with the following difference: the input is the original 2D pose concatenated to the predicted 3D pose and error prediction. We only stack two transformer encoders with a hidden dimension of 256, and we do not use intermediate supervision. As with the Joint Transformer, the Refinement Transformer tokenizes each joint and uses a 1D convolution to embed the 8-channel input to the hidden dimension. Following the stacked transformer encoders, we use a linear layer to predict the final 3D pose.

C. Implementation details
We implement our approach in PyTorch [38] and use a single NVIDIA GeForce RTX 2080 TI for training. We train the Joint Transformer for 30 epochs with a batch size of 256 using the AdamW [39] optimizer, an initial learning rate of 0.001 and cosine annealing learning rate decay [40]. All of our prediction layers also include dropout of 0.2 during training. Afterwards, we fix the weights of the Joint Transformer and train the Refinement Transformer using the 3D prediction loss and employing the same hyperparameters. During evaluation we use test-time data augmentation by horizontal flipping, following [41].

IV. EXPERIMENTS
In this section, we first introduce the datasets used to evaluate our proposed approach. The results are then compared to the state of the art, and an ablation study is performed.

A. Datasets and Evaluation
We consider two popular benchmarks for 3D HPE following recent works [19].
Human3.6M [42]: This is the most widely-used dataset for 3D human pose estimation. It uses a motion capture system and 4 video cameras to capture the 3D pose information and accompanying images, respectively. The camera calibration parameters are used to project the 3D joint positions to the 2D image plane of each camera. The dataset contains 3.6 million images of 7 professional actors performing 15 generic movements such as walking, eating, sitting, making a phone call and engaging in a discussion. We follow the standard protocol, using subjects 1, 5, 6, 7 and 8 for training, and subjects 9 and 11 for evaluation.
MPI-INF-3DHP [43]: This dataset contains images of three different scenarios: (i) studio with a green screen (GS), (ii) studio without green screen (noGS) and (iii) outdoor scene (Outdoor). We follow the common skeleton representation for both of these datasets, which contains 17 joints.
Following common practice, for Human3.6M we evaluate by using the mean per-joint pixel error (MPJPE) in mm between the ground truth and our predictions across all joints and cameras, after alignment of the root joint (Protocol #1). It is also common to align the prediction with the ground truth using a rigid transformation [44] (Protocol #2). For the MPI-INF-3DHP test set we use 3D-PCK (Percentage of Correct Keypoints) and AUC (Area Under the Curve) as evaluation metrics following previous works [45], [19], [18].   '21  -

B. Comparison with State-of-the-Art Methods
We compare the performance of our proposed model with recent state-of-the-art methods for single-frame 3D human pose estimation across two popular datasets: Human3.6M and MPI-INF-3DHP. We include both direct estimation and 2D-3D lifting methods in our analysis. Existing lifting methods use either multilayer perceptron or graph convolutional models to map from 2D to 3D. In contrast, the Joint Transformer uses a transformer architecture with intermediate supervision, error prediction and refinement. To highlight the significance of our improvements, we also compare to a "Base Transformer" architecture that consists of a linear embedding, spatial positional encoding [2] and transformer encoder blocks.
We first investigate the in-the-wild performance of our network where it takes the 2D predictions of a 2D pose detector as input. Table I(a) shows the results on the Human3.6M dataset on 2D predictions of the cascaded pyramid network (CPN). Our Joint Transformer outperforms the state-of-theart approaches by more than 1.4 mm. The addition of the Refinement Transformer decreases our error a further 0.4 mm for a total improvement of 1.8 mm. Our Joint Transformer also outperforms the Baseline Transformer without intermediate supervision, error prediction and with linear pose embedding by more than 3 mm.
Since the above results are dependent on the quality of the output of the 2D pose detector, it is useful to remove the effect of the 2D backbone to characterise the theoretical performance of our network. Table I(b) presents results on the Human3.6M dataset with ground truth 2D joint positions passed as input. Here, we find that our Joint Transformer surpasses the state of the art by 1.8 mm. In this case, we find that our Refinement Transformer does not further decrease the prediction error. In fact, the performance of the Refinement Transformer seems correlated to the magnitude of the error prediction of the Joint Transformer. In the case of the groundtruth 2D inputs the predicted error is quite small, whilst the larger magnitude of the error prediction for the CPN keypoints can be effectively used by the Refinement Transformer to achieve a better prediction. In comparison to the state of the art, our method only uses 1.48M parameters, compared to 3.70M and 4.38M parameters for the second- [19] and third- [8] placed methods respectively.
To show the generalisation ability of our method, we evaluate our Joint Transformer trained on Human3.6M directly on the MPI-INF-3DHP test dataset without any additional training. As shown in Table II, we outperform the previous state of the art, even though some previous methods use additional training data from MPI-INF-3DHP. We also present the performance of our Joint Transformer followed by the Refinement Transformer. As can be seen, the Refinement Transformer further enhances our results by an additional small margin. This shows the ability of our method to generalise to unseen datasets.

C. Ablation
In this section, we evaluate the effectiveness of our modifications to the standard transformer architecture on the Hu-man3.6M dataset [42]. The results are reported in Table III [42]. the network in a multi-task framework further improves the results. We also observe that explicitly adding positional encoding to the transformer tokens reduces the performance. Since the order of the joints never changes, their positions are already implicitly encoded and further addition of an explicit encoding seems to confuse the network somewhat. This is the case for both the frequency based positional encoding, as well as the spatial encoding [2]. In the lower part of the table, we show the effect on a different number of transformer encoders and size of the hidden dimension. We show that the highest performance and most stable training can be achieved by using 4 layers and a hidden dimension of 64. While a larger number in either of these parameters increases the capacity of the network, the larger capacity seems not to be needed for best results. Finally, we can also observe that using a 1D convolution to embed the 2D inputs to the hidden dimension instead of a linear layer not only saves some network parameters, but also leads to better performance.
V. LIMITATIONS While the proposed system is robust to GT keypoints and robust detectors, we expect that the use of a noisy keypoint detector will contribute highly to poor performance. The Refinement Transformer improves results for the single-frame scenario. However, it is not trained on temporal noise and as such temporal inconsistencies will propagate to the estimated 3D poses.

VI. CONCLUSION
In this work, we have presented a novel architecture for 3D pose estimation to analyse the previously-unexplored performance of transformers on single images. We demonstrate that implicitly encoding kinematic joint structure allows for a robust learning framework that outperforms the state of the art on established benchmarks. While the current approach addresses only single-frame input, it may be used as a modular component of temporal or multi-frame architectures in subsequent research.

VII. ACKNOWLEDGEMENTS
This publication has emanated from research conducted with the financial support of Science Foundation Ireland (SFI) under the Grant Number 15/RP/2776.