Skip to content
imaged

Depth estimation

Depth Anything V2 Small

Sees how far away every part of a photo is, from a single image: the small, Apache-2.0 version of the leading monocular depth model.

Apache-2.0depth estimationmonocular depthdepth anythingdinov2apache-2.0
Choose a variant

About this model

Depth Anything V2 estimates depth from one ordinary photo: for every pixel, how near or far it is relative to the rest of the scene. It works on indoor and outdoor scenes, people, objects and landscapes without any setup.

The Small model (24.8 million parameters) uses a DINOv2 ViT-S encoder and a DPT decoder, trained on synthetic images with precise depth and then on 62 million real images labeled by a larger teacher model.

The output is relative inverse depth: larger values are nearer, and values compare only within one photo (there are no meters). depth_map() shows it as an image; depth_at(x, y) gives the value at a pixel.

What you can build

  • Blur or replace the background behind the subject (portrait effects)
  • Separate foreground from background for AR and photo editing
  • Order objects by distance or find the nearest thing in front of a camera
  • 3D-photo and parallax effects from a single image

People crossing street

f16
Input
People crossing street (Unsplash)

Mike Petrucci mikepetrucci, CC0, https://commons.wikimedia.org/wiki/File:People_crossing_street_(Unsplash).jpg

Output
The depth map: near warm and bright, far dark
depth_map() on the Metal (FP16 pack), drawn near pale yellow to far dark blue. depth_at() down the middle: top 0.00, centre 0.27, bottom 10.19 (larger is nearer).

Harbor boats

f16
Input
North Harbor Lysekil with motor boat

W.carter, Public domain, https://commons.wikimedia.org/wiki/File:North_Harbor_Lysekil_with_motor_boat.jpg

Output
The depth map: near warm and bright, far dark
depth_map() on the Metal (FP16 pack), drawn near pale yellow to far dark blue. depth_at() down the middle: top 0.00, centre 1.44, bottom 7.17 (larger is nearer).

Cyclists road

f16
Input
0014Outdoor location photo shoot group photographs of deaf-mute road cyclists 34

Judgefloro, CC0, https://commons.wikimedia.org/wiki/File:0014Outdoor_location_photo_shoot_group_photographs_of_deaf-mute_road_cyclists_34.jpg

Output
The depth map: near warm and bright, far dark
depth_map() on the Metal (FP16 pack), drawn near pale yellow to far dark blue. depth_at() down the middle: top 0.00, centre 3.06, bottom 5.18 (larger is nearer).

Variants & downloads

Choose the build for your app

Model files are hosted on Google Drive. Large files may open a confirmation page before downloading.

Standard

Slab

Weights stored in FP16: half the size of FP32, the same depth (see Accuracy).

Platforms: macos · android

depth-anything-v2-small-f16.slab

50.7 MB · Hosted download

Download
SHA-256 checksum
061697a6c03d494a9e8f0b83dd62368cbc126e5e75b78539002c4c1acc911fbf

LICENSE-Depth-Anything-V2.txt

11 KB

Download
SHA-256 checksum
8b21a7ca65452932f2f1418faf0e89fbdef475974b5ebef02a0552313d6e251c
Conversion details
command
git clone https://github.com/DepthAnything/Depth-Anything-V2 && git -C Depth-Anything-V2 checkout a561b849ebae10a6f5ef49e26c83cbbcd36c71bf curl -L -o depth_anything_v2_vits.pth https://huggingface.co/depth-anything/Depth-Anything-V2-Small/resolve/03876f8651c73a60fe4c2c48294e09fcb6838fcf/depth_anything_v2_vits.pth python -c "import sys, torch; sys.path.insert(0, 'Depth-Anything-V2'); from depth_anything_v2.dpt import DepthAnythingV2; m = DepthAnythingV2(encoder='vits', features=64, out_channels=[48, 96, 192, 384]); m.load_state_dict(torch.load('depth_anything_v2_vits.pth', map_location='cpu', weights_only=True)); torch.onnx.export(m.eval(), torch.randn(1, 3, 518, 518), 'model.onnx', input_names=['image'], output_names=['depth'], opset_version=17, dynamo=False)" slab-load convert model.onnx model.slab --input image=1x3x518x518 --meta task=depth --meta resize=stretch --meta interpolation=bicubic --meta normalize=imagenet --meta color=rgb slab-load quantize model.slab depth-anything-v2-small-f16.slab --f16 slab-load meta set depth-anything-v2-small-f16.slab default_backend.macos=gpu

Integration examples

Python

python

import slab

cfg = slab.Config(cache_dir="/tmp/slab_cache", license=open("license.slablic.txt").read())
session = slab.Session(cfg, "depth-anything-v2-small-f16.slab", warmup=True)
photo = slab.Frame.open("photo.jpg")
out = session.run(slab.Input(frame=photo))
view = out.depth_map()                                  # Gray8 Frame, the photo's size: 255 nearest, 0 farthest
print(out.depth_at(photo.width / 2, photo.height / 2))  # raw value at the centre (larger is nearer)

Device & backend compatibility

Pack default: macos / GPU. The fastest backend on the Mac (about 28 ms per photo); the Neural Engine takes 65 ms and 35 s to prepare.

Available execution backends for Depth Anything V2 Small
PlatformEngineStatusPrecision
apple

CPU

CPU

Supported

Measured on macOS.

f32
apple

Metal

GPU

Supported

Measured on macOS. The default.

f32
apple

Apple Neural Engine

NPU

Supported

