← All models

image-segmentation Β· vision Β· WASM Β· ~15 MB

SegFormer-B0 β€” give every pixel a name

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.

At a glance

ModelXenova/segformer-b0-finetuned-ade-512-512
Task / pipelineimage-segmentation (semantic subtask β€” a full label map)
ArchitectureSegFormer: a hierarchical transformer encoder (MiT-B0) + a lightweight all-MLP decode head
Classes150 ADE20K scene categories (wall, floor, sky, tree, person, car, road…)
Quantizationq8 (8-bit) ONNX
BackendWebAssembly (runs anywhere; no WebGPU needed)
Download~15 MB, cached after first load
LicenseNVIDIA Source Code License (research; non-commercial)
Web APIsWebAssembly, Web Workers, Canvas, FileReader β€” all Baseline widely available

Run it

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.

Drop a photo here, or click to choose
A riverside landscape at golden hour with sky, water and trees A cozy bedroom interior with wall, floor and furniture Two cats on a couch by a wall
60%

Class legend

Run segmentation to label the scene.

See inside

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.

Run segmentation to see the label map and class distribution.

Why it matters

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.

Use cases

Basics

Segment a scene and read the colour map and legend β€” see semantic segmentation plainly.

Practical

Sky replacement β€” select the "sky" class and drop in a new sky, on-device.

Wild

Turn any photo into a flat colour-blocked "map" poster you can download.

Multi-model

SegFormer scene classes + Depth Anything β†’ a map coloured by class and shaded by distance.

How the API works

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.

References