Depth from one picture

Turn a single photo, your own picture, or a camera snapshot into a depth map and a 3D relief with Depth Anything V2 running in your browser.

IntermediateExplained in Depth from a single image

Depth from one picture

Depth Anything V2 guesses how near every pixel is from a single photo. It gives relative inverse depth: an order, not meters.

Show
Tap to place
Sample photos

Your photos and camera frames are processed on this device and never uploaded.

Recorded from Depth Anything V2 Small

Loading the model's recorded outputs for four of the sample photos (the corridor, the street, the print, and the dog), at the model's own resolution.

About the download

Estimate the depth of any photo from a single picture. This uses Depth Anything V2 Small, a 25-million-parameter model (2024) that estimates how near or far every pixel of a single photo is.

The first time, your browser downloads about 50 MB of model files from Hugging Face, plus a 14 MB runtime from this site. Both are cached for later visits. Everything runs on your device; no photo or camera frame is sent anywhere.

Manage downloads

Loading the recorded results

A (0 farthest, 1 nearest)n/a
Bn/a
The model saysPlace both A and B
Time for this picturen/a

Challenges

0 of 2 complete

  1. Place A on a spot the model puts at the far end of its scale, within 2% of the farthest point in the picture. (not yet)
  2. On the woodblock print, put A on the bird or branch and B on the plain paper, at least half the model's scale apart. (not yet)

Try this

  • On the corridor, compare a point on the near floor with one at the far end.
  • Find the far end of the model’s scale on the street photo.
  • Try the woodblock print, then 3D relief.
  • Take a camera photo of a mirror or a window. Nothing leaves your device.
Relative depth, its order, and its alignmentPython with NumPy
import numpy as np

depth = np.array([1.0, 2.0, 4.0, 8.0, 50.0])  # meters
inverse = 1 / depth

# Output with an unknown scale and offset, plus a little error.
rng = np.random.default_rng(0)
output = 3.0 * inverse + 0.4 + rng.normal(0, 0.01, depth.size)
print("nearest first, model:", np.argsort(-output))

# Align with the best scale and offset, as benchmarks do.
A = np.stack([output, np.ones_like(output)], axis=1)
scale, shift = np.linalg.lstsq(A, inverse, rcond=None)[0]
print("recovered distances:", np.round(1 / (scale * output + shift), 1))
nearest first, model: [0 1 2 3 4]
recovered distances: [ 1.   2.   4.   8.  54.4]

Sample photos, all CC0 on Wikimedia Commons: Dog by Joselodos; Cat by Vyshnavi medicharla; Cat on a motorcycle by CAPTAIN RAJU; Breakfast by Andy Li; Street by Mucklagh; Cafe by Andy Li; Corridor by Sindugab; Woodblock print by Utagawa Hiroshige (Metropolitan Museum of Art).

Try "embedding", "softmax", "overfitting", or "backpropagation".