Measured on macOS. The Neural Engine computes in FP16.

f16
android

CPU

CPU

Supported

Measured on a Samsung Galaxy S23 Ultra (Snapdragon 8 Gen 2, Adreno 740), Android 17.

f32
android

Vulkan

GPU

Supported

Measured on a Samsung Galaxy S23 Ultra (Snapdragon 8 Gen 2, Adreno 740), Android 17.

f32
android

Qualcomm Hexagon NPU (QNN)

NPU

Not supported

Tried on a Samsung Galaxy S23 Ultra (Hexagon v73): One of the model's nodes does not translate to QNN in Slab yet.

—

Performance

Results depend on the device, runtime, and test conditions. Each measurement keeps its own context.

Mac with Apple M1 Max

Slab · CPU

macOS 26.6.2

556.9 ms

Measured time · scope below

f16Session open (ms): 10 Platform: macos Runs: 100 Input: 1, 3, 518, 518 Measured: 2026-10-29

Median of 100 warm runs of the model (Slab's run time). From a 1920 x 1080 photo, resizing included: 562.3 ms median. depth_map() at 1920 x 1080 adds about 9 ms; depth_at() under a microsecond.

Mac with Apple M1 Max

Slab · GPU

macOS 26.6.2

27.5 ms

Measured time · scope below

f16Session open (ms): 191 Platform: macos Runs: 100 Input: 1, 3, 518, 518 Measured: 2026-10-29

Median of 100 warm runs of the model (Slab's run time). From a 1920 x 1080 photo, resizing included: 28.9 ms median. depth_map() at 1920 x 1080 adds about 9 ms; depth_at() under a microsecond.

Mac with Apple M1 Max

Slab · NPU

macOS 26.6.2

64.7 ms

Measured time · scope below

f16Session open (ms): 34555 Platform: macos Runs: 100 Input: 1, 3, 518, 518 Measured: 2026-10-29

Median of 100 warm runs of the model (Slab's run time). From a 1920 x 1080 photo, resizing included: 65.3 ms median. depth_map() at 1920 x 1080 adds about 9 ms; depth_at() under a microsecond.

Samsung Galaxy S23 Ultra (Snapdragon 8 Gen 2)

Slab · CPU

Android 17

2.26 s

Measured time · scope below

f16Session open (ms): 110 Platform: android Runs: 10 Input: 1, 3, 518, 518 Measured: 2026-11-06

Median of 10 warm runs of the model (Slab's run time). From a 1920 x 1080 photo, resizing included: 2115 ms median. open_ms: opening the session. Peak memory (resident) after the runs: 357 MB.

Samsung Galaxy S23 Ultra (Snapdragon 8 Gen 2)

Slab · GPU

Android 17

676.0 ms

Measured time · scope below

f16Session open (ms): 158 Platform: android Runs: 17 Input: 1, 3, 518, 518 Measured: 2026-11-06

Median of 17 warm runs of the model (Slab's run time). From a 1920 x 1080 photo, resizing included: 570 ms median. open_ms: opening the session with the GPU programs already in the cache folder (the first open on a device compiles them, about 0.3 s more). Peak memory (resident) after the runs: 172 MB.

Accuracy checks

macos · CPU · f16

The upstream PyTorch model on the same 518 x 518 stretch (PIL bicubic), its output resized bilinearly to the photo; 23 public-domain and CC0 photos (Wikimedia Commons). Depth is relative, so Slab's depth_map() is fitted to the reference by scale and shift before scoring

Correlation 0.9995 (0.9980 on the worst photo), remaining error 0.82% of the depth range. On identical input tensors the raw output is within 5.7e-03 of PyTorch (relative to its largest value). Against the upstream infer_image (aspect ratio kept, short side 518, OpenCV bicubic): correlation 0.9965, error 2.20%.

macos · GPU · f16

The upstream PyTorch model on the same 518 x 518 stretch (PIL bicubic), its output resized bilinearly to the photo; 23 public-domain and CC0 photos (Wikimedia Commons). Depth is relative, so Slab's depth_map() is fitted to the reference by scale and shift before scoring

Correlation 0.9995 (0.9980 on the worst photo), remaining error 0.82% of the depth range. On identical input tensors the raw output is within 5.7e-03 of PyTorch (relative to its largest value). Against the upstream infer_image (aspect ratio kept, short side 518, OpenCV bicubic): correlation 0.9965, error 2.20%.

macos · NPU · f16

The upstream PyTorch model on the same 518 x 518 stretch (PIL bicubic), its output resized bilinearly to the photo; 23 public-domain and CC0 photos (Wikimedia Commons). Depth is relative, so Slab's depth_map() is fitted to the reference by scale and shift before scoring

Correlation 0.9995 (0.9978 on the worst photo), remaining error 0.82% of the depth range. On identical input tensors the raw output is within 4.4e-02 of PyTorch (relative to its largest value). Against the upstream infer_image (aspect ratio kept, short side 518, OpenCV bicubic): correlation 0.9965, error 2.19%.

Before you choose this model

  • Relative depth only: no distances in meters, and values from two photos are not comparable.
  • Mirrors, glass and screens can confuse it.
  • The pack runs at a fixed 518 x 518 and stretches the photo to it. The upstream script keeps the aspect ratio; across our photos the two maps correlate at 0.9965 (2.2% of the range apart after matching scale and shift).
  • On the Neural Engine it takes about 35 s to prepare; use the GPU.
  • Only the Small model is Apache-2.0; Depth Anything V2 Base and Large are non-commercial.