MediaPipe Selfie Segmenter (Square 256×256)

Ultra-lightweight portrait segmentation model (selfie_segmenter.tflite, 250 KB, FP16 weights, 256 x 256 square input) for background blur/replacement in video calls and mobile AR using the MediaPipe Image Segmenter (ImageSegmenter) task.

Documentation: MediaPipe Image Segmenter Docs

Samples: Android · iOS · Python Colab · Web · Flutter

Try live: Web Demo

MobileNetV3-like encoder-decoder network with skip connections outputting a [1, 256, 256, 1] person confidence mask (0 = background, 1 = selfie) optimized for XNNPACK CPU and mobile GPU inference.

Files

File Precision Size SHA-256
selfie_segmenter.tflite float16 249.5 KB (249,537 B) 191ac9529ae506ee0beefa6b2c945a172dab9d07d1e802a290a4e4038226658b

Companion Files in Repo Root

File Role Size SHA-256
Model Card MediaPipe Selfie Segmentation.pdf Upstream Google model card (PDF) 2.29 MB (2,286,837 B) ef2e8d350891ba71699ac1e079658e697fc8d48c0f9253922990e907ecdade60

Download

pip install -U huggingface_hub
hf download litert-community/MediaPipe-ImageSegmenter-Selfie-Square selfie_segmenter.tflite --local-dir .

Inputs, Outputs, and Model Specifications

selfie_segmenter.tflite

  • Embedded TFLITE_METADATA: name ImageSegmenter · version 1 · author MediaPipe · packed associated files: labels.txt
Direction Tensor Shape Type Notes
Input input_1 [1, 256, 256, 3] float32 image — Input image to be processed. — Normalization: mean=[0.0], std=[255.0]
Output activation_10 [1, 256, 256, 1] float32 segmentation_masks — Masks over the target objects with high accuracy. — Labels: labels.txt

Use with MediaPipe Tasks

Python Quickstart

pip install -U mediapipe huggingface_hub
import mediapipe as mp
from huggingface_hub import hf_hub_download

model_path = hf_hub_download(
    repo_id="litert-community/MediaPipe-ImageSegmenter-Selfie-Square",
    filename="selfie_segmenter.tflite",
)

BaseOptions = mp.tasks.BaseOptions
ImageSegmenter = mp.tasks.vision.ImageSegmenter
ImageSegmenterOptions = mp.tasks.vision.ImageSegmenterOptions
VisionRunningMode = mp.tasks.vision.RunningMode

options = ImageSegmenterOptions(
    base_options=BaseOptions(model_asset_path=model_path),
    running_mode=VisionRunningMode.IMAGE,
    output_category_mask=True,
    output_confidence_masks=True,
)

with ImageSegmenter.create_from_options(options) as runner:
    mp_image = mp.Image.create_from_file("input.jpg")
    result = runner.segment(mp_image)
    print("Confidence masks:", len(result.confidence_masks), "Category mask size:", result.category_mask.width)

Cross-Platform Guides & Samples

Latency Benchmarks

End-to-end MediaPipe Task pipeline average latency reported by the Image Segmenter documentation:

Model Variant Device CPU Latency GPU Latency
SelfieSegmenter (square) Pixel 6 33.46 ms 35.15 ms

Intended Use, Limitations, and Fairness

Summarized from the bundled Model Card MediaPipe Selfie Segmentation.pdf (Google, May 6, 2021):

  • Intended applications: Real-time human/background segmentation for augmented reality and video conferencing.
  • Out-of-scope uses:
    • Any form of surveillance or identity recognition is explicitly out of scope and not enabled by this technology.
    • Human life-critical decisions, multiple people across widely different scales, or people > 4 meters (14 ft) from the camera.
  • Fairness evaluation (General 256×256 model, 1,594 images vs. 98.74% human inter-annotator IoU):
    • 17 UN geographic subregions: average IoU 96.48 ± 0.84% (range 95.71%–97.59%; max region deviation 1.11%).
    • Fitzpatrick skin tones 1–6: average IoU 96.57% (range 95.64%–96.74%).
    • Perceived gender: 96.25% Female / 96.86% Male.

Provenance

Every model binary in this repository is byte-identical (unmodified FlatBuffer weights and embedded TFLITE_METADATA bytes) to the official artifact served by Google from storage.googleapis.com/mediapipe-models.

Repo File Upstream URL GCS Generation Upstream Last-Modified Pinned Bucket Version
selfie_segmenter.tflite selfie_segmenter.tflite 1683436453600523 Sun, 07 May 2023 05:14:13 GMT /1/

License and Citation

  • License: apache-2.0 — Stated as Apache License, Version 2.0 in the bundled upstream Google model-card PDF.
Downloads last month
-
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Collection including litert-community/MediaPipe-ImageSegmenter-Selfie-Square