Skip to content
zero-shot-image-classification vision-language 152.71 MB WASM q8 ViT-B/32 Β· 7Γ—7 = 49 patches 66.6% ImageNet-1k ZS MIT

CLIP ViT-B/32 (LAION-2B) β€” Open-Vocabulary Vision

Trained with OpenCLIP on the open LAION-2B English dataset (34B samples seen, batch size 79k), CLIP-ViT-B-32-laion2B-s34B-b79K reaches 66.6% zero-shot ImageNet-1k top-1 accuracy β€” encoding 224Γ—224 images as 7Γ—7 = 49 coarse 32Γ—32 patches + [CLS] into a shared 512-d image-text space locally on CPU WebAssembly.

At a glance

Upstream model laion/CLIP-ViT-B-32-laion2B-s34B-b79K (MIT)
ONNX export onnx-community/CLIP-ViT-B-32-laion2B-s34B-b79K-ONNX (onnx/model_quantized.onnx)
Task / pipeline zero-shot-image-classification (local @huggingface/transformers@4.3.0 pin in worker.js β€” 3.7.5 WASM lacks ConvInteger(10) for /vision_model/embeddings/patch_embedding/Conv_quant)
Architecture CLIPModel β€” 12-layer ViT-B/32 vision tower (768d, 12 heads, 224Γ—224, 32Γ—32 patches = 7Γ—7 = 49 spatial tokens + [CLS]) + 12-layer text transformer (512d, 8 heads, max 77 tokens, vocab 49,408) β†’ 512-d projection
Benchmark & data 66.6% ImageNet-1k zero-shot top-1 Β· OpenCLIP on LAION-2B English (34B samples seen)
Quantisation & size q8 INT8 (152.71 MB / 152,708,043 B) + tokenizer.json (3.64 MB / 3,642,073 B)
Backend WebAssembly (wasm) β€” runs on laptop or desktop CPU without WebGPU
Web APIs Web Workers, Cache Storage, Canvas 2D, Clipboard, MediaDevices (all Baseline)

Run it β€” Live Open-Vocabulary Classifier

Loading starter photo…

Latency–
Top-1 & margin–
Entropy–
NaN count–
RuntimeWASM q8 Β· 152.71 MB

See inside CLIP ViT-B/32 LAION-2B

The ViT-B/32 tower divides a 224Γ—224 center-cropped image into 7Γ—7 = 49 coarse 32Γ—32 patches plus a [CLS] token, projecting to a unit-normalized 512-d embedding. Logits scale cosine similarities by the learned logit_scale (initialized at exp(2.6592) β‰ˆ 14.29Γ— and trained toward ~100Γ—). Below are the exact cosines, scaled logits, softmax probabilities, and the pairwise cosine similarity matrix across your text prompts.

Embedding dim512-d
Prompt tokens–
Fitted logit_scale–
Eff. choices (2^H)–
Per-candidate prompt scores, cosine similarity, and raw logits
# Label Wrapped prompt Cosine sim Raw logit Softmax %
Run a classification above to inspect raw logits and cosines.
Pairwise 512-d prompt text-embedding cosine similarity matrix (β‰₯0.85 highlights overlapping prompts)
Run a classification above to compute the 512-d pairwise prompt cosine matrix.
Show the code β€” Worker coalesced load & epoch-guarded pipeline initialization
Show the code β€” Off-thread zero-shot classification, logits, image/text embeddings
Show the code β€” computePairwisePromptMatrix() 512-d prompt cosine matrix

Why CLIP ViT-B/32 LAION-2B matters

Unlike proprietary OpenAI CLIP checkpoints trained on closed WebImageText-400M, LAION-2B ViT-B/32 is fully reproducible on open web-crawled image-text pairs and still hits 66.6% ImageNet-1k zero-shot accuracy:

Use-case ladder

How the API works

CLIP ViT-B/32 LAION-2B runs via the Transformers.js zero-shot-image-classification pipeline inside a Web Worker pinned locally to @huggingface/transformers@4.3.0 so ORT-Web executes the quantized ConvInteger(10) patch-embedding convolution cleanly:

import { pipeline } from "https://cdn.jsdelivr.net/npm/@huggingface/transformers@4.3.0";

const classifier = await pipeline(
  "zero-shot-image-classification",
  "onnx-community/CLIP-ViT-B-32-laion2B-s34B-b79K-ONNX",
  { device: "wasm", dtype: "q8" },
);

const scores = await classifier(image, ["a dog on grass", "a pizza on a plate"], {
  hypothesis_template: "a photo of {}",
});
// β†’ [{ label: "a dog on grass", score: 0.99 }, ...]

References