Skip to content
imaged

Semantic segmentation

SegFormer-B0 (ADE20K)

Labels every pixel of a scene with one of 150 classes: sky, road, wall, person, tree and more. Small and fast. NVIDIA license, non-commercial.

NVIDIA Source Code License for SegFormer (non-commercial)semantic segmentationscene parsingsegformertransformerade20knon-commercial
Choose a variant

About this model

SegFormer-B0 reads a whole scene and gives every pixel a class among the 150 of ADE20K: stuff like sky, road, grass, wall and water, and things like people, cars, chairs and boats. Unlike instance segmentation, all cars share one class and are not told apart.

B0 is the smallest SegFormer: a 3.7 million parameter transformer encoder with a light all-MLP decoder, trained by NVIDIA on ADE20K at 512 x 512.

What you can build

  • Understand the layout of a scene: where the floor, walls and sky are
  • Replace or blur the sky or background
  • Estimate how much of a view is road, vegetation or water
  • Give robots or AR apps a coarse map of surfaces

Parking lot cars

f16
Input
Cars in a parking lot across a road (2024) - 0743

Roc0ast3r, CC0, https://commons.wikimedia.org/wiki/File:Cars_in_a_parking_lot_across_a_road_(2024)_-_0743.jpg

Output
The photo colored by the class SegFormer-B0 (ADE20K) gives each pixel, with a legend of the largest classes
Largest classes on the Metal (FP16 pack), share of the photo:
sky 43.0%
road 24.0%
mountain 14.0%
sidewalk 5.8%
car 5.5%
building 2.6%
rock 1.5%
sand 1.4%

Harbor boats

f16
Input
North Harbor Lysekil with motor boat

W.carter, Public domain, https://commons.wikimedia.org/wiki/File:North_Harbor_Lysekil_with_motor_boat.jpg

Output
The photo colored by the class SegFormer-B0 (ADE20K) gives each pixel, with a legend of the largest classes
Largest classes on the Metal (FP16 pack), share of the photo:
water 40.8%
sky 24.7%
mountain 12.9%
pier 7.3%
bridge 6.3%
railing 5.7%
boat 1.6%
person 0.4%

Suspension bridge

f16
Input
Cincinnati-roebling-suspension-bridge

Derek Jensen (Tysto), Public domain, https://commons.wikimedia.org/wiki/File:Cincinnati-roebling-suspension-bridge.jpg

Output
The photo colored by the class SegFormer-B0 (ADE20K) gives each pixel, with a legend of the largest classes
Largest classes on the Metal (FP16 pack), share of the photo:
sky 40.2%
bridge 36.6%
water 16.1%
building 2.5%
tree 2.1%
earth 1.9%
grass 0.6%
streetlight 0.1%

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. Slab decodes them to float when loading, so it runs at the same speed; results move more than with FP16 (see Accuracy).

Platforms: macos · android

segformer-b0-ade-int8.slab

7.6 MB · Hosted download

Download
SHA-256 checksum
672929b747c4f02f74c93fda0750734baee7fb0e2fad4bd1f763d41fa702a992

LICENSE-SegFormer.txt

4 KB

Download
SHA-256 checksum
f549820c06519e3105e5174a2fd7285224ffd2268a7f879a843b1a255fd04a61
Conversion details
command
python -c "import torch; from transformers import SegformerForSemanticSegmentation as S; m = S.from_pretrained('nvidia/segformer-b0-finetuned-ade-512-512', revision='489d5cd81a0b59fab9b7ea758d3548ebe99677da').eval(); W = type('W', (torch.nn.Module,), {'forward': lambda s, x: s.m(pixel_values=x).logits}); w = W(); w.m = m; torch.onnx.export(w,torch.randn(1, 3, 512, 512), 'model.onnx', input_names=['pixel_values'], output_names=['logits'], opset_version=17, dynamo=False); open('labels.txt', 'w').write('\n'.join(m.config.id2label[i] for i in range(150)))" slab-load convert model.onnx model.slab --input pixel_values=1x3x512x512 --meta task=segment --meta resize=stretch --meta interpolation=bilinear --meta antialias:bool=true --meta normalize=imagenet --meta color=rgb --meta labels:labels=@labels.txt slab-load quantize model.slab segformer-b0-ade-int8.slab slab-load meta set segformer-b0-ade-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, "segformer-b0-ade-f16.slab", warmup=True)
photo = slab.Frame.open("photo.jpg")
out = session.run(slab.Input(frame=photo))
seg = out.class_map()          # Gray8 Frame, the photo's size
print(out.label(seg[10, 10]))   # the class at row 10, column 10, e.g. "sky"

Device & backend compatibility

