At a glance
| Upstream model | facebook/dinov2-base (Meta AI Research β Oquab et al., TMLR 2024 / arXiv:2304.07193, self-supervised on LVD-142M) |
|---|---|
| Browser ONNX repo |
Xenova/dinov2-base
(onnx/model_quantized.onnx β 90,974,542 B / 90.97 MB)
|
| License | Apache-2.0 (permissive open-source commercial & research use) |
| Task & architecture |
image-feature-extraction Β· Dinov2Model (dinov2, 86.6M params,
12 layers, 768-d hidden, 12 attention heads, 3072 MLP, GELU, LayerScale, 256px shortest-edge resize +
224Γ224 center crop, patch 14, 0 register tokens)
|
| Output tensor shape |
last_hidden_state shape [1, 257, 768] (197,376 values):
index 0 = [CLS] (1Γ768) Β·
indices 1..256 = 16Γ16 = 256 spatial patch tokens (256Γ768)
|
| Distinct from v1 & Registers/v3 | Scales from ViT-S/16 (384-d, 14Γ14 patches) up to ViT-B/14 (768-d, 16Γ16 patches) with finer spatial resolution, while still running with 0 register tokens β exposing DINOv2's famous high-norm background "artifact" tokens that later motivated DINOv2-Registers and DINOv3. |
| Runtime & backend |
Shared Transformers.js pin (../../lib/webai.js) Β· CPU WASM q8 (90.97 MB, universal;
runs off-main-thread in worker.js)
|
1. Live 16Γ16 Patch Cosine Explorer
Drop an image anywhere in this box, paste from clipboard (Ctrl/β+V), capture from webcam, or pick a curated photo below.
Initialise DINOv2-Base above, then click or arrow-key any 16Γ16 cell to inspect patch cosine similarity.
Live [1, 257, 768] Tensor Anatomy
DINOv2-Base uses 0 register tokens: index 0 is the global [CLS]
vector and indices 1..256 map directly to the 16Γ16 spatial grid.
[CLS] (1Γ768)
Patch norm spread & top cosine matches will appear here after the forward pass.
Why DINOv2-Base matters
DINOv2 scaled self-supervised ViT pretraining to the curated LVD-142M dataset with patch-14
tokenization, producing general-purpose visual features that transfer zero-shot across retrieval, dense
segmentation, depth, and correspondence. At 90.97 MB under Apache-2.0 and universal CPU WASM,
DINOv2-Base unlocks:
- Higher-capacity 768-d visual indexing: finer intra-class discrimination and cleaner near-duplicate clustering across local photo libraries with zero server upload.
- 256-patch dense correspondence:
16Γ16spatial resolution (30% denser than patch-16) aligns semantic object parts across scenes and viewpoints without labels. - Inspectable artifact tokens: observe register-free high-norm background patches firsthand in a Base-scale model (86.6M params), explaining why DINOv2-Registers added 4 scratch tokens.
- Open-set crop Re-ID: pair
11.33 MBD-FINE Small Obj365 with90.97 MBDINOv2-Base (102.3 MBtotal) for instance-level crop twin matching.
Use-case ladder
1. Basics Β· 768-d PCA & Artifact Norms
3-component RGB PCA over all 256 patch tokens plus a Patch L2-Norm Artifact Map exposing register-free background spikes.
2. Practical Β· 768-d Visual Dedup & Search
Multi-photo upload, mid-batch Cancel, cosine ranking, pairwise cluster slider, and formula-safe CSV/JSON export.
3. Wild Β· 256Γ256 Correspondence & Invariance
Mutual argmax patch correspondence across Photo A β B plus a live 6-transform geometric invariance suite.
4. Multi-model Β· D-FINE 365 β DINOv2-Base Re-ID
Chain 11.33 MB 365-class object detection with 90.97 MB DINOv2-Base crop embeddings (102.3 MB total) for visual twin matching.
How the API works
Load Xenova/dinov2-base once via the shared Transformers.js image-feature-extraction
pipeline on WASM q8, then run pipe.processor(image) + pipe.model(inputs)
inside a dedicated Web Worker to unpack last_hidden_state ([1, 257, 768]).