vision-subject-cutout

command
v0.6.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2026 License: MIT Imports: 14 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

vision-subject-cutout

Zero-CGo (CGO_ENABLED=0), zero-TCC macOS Neural Engine subject lifting ("Lift Subject from Background") and GPU portrait-blur compositing using vision, coreimage, coregraphics, and x/capture — with no Python, ONNX, or bundled model weights.

What It Does

  1. Loads -in <image> or synthesizes a 640x640 high-contrast studio scene via CoreGraphics when -in is omitted.
  2. Runs VNGenerateForegroundInstanceMaskRequest on the Apple Neural Engine to segment foreground instances.
  3. Generates a transparent-background cutout PNG and a GPU portrait-blur PNG (CIGaussianBlur + CIBlendWithMask via CIContext) and writes both via x/capture.

Usage

# Zero-friction run on built-in synthetic scene:
CGO_ENABLED=0 go run ./examples/vision/vision-subject-cutout

# Run on your own image:
CGO_ENABLED=0 go run ./examples/vision/vision-subject-cutout -in photo.jpg -out cutout.png -blur blur.png -radius 20

Flags:

  • -in — input image path (default: synthetic 640x640 studio scene)
  • -out — transparent cutout PNG path (default: temp dir)
  • -blur — portrait-blur PNG path (default: temp dir)
  • -radius — Gaussian blur sigma for background (default 18.0)

Sample Output

Input:      synthetic studio scene (640x640)
Instances:  1 detected (ANE mask: 4.193s)
Coverage:   22.1% foreground pixels (GPU blur+composite: 169ms)
Cutout PNG: /var/folders/.../cutout.png (25621 bytes)
Blur PNG:   /var/folders/.../portrait-blur.png (44055 bytes, sigma=18.0)

Documentation

Rendered for darwin/amd64

Overview

Command vision-subject-cutout lifts foreground subjects from images using macOS Vision's Neural Engine instance mask and CoreImage GPU compositing.

Usage:

vision-subject-cutout [-in image.png] [-out cutout.png] [-blur blur.png] [-radius 18]

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL