← All models

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

Face Parsing β€” give every pixel of a face a name

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.

At a glance

ModelXenova/face-parsing (ONNX build of jonathandinu/face-parsing)
Task / pipelineimage-segmentation (semantic subtask β€” a full 19-class label map)
ArchitectureSegFormer (MiT-B5 hierarchical transformer encoder + all-MLP decode head), finetuned on CelebAMask-HQ
Classes19 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
Quantizationq8 (8-bit) ONNX
BackendWebAssembly (runs anywhere; no WebGPU needed)
Download~90 MB (q8), cached after first load
LicenseNon-commercial research β€” CelebAMask-HQ terms (research/educational use)
Web APIsWebAssembly, Web Workers, Canvas, FileReader β€” all Baseline widely available

Run it

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.

Drop a face photo here, or click to choose
Sample face, broad smile Sample face, serious expression, wearing glasses Sample face, soft neutral expression Public-domain studio portrait of a young woman, 1940s
60%

Part legend

Run parsing to label the face.

See inside

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.

Run parsing to see the label map and part distribution.

Why it matters

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.

Use cases

Basics

Parse a face and read the colour map and legend β€” see fine-grained face segmentation plainly.

Practical

Digital makeup: tint the lips, hair, or eyes by selecting their parts β€” on-device recolour.

Wild

Turn a portrait into a flat colour-blocked "anatomy" poster of its parts, downloadable.

Multi-model

Face parsing + DepthAnything β†’ recolour hair only where it faces the light.

How the API works

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.

References