Image classification
ResNet-50
The classic image classifier: names the main subject of a photo among 1,000 categories.
About this model
ResNet-50 is the best-known image classifier and the usual point of comparison. It names the main subject of a photo among the 1,000 ImageNet categories (25.6 million parameters).
These are torchvision's IMAGENET1K_V2 weights, with 80.9% top-1 accuracy on ImageNet as torchvision reports it. They were trained with label smoothing, so their scores are lower than other models' for the same confidence (a top score of 0.3 to 0.4 is typical).
What you can build
- A well-understood baseline for photo classification
- Feature extraction backbone for your own classifier
Golden retriever dog
f16Karen Arnold, CC0, https://commons.wikimedia.org/wiki/File:Golden-retriever-dog-1362597631o6g.jpg
Top 5 on the Apple Neural Engine (FP16 pack): golden retriever: 39.2% flat-coated retriever: 1.0% tennis ball: 1.0% soccer ball: 0.5% clumber: 0.4%
Macaw parrot
f16Christopher Kuszajewski, CC0, https://commons.wikimedia.org/wiki/File:Macaw_parrot_sitting_on_a_tree_branch.jpg_.jpg
Top 5 on the Apple Neural Engine (FP16 pack): macaw: 34.1% African grey: 0.2% sulphur-crested cockatoo: 0.2% lorikeet: 0.2% screen: 0.1%
Steam locomotive
f16Karora, Public domain, https://commons.wikimedia.org/wiki/File:JA1271_crossing_the_Otaki_River.jpg
Top 5 on the Apple Neural Engine (FP16 pack): steam locomotive: 31.2% viaduct: 10.9% freight car: 4.2% passenger car: 3.7% pier: 1.2%
Variants & downloads
Choose the build for your appModel files are hosted on Google Drive. Large files may open a confirmation page before downloading.
Standard
SlabWeights stored in FP16: half the size of FP32, the same predictions.
Platforms: macos · android
resnet-50-f16.slab
49.6 MB · Hosted download
SHA-256 checksum
06ff7a4e0b9b302487cf7c691ac10c5cb472b1526e2b848c7a3151713fbe5053LICENSE-torchvision.txt
1 KB
SHA-256 checksum
6502f676851cfe25f8af75531dfb32375b7325b73c37e7b43741fa422893e71dConversion details
- command
- python -c "import torch, torchvision; m = torchvision.models.resnet50(weights='IMAGENET1K_V2').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 "import torchvision; open('labels.txt', 'w').write('\n'.join(torchvision.models.ResNet50_Weights.IMAGENET1K_V2.meta['categories']))" slab-load convert model.onnx model.slab --input image=1x3x224x224 --meta task=classify --meta resize=center_crop --meta resize_size:i64=232 --meta interpolation=bilinear --meta antialias:bool=true --meta normalize=imagenet --meta color=rgb --meta labels:labels=@labels.txt slab-load quantize model.slab resnet-50-f16.slab --f16 slab-load meta set resnet-50-f16.slab default_backend.macos=npu
Integration examples
Python
python
import slab
cfg = slab.Config(cache_dir="/tmp/slab_cache", license=open("license.slablic.txt").read())
session = slab.Session(cfg, "resnet-50-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 / NPU. Fastest on the Mac (about 1 to 2 ms per photo) and quick to prepare.
| Platform | Engine | Status | Precision |
|---|---|---|---|
| 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 | Supported Measured on a Samsung Galaxy S23 Ultra (Snapdragon 8 Gen 2, Adreno 740), Android 17. The NPU computes in FP16 (the int8 pack's weights are widened to FP16). | f16 |
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
21.0 ms
Measured time · scope below
Median of 100 warm runs of the model (Slab's run time). From a 1920 x 1080 photo, preprocessing included: 21.88 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
5.1 ms
Measured time · scope below
Median of 100 warm runs of the model (Slab's run time). From a 1920 x 1080 photo, preprocessing included: 5.70 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
2.0 ms
Measured time · scope below
Median of 100 warm runs of the model (Slab's run time). From a 1920 x 1080 photo, preprocessing included: 4.37 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
112.0 ms
Measured time · scope below
Median of 100 warm runs of the model (Slab's run time). From a 1920 x 1080 photo, preprocessing included: 108 ms median. open_ms: opening the session. Peak memory (resident) after the runs: 163 MB.
Samsung Galaxy S23 Ultra (Snapdragon 8 Gen 2)
Slab · GPU
Android 17
39.9 ms
Measured time · scope below
Median of 100 warm runs of the model (Slab's run time). From a 1920 x 1080 photo, preprocessing included: 42.7 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: 167 MB.
Samsung Galaxy S23 Ultra (Snapdragon 8 Gen 2)
Slab · NPU
Android 17
3.1 ms
Measured time · scope below
Median of 100 warm runs of the model (Slab's run time). From a 1920 x 1080 photo, preprocessing on the CPU included: 5.29 ms median. open_ms: opening the session, including preparing the model for the Hexagon NPU. Peak memory (resident) after the runs: 206 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.005.
android · NPU · f16
Slab's CPU engine (FP32) on the same 1920 x 1080 photo
Cosine similarity of the output with the CPU's: 1.00000; the same top answer and the same top 5.
Before you choose this model
- Knows only the 1,000 ImageNet categories.
- One label per photo.
- Scores are low by design (label smoothing); compare rankings, not absolute values.