Skip to content
image-segmentation Β· vision WASM q8 Β· 28.94 MB MiT-B2 [3,4,6,3] Β· 27.5M params 150 ADE20K classes Β· 512Γ—512 NVIDIA Source Code License

SegFormer-B2 (ADE20K 512Γ—512) β€” Dense Semantic Segmentation Lab

NVIDIA's SegFormer-B2 scales the hierarchical Mix Transformer encoder from [2, 2, 2, 2] / [32, 64, 160, 256] (B0) up to depths: [3, 4, 6, 3] and hidden_sizes: [64, 128, 320, 512] with a 768-dim all-MLP decode head β€” jumping from 37.4% to 46.5% mIoU on ADE20K (+9.1 mIoU). Runs completely on-device in a Web Worker via Transformers.js 3.7.5 (CPU WASM q8, onnx/model_quantized.onnx).

At a glance

Upstream model nvidia/segformer-b2-finetuned-ade-512-512 (27.5M params, 62.4 GFLOPs, 46.5% SS / 47.5% MS ADE20K mIoU)
Browser ONNX repo Xenova/segformer-b2-finetuned-ade-512-512 β†’ onnx/model_quantized.onnx
Pipeline task image-segmentation (pipeline("image-segmentation", "Xenova/segformer-b2-finetuned-ade-512-512"))
Architecture SegformerForSemanticSegmentation (segformer): MiT-B2 depths: [3, 4, 6, 3], hidden_sizes: [64, 128, 320, 512], patch_sizes: [7, 3, 3, 3], strides: [4, 2, 2, 2], decoder_hidden_size: 768, 512Γ—512 preprocessor (do_reduce_labels: true)
Output [{ score: null, label, mask: RawImage }] β€” folded via per-pixel argmax into 150 ADE20K labels
Quantization & size q8: 28.94 MB (onnx/model_quantized.onnx, 28,939,869 B; fp16 55.72 MB Β· fp32 110.45 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 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 under the cursor, or press any legend pill to isolate that class across the frame.

Loading a curated scene…

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

Backend / dtype–
Inference–
Classes found–
Visible (filtered)–
Dominant class–
Map resolution–
Non-finite masks–

Interactive class coverage legend (press to isolate on canvas)

Raw argmax label map

Class area distribution

Detected ADE20K classes & pixel coverage
ADE20K ID Class Category Pixels Coverage Scale tier
Run segmentation to inspect ADE20K class coverage.

See inside β€” 4-stage hierarchical MiT-B2 vs MiT-B0

SegFormer removes positional encodings by using overlapped patch merging (7Γ—7 stride 4, then 3Γ—3 stride 2) and efficient sequence-reduction self-attention (sr_ratios: [8, 4, 2, 1]). All four stage feature maps are projected to a shared width (decoder_hidden_size: 768 in B2 vs 256 in B0) and fused by a single all-MLP head before upsampling to image resolution.

MiT-B2 vs MiT-B0 hierarchical encoder stages at 512Γ—512 input (from config.json)
Stage Stride Feature map Patch / SR ratio Heads MiT-B2 (depth Β· dim) MiT-B0 (depth Β· dim)
Show the code β€” epoch-guarded pipeline load in worker.js
Show the code β€” ADE20K semantic super-category aggregation

Use-case ladder

References