DPT
Ranftl 2021 · Paper
One-line summary — Replaces the CNN backbone with a Vision Transformer for dense prediction (depth, segmentation), exploiting global self-attention at every layer to produce globally coherent depth maps.
Problem
Fully-convolutional networks dominate dense prediction, but their encoders progressively downsample: feature resolution and granularity lost in the deeper stages are hard to recover in the decoder, and individual convolutions have limited receptive fields, so broad context is only acquired late in very deep stacks. For pixel-level tasks like monocular depth this causes locally inconsistent, globally wobbly predictions. DPT asks whether a Vision Transformer backbone — constant representation resolution, global receptive field at every stage — yields finer-grained and more globally coherent dense predictions.
Method & architecture
Transformer encoder. The image is decomposed into non-overlapping patches of pixels (), each flattened and linearly projected to a token; a learnable position embedding and a special readout token are added, giving tokens , with . transformer layers of multi-headed self-attention transform them into . Because tokens correspond one-to-one with patches, spatial resolution is constant through all stages, and every token can attend to every other from the first layer. Variants: ViT-Base (, 12 layers), ViT-Large (, 24 layers), and ViT-Hybrid (ResNet-50 features as tokens, 12 layers).
Reassemble. Tokens from four transformer depths are converted back into image-like feature maps by a three-stage operation
where folds the readout token into the patch tokens (the default projects the concatenation per token), reshapes tokens to an map by patch position, and rescales it to via projection plus (transpose-)convolution, with . For ViT-Large the tapped layers are (assembled at lower resolution for deeper layers); ViT-Base uses ; ViT-Hybrid uses the two first ResNet blocks plus stages .
Convolutional fusion decoder. RefineNet-style fusion blocks with residual convolutional units progressively combine consecutive-stage feature maps, upsampling by 2 at each stage; the final representation has half the input resolution and feeds a task-specific output head. Position embeddings are linearly interpolated on the fly, so DPT handles varying image sizes like an FCN.
Depth training recipe. Follows the MiDaS protocol — scale- and shift-invariant trimmed loss on inverse depth plus multi-scale gradient matching — but on MIX 6, a ~1.4M-image meta-dataset (MIX 5 plus five additional datasets), the largest depth training set compiled at the time, trained with multi-objective (Pareto) dataset mixing for 60 epochs at .
Results
Zero-shot cross-dataset transfer (all metrics lower-is-better): DPT-Large trained on MIX 6 reaches DIW WHDR 10.82, ETH3D AbsRel 0.089, Sintel AbsRel 0.270, and outlier rates 8.46 (KITTI), 8.32 (NYU), 9.97 (TUM), versus the previous-best fully-convolutional MiDaS (MIX 5): 12.46 / 0.129 / 0.327 / 23.90 / 9.55 / 14.29. Average relative improvement is 28% for DPT-Large and 23% for DPT-Hybrid; retraining the convolutional MiDaS on the same MIX 6 improves it only marginally, showing the FCN cannot exploit the extra data the way the transformer can. Fine-tuned DPT-Hybrid set new states of the art on NYUv2 ( 0.904, AbsRel 0.110, RMSE 0.357) and KITTI ( 0.959, AbsRel 0.062, RMSE 2.573). For semantic segmentation, DPT-Hybrid set a new state of the art on ADE20K with 49.02% mIoU and on Pascal Context after fine-tuning.
Why it matters for SLAM
DPT made ViT encoders the default for monocular depth: DPT-Large became the backbone of MiDaS v3 and Depth Anything v1, which are the depth priors most commonly injected into monocular and dense SLAM systems. When a SLAM pipeline consumes a “relative depth network” today, it is very likely a DPT-style architecture underneath. Its globally consistent depth is exactly what dense mapping needs — locally wobbly depth maps break TSDF or surfel fusion.
Related
- MiDaS — the robust relative-depth training recipe DPT plugs into
- MonoDepth — earlier self-supervised monocular depth lineage
- ZoeDepth — adds metric scale on top of relative-depth pre-training
- Depth Anything — foundation-scale depth model built on the DPT architecture
- Metric3D — metric-depth line that also trains on massive mixed data