image-classification Β· vision Β· WASM Β· ~23 MB
Same 1,000-way ImageNet job as the ViT and ConvNeXt demos, but with a hybrid design: MobileViT-Small is a 5.6M-parameter network that interleaves MobileNetV2-style convolutions with transformer blocks that process unfolded patches β global attention where it counts, local convolutions where they're cheap, and no positional embeddings at all. Classify an image and read the real millisecond latency; the story here is transformer accuracy at a convolution footprint.
| Model | Xenova/mobilevit-small (ONNX mirror of apple/mobilevit-small) |
|---|---|
| Task / pipeline | image-classification |
| Architecture | MobileViT-Small β 5.6M params; MobileNetV2-style conv blocks + MobileViT blocks (unfold β transformer over patches β refold), no positional embeddings; 256Γ256 input |
| Labels | ImageNet-1k = 1,000 outputs |
| Quantization | fp32 (see note) β the canonical q8 export produced semantically broken labels in browser testing |
| Backend | WebAssembly (runs without WebGPU) |
| Download | ~23 MB β vs ~29 MB (ConvNeXt) and ~88 MB (ViT) |
| License | Apple sample code license (HF card: other) β exact Apple checkpoint |
| Web APIs | WebAssembly, Web Workers, FileReader, getUserMedia (webcam demo) β all Baseline widely available |
This repo prefers 8-bit weights, but the canonical q8 conversion failed semantic sanity in the exact browser probe: a rights-cleared fixture of two cats on a couch came back as jellyfish (18.1%) with a sea-creature top-5 (sturgeon, sea anemone, nautilus, sea lion). The canonical fp32 graph classified the same image as Egyptian cat (46.1%), tiger cat (16.2%), tabby (10.1%). fp32 is therefore the honest choice and is still only ~23 MB.
Pick or drop an image and hit Classify. Watch the latency read-out β MobileViT is built to be quick.

5 labels
MobileViT's final layer produces one raw logit per class, and a softmax turns those into probabilities. The table shows the top classes with their raw logit next to the softmax probability, plus the shape of the distribution: top-1 margin and normalised entropy.
| Class | logit | softmax |
|---|
Confidence (low β β high):
Download size and parameter counts are fixed facts. The "latency here" cell fills in with a real measured run once you classify above.
| Model | Params | Download | Outputs | Latency here |
|---|---|---|---|---|
| MobileViT-Small | 5.6M | ~23 MB | 1,000 | run above β |
| ConvNeXt-Tiny | ~28M | ~29 MB | 1,000 | 5Γ the params |
| ViT-B/16 | ~86M | ~88 MB | 1,000 | 15Γ the params |
MobileViT was Apple's answer to a simple question: can a phone get transformer-grade accuracy without transformer-grade cost? By folding global self-attention into an otherwise conventional convnet β and skipping positional embeddings entirely β it matches or beats comparable CNNs and light ViTs at a fraction of the size of ViT-B. When the constraint is battery, bandwidth, or latency β not the last point of accuracy β this hybrid is what you reach for.
Classify a sample and read the top-k with a real latency read-out.
Real-time webcam tagging β the mobile use case: classify live camera frames.
Torture test: shrink and JPEG-crush an image and find where the small hybrid breaks.
Fast prefilter β confirm: MobileViT triages, ViT double-checks only the uncertain ones.
The convenience path is two lines with Transformers.js:
import { pipeline } from "@huggingface/transformers";
const classify = await pipeline(
"image-classification",
"Xenova/mobilevit-small",
{ dtype: "fp32" },
); // downloads + caches ~23 MB once
const output = await classify(imageURL, { top_k: 5 });
// β [{ label: "Egyptian cat", score: 0.46 }, { label: "tiger cat", score: 0.16 }, β¦]
This page goes one level deeper for "See inside": instead of the pipeline it runs the model's
own processor then model() in a single forward pass, so it can read the
raw logits tensor (all 1,000 ImageNet classes) and compute the softmax, entropy,
and margin itself. Inference runs in a Web Worker so the page remains responsive.