At a glance
| Upstream model | google/vit-base-patch16-224-in21k (Google Research β Dosovitskiy et al., ICLR 2021 / arXiv:2010.11929, ImageNet-21k pretraining) |
|---|---|
| Browser ONNX repo |
Xenova/vit-base-patch16-224-in21k
(onnx/model_quantized.onnx 87,453,205 B + configs 848 B =
87,454,053 B / 87.45 MB)
|
| License | Apache-2.0 (permissive open-source commercial & research use) |
| Task & architecture |
image-feature-extraction Β· ViTModel (vit, 86.4M params,
12 layers, 768-d hidden, 12 attention heads, 3072 MLP, GELU, QKV bias, 224Γ224 bilinear resize,
mean/std [0.5, 0.5, 0.5], patch 16, 0 register tokens)
|
| Output tensor shape |
last_hidden_state shape [1, 197, 768] (151,296 floats; no
pooler_output in ONNX): index 0 = [CLS] (1Γ768) Β· indices
1..196 = 14Γ14 = 196 spatial patch tokens (196Γ768)
|
| Distinct from ViT-1k & DINOv2 |
Unlike ViT Image Classification (which attaches a fixed
1,000-class ImageNet-1k head), this in21k base checkpoint outputs raw 768-d representations
for custom categories, clustering, and retrieval β and contrasts supervised 21k pretraining (14Γ14 grid)
with self-supervised DINOv2-Base (16Γ16 patch-14 grid).
|
| Runtime & backend |
Shared Transformers.js pin (../../lib/webai.js, @huggingface/transformers@3.7.5)
Β· CPU WASM q8 (87.45 MB, universal; off-main-thread Web Worker in worker.js)
|
1. Live 14Γ14 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 ViT-Base IN21k above, then click or arrow-key any 14Γ14 cell to inspect patch cosine similarity.
Live [1, 197, 768] Tensor Anatomy
ViT-Base IN21k emits 197 tokens (no 1k head, 0 registers): index 0 is the
global [CLS] token and indices 1..196 map to the 14Γ14 patch grid.
[CLS] (1Γ768)
Patch norm spread & top cosine matches will appear here after the forward pass.
Why ViT-Base IN21k matters
Before a Vision Transformer is fine-tuned onto ImageNet-1k's 1,000 classes, its ImageNet-21k backbone learns
broad semantic structure over 14 million images and 21,843 concepts. At 87.45 MB under
Apache-2.0 and universal CPU WASM, vit-base-patch16-224-in21k unlocks:
- Zero-training few-shot k-NN classification: classify custom product, wildlife, or inspection categories in-browser by comparing
768-d[CLS]embeddings against a handful of labeled examples. - Local gallery deduplication & clustering: group visually similar shots before upload or cloud sync without touching a server.
- Supervised vs self-supervised patch inspection: probe all
14Γ14patch embeddings via RGB PCA, norm distributions, and cross-image correspondence. - Hybrid concept clustering + zero-shot naming: cluster unlabeled images with ViT-21k (
87.45 MB) and automatically assign readable semantic names with TinyCLIP (24.28 MB).
Use-case ladder
1. Basics Β· 14Γ14 PCA & Pooling Lab
Compare [CLS] vs Mean-Patch vs Fused pooling and inspect 3-channel RGB PCA & norm spikes over all 196 patches.
2. Practical Β· Few-Shot k-NN & Dedup
Multi-photo upload, mid-batch Cancel, Leave-One-Out k-NN accuracy, near-duplicate clusters, and OWASP CSV/JSON export.
3. Wild Β· 196Γ196 Correspondence & Invariance
Mutual argmax patch correspondence across Photo A β B plus a live 6-transform geometric invariance suite.
4. Multi-model Β· ViT-21k Clusters β TinyCLIP Names
Cluster unlabeled photos with 87.45 MB ViT-IN21k embeddings, then name each cluster zero-shot via 24.28 MB TinyCLIP.
How the API works
Load Xenova/vit-base-patch16-224-in21k 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, 197, 768]).