zero-shot-image-classification · vision + language · WASM · ~66 MB
MobileCLIP is Apple's mobile-optimised CLIP. Same trick as the CLIP page — score an image against any labels you invent — but with a vision tower engineered to encode an image fast on everyday hardware. Give it an image and a few made-up labels and watch it rank them, entirely on your device, with the real encode time on screen.
| Model | Xenova/mobileclip_s0 |
|---|---|
| Task / pipeline | zero-shot-image-classification (two-tower, loaded by hand) |
| Architecture | MobileCLIP-S0: a fast hybrid CNN/transformer vision tower + text transformer → shared 512-d space |
| Quantization | vision fp16, text q8 — quantising the vision tower to q8 measurably flips the ranking, so it stays fp16 (see "How the API works") |
| Backend | WebAssembly (runs anywhere; no WebGPU needed) |
| Download | ~66 MB (vision ~23 MB + text ~43 MB), cached after first load |
| License | Apple ML Research (MobileCLIP), Apache-2.0 export |
| Web APIs | WebAssembly, Web Workers, FileReader — all Baseline widely available |
Pick or drop an image, type comma-separated labels, and hit Classify. The bars are a softmax over MobileCLIP's cosine similarity between the image and each label. Watch the vision vs text encode latency.

MobileCLIP turns your image into one 512-number vector and each label into its own 512-number vector, then measures the cosine similarity between the image vector and every label vector. Those similarities are scaled by CLIP's temperature (×100) into logits, and a softmax turns them into the percentages above. The interesting number here is the vision encode time — that's where MobileCLIP's mobile-tuned architecture earns its name versus a full ViT.
| Label | cosine sim | logit (×scale) | softmax |
|---|
Zero-shot image understanding is powerful, but a full CLIP vision encoder is heavy — too heavy to run on every frame or every thumbnail on a phone. MobileCLIP keeps the "label set is an input" superpower while making the image encode cheap enough to actually ship at scale, on device.
safe, weapon, graphic) fast enough to gate an upload flow client-side.One image, your labels, the encode latency — feel fast zero-shot classification first-hand.
Batch tagging & moderation triage — score many images against a fixed label set, fast.
Live webcam "vibe check" — classify the camera against moods in real time.
Speed race — run MobileCLIP and the full CLIP on the same image and compare encode times.
MobileCLIP's Transformers.js repo ships the two towers separately, so we load them by hand and compute the cosine ourselves:
import {
AutoTokenizer, AutoProcessor,
CLIPVisionModelWithProjection, CLIPTextModelWithProjection, RawImage,
} from "@huggingface/transformers";
const id = "Xenova/mobileclip_s0";
const tokenizer = await AutoTokenizer.from_pretrained(id);
const processor = await AutoProcessor.from_pretrained(id);
const vision = await CLIPVisionModelWithProjection.from_pretrained(id, { dtype: "fp16" });
const text = await CLIPTextModelWithProjection.from_pretrained(id, { dtype: "q8" });
const { image_embeds } = await vision(await processor(await RawImage.read(url)));
const { text_embeds } = await text(tokenizer(labels,
{ padding: "max_length", max_length: 77, truncation: true })); // fixed 77-token context
// cosine(image_embeds, text_embeds[i]) → similarity per label; softmax(×100) → the bars
Two honest details this page bakes in: the text tower needs a fixed 77-token context (OpenCLIP positional embeddings), and the vision tower runs fp16, not q8 — 8-bit quantising the vision tower measurably flips the ranking on the reference image, so only the larger text tower is quantised. Inference runs in a Web Worker so the page never janks.