Skip to content
imaged

Image classification

ViT-B/16

Vision transformer classifier with the highest accuracy in this group: 1,000 categories.

Apache-2.0imagenettransformeraccurate
Choose a variant

About this model

ViT-B/16 is a vision transformer: it cuts a photo into 16 x 16 patches and relates them with attention, the same design behind CLIP and SigLIP. It names the main subject among the 1,000 ImageNet categories (86.6 million parameters).

These weights were pretrained on ImageNet-21k by Google Research and fine-tuned on ImageNet-1k by Ross Wightman (timm's augreg2). timm reports 85.1% top-1 accuracy on ImageNet.

What you can build

  • The most accurate photo classification in this gallery
  • A transformer backbone for embeddings and fine-tuning

Golden retriever dog

f16
Input
Golden-retriever-dog-1362597631o6g

Karen Arnold, CC0, https://commons.wikimedia.org/wiki/File:Golden-retriever-dog-1362597631o6g.jpg

Output
Top 5 on the Metal (FP16 pack):
golden retriever: 83.2%
Labrador retriever: 3.2%
tennis ball: 0.4%
kuvasz: 0.3%
Sussex spaniel: 0.2%

Macaw parrot

f16
Input
Macaw parrot sitting on a tree branch.jpg

Christopher Kuszajewski, CC0, https://commons.wikimedia.org/wiki/File:Macaw_parrot_sitting_on_a_tree_branch.jpg_.jpg

Output
Top 5 on the Metal (FP16 pack):
macaw: 89.0%
African grey: 0.1%
lorikeet: 0.1%
toucan: 0.1%
jay: 0.0%

Steam locomotive

f16
Input
JA1271 crossing the Otaki River

Karora, Public domain, https://commons.wikimedia.org/wiki/File:JA1271_crossing_the_Otaki_River.jpg

Output
Top 5 on the Metal (FP16 pack):
steam locomotive: 73.0%
viaduct: 6.0%
passenger car: 1.6%
electric locomotive: 1.1%
pier: 1.0%

Variants & downloads

Choose the build for your app

Model files are hosted on Google Drive. Large files may open a confirmation page before downloading.

Standard

Slab

Weights stored in FP16: half the size of FP32, the same predictions.

Platforms: macos · android

vit-b-16-f16.slab

168 MB · Hosted download

Download
SHA-256 checksum
0a5534cca5df7e9ff3036409aae1f3d0a3919d804f1be2a1978588076971bc95

LICENSE-Apache-2.0.txt

11 KB

Download
SHA-256 checksum
ece72784a32facfa7ef4779cfa5996365e8841dfb97a4f1be47bf20c8017e43c
Conversion details
command
python -c "import torch, timm; m = timm.create_model('vit_base_patch16_224.augreg2_in21k_ft_in1k', pretrained=True).eval(); torch.onnx.export(m, torch.randn(1, 3, 224, 224), 'model.onnx', input_names=['image'], output_names=['logits'], opset_version=17, dynamo=False)" python -c "from timm.data import ImageNetInfo; i = ImageNetInfo(); open('labels.txt', 'w').write('\n'.join(i.index_to_description(k).split(',')[0] for k in range(1000)))" slab-load convert model.onnx model.slab --input image=1x3x224x224 --meta task=classify --meta resize=center_crop --meta resize_size:i64=248 --meta interpolation=bicubic --meta antialias:bool=true --meta normalize=neg_one_to_one --meta color=rgb --meta labels:labels=@labels.txt slab-load quantize model.slab vit-b-16-f16.slab --f16 slab-load meta set vit-b-16-f16.slab default_backend.macos=gpu

Integration examples

Python

python

import slab

cfg = slab.Config(cache_dir="/tmp/slab_cache", license=open("license.slablic.txt").read())
session = slab.Session(cfg, "vit-b-16-f16.slab", warmup=True)
out = session.run(slab.Input(frame=slab.Frame.open("photo.jpg")))
for c in out.top_k(5):
    print(f"{c.label}: {c.score:.1%}")

Device & backend compatibility

Pack default: macos / GPU. On the Mac the Neural Engine is barely faster per photo but takes several seconds to prepare the model; the GPU prepares it in a fraction of a second.

Available execution backends for ViT-B/16
PlatformEngineStatusPrecision
apple

CPU

CPU

Supported

Measured on macOS.

f32
apple

Metal

GPU

Supported

Measured on macOS.

f32
apple

Apple Neural Engine

NPU

Supported

Measured on macOS. The Neural Engine computes in FP16; preparing the model for it takes noticeably longer than for the GPU (see open time under Performance).

f16
android

CPU

CPU

Supported

Measured on a Samsung Galaxy S23 Ultra (Snapdragon 8 Gen 2, Adreno 740), Android 17.

f32
android

Vulkan

GPU

Supported

Measured on a Samsung Galaxy S23 Ultra (Snapdragon 8 Gen 2, Adreno 740), Android 17.

f32
android

Qualcomm Hexagon NPU (QNN)

NPU

Not supported

Tried on a Samsung Galaxy S23 Ultra (Hexagon v73): One of the model's nodes does not translate to QNN in Slab yet.

—

Performance

Results depend on the device, runtime, and test conditions. Each measurement keeps its own context.

Mac with Apple M1 Max

Slab · CPU

macOS 26.6.2

78.5 ms

Measured time · scope below

f16Session open (ms): 36 Platform: macos Runs: 100 Input: 1, 3, 224, 224 Measured: 2026-10-28

Median of 100 warm runs of the model (Slab's run time). From a 1920 x 1080 photo, preprocessing included: 79.41 ms median. open_ms: opening the session, including preparing the model for the CPU.

Mac with Apple M1 Max

Slab · GPU

macOS 26.6.2

10.5 ms

Measured time · scope below

f16Session open (ms): 259 Platform: macos Runs: 100 Input: 1, 3, 224, 224 Measured: 2026-10-28

Median of 100 warm runs of the model (Slab's run time). From a 1920 x 1080 photo, preprocessing included: 11.31 ms median. open_ms: opening the session, including preparing the model for the Metal.

Mac with Apple M1 Max

Slab · NPU

macOS 26.6.2

9.9 ms

Measured time · scope below

f16Session open (ms): 8688 Platform: macos Runs: 100 Input: 1, 3, 224, 224 Measured: 2026-10-28

Median of 100 warm runs of the model (Slab's run time). From a 1920 x 1080 photo, preprocessing included: 10.86 ms median. open_ms: opening the session, including preparing the model for the Apple Neural Engine.

Samsung Galaxy S23 Ultra (Snapdragon 8 Gen 2)

Slab · CPU

Android 17

561.0 ms

Measured time · scope below

f16Session open (ms): 85 Platform: android Runs: 20 Input: 1, 3, 224, 224 Measured: 2026-11-06

Median of 20 warm runs of the model (Slab's run time). From a 1920 x 1080 photo, preprocessing included: 545 ms median. open_ms: opening the session. Peak memory (resident) after the runs: 397 MB.

Samsung Galaxy S23 Ultra (Snapdragon 8 Gen 2)

Slab · GPU

Android 17

277.0 ms

Measured time · scope below

f16Session open (ms): 191 Platform: android Runs: 35 Input: 1, 3, 224, 224 Measured: 2026-11-06

Median of 35 warm runs of the model (Slab's run time). From a 1920 x 1080 photo, preprocessing included: 281 ms median. open_ms: opening the session with the GPU programs already in the cache folder (the first open on a device compiles them, about 0.3 s more). Peak memory (resident) after the runs: 401 MB.

Accuracy checks

macos · CPU · f16

The upstream PyTorch model with its own preprocessing, on 53 public-domain photos (Wikimedia Commons)

Same top answer on 53/53 photos with Slab doing the preprocessing; on identical input tensors, same top answer on 53/53, upstream's answer among Slab's top 5 on 53/53, largest probability difference 0.003.

macos · GPU · f16

The upstream PyTorch model with its own preprocessing, on 53 public-domain photos (Wikimedia Commons)

Same top answer on 53/53 photos with Slab doing the preprocessing; on identical input tensors, same top answer on 53/53, upstream's answer among Slab's top 5 on 53/53, largest probability difference 0.003.

macos · NPU · f16

The upstream PyTorch model with its own preprocessing, on 53 public-domain photos (Wikimedia Commons)

Same top answer on 53/53 photos with Slab doing the preprocessing; on identical input tensors, same top answer on 53/53, upstream's answer among Slab's top 5 on 53/53, largest probability difference 0.007.

Before you choose this model

  • Knows only the 1,000 ImageNet categories.
  • Large: 168 MB in FP16 and about 10 ms per photo on an M1 Max GPU; prefer ConvNeXt-Tiny or MobileNetV3 on phones.