image-segmentation Β· vision Β· WASM Β· ~90 MB
This is fine-grained face segmentation: not "cut out the head" and not "find the face box" β every single pixel of a face is classified into one of 19 parts (skin, hair, left/right eye, brows, nose, upper/lower lip, ears, neck, glasses, hat, clothingβ¦). Pick a portrait and watch it become a colour-blocked map of facial regions, entirely on your device.
A different job from the face demos already here: face detection draws a box, face landmarks place points, and portrait matting cuts the whole person out. Face parsing labels the interior β the actual pixels of hair vs skin vs lips vs eyes.
| Model | Xenova/face-parsing (ONNX build of jonathandinu/face-parsing) |
|---|---|
| Task / pipeline | image-segmentation (semantic subtask β a full 19-class label map) |
| Architecture | SegFormer (MiT-B5 hierarchical transformer encoder + all-MLP decode head), finetuned on CelebAMask-HQ |
| Classes | 19 face parts: background, skin, nose, glasses, l/r eye, l/r brow, l/r ear, mouth, upper/lower lip, hair, hat, earring, necklace, neck, clothing |
| Quantization | q8 (8-bit) ONNX |
| Backend | WebAssembly (runs anywhere; no WebGPU needed) |
| Download | ~90 MB (q8), cached after first load |
| License | Non-commercial research β CelebAMask-HQ terms (research/educational use) |
| Web APIs | WebAssembly, Web Workers, Canvas, FileReader β all Baseline widely available |
Pick or drop a face photo and hit Parse. Every pixel gets a part label; the map is drawn over your photo. Slide the opacity to fade between the photo and the pure colour map.
Part legend
The model outputs a score for every one of the 19 parts at every pixel, then takes the argmax β the winning part 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 part distribution: how much of the frame each part claimed. That coverage vector is a compact "how is this face composed?" signature β useful for cropping, framing, or driving region-aware edits.
A per-pixel face-part map is the raw material for portrait and avatar features β and having it run locally means you can analyse or edit a face without uploading someone's photo to a server.
Parse a face and read the colour map and legend β see fine-grained face segmentation plainly.
Digital makeup: tint the lips, hair, or eyes by selecting their parts β on-device recolour.
Turn a portrait into a flat colour-blocked "anatomy" poster of its parts, downloadable.
Face parsing + DepthAnything β recolour hair only where it faces the light.
Face parsing is the standard Transformers.js semantic-segmentation pipeline. It returns one entry per part present, each with a full-resolution mask:
import { pipeline } from "@huggingface/transformers";
const parse = await pipeline(
"image-segmentation",
"Xenova/face-parsing",
); // downloads + caches ~90 MB once
const output = await parse(imageURL);
// β [{ score: null, label: "skin", mask: RawImage },
// { score: null, label: "hair", mask: RawImage },
// { score: null, label: "l_eye", mask: RawImage }, β¦ ]
// each mask is 0/255 for that part; together they tile the whole image
This page runs that in a Web Worker, then folds the per-part masks into a single colour-coded overlay (argmax per pixel) and a per-part pixel count β so the map, legend, and coverage bars are all views of the one label map the model produced. Nothing is uploaded.