mask-generation · vision · MediaPipe Tasks 0.10.18 · 5.94 MB

MagicTouch — point at it, select it

Google's recommended MagicTouch model turns one normalized image coordinate into a foreground probability for every pixel. It is a MobileNetV3-like convolutional network with a custom decoder, optimized for browser and mobile use. The pinned float32 model, inference, tensor reduction, and dense compositing all stay on your device.

At a glance

Exact runtime, artifact, and output contract
ModelGoogle MediaPipe MagicTouch (recommended)
Taskmask-generation from one foreground keypoint
Runtime@mediapipe/tasks-vision@0.10.18, InteractiveSegmenter.segment(), worker-first
Pinned artifactfloat32 generation 1 · 6,227,884 bytes · SHA-256 e24338a717c1b7ad8d159666677ef400babb7f33b8ad60c4d96db4ecf694cd25
ArchitectureMobileNetV3-like CNN with customized decoder
Input512×512×4: RGB plus a one-hot prior map for the point of interest
Output512×512×2 background/foreground logits, exposed as confidence and category masks at image resolution
BackendCPU/WASM fallback; GPU delegate only after a real adapter probe
LicenseApache-2.0 (model card, 13 March 2023)

Why it matters

A point is a much lighter prompt than drawing a polygon. That makes precise object selection available to private photo editors, annotation tools, visual accessibility workflows, and creative effects without a server round-trip.

Five-angle portfolio

How the API works

const segmenter = await InteractiveSegmenter.createFromOptions(vision, {
  baseOptions: { modelAssetBuffer: verifiedMagicTouchBytes, delegate: "CPU" },
  outputCategoryMask: true,
  outputConfidenceMasks: true,
});
const result = segmenter.segment(imageBitmap, {
  keypoint: { x: 0.50, y: 0.50 }, // normalized coordinates
});
const foreground = result.confidenceMasks[0].getAsFloat32Array();

The raw MagicTouch model tensor has background and foreground channels. The MediaPipe task API demonstrated here exposes one normalized foreground confidence mask at confidenceMasks[0], plus the category mask. This implementation fetches the exact numbered artifact only after consent, checks its SHA-256 before creating the task, keeps one verified Cache Storage copy, and uses the shared loader for current/partial/clear/retry lifecycle. The site owns that 5.94 MB transfer: interrupted transfers restart from byte zero rather than claiming byte-range resume. It transfers the image bitmap into a dedicated worker and returns a transferred RGBA composite.

References and provenance