object-detection × depth-estimation WASM q8 · 56.96 MB + 27.26 MB 2 independent Web Workers Apache-2.0 + Apache-2.0

2-Stage Scene Spatializer: YOLOS-Small × Depth Anything v2 Small

Stage 1 — YOLOS-Small finds every COCO object and its bounding box. Stage 2 — Depth Anything v2 Small computes a dense per-pixel relative depth map of the same frame. Combining them ranks every detected object from nearest foreground to farthest background.

The two independent model stages

Stage 1 · YOLOS-Small detector

Xenova/yolos-small · object-detection · WASM q8 · 56.96 MB · Pure ViT-Small + 100 [DET] tokens.

Stage 2 · Depth Anything v2 Small

onnx-community/depth-anything-v2-small · depth-estimation · WASM q8 · 27.26 MB · relative inverse depth.

Loading a sample photo…

Scene input & spatial overlay

Select a box or card to inspect its median relative depth.

Stage 1 (YOLOS)–
Stage 2 (Depth)–
Foreground (≥ 0.65)–
Mid-ground (0.35–0.65)–
Background (< 0.35)–

Depth-ordered scene inventory (nearest → farthest)

Spatial object inventory ordered by median relative inverse depth (255 = nearest)
Rank Class Confidence Band Median depth IQR (p25–p75) Box [x1, y1, x2, y2]
Load both models and run the spatializer to rank objects by depth.

See inside — computing per-object median depth

Sampling the outer corners of a bounding box often picks up walls or sky behind the object. Here, computeBoxDepthStats() reads an exact 256-bin histogram over the inner 70% core of each YOLOS-Small box in the Depth Anything v2 inverse-depth map (255 = nearest, 0 = farthest) and reports the median plus interquartile range (p25–p75) in O(box area) with zero sorting allocations.

Show the code — inner-core 256-bin depth median and IQR calculation
Show the code — foreground / mid-ground / background ranking
Show the code — Stage 2 Depth Anything v2 estimation & off-thread colormap