KPE: Keypoint Pose Encoding for Transformer-based Image Generation

Soon Yau Cheong, Armin Mustafa, Andrew Gilbert · DOI · OpenReview

Abstract

Transformers have recently been shown to generate high quality images from text input. However, the existing method of pose conditioning using skeleton image tokens is computationally inefficient and generate low quality images. Therefore we propose a new method; Keypoint Pose Encoding (KPE); KPE is 10 times more memory efficient and over 73% faster at generating high quality images from text input conditioned on the pose. The pose constraint improves the image quality and reduces errors on body extremities such as arms and legs. The additional benefits include invariance to changes in the target image domain and image resolution, making it easily scalable to higher resolution images. We demonstrate the versatility of KPE by generating photorealistic multiperson images derived from the DeepFashion dataset. We also introduce a evaluation method People Count Error (PCE) that is effective in detecting error in generated human images.

Introduction

Generating high-quality images of people from text descriptions is notoriously difficult because the human body has a high "degree of freedom"—describing every joint angle, limb position, and clothing detail in words is nearly impossible. To solve this, researchers often use pose conditioning, where the model is given a "skeleton" as a guide.

However, standard transformer models treat these skeletons as images, converting them into "image tokens." This is computationally expensive because transformer complexity grows quadratically with the number of tokens. Using image-based poses limits resolution and wastes memory on redundant background pixels. Furthermore, these models often struggle with body extremities, resulting in artifacts like floating limbs or extra arms.

Overview of the KPE generation process: Pose keypoints and text descriptions are combined to produce high-fidelity multi-person images.

Methodology: Keypoint Pose Encoding

The authors introduce Keypoint Pose Encoding (KPE), which moves away from pixels entirely in favor of coordinate representations.

Coordinate Representation and Tokenization

Instead of a skeleton image, KPE represents pose as a set of $(x, y, v)$ tuples, where $x$ and $y$ are normalized coordinates and $v$ is a visibility score. To make this work with a transformer, keypoints are grouped by joint type across all people in an image. For example, a single token might contain the right-eye coordinates for every person in the scene.

Hybrid Architecture

The model is an autoregressive transformer that processes three types of tokens in a single sequence:

  1. Text tokens (via Byte Pair Encoding)
  2. Pose tokens (via KPE)
  3. Image tokens (via VQ-VAE)

Unlike text and image tokens, which are discrete categories, keypoints are continuous values. The architecture applies an L2 loss for the pose embeddings to maintain precision, while using standard cross-entropy loss for text and images.

The KPE architecture: A transformer processes text, pose keypoints, and target image tokens through specialized encoders and linear projections.

Key Insights and Results

The core innovation of KPE is the realization that transformers do not need a 2D spatial grid to understand human structure. By feeding the model raw coordinates, the "noise" of a skeleton image is stripped away, allowing the model to focus purely on anatomical constraints.

Efficiency and Speed

KPE is 10x more memory efficient than using skeleton image tokens. Inference is also 73% faster than VQGAN-based baselines, taking approximately 0.6 seconds on an RTX 5000 GPU.

Anatomical Accuracy and PCE

The authors proposed the People Count Error (PCE) metric to catch specific anatomical errors that standard metrics like FID might miss. PCE uses a pose estimator to count people in a generated image; if the count doesn't match the prompt (e.g., a floating arm is detected as a "third person"), the image is flagged. KPE achieved a PCE of 0.6, significantly lower than the 1.2 for skeleton-image methods and 8.2 for text-only models.

Conclusion

While KPE significantly improves efficiency and anatomical realism, it is currently limited by dataset bias. The DeepFashion dataset is skewed toward specific demographics, leading to gender disentanglement issues where the model may struggle to generate masculine features for certain poses. Future work will focus on applying KPE to more diverse datasets to mitigate these biases.

Summary updated

BibTeX
@inproceedings{cheong2022kpe,
  author = {Soon Yau Cheong and Armin Mustafa and Andrew Gilbert},
  title = {{KPE: Keypoint Pose Encoding for Transformer-based Image Generation}},
  booktitle = {BMVC},
  year = {2022},
  doi = {10.48550/arxiv.2203.04907},
}
Figure