/media-os:media-matte [model] [input] [output]from media-os
Removes backgrounds from images and videos using open-source AI models (rembg, BiRefNet, RMBG-2.0, RVM). Supports stills, video with temporal coherence, and compositing onto new backgrounds.
Ships in media-os. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Context: $ARGUMENTS
composite subcommand → Step 5.rembg run flickers in the edges — use RVM for temporal coherence.ffmpeg-chromakey instead. A real green screen is cheaper and sharper than neural matting.cv-mediapipe / cv-opencv.| Model | License | Best for | Form | Video? |
|---|---|---|---|---|
| rembg | MIT | General still images, pip-installable | pip install rembg CLI + Python | Frame-by-frame only |
| BiRefNet | MIT | Hair, fur, semi-transparent edges | Python (torch + HF transformers) | Frame-by-frame only |
| RMBG-2.0 | Apache 2.0 | Products, e-commerce | HuggingFace briaai/RMBG-2.0 | Frame-by-frame only |
| RVM | GPL-3.0 | Video with temporal coherence | Python (torch); TorchScript/ONNX | Yes, native |
Decision rules:
isnet-general-use (default). Fastest install.Do NOT use: Adobe Sensei (proprietary cloud), backgroundremover.app (freemium SaaS), RMBG v1.4 (CC-BY-NC — non-commercial only; the v2.0 release IS Apache 2.0 and is what this skill uses).
scripts/matte.py install <model> prints the platform-specific command. It does not auto-install.
# rembg (Python pip; default u2net / isnet weights bundled, Apache-2.0 weights)
uv pip install "rembg[cli]"
# BiRefNet (from HuggingFace)
uv pip install torch torchvision transformers pillow
# RMBG-2.0
uv pip install torch transformers pillow
# Then from Python: AutoModelForImageSegmentation.from_pretrained("briaai/RMBG-2.0", trust_remote_code=True)
# RVM
git clone https://github.com/PeterL1n/RobustVideoMatting
uv pip install torch torchvision av tqdm pims
# Or PyPI: uv pip install rvm (community wrapper)
# CLI (bundled with 'rembg[cli]')
rembg i photo.jpg photo_cutout.png
# Pick a model (-m):
rembg i -m isnet-general-use photo.jpg photo_cutout.png
# Other models: u2net, u2netp, u2net_human_seg, isnet-anime, silueta, sam (requires GPU + prompts)
# Alpha-matting for cleaner edges (slow):
rembg i -a photo.jpg photo_cutout.png
Driver script:
uv run ${CLAUDE_SKILL_DIR}/scripts/matte.py image \
--model rembg --in photo.jpg --out photo_cutout.png \
--model-name isnet-general-use
# Minimal Python via transformers:
from transformers import AutoModelForImageSegmentation
from PIL import Image
import torch, torchvision.transforms as T
model = AutoModelForImageSegmentation.from_pretrained(
"ZhengPeng7/BiRefNet", trust_remote_code=True
)
model.eval().to("cuda") # or "cpu"
img = Image.open("photo.jpg").convert("RGB")
tx = T.Compose([T.Resize((1024, 1024)), T.ToTensor(),
T.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])])
with torch.no_grad():
mask = model(tx(img).unsqueeze(0).to("cuda"))[-1].sigmoid().cpu()[0, 0]
alpha = T.Resize(img.size[::-1])(mask.unsqueeze(0))[0].numpy()
# Composite alpha into RGBA output
The driver wraps this:
uv run ${CLAUDE_SKILL_DIR}/scripts/matte.py image \
--model birefnet --in photo.jpg --out photo_cutout.png
from transformers import AutoModelForImageSegmentation
model = AutoModelForImageSegmentation.from_pretrained("briaai/RMBG-2.0", trust_remote_code=True)
# Same inference loop as BiRefNet — both are transformers-compatible segmentation models.
Driver:
uv run ${CLAUDE_SKILL_DIR}/scripts/matte.py image \
--model rmbg2 --in product.jpg --out product_cutout.png
RVM is temporal: it looks at previous frames' hidden state so edges don't flicker.
# Upstream inference script (from the RVM repo)
python inference.py \
--variant mobilenetv3 \
--checkpoint rvm_mobilenetv3.pth \
--device cuda \
--input-source input.mp4 \
--output-type video \
--output-composition comp.mp4 \
--output-alpha alpha.mp4 \
--output-foreground fg.mp4 \
--output-video-mbps 8 \
--seq-chunk 1
# Variants: mobilenetv3 (fast, realtime), resnet50 (slow, higher quality)
Driver:
uv run ${CLAUDE_SKILL_DIR}/scripts/matte.py video \
--model rvm --in input.mp4 --out composite.mp4 \
--variant mobilenetv3 --bg bg.png
The script writes:
composite.mp4 — subject over the supplied --bg (PNG, JPG, or MP4)alpha.mp4 (optional via --alpha) — 8-bit mask videofg.mp4 (optional via --foreground) — premultiplied subjectIf the AI mask is almost right but the user has a rough trimap (black = bg, white = fg, gray = unknown), RVM and BiRefNet can refine. rembg supports alpha-matting (-a) which does a similar edge refinement via pymatting:
uv run ${CLAUDE_SKILL_DIR}/scripts/matte.py refine \
--in photo.jpg --mask trimap.png --out refined.png
# Still on still
uv run ${CLAUDE_SKILL_DIR}/scripts/matte.py composite \
--fg subject_rgba.png --bg beach.jpg --out final.png
# Video on still/video — ffmpeg overlay with alpha
ffmpeg -i bg.mp4 -i alpha.mp4 -i fg.mp4 \
-filter_complex "[1:v]format=yuva420p,alphaextract[a];[2:v][a]alphamerge[subject];[0:v][subject]overlay=shortest=1[v]" \
-map "[v]" -c:v libx264 -preset slow -crf 18 -pix_fmt yuv420p composite.mp4
u2netp variant ships with its own license — check the file header if you depend on it.briaai/RMBG-2.0, not briaai/RMBG-1.4.inference.py via subprocess.run, preserving the boundary. Do the same in your own product..mov with prores_ks -profile:v 4444 or .webm with VP9 (-pix_fmt yuva420p). MP4 does not carry alpha on most players.--output-type png_sequence and remux into ProRes 4444 / VP9+alpha.isnet-general-use is CPU-tolerable for single images.pymatting / rembg -a) if edges still look chunky.uv run ${CLAUDE_SKILL_DIR}/scripts/matte.py image \
--model rembg --in portrait.jpg --out portrait_cutout.png
uv run ${CLAUDE_SKILL_DIR}/scripts/matte.py image \
--model rmbg2 --in shoe.jpg --out shoe_cutout.png
uv run ${CLAUDE_SKILL_DIR}/scripts/matte.py video \
--model rvm --in interview.mp4 --out out.mp4 --bg office.jpg --variant mobilenetv3
for f in products/*.jpg; do
uv run ${CLAUDE_SKILL_DIR}/scripts/matte.py image \
--model rmbg2 --in "$f" --out "cutouts/$(basename "${f%.*}").png"
done
uv run ${CLAUDE_SKILL_DIR}/scripts/matte.py check
rembg: command not foundCause: rembg not installed.
Solution: uv pip install "rembg[cli]". CLI becomes available as rembg. Also run rembg d once to pre-download a default model (otherwise first run downloads on the fly).
Cause: u2net / isnet is a segmentation model, not a matting model.
Solution: switch to BiRefNet (--model birefnet), or use rembg -a (alpha matting via pymatting), or hand off to a trimap-aware refine step.
ModuleNotFoundError: No module named 'model'Cause: RVM's inference.py expects to be run from inside the RVM repo (relative imports).
Solution: cd into the cloned RobustVideoMatting directory, then run. The driver script does this via cwd= in subprocess.run.
Cause: premultiplied vs. straight alpha mismatch.
Solution: let ffmpeg handle premultiplication: premultiply=inplace=1 before alphamerge. Or export the foreground as straight alpha with RVM's --output-foreground and composite with overlay=format=rgb flags.
.mp4 output has no transparencyCause: MP4 + H.264 yuv420p can't carry alpha across most players.
Solution: for transparent video use .mov with prores_ks -profile:v 4444 -pix_fmt yuva444p10le, or .webm with VP9 (libvpx-vp9 -pix_fmt yuva420p).
Cause: no GPU.
Solution: smaller input size (512×512), or switch to rembg on CPU (still slower than GPU but acceptable for single images), or batch on a cloud GPU.
references/models.md.references/LICENSES.md.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub damionrashford/media-os --plugin media-os110 skills in this plugin
/audio-coreaudioManipulate macOS audio at the Core Audio HAL layer: afinfo (audio file metadata), afplay (play), afconvert (convert format/rate/bit-depth/channel layout), say (TTS), SwitchAudioSource (change default input/output/system device — brew install switchaudio-osx), audiodevice CLIs (npm/Go variants), AppleScript via osascript to drive System Preferences Sound. HAL plugins at /Library/Audio/Plug-Ins/HAL/ load virtual drivers (BlackHole 2ch/16ch/64ch, Loopback, Background Music). Aggregate Device (drift-corrected multi-in) and Multi-Output Device via Audio MIDI Setup.app or AudioHardwareCreateAggregateDevice. Use when the user asks to change default macOS audio device, route audio between apps on Mac, install BlackHole, build an Aggregate Device, convert audio files with afconvert, or script Mac audio from the terminal.
/audio-jackRoute professional low-latency audio with JACK Audio Connection Kit (jackaudio.org): jackd server (ALSA/CoreAudio/PortAudio/ASIO backends), jack_control (D-Bus JACK2 config), jack_lsp (list ports/connections), jack_connect/jack_disconnect (manage links), jack_cpu_load, jack_samplerate, jack_bufsize (runtime period size), jack_transport, jack_rec (multi-channel WAV recording), jack_iodelay (round-trip latency), jack_wait, jack_midi_dump. JACK1 C maintenance vs JACK2 C++ multicore. Modern Linux swaps jackd for PipeWire's libjack shim — same client API. JackTrip for uncompressed multichannel UDP over the Internet. Use when the user asks to run a JACK server, connect audio clients, measure roundtrip latency, record from JACK ports, set JACK period size, or bridge JACK over the network with JackTrip.
/audio-pipewireRoute and introspect Linux audio/video/MIDI graphs with PipeWire: pw-cli (interactive object/module control), pw-dump (full graph JSON with --monitor), pw-link (list/create/destroy port links), pw-cat / pw-play / pw-record (playback+record), pw-top (real-time DSP load + xrun viewer), pw-metadata (shared metadata store), pw-loopback (source/sink bridges), pw-midiplay/pw-midirecord, pw-jack (JACK client compat shim), pw-mon, pw-profiler. WirePlumber session manager handles routing/defaults/profiles. Replaces PulseAudio (via pipewire-pulse) and JACK (via libjack.so shim) simultaneously. Use when the user asks to route Linux audio, link two apps, list audio devices on Linux, create a loopback, record system audio, monitor the audio graph, or set up a virtual audio device on modern Linux.
/audio-wasapiManipulate Windows audio via WASAPI (learn.microsoft.com/coreaudio): SoundVolumeView + svcl.exe (NirSoft — set default device, per-app volumes, save/load profiles), AudioDeviceCmdlets PowerShell module (Get-AudioDevice, Set-AudioDevice, Get-AudioDevicePlaybackMute), nircmd setdefaultsounddevice. Shared mode (Windows engine resamples all streams to endpoint fixed format) vs Exclusive mode (bit-perfect, audiophile, ~sub-3ms latency with IAudioClient3 + event-driven callbacks). WASAPI then MMDevice then Audio Engine (audiodg.exe) then WDM/KS. ASIO is Steinberg's parallel stack bypassing Windows audio. Virtual audio devices: VB-Audio Virtual Cable, VoiceMeeter/Banana/Potato. Use when the user asks to change Windows default audio device, route app audio, use VoiceMeeter, install VB-Cable, set a specific device from PowerShell, or enable exclusive-mode low-latency output.
/cv-mediapipeGoogle MediaPipe Tasks API (current supported, NOT legacy mediapipe.solutions): Vision Tasks (Face Detector, Face Landmarker, Face Stylizer, Hand Landmarker, Gesture Recognizer, Pose Landmarker, Holistic Landmarker, Object Detector, Image Classifier, Image Segmenter, Interactive Segmenter, Image Embedder, Image Generator), Audio Tasks (Audio Classifier), Text Tasks (Text Classifier, Text Embedder, Language Detector), GenAI Tasks (LLM Inference — on-device Gemma/Phi-2/Falcon/StableLM). Three run modes: IMAGE, VIDEO, LIVE_STREAM (async). Python: mediapipe.tasks.python.vision/audio/text/genai. Docs at ai.google.dev/edge/mediapipe/solutions. Model Maker for transfer learning. Use when the user asks to detect pose/face/hand landmarks, classify an image, run a body-pose model, segment people, recognize gestures, do on-device LLM inference via MediaPipe, or build a mobile/embedded CV pipeline.
/cv-opencvComputer vision on images + video with OpenCV (docs.opencv.org/4.x/): core (Mat / ndarray, linalg), imgproc (filtering, morphology, geometric transforms, color conv, histograms, contours), imgcodecs (imread/imwrite — PNG, JPEG, TIFF, WebP, EXR), videoio (VideoCapture / VideoWriter — FFMPEG, GStreamer, V4L2, AVFoundation, MSMF backends), calib3d (camera calibration, stereo, solvePnP, homography), features2d (ORB, AKAZE, BRISK, KAZE, SIFT), objdetect (FaceDetectorYN, FaceRecognizerSF, HOG, ArUco, QRCode), dnn (ONNX/TF/Caffe/Darknet, CUDA + OpenVINO + Vulkan backends, model zoo at github.com/opencv/opencv_zoo), photo (inpainting, denoising, HDR Debevec/Robertson), stitching (panorama), video (optical flow Farneback/LK/DIS, BackgroundSubtractorMOG2/KNN, tracking KCF/CSRT/MIL/Nano/Vit/DaSiamRPN). Python-first via cv2. Use when the user asks to detect faces, track objects, run YOLO inference, capture + process webcam frames, calibrate a camera, stitch a panorama, or use OpenCV from Python/C++.
Other plugins' skills for the same job