image-segmentation Β· vision Β· WASM Β· ~29 MB
This is human parsing: not "cut out the person" and not "find the face" β every pixel of a person is classified into one of 18 clothing and body classes (upper-clothes, dress, skirt, pants, hat, scarf, belt, bag, shoes, hair, face, arms, legs). Pick a photo and watch it become a colour-blocked map of garments, entirely on your device.
A different job from the segmentation demos already here: portrait matting cuts the whole person out as one silhouette, face parsing labels facial regions, and background removal is binary foreground/background. Clothes parsing labels which garment each pixel belongs to β the raw material for fashion tagging, virtual try-on, and per-garment edits.
| Model | Xenova/segformer_b2_clothes (ONNX build of mattmdjaga/segformer_b2_clothes) |
|---|---|
| Task / pipeline | image-segmentation (semantic subtask β a full 18-class label map) |
| Architecture | SegFormer (MiT-B2 hierarchical transformer encoder + all-MLP decode head), finetuned on human/ATR parsing |
| Classes | 18: background, hat, hair, sunglasses, upper-clothes, skirt, pants, dress, belt, left/right shoe, face, left/right leg, left/right arm, bag, scarf |
| Quantization | q8 (8-bit) ONNX |
| Backend | WebAssembly (runs anywhere; no WebGPU needed) |
| Download | ~29 MB (q8), cached after first load |
| License | Other β see model card (SegFormer/MiT base carries NVIDIA's research-use terms) |
| Web APIs | WebAssembly, Web Workers, Canvas, FileReader β all Baseline widely available |
Pick or drop a photo of a person and hit Parse. Every pixel gets a garment/body label; the map is drawn over your photo. Slide the opacity to fade between the photo and the pure colour map.
Garment legend
The model outputs a score for every one of the 18 classes at every pixel, then takes the argmax β the winning class per pixel β to make the label map. On the left is that map on its own (the raw model output, no photo). On the right, the class distribution: how much of the frame each garment/body part claimed. That coverage vector is a compact "what is this person wearing?" signature β useful for fashion tagging, retrieval, or driving per-garment edits.
A per-pixel garment map is the raw material for fashion, retail, and avatar features β and having it run locally means you can analyse or edit what someone is wearing without uploading their photo to a server.
Parse a person and read the colour map and legend β see human parsing plainly.
Fashion tagger + garment cut-out: get "what are they wearing" tags and extract one garment on a transparent background.
Outfit recolour: restyle the upper-clothes, dress, or pants to a new colour, on-device.
Clothes parsing β CLIP: extract the outfit, then ask CLIP what style it is.
Clothes parsing is the standard Transformers.js semantic-segmentation pipeline. It returns one entry per class present, each with a full-resolution mask:
import { pipeline } from "@huggingface/transformers";
const parse = await pipeline(
"image-segmentation",
"Xenova/segformer_b2_clothes",
); // downloads + caches ~29 MB once
const output = await parse(imageURL);
// β [{ score: null, label: "Upper-clothes", mask: RawImage },
// { score: null, label: "Pants", mask: RawImage },
// { score: null, label: "Hair", 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 (argmax per pixel) and a per-class pixel count β so the map, legend, and coverage bars are all views of the one label map the model produced. Nothing is uploaded.
Sample images: studio portrait β Jones, W. A. (Public domain); market crowd β Francisco Anzola (CC BY 3.0); street scene β Ken & Nyetta (CC BY 2.0). All via Wikimedia Commons.