Pack default: macos / GPU. The fastest backend on the Mac (about 10 ms per frame); the Neural Engine takes 18 ms and 7 s to open.

Available execution backends for SegFormer-B0 (ADE20K)
PlatformEngineStatusPrecision
apple

CPU

CPU

Supported

Measured on macOS.

f32
apple

Metal

GPU

Supported

Measured on macOS. The default.

f32
apple

Apple Neural Engine

NPU

Supported

Measured on macOS. The Neural Engine computes in FP16.

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

163.0 ms

Measured time · scope below

int8Session open (ms): 18 Platform: macos Runs: 100 Input: 1, 3, 512, 512 Measured: 2026-10-28

Median of 100 warm runs of the model (Slab's run time). From a 1920 x 1080 photo, resizing included: 165.00 ms median. class_map() at 1920 x 1080 adds about 11 ms.

Mac with Apple M1 Max

Slab · GPU

macOS 26.6.2

9.9 ms

Measured time · scope below

int8Session open (ms): 35 Platform: macos Runs: 100 Input: 1, 3, 512, 512 Measured: 2026-10-28

Median of 100 warm runs of the model (Slab's run time). From a 1920 x 1080 photo, resizing included: 11.67 ms median. class_map() at 1920 x 1080 adds about 11 ms.

Mac with Apple M1 Max

Slab · NPU

macOS 26.6.2

17.7 ms

Measured time · scope below

int8Session open (ms): 15954 Platform: macos Runs: 100 Input: 1, 3, 512, 512 Measured: 2026-10-28

Median of 100 warm runs of the model (Slab's run time). From a 1920 x 1080 photo, resizing included: 17.81 ms median. class_map() at 1920 x 1080 adds about 11 ms.

Samsung Galaxy S23 Ultra (Snapdragon 8 Gen 2)

Slab · CPU

Android 17

458.0 ms

Measured time · scope below

int8Session open (ms): 42 Platform: android Runs: 27 Input: 1, 3, 512, 512 Measured: 2026-11-06

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

Samsung Galaxy S23 Ultra (Snapdragon 8 Gen 2)

Slab · GPU

Android 17

214.0 ms

Measured time · scope below

int8Session open (ms): 85 Platform: android Runs: 46 Input: 1, 3, 512, 512 Measured: 2026-11-06

Median of 46 warm runs of the model (Slab's run time). From a 1920 x 1080 photo, resizing included: 216 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: 109 MB.

Samsung Galaxy S23 Ultra (Snapdragon 8 Gen 2)

Slab · NPU

Android 17

100.0 ms

Measured time · scope below

int8Session open (ms): 393 Platform: android Runs: 80 Input: 1, 3, 512, 512 Measured: 2026-11-06

Median of 80 warm runs of the model (Slab's run time). From a 1920 x 1080 photo, preprocessing on the CPU included: 122 ms median. open_ms: opening the session, including preparing the model for the Hexagon NPU. Peak memory (resident) after the runs: 102 MB.

Accuracy checks

macos · CPU · int8

The model's Hugging Face image processor, the PyTorch model and post_process_semantic_segmentation at the photo's size (transformers 5.21), 67 public-domain and CC0 photos (Wikimedia Commons); agreement is the share of pixels given the same class, class IoU the mean over the classes in either map

With Slab preprocessing and class_map(): 98.15% of pixels agree (92.39% on the worst photo), class IoU 0.814. On identical input tensors: 98.15% of pixels agree, class IoU 0.815.

macos · GPU · int8

The model's Hugging Face image processor, the PyTorch model and post_process_semantic_segmentation at the photo's size (transformers 5.21), 67 public-domain and CC0 photos (Wikimedia Commons); agreement is the share of pixels given the same class, class IoU the mean over the classes in either map

With Slab preprocessing and class_map(): 98.15% of pixels agree (92.39% on the worst photo), class IoU 0.814. On identical input tensors: 98.15% of pixels agree, class IoU 0.815.

macos · NPU · int8

The model's Hugging Face image processor, the PyTorch model and post_process_semantic_segmentation at the photo's size (transformers 5.21), 67 public-domain and CC0 photos (Wikimedia Commons); agreement is the share of pixels given the same class, class IoU the mean over the classes in either map

With Slab preprocessing and class_map(): 97.92% of pixels agree (91.98% on the worst photo), class IoU 0.776. On identical input tensors: 97.92% of pixels agree, class IoU 0.778.

android · NPU · int8

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 class on 99.99% of pixels.

Before you choose this model

  • Non-commercial use only (NVIDIA Source Code License).
  • The class map comes from a 128 x 128 grid, so small objects and thin structures are often absorbed into their surroundings.
  • It does not separate objects of the same class.
  • The input is stretched to a square, which distorts very wide or tall photos.