← All models

image-segmentation Β· vision Β· MediaPipe Β· ~2.8 MB

Image Segmenter β€” every pixel gets a class

Google's MediaPipe Image Segmenter (a DeepLab v3+ trained on PASCAL VOC 2012) labels every pixel of a photo with one of 21 classes β€” person, dog, cat, car, bicycle, chair, TV… β€” and returns a category mask plus a confidence mask per class. It's a real .tflite model that runs on-device via WebAssembly (with a GPU delegate when available). Pick a photo and watch the mask appear.

At a glance

ModelMediaPipe Image Segmenter β€” DeepLab v3+ (Google)
RuntimeMediaPipe Tasks Vision (@mediapipe/tasks-vision) β€” official .tflite bundle
OutputCategory mask (one class index per pixel) + 21 float confidence masks + label map
Classes21 PASCAL VOC 2012 classes (background + 20 object/animal/person classes)
DelegateGPU when a WebGPU/WebGL adapter exists, otherwise CPU (XNNPACK)
Download~2.8 MB deeplab_v3.tflite, cached by the browser after first load
LicenseApache-2.0 (Google MediaPipe)
Web APIsWebAssembly, Canvas β€” all Baseline widely available

Run it

Pick a sample photo or drop your own. The model labels each pixel; the legend lists every class found with its coverage and mean confidence.

Drop a photo here, or click to choose
Portrait of a person A dog outdoors A cat A street scene

Classes found

Coverage = share of pixels labelled with that class; conf = the model's mean confidence over those pixels (from the per-class confidence masks).

Segment an image to see its class legend.

See inside

The model returns a category mask (one byte per pixel: the winning class index) and a confidence mask per class (one float per pixel per class). The table below is computed from exactly those arrays for the current image β€” pixel counts per class, share of the frame, and mean confidence. The label map comes from the model bundle itself (getLabels()).

Segment an image to see its per-class pixel statistics.

Why it matters

Semantic segmentation β€” "which object is each pixel part of?" β€” used to mean a server-side vision API. This 2.8 MB model turns it into a local function call in any browser: private, offline, fast enough for interactive editing. Unlike promptable segmenters (SAM) you get a named class for every region in one pass, so apps can act on "the person" or "the TV" without any clicking.

Use cases

Basics

One photo in, 21 classes out β€” read the mask, the coverage and the confidence for each class found.

Practical

Person cutout studio: lift people off their background and export a transparent PNG.

Wild

Class spotlight: click a class in the legend and watch everything else fade away.

How the API works

MediaPipe Tasks loads the official .tflite model and gives you a segmenter you call per image:

import { FilesetResolver, ImageSegmenter } from "@mediapipe/tasks-vision";

const vision = await FilesetResolver.forVisionTasks(".../wasm");
const segmenter = await ImageSegmenter.createFromOptions(vision, {
  baseOptions: {
    modelAssetPath: ".../deeplab_v3.tflite",  // ~2.8 MB, 21 VOC classes
    delegate: "GPU",                           // or "CPU"
  },
  runningMode: "IMAGE",                        // or "VIDEO"
  outputCategoryMask: true,                    // one class index per pixel
  outputConfidenceMasks: true,                 // one float mask per class
});

const result = segmenter.segment(imageElement);
// result.categoryMask.getAsUint8Array()  β†’ Uint8Array, class index per pixel
// result.confidenceMasks[i]              β†’ float mask for class i
// segmenter.getLabels()                  β†’ the bundle's label map (21 VOC names)

This page runs the segmenter in a Web Worker through the showcase's shared auto-init loader; the main thread only colorizes the returned mask. Inference uses the WASM/CPU delegate here (a GPU delegate is used automatically when a real adapter exists).

References