Skip to content
image-segmentation Β· vision WASM q8 Β· 14.49 MB MiT-B1 [2,2,2,2] Β· 13.7M params Β· 15.9 GFLOPs 150 ADE20K classes Β· 128Γ—128 logits NVIDIA Source Code License

SegFormer-B1 (ADE20K 512Γ—512) β€” Semantic Segmentation & Logit Confidence Lab

NVIDIA's SegFormer-B1 keeps B0's fast [2, 2, 2, 2] depth and 256-dim all-MLP decoder while doubling the hierarchical encoder widths to [64, 128, 320, 512] β€” jumping from 37.4% to 42.2% mIoU on ADE20K at only 15.9 GFLOPs and 14.49 MB q8 ONNX. Runs locally in a Web Worker via shared Transformers.js 3.7.5 on CPU WASM.

At a glance

Upstream model nvidia/segformer-b1-finetuned-ade-512-512 (13.7M params: 13.1M enc / 0.6M dec Β· 15.9 GFLOPs Β· 42.2% SS / 43.1% MS ADE20K mIoU)
Browser ONNX repo Xenova/segformer-b1-finetuned-ade-512-512 β†’ onnx/model_quantized.onnx
Pipeline task image-segmentation (pipeline("image-segmentation", "Xenova/segformer-b1-finetuned-ade-512-512"))
Architecture SegformerForSemanticSegmentation (segformer): MiT-B1 depths: [2, 2, 2, 2], hidden_sizes: [64, 128, 320, 512], num_attention_heads: [1, 2, 5, 8], sr_ratios: [8, 4, 2, 1], decoder_hidden_size: 256, 512Γ—512 preprocessor (do_reduce_labels: true)
Output tensor logits [1, 150, 128, 128] β†’ bilinearly upsampled argmax across 150 ADE20K labels + per-pixel softmax winning confidence
Quantization & size q8: 14.49 MB (onnx/model_quantized.onnx, 14,492,685 B + 8,080 B JSON configs = 14.50 MB total; fp16 27.87 MB Β· fp32 55.19 MB unused)
Runtime & backend Shared ../../lib/webai.js with Transformers.js 3.7.5 Β· CPU WASM in a module Web Worker
License other β€” NVIDIA Source Code License (research / non-commercial; see model repo)

Live 150-class semantic mask & softmax confidence lab

Drop, upload, paste, capture a camera snapshot, or pick a curated zero-person scene. Hover or tap the mask canvas to inspect the exact ADE20K class and softmax probability at that pixel, raise the confidence threshold to mask out ambiguous boundaries, or press any class pill to isolate it.

Loading a curated scene…

Hover or tap the canvas to inspect pixel coordinates, ADE20K class, and softmax confidence, or select a pill below.

Backend / dtype–
Inference–
Classes found–
Mean softmax conf–
Uncertain (<thr)–
Dominant class–
Logits / map–
Non-finite logits–

Interactive class coverage pills (press to isolate on canvas)

Raw argmax label map

Per-pixel softmax confidence distribution

Detected ADE20K classes, pixel share & mean softmax confidence
ADE20K ID Class Group Pixels Share Mean conf
Run segmentation to inspect ADE20K class coverage.

See inside β€” 4-stage hierarchical MiT-B1 encoder & logits

Unlike ViT, SegFormer uses overlapped patch merging (7Γ—7 stride 4 at Stage 1, then 3Γ—3 stride 2) with zero positional embeddings and sequence-reduction attention (sr_ratios: [8, 4, 2, 1]). MiT-B1 keeps B0's 2-block-per-stage depth while doubling channel widths to [64, 128, 320, 512], then projects all four stages into a 256-dim all-MLP decoder producing [1, 150, 128, 128] logits.

MiT-B1 hierarchical encoder stages at 512Γ—512 input (from config.json)
Stage Stride Feature map Tokens Patch / SR Heads B1 (B0) dim Role
Show the code β€” epoch-guarded pipeline load in worker.js
Show the code β€” per-pixel softmax probability extraction from [1, 150, 128, 128] logits

Why SegFormer-B1 matters

SegFormer-B1 sits at the browser sweet spot: half the download size of B2 (14.49 MB vs 28.94 MB) and nearly 4Γ— fewer FLOPs (15.9 vs 62.4 GFLOPs), while delivering +4.8 mIoU over B0 (42.2% vs 37.4%).

Use-case ladder

References