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.
Your photos and camera frames are processed on this device and never uploaded.
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
- 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)
- 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).