โ† All models

image-feature-extraction ยท vision ยท WASM ยท ~25 MB

DINOv2-with-registers โ€” the same image vectors, with the artifacts removed

DINOv2 turns any image into a 384-number descriptor with no labels โ€” but a plain vision transformer quietly hijacks a few background patches to stash global information, spiking their feature norms and muddying the local features used for dense tasks. This model adds a handful of dedicated register tokens that soak up that global state, so the patch features stay clean. Same descriptor, cleaner attention. Add a few images and watch it build a live similarity matrix; then look inside at the patch-norm map that tells the registers story. Nothing leaves your device.

At a glance

Modelonnx-community/dinov2-with-registers-small (ONNX build of facebook/dinov2-with-registers-small)
Task / pipelineimage-feature-extraction
ArchitectureViT-S/14 (22M params) + 4 register tokens โ†’ 384-d image descriptor + per-patch features
The register ideaextra learnable tokens give the model somewhere to keep global scratch state, so patch tokens aren't hijacked (no high-norm "artifact" patches) โ€” Vision Transformers Need Registers, Darcet et al. 2023
TrainingSelf-supervised (DINO + iBOT), no labels โ€” LVD-142M images
Descriptorthe [CLS] token vector (384-d), L2-normalized โ†’ cosine = dot product
Quantizationq8 (8-bit) ONNX
BackendWebAssembly (runs anywhere; no WebGPU needed)
Download~25 MB, cached after first load
LicenseApache-2.0 (Meta AI)
Web APIsWebAssembly, Web Workers, File API โ€” all Baseline widely available

Distinct from the plain DINOv2-small demo: same task and descriptor size, but the register tokens change what the patch features look like โ€” compare the patch-norm maps on both pages.

Run it โ€” image similarity matrix

Start with the sample set (two cats, two cars, a mountain, a flower) or add your own. The model embeds each image; the matrix shows the cosine similarity between every pair โ€” 1.00 down the diagonal, higher where two images look alike. Uploaded images never leave your browser.

See inside โ€” patch features, the artifact map & the register tokens

The model splits the image into a grid of 14ร—14-pixel patches and produces one feature vector per patch, plus a global [CLS] descriptor and 4 register tokens. Two heatmaps tell the story. Cosine-to-CLS shows which patches most define "what this image is" (the foreground). Patch norm is the punchline of the registers paper: in a plain ViT a few background patches spike to huge norms (the artifacts), but here โ€” with registers absorbing the global state โ€” the norms stay smooth. The register tokens themselves carry that global scratch state, which is why their norms sit well above a typical patch.

Embed some images to inspect their features.

Why it matters

A general-purpose image descriptor is the vision equivalent of a text embedding โ€” and because DINOv2 is trained without labels, it isn't boxed into a fixed list of classes. The register variant matters wherever you rely on the local patch features, not just the global vector: cleaner patch features mean smoother attention, better dense correspondence, and fewer spurious hot-spots in background regions. At 25 MB it runs in a tab, so you can index and compare a user's own photos โ€” and line up regions between them โ€” without uploading a single one.

Use cases

Basics

Two images in, one similarity number out โ€” plus the patch heatmap and artifact map for each.

Practical

Near-duplicate finder and reverse-image-search over a small on-device set.

Wild

Dense patch correspondence โ€” colour-match the same regions across two images with the clean patch features.

Multi-model

Retrieve the nearest image with DINOv2-registers, then label it with a ViT classifier.

How the API works

The image-feature-extraction pipeline is the whole recipe; drop to the raw model for patch features:

import { pipeline, RawImage } from "@huggingface/transformers";

const extractor = await pipeline(
  "image-feature-extraction",
  "onnx-community/dinov2-with-registers-small",
); // downloads + caches ~25 MB once

// Simple path: one pooled 384-d descriptor per image.
const out = await extractor("cat.jpg", { pool: true });
const vec = out.tolist()[0]; // 384 numbers

// unit-normalize, then cosine similarity is just the dot product:
const norm = (v) => { const n = Math.hypot(...v); return v.map((x) => x / n); };
const sim = (a, b) => a.reduce((s, x, i) => s + x * b[i], 0);

// Deeper path: the raw model gives the per-TOKEN sequence โ€” [CLS] + registers + patches.
const image = await RawImage.read("cat.jpg");
const inputs = await extractor.processor(image);
const { last_hidden_state } = await extractor.model(inputs);
// last_hidden_state: [1, 1 + numRegisters + numPatches, 384].
// token 0 = [CLS]; tokens 1..numRegisters = registers; the rest = patch grid.
const nReg = extractor.model.config.num_register_tokens; // 4

This page asks the worker for the un-normalized [CLS] vector plus each patch token's norm and cosine-to-CLS, so "See inside" can show the real magnitudes and the artifact map. Inference runs in a Web Worker so building the matrix never janks the page.

References