image-segmentation Β· vision Β· WASM Β· ~15 MB
This is dense semantic segmentation: not "cut out the subject" and not "mask the thing I clicked" β every single pixel is classified into one of 150 everyday scene categories from ADE20K (sky, road, person, building, tree, wall, floor, carβ¦). Drop a photo and watch it become a colour-blocked map of what's where, entirely on your device.
| Model | Xenova/segformer-b0-finetuned-ade-512-512 |
|---|---|
| Task / pipeline | image-segmentation (semantic subtask β a full label map) |
| Architecture | SegFormer: a hierarchical transformer encoder (MiT-B0) + a lightweight all-MLP decode head |
| Classes | 150 ADE20K scene categories (wall, floor, sky, tree, person, car, roadβ¦) |
| Quantization | q8 (8-bit) ONNX |
| Backend | WebAssembly (runs anywhere; no WebGPU needed) |
| Download | ~15 MB, cached after first load |
| License | NVIDIA Source Code License (research; non-commercial) |
| Web APIs | WebAssembly, Web Workers, Canvas, FileReader β all Baseline widely available |
Pick or drop a photo and hit Segment. Every pixel gets a class; the map is drawn over your photo. Slide the opacity to fade between the photo and the pure colour map.
Class legend
SegFormer outputs a score for every one of the 150 classes at every pixel, then takes the argmax β the winning class per pixel β to make the label map. On the left is that label map on its own (the raw model output, no photo). On the right, the class distribution: how much of the frame each class claimed. That coverage vector is a compact "what kind of scene is this?" signature you can feed to other logic.
A per-pixel scene map is the raw material for a surprising number of features β and having it run locally means you can label a photo, or a video frame, without an upload or an API bill.
Segment a scene and read the colour map and legend β see semantic segmentation plainly.
Sky replacement β select the "sky" class and drop in a new sky, on-device.
Turn any photo into a flat colour-blocked "map" poster you can download.
SegFormer scene classes + Depth Anything β a map coloured by class and shaded by distance.
Semantic segmentation is a one-liner with Transformers.js. The pipeline returns one entry per class present, each with a full-resolution mask:
import { pipeline } from "@huggingface/transformers";
const segment = await pipeline(
"image-segmentation",
"Xenova/segformer-b0-finetuned-ade-512-512",
); // downloads + caches ~15 MB once
const output = await segment(imageURL);
// β [{ score: null, label: "sky", mask: RawImage },
// { score: null, label: "tree", mask: RawImage },
// { score: null, label: "road", mask: RawImage }, β¦ ]
// each mask is 0/255 for that class; together they tile the whole image
This page runs that in a Web Worker, then folds the per-class masks into a single colour-coded overlay and a per-class pixel count β so the map, legend, and coverage bars are all just views of the one label map the model produced. Nothing is uploaded.