Sub topic 7
Backbones and High-Resolution Architectures
This chapter assumes you know how convolutional networks produce feature maps at decreasing resolution, how heatmaps represent keypoints (from the earlier chapters), and what stride means. It explains why a plain classification backbone is a poor fit for pose, and how pose architectures recover spatial detail.
Why classification backbones need changes
A classification backbone such as ResNet-50 downsamples an input by a factor of 32. A 256×192 crop ends up as an 8×6 feature map. That is enough to say "this is a person," but a keypoint must be placed to within a few pixels. At stride 32, one cell covers 32×32 input pixels, so even a perfect arg-max would be off by up to 16 pixels in each direction.
Pose architectures therefore need two things at once:
- Deep, semantically rich features, so the model can tell a left wrist from a right wrist using context such as body shape and limb layout.
- High spatial resolution at the output, so the heatmap peak can be located precisely.
Most designs differ in how they reconcile these two demands. The stride argument in the decoding function from the previous chapter is the quantity at stake: the smaller the stride between heatmap and input, the smaller the quantization error.
| Output stride | Heatmap size for 256×192 input | Worst-case quantization error per axis |
|---|---|---|
| 32 | 8×6 | 16 px |
| 8 | 32×24 | 4 px |
| 4 | 64×48 | 2 px |
Most top-down models use stride 4. This is a compromise: a stride of 1 would cost far more computation and memory, and sub-pixel refinement in decoding recovers much of the remaining error.
Strategy 1: Upsample after a backbone
The simplest design keeps a standard backbone and adds a small head that increases resolution. SimpleBaseline (Xiao et al., 2018) takes ResNet and appends three deconvolution (transposed convolution) layers. Each layer doubles the resolution, taking stride 32 to stride 4. A final 1×1 convolution outputs K channels, one heatmap per keypoint.
import torch
import torch.nn as nn
import torchvision
class SimplePoseNet(nn.Module):
def __init__(self, num_keypoints=17):
super().__init__()
resnet = torchvision.models.resnet50(weights=None)
# Drop the average pool and classifier: keep stride-32 features.
self.backbone = nn.Sequential(*list(resnet.children())[:-2])
layers = []
in_ch = 2048
for _ in range(3):
layers += [
nn.ConvTranspose2d(in_ch, 256, kernel_size=4, stride=2, padding=1, bias=False),
nn.BatchNorm2d(256),
nn.ReLU(inplace=True),
]
in_ch = 256
self.upsample = nn.Sequential(*layers)
self.head = nn.Conv2d(256, num_keypoints, kernel_size=1)
def forward(self, x):
return self.head(self.upsample(self.backbone(x)))
model = SimplePoseNet()
out = model(torch.zeros(1, 3, 256, 192))
print(out.shape) # torch.Size([1, 17, 64, 48])The output is 64×48, a stride of 4 relative to the 256×192 input. This design is easy to build and train. Its weakness is that the high-resolution features are reconstructed from a low-resolution, information-poor representation. Fine detail lost in downsampling cannot be fully recovered.
Strategy 2: Encoder-decoder with skip connections
Hourglass networks (Newell et al., 2016) and related designs reduce resolution step by step, then increase it again. Skip connections carry high-resolution features from the downsampling path directly to the matching level of the upsampling path. This gives the decoder access to the original spatial detail.
Hourglass modules are also stacked. Each stack outputs its own heatmaps and receives a loss, a technique called intermediate supervision. Later stacks refine the earlier predictions, which helps with ambiguous joints such as occluded limbs. The cost is depth: stacking many modules makes the network slow, and gradients must travel far without intermediate losses.
Strategy 3: Keep high resolution throughout (HRNet)
HRNet (Sun et al., 2019) takes a different approach. Instead of going from high to low resolution and back, it maintains a high-resolution branch from start to finish and adds lower-resolution branches in parallel. The branches repeatedly exchange information.
A new, lower-resolution branch is added at the start of each stage (stride 4, 8, 16, 32 in HRNet). Within a stage, a fusion step lets every branch receive information from every other branch:
- A higher-resolution branch is downsampled with strided convolutions before being passed to a lower-resolution branch.
- A lower-resolution branch is upsampled (bilinear or nearest-neighbour, then a 1×1 convolution to match channels) before being passed to a higher-resolution branch.
- The results are summed.
Because the high-resolution representation is never discarded, it is refined with semantic context repeatedly rather than reconstructed at the end. HRNet-W32 and HRNet-W48 (the number is the channel width of the highest-resolution branch) have long been strong baselines on COCO keypoints. The trade-off is cost: they use more memory and are slower than ResNet-based SimpleBaseline at comparable accuracy, and the parallel branches are harder to export to some inference runtimes.
Strategy 4: Transformer backbones
Vision transformers can serve as pose backbones. ViTPose (Xu et al., 2022) uses a plain ViT as the encoder, with a lightweight decoder (deconvolution layers or simple upsampling) to produce heatmaps. A ViT has constant resolution inside its blocks, set by the patch size (commonly 16), so it never loses spatial resolution deeply the way a CNN does. Large-scale pretraining, for example masked autoencoder pretraining, supplies the semantic features.
The trade-offs differ from CNNs. Self-attention cost grows quadratically with the number of tokens, so larger inputs get expensive quickly. Transformers also depend more on pretraining and benefit more from scaling model size. In return, a simple design scales smoothly: ViTPose reports accuracy gains from the base model up to a billion-parameter model without architectural changes.
Choosing a backbone
The right choice depends on the deployment constraint more than on a leaderboard.
| Architecture | Strength | Weakness | Typical use |
|---|---|---|---|
| ResNet + deconv | Simple, fast to train, widely supported | Weaker fine localisation | Baselines, edge deployment |
| Hourglass | Intermediate supervision, refinement | Deep and slow, older | Research, legacy code |
| HRNet | Strong precision, high-resolution features throughout | Memory and latency cost | Accuracy-focused top-down systems |
| ViTPose | Scales with pretraining and size | Large models, attention cost | Maximum accuracy with GPU budget |
| Lightweight CNN (MobileNet-style) | Low latency | Lower accuracy | Mobile, real-time |
Two practical rules help:
- Match input resolution to the task. Small joints such as wrists and ankles benefit from larger crops (for example 384×288 instead of 256×192). Accuracy typically increases with input size, and so does cost.
- Decide whether you need real-time speed. In a top-down pipeline, the pose network runs once per detected person, so cost scales with crowd size. A heavy backbone on a crowded scene can miss a frame budget even when it passes on a single-person test.
Common errors
- Forgetting the stride when decoding. If you change the backbone or head, the heatmap size changes. Compute the stride from the actual shapes (input width divided by heatmap width) rather than hard-coding 4.
- Mismatched input normalisation. Pretrained backbones expect the mean and standard deviation they were trained with. Feeding raw 0–255 pixels degrades the heatmaps silently.
- Treating deconvolution checkerboard artefacts as signal. Transposed convolutions with mismatched kernel and stride can produce a grid pattern in the heatmaps. A kernel size of 4 with stride 2 and padding 1, as above, avoids it.
- Comparing models at different input sizes. An AP gain may come from a larger crop, not a better architecture. Compare at equal input size and note the compute (GFLOPs).
Exercise
A top-down model takes 384×288 crops (height × width) and outputs 17 heatmaps of size 96×72. What is the output stride, and what is the largest error per axis that comes only from taking the arg-max on this grid? Why might a team choose HRNet over a ResNet with three deconvolution layers if both reach this stride?
Show answer
The stride is 384/96 = 4 (and 288/72 = 4). Taking the arg-max can place a keypoint up to half a cell away, so the worst-case error is 2 input pixels per axis. HRNet keeps a high-resolution representation through the whole network and fuses it repeatedly with low-resolution context, so its stride-4 features carry more precise spatial information than features rebuilt by deconvolution from a stride-32 map. The team accepts higher memory and latency in exchange for better localisation, especially on small joints such as wrists.