← All models

depth-estimation Β· vision Β· WebGPU (fp16) / WASM (q8) Β· ~210 MB

DPT β€” the transformer that started dense depth prediction

Before Depth Anything, there was DPT: the 2021 Dense Prediction Transformer that first showed a Vision Transformer could read distance out of a single photo. This is Intel's dpt-hybrid-midas β€” a ViT-hybrid encoder trained the MiDaS way β€” running entirely on your device. One flat photo in, a distance-per-pixel map out. The photo never leaves the tab.

At a glance

ModelXenova/dpt-hybrid-midas (ONNX port of Intel/dpt-hybrid-midas)
Task / pipelinedepth-estimation β€” monocular (single-image) relative depth
ArchitectureDPT: ViT-hybrid encoder (ResNet-50 stem β†’ ViT-Base) + DPT decode head, MiDaS-trained β†’ one depth value per pixel
Quantizationfp16 (WebGPU) / q8 8-bit (WASM) ONNX
BackendWebGPU (fp16) when a real adapter exists; otherwise WebAssembly (q8) β€” honest fallback, still real inference
Download~210 MB (q8) / ~267 MB (fp16), cached after first load
LicenseApache-2.0 (Intel DPT / MiDaS)
Web APIsWebGPU, Web Workers, Canvas 2D, FileReader β€” WebGPU is the only non-Baseline piece, and the page says so if it's missing

DPT-Hybrid is a bigger, older model than Depth Anything Small, so on the CPU (WASM) path the first estimate after loading can take several seconds β€” honest progress is shown, and it is genuinely running on your device.

Run it

Pick or drop a photo, then estimate depth. Warmer / brighter means closer; darker means further away. Switch the colour map to read the scene differently.

Drop a photo, or click to choose
Two cats on a couch A sunlit bedroom A riverside at golden hour

Input

Selected photo

Estimated depth

farnear

See inside

DPT doesn't output a picture β€” it outputs a tensor of real numbers, one per pixel: raw relative inverse depth (MiDaS convention β€” bigger = nearer). The colour map above is just those numbers, min–max normalized to 0–255. Below is the honest view: the raw range straight from the model and how the depths are distributed across the scene.

Estimate a depth map to see the raw numbers.

DPT vs Depth Anything β€” same job, different engine

Both give you a per-pixel depth map from one photo, and both normalise to the same brighter-is-nearer image β€” so they're drop-in swappable in an app. What differs is what's under the hood, and it shows up in the details each one recovers.

 DPT (this page)Depth Anything v2
BackboneViT-hybrid (ResNet-50 stem + ViT-Base)DINOv2 self-supervised ViT
TrainingMiDaS multi-dataset mix (2021)62M unlabelled + pseudo-labelled images (2024)
Outputrelative inverse depthrelative inverse depth
Size (q8)~210 MB~40–100 MB
Feelsolid global geometry, softer fine edgescrisper thin structures & edges

Want to compare on the same photo? Open Depth Anything Basics in another tab and run the same sample.

Why it matters

Depth used to need special hardware β€” a stereo rig, a LiDAR sensor, a structured-light camera. DPT estimates it from a single frame, and it's small and standard enough to run in a web page. Once you know how far away each pixel is, a whole class of effects opens up client-side:

Use cases

Basics

One photo in, a colourised depth map out β€” read distance as colour.

Practical

Depth-driven background blur β€” fake a portrait-mode lens in the browser.

Wild

3D parallax β€” tilt a flat photo with your mouse and feel the depth.

Multi-model

DPT + SegFormer β†’ how far away is each thing? Depth averaged per semantic class.

How the API works

Depth is a one-liner with Transformers.js. The pipeline returns both a ready-to-display image and the raw tensor:

import { pipeline } from "@huggingface/transformers";

const estimator = await pipeline(
  "depth-estimation",
  "Xenova/dpt-hybrid-midas",
  { device: "webgpu", dtype: "fp16" },   // ~267 MB fp16 / ~210 MB q8, cached after first load
);

const { depth, predicted_depth } = await estimator(imageURL);
// depth          β†’ RawImage: grayscale, min–max normalized to 0–255 (great for display)
// predicted_depth β†’ Tensor:  the raw per-pixel relative inverse depth (dims = [H, W]); bigger = nearer

The pipeline id and output shape are identical to Depth Anything's β€” only the model string changes β€” so swapping depth backbones is a one-line edit. This page colourises depth on a canvas and reads predicted_depth for the real range + distribution in "See inside". Inference runs in a Web Worker, so estimating a large photo never freezes the page.

References