Depth Anything V2 Small β Karume
What is this
A monocular relative depth distribution, converted into the WebGPU inference runtime
Karume's container format (a single safetensors file = weights + a graph JSON
embedded in __metadata__). Runs as-is in the browser and in Deno.
- One graph, one call: pixels in, one f32 depth value per pixel out, at the same size as the image you handed over.
- Relative depth has no unit and no origin β larger means nearer, and only the ordering carries meaning. This is not a metric-depth checkpoint: the numbers are not metres and are not comparable across images.
- Pre- and post-processing are included. The pipeline resizes to 518 Γ 518, normalizes with the constants below,
runs the graph, and scales the depth map back to the original resolution. Decoding
PNG / JPEG is not part of this β use
createImageBitmapin the browser, or any decoder in Deno. - Normalization and colouring are yours. The pipeline returns the raw f32 map, not a
[0, 1]image: folding it with min/max would throw the scale away, and which colour map to use is a decision this repository should not make for you. - Not readable by transformers (it's a different container with an embedded graph); the reader is a pipeline that implements
depth-anything/1. - Exporter used for the conversion:
karume/0.9.0. The distribution manifest iskarume.json(karume/4).
Base weights and attribution
Converted into the container format β the original checkpoints are not distributed here.
small: depth-anything/Depth-Anything-V2-Small-hf, licensed apache-2.0 (as of retrieval; full text β a verbatim copy is inLICENSE.md).- Only the Small checkpoint is Apache-2.0. Upstream ships Base and Large under CC BY-NC 4.0, so they are not converted or redistributed here.
- Training data: see the upstream model card. Depth Anything V2 is distilled from a teacher trained on synthetic data and then trained on pseudo-labelled real images β check the upstream sources against your own use case.
- Architecture: DINOv2 backbone + DPT head (arxiv.org/abs/2406.09414).
- Changes made here (also listed in
NOTICE.md, per Apache 2.0 Β§4(b)): conversion into the Karume container format. No retraining, no fine-tuning and no quantization β the weights are the source checkpoint's own f32 values. The graph is the upstreamforwardwith two layout-only rewrites (the last fusion stage's upsample takes an explicit output size instead of a scale factor, and the position-embedding interpolation is pinned to the pretraining resolution where it is the identity β both bit-exact), plus one module rewrite that is equivalent up to floating-point rounding: the DPT reassemble stage's transposed convolutions became a 1Γ1 convolution followed by a pixel shuffle (they havekernel == stride, so the two are exactly the same sum in a different order β measured max 1.4e-06 on depth values whose RMS is around 1).
Models
| Model | Pipeline | Quants | Default quant |
|---|---|---|---|
small (default) |
depth-anything/1 |
f32 |
f32 |
model selects one of these; omitted, it is small. quant defaults to that model's own default quant.
Usage
import { DepthAnythingPipeline } from "jsr:@karume/models";
await using pipeline = await DepthAnythingPipeline.fromPretrained({
repo: "hdae/karume-depth-anything-v2",
// Pin a commit for reproducible builds β without it you track `main`, and a future
// repo update (renamed files, new manifest format) may break your app.
// Copy the full hash from this repo's "Files and versions" tab:
// revision: "<full commit sha>",
}, {
// model: "small", // default β available: small
// quant: "f32", // default β available: f32
});
// RGB8, row-major, 3 bytes per pixel. Decoding is the caller's job.
const depth = await pipeline.estimate({ data: pixels, width, height });
// depth.data is one f32 per pixel, same width/height as the input, larger = nearer.
// Fold it to [0, 1] yourself when you want to look at it:
let min = Infinity;
let max = -Infinity;
for (const value of depth.data) {
if (value < min) min = value;
if (value > max) max = value;
}
const span = max - min;
const gray = depth.data.map((value) => (span > 0 ? (value - min) / span : 0));
estimate() keeps one GPU session alive for the lifetime of the pipeline, so processing
many images uploads the weights once; concurrent calls are queued rather than run side by
side. Weights are fetched once and cached (verified against karume.json's size /
sha256).
Model: small
Quants
| Quant | What it is | Download | Weights | Compute |
|---|---|---|---|---|
f32 (default) |
β | 94.5 MiB | depth = f32 |
β |
If no quant is given, it runs as f32 (this model's recommended default).
Per-file size and sha256 live in karume.json β verify against that at the fetch layer.
Dtype labels use the runtime's storage dtype vocabulary (f16 / i8 / i4), not the fp16 spelling common elsewhere in the ecosystem.
Input and output
Derived from the checkpoint's own preprocessor_config.json and the exported graph, and
checked against each other when this repository was assembled.
- input: RGB8 pixels, resized to 518 Γ 518 (bicubic, antialiased). Note the filter: this checkpoint asks for bicubic, unlike most image towers.
- The aspect ratio is not preserved. The graph is baked at the single square pretraining resolution (the position embeddings are tied to the patch grid), so a non-square photo is stretched rather than letterboxed. Crop it yourself first if that matters for your images.
- normalization:
(pixel / 255 - mean) / std, mean 0.485 / 0.456 / 0.406, std 0.229 / 0.224 / 0.225 - output: one f32 per pixel at the size of the image you passed in β relative depth, non-negative (the head ends in a ReLU, so far regions sit at exactly 0), larger = nearer. The graph itself emits the map at the resized resolution; scaling it back to your image happens on the host, bilinearly.
Model tree for hdae/karume-depth-anything-v2
Base model
depth-anything/Depth-Anything-V2-Small-hf