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.
Camera frames stay strictly on your device. Capture a snapshot to segment every pixel.
Camera idle.
Loading a curated sceneβ¦
Hover or tap the canvas to inspect pixel coordinates, ADE20K class, and softmax confidence, or select a pill below.
Interactive class coverage pills (press to isolate on canvas)
Per-pixel softmax confidence distribution
| 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.
| 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%).
- Mobile-friendly scene parsing β rich architectural and outdoor segmentation without multi-second B2 latency or 30+ MB weights.
- Confidence-aware masking β read real per-pixel softmax margins from the
128Γ128decoder logits to gate uncertain edges before automated edits. - Privacy-preserving audits β classify indoor rooms, street assets, or user uploads strictly on-device with zero upload cost.
Use-case ladder
Basics
Full B0βB5 scaling table, live 256β768 px resolution lab, stride-grid ablation (128/64), and softmax histogram.
Practical
Cancellable FIFO batch scene-audit queue with target ADE20K checklist and OWASP-safe CSV/JSON/Markdown exports.
Wild
Empirical robustness stress suite measuring pixel agreement, mIoU, class retention, and confidence drift under 6 perturbations.
Multi-model
Compare SegFormer-B1 (14.49 MB) head-to-head against sibling SegFormer-B0 (4.42 MB) for pixel IoU & boundary flips.