The MediaPipe Interactive Image Segmenter task lets you divide an image into two regions: a selected
object and everything else. The task takes a location in an image, estimates the
boundaries of an object at that location, and returns image data defining the
area of the object. You can use this task to interactively select an object in
an image and use the output to apply effects to the image, such as color
overlays highlighting the object or blurring the background around it. This task
operates on image data with a machine learning (ML) model and you can use it on
single images, video files, or a continuous video stream.
Start using this task by following one of these implementation guides for your
target platform. These platform-specific guides walk you through a basic
implementation of this task, including a recommended model, and code example
with recommended configuration options:
This section describes the capabilities, inputs, outputs, and configuration
options of this task.
Features
Input image processing - Processing includes image rotation, resizing,
normalization, and color space conversion.
Task inputs
Task outputs
Point of interest coordinates for an object in an image
Image file to be processed
Interactive Image Segmenter outputs segmented image data, which can include one or
both of the following, depending on the configuration options you set:
CATEGORY_MASK: a list containing a segmented mask
as a uint8 format image. Each pixel value indicates if it is part of the
object located at the area of interest.
CONFIDENCE_MASK: a list of channels containing a
segmented mask with pixel values in float32 format. Each pixel value
indicates the level of confidence that it is part of the object located
at the area of interest.
Configurations options
This task has the following configuration options:
Option Name
Description
Value Range
Default Value
output_category_mask
If set to True, the output includes a segmentation mask
as a uint8 image, where each pixel value indicates if the pixel is part of
the object located at the area of interest.
{True, False}
False
output_confidence_masks
If set to True, the output includes a segmentation mask
as a float value image, where each float value represents the confidence
that the pixel is part of the object located at the area of interest.
{True, False}
True
display_names_locale
Sets the language of labels to use for display names provided in the
metadata of the task's model, if available. Default is en for
English. You can add localized labels to the metadata of a custom model
using the TensorFlow Lite Metadata Writer API
Locale code
en
Models
The Interactive Image Segmenter can be used with more than one ML model. Start with the
default, recommended model for your target platform when you start developing
with this task. The other available models typically make trade-offs between
performance, accuracy, resolution, and resource requirements, and in some cases,
include additional features.
MagicTouch model (recommended)
This model identifies segments given image coordinates for an area of interest.
The model uses a Convolutional Neural Network, similar to a
MobileNetV3
architecture, with a customized decoder.
Here's the task benchmarks for the whole pipeline based on the above
pre-trained models. The latency result is the average latency on Pixel 6 using
CPU / GPU.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-01-13 UTC."],[],[],null,["# Interactive image segmentation task guide\n\nThe MediaPipe Interactive Image Segmenter task lets you divide an image into two regions: a selected\nobject and everything else. The task takes a location in an image, estimates the\nboundaries of an object at that location, and returns image data defining the\narea of the object. You can use this task to interactively select an object in\nan image and use the output to apply effects to the image, such as color\noverlays highlighting the object or blurring the background around it. This task\noperates on image data with a machine learning (ML) model and you can use it on\nsingle images, video files, or a continuous video stream.\n\n[Try it!arrow_forward](https://mediapipe-studio.webapps.google.com/demo/interactive_segmenter)\n\nGet Started\n-----------\n\nStart using this task by following one of these implementation guides for your\ntarget platform. These platform-specific guides walk you through a basic\nimplementation of this task, including a recommended model, and code example\nwith recommended configuration options:\n\n- **Android** - [Code example](https://github.com/googlesamples/mediapipe/blob/main/examples/interactive_segmentation/android) - [Guide](./android)\n- **Python** - [Code example](https://colab.sandbox.google.com/github/googlesamples/mediapipe/blob/main/examples/interactive_segmentation/python/interactive_segmenter.ipynb) - [Guide](./python)\n- **Web** - [Code example](https://codepen.io/mediapipe-preview/pen/ZEqzpRg) - [Guide](./web_js)\n\nTask details\n------------\n\nThis section describes the capabilities, inputs, outputs, and configuration\noptions of this task.\n\n### Features\n\n- **Input image processing** - Processing includes image rotation, resizing, normalization, and color space conversion.\n\n| Task inputs | Task outputs |\n|----------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| - Point of interest coordinates for an object in an image - Image file to be processed | Interactive Image Segmenter outputs segmented image data, which can include one or both of the following, depending on the configuration options you set: - `CATEGORY_MASK`: a list containing a segmented mask as a uint8 format image. Each pixel value indicates if it is part of the object located at the area of interest. \u003c!-- --\u003e - `CONFIDENCE_MASK`: a list of channels containing a segmented mask with pixel values in float32 format. Each pixel value indicates the level of confidence that it is part of the object located at the area of interest. |\n\n### Configurations options\n\nThis task has the following configuration options:\n\n| Option Name | Description | Value Range | Default Value |\n|---------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------|---------------|\n| `output_category_mask` | If set to `True`, the output includes a segmentation mask as a uint8 image, where each pixel value indicates if the pixel is part of the object located at the area of interest. | {`True, False`} | `False` |\n| `output_confidence_masks` | If set to `True`, the output includes a segmentation mask as a float value image, where each float value represents the confidence that the pixel is part of the object located at the area of interest. | {`True, False`} | `True` |\n| `display_names_locale` | Sets the language of labels to use for display names provided in the metadata of the task's model, if available. Default is `en` for English. You can add localized labels to the metadata of a custom model using the [TensorFlow Lite Metadata Writer API](https://ai.google.dev/edge/lite/models/metadata_writer_tutorial) | Locale code | en |\n\nModels\n------\n\nThe Interactive Image Segmenter can be used with more than one ML model. Start with the\ndefault, recommended model for your target platform when you start developing\nwith this task. The other available models typically make trade-offs between\nperformance, accuracy, resolution, and resource requirements, and in some cases,\ninclude additional features.\n| **Attention:** This MediaPipe Solutions Preview is an early release. [Learn more](/edge/mediapipe/solutions/about#notice).\n\n### MagicTouch model (recommended)\n\nThis model identifies segments given image coordinates for an area of interest.\nThe model uses a Convolutional Neural Network, similar to a\n[MobileNetV3](https://www.kaggle.com/models?query=mobilenet-v3)\narchitecture, with a customized decoder.\n\n| Model name | Input shape | Quantization type | Model Card | Versions |\n|-----------------------------------------------------------------------------------------------------------------------------------|---------------|-------------------|---------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------|\n| [MagicTouch](https://storage.googleapis.com/mediapipe-models/interactive_segmenter/magic_touch/float32/latest/magic_touch.tflite) | 512 x 512 x 4 | None (float32) | [info](https://storage.googleapis.com/mediapipe-assets/Model%20Card%20MagicTouch.pdf) | [Latest](https://storage.googleapis.com/mediapipe-models/interactive_segmenter/magic_touch/float32/latest/magic_touch.tflite) |\n\nTask benchmarks\n---------------\n\nHere's the task benchmarks for the whole pipeline based on the above\npre-trained models. The latency result is the average latency on Pixel 6 using\nCPU / GPU.\n\n| Model Name | CPU Latency | GPU Latency |\n|------------|-------------|-------------|\n| MagicTouch | 130.11ms | 67.25ms |"]]