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.

Small

Slab

Weights stored as int8 in blocks of 64: about a quarter of FP32. Slab decodes them to float when loading, so it runs at the same speed; accuracy is measured below.

Platforms: macos · android

vit-b-16-int8.slab

91.0 MB · Hosted download

Download
SHA-256 checksum
04c96d097f617b541e018d80f23053ec63d862f9393a99b72858d9ff92fe5653

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-int8.slab slab-load meta set vit-b-16-int8.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

82.9 ms

Measured time · scope below

int8Session open (ms): 70 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: 90.64 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.3 ms

Measured time · scope below

int8Session open (ms): 183 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.50 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

10.1 ms

Measured time · scope below

int8Session open (ms): 9035 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.79 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

571.0 ms

Measured time · scope below

int8Session open (ms): 62 Platform: android Runs: 21 Input: 1, 3, 224, 224 Measured: 2026-11-06

Median of 21 warm runs of the model (Slab's run time). From a 1920 x 1080 photo, preprocessing included: 550 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

278.0 ms

Measured time · scope below

int8Session open (ms): 195 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 · int8

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.052.

macos · GPU · int8

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.052.

macos · NPU · int8

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.055.

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.