depth-estimation Β· vision Β· WebGPU (fp16) / WASM (fp32) Β· ~72β143 MB
Most monocular depth models give you a relative map β a nearer/farther ordering in arbitrary units. Metric3D is different: it predicts absolute depth in metres against a canonical camera, so the numbers are real distances you can compare across the scene. Give it one photo and read how far every pixel is. It's small enough to run on WebGPU or plain WASM, and the photo never leaves the tab.
| Model | onnx-community/metric3d-vit-small |
|---|---|
| Task / pipeline | depth-estimation β monocular, metric-scale (model_type metric3d) |
| Architecture | Metric3D: a ViT-Small depth backbone trained with a canonical-camera transform so a single feed-forward pass predicts absolute metric depth across datasets |
| Output | predicted_depth β a per-pixel tensor of depth in metres; plus a 0β255 normalized image for display |
| Quantization | fp16 (WebGPU, ~72 MB) or fp32 (WASM, ~143 MB) |
| Backend | WebGPU when a GPU adapter exists, else WebAssembly β it runs either way |
| Download | ~72 MB (fp16) / ~143 MB (fp32), cached after first load |
| License | cc0-1.0 (onnx-community ONNX export) |
| Metric caveat | Absolute metres assume the model's canonical camera intrinsics β exact at the reference focal length, a calibrated estimate for an arbitrary photo. The relative metric structure across the scene is the robust signal. |
| Web APIs | WebGPU (optional), Web Workers, OffscreenCanvas, Canvas 2D, FileReader |
Pick or drop a photo, then estimate depth. The colour maps distance: the legend shows the real metre range. Darker/cooler is nearer, brighter/warmer is farther. Runs on WebGPU if you have it, otherwise on WASM.
Metric3D outputs a tensor of real numbers in metres, one per pixel. That's what makes it metric rather than relative: the values are absolute distances against a canonical camera, not arbitrary units re-normalized per image. Below is the honest view β the raw metre range straight from the model, the mean depth, and the distribution β plus the camera-intrinsics caveat that keeps the claim honest.
| predicted_depth shape | β |
|---|---|
| raw depth range | β |
| mean depth | β |
| near / far plane | β |
| pixels estimated | β |
Camera intrinsics. Metric3D calibrates to a canonical focal length, so absolute metres are exact for that reference and an estimate for a photo with different intrinsics. Ratios and relative distances across the scene are the robust part β which is exactly what the "measure distances" demo relies on.
Depth Anything and DPT give a relative map β great for parallax and background blur, but the range is arbitrary and re-normalized per image, so "3" in one photo isn't "3" in another. Metric3D commits to metres: the same scene reads the same absolute distances, which is what lets you measure. (Apple's DepthPro is also metric but a much larger, WebGPU-only model tuned for razor-sharp boundaries β Metric3D is the small, WASM-friendly metric option.)
Absolute depth in metres from a single frame β no stereo rig, no LiDAR β turns a photo into measurable geometry:
One photo in, a colourised metric depth map out β read distance as colour, with a metre legend.
Tap any point to read its distance in metres, and tap two to get the depth gap.
3D parallax β tilt a flat photo with your pointer, driven by real metric depth.
Metric depth + segmentation β the mean distance in metres of each labelled region.
Depth is a one-liner with Transformers.js. The pipeline returns both a ready-to-display image and the raw metric tensor:
import { pipeline } from "@huggingface/transformers";
const estimator = await pipeline(
"depth-estimation",
"onnx-community/metric3d-vit-small",
{ device: "webgpu", dtype: "fp16" }, // or device:"wasm", dtype:"fp32"
);
const { depth, predicted_depth } = await estimator(imageURL);
// depth β RawImage: grayscale, minβmax normalized to 0β255 (for display)
// predicted_depth β Tensor: the raw per-pixel depth in METRES (dims = [H, W])
This page colourises depth and reads predicted_depth for the real metre
range + distribution, in "See inside". Both the inference AND the per-pixel colour composite run in
a Web Worker (the worker transfers a ready ImageBitmap), so estimating a large photo never freezes
the page. Metric3D runs on WebGPU when available and falls back to WASM otherwise.