DEV Community

local ai
local ai

Posted on

I Spent Two Hours Rotoscoping a Dance Video. Then an AI Did It in Two Minutes.

I Spent Two Hours Rotoscoping a Dance Video. Then an AI Did It in Two Minutes.

Cover

Last Wednesday night, I had a simple task: extract a dancer from a video and put her on a clean background.

Simple, right?

I opened Premiere Pro. Fired up the Roto Brush. Two hours later, the hair was a smeared mess, the skirt edges looked like they'd been cut with safety scissors, and I was questioning my career choices.

Then I tried an online matting tool. Uploaded the video, waited five minutes, and got back something that flickered like a strobe light — the extraction boundary jittered on every single frame.

At 1 AM, frustrated and caffeinated, I stumbled on a GitHub repo called MatAnyone2.

Two minutes later, I had my jaw on the floor.

What Is MatAnyone2?

MatAnyone2 Results

MatAnyone2 is a video matting framework developed by researchers at S-Lab (Nanyang Technological University) and SenseTime Research. It was just accepted to CVPR 2026 — the top conference in computer vision.

What it does: takes a regular video — no green screen, no special lighting — and extracts people with pixel-perfect alpha mattes. That means hair strands, translucent fabrics, wispy edges — all preserved with precise transparency values.

This isn't binary segmentation (person = 1, background = 0). This is real matting. Every pixel gets a transparency value between 0 and 1. The difference matters enormously when you composite onto a new background.

How It Works (The Interesting Part)

MatAnyone 1 vs 2 Comparison

The core innovation is something called the Matting Quality Evaluator (MQE) — essentially, the model has its own built-in quality inspector.

Here's the problem it solves: traditional matting models train on synthetic data. You take a foreground, paste it on a background, and the model learns to undo that composition. But synthetic data is too clean. Real-world videos have wind-blown hair, changing lighting, motion blur, complex occlusions. Models trained purely on synthetic data choke on these.

MatAnyone2's approach is clever. The MQE generates a pixel-level quality map for each matte — marking which regions are reliable and which are garbage. During training, the model only learns from the reliable pixels. Bad predictions get suppressed instead of reinforcing mistakes.

Using this mechanism, the team built VMReal: a dataset of 28,000 real-world video clips and 2.4 million frames, each annotated with quality evaluation maps. That's why it works so well on real footage — it was trained on real footage.

My First Run

The workflow is dead simple:

  1. Upload your video
  2. Click a few points on the first frame to mark your subject (SAM handles the mask generation)
  3. Hit "Video Matting"

Interactive Demo

On my RTX 3080, that dance video processed in about two minutes.

I opened the alpha channel output and just stared at it. Individual hair strands. The gap between fingers. The semi-transparent edge of a flowing skirt. All clean. All temporally consistent — no flickering between frames.

Those two hours I spent with Roto Brush suddenly felt very personal.

Real Results

Here are some test samples to give you a feel for the extraction quality:

Sample 1

Sample 2

Sample 3

Look at the hair boundaries. Look at the semi-transparent regions. This isn't a hard cutout — it's a proper alpha matte with continuous transparency values. When you composite these onto a new background, there's no "sticker effect."

Multi-Person Support

You can mark multiple people in the same video and extract them separately. For anyone doing VFX compositing, this is a game-changer.

The Data Pipeline

Data Pipeline

What I find particularly elegant is how the MQE doubles as a data curator. Multiple matting models process the same video. The MQE evaluates each result, picks the best regions from each, and stitches them into a higher-quality composite annotation.

This means annotation quality improves as more models and data are added. It's not a static tool — it's a system that gets better over time.

Getting Started

Hardware Requirements

  • NVIDIA GPU (8GB+ VRAM recommended)
  • CUDA support

Command Line (Fastest)

python inference_matanyone2.py -i your_video.mp4 -m your_mask.png -o results/
Enter fullscreen mode Exit fullscreen mode

Feed it a video and a first-frame mask. Out comes a foreground video (green screen composite) and an alpha matte video.

Interactive GUI (Recommended for First-Timers)

Launch the Gradio interface and everything is point-and-click. SAM is built in, so you don't need to prepare masks in advance.

Python API (For Integration)

from matanyone2 import MatAnyone2, InferenceCore

model = MatAnyone2.from_pretrained("PeiqingYang/MatAnyone2")
processor = InferenceCore(model, device="cuda:0")
processor.process_video(
    input_path="your_video.mp4",
    mask_path="your_mask.png",
    output_path="results",
)
Enter fullscreen mode Exit fullscreen mode

Three lines. Drop it into your existing pipeline.

How It Compares

Tool Hair Detail Temporal Consistency Transparency Green Screen Required
Premiere Roto Brush Manual labor Decent Poor No
Online Matting Tools Average Poor (flickers) Not supported No
Traditional Green Screen Good Good Good Yes
MatAnyone2 Excellent Excellent Excellent No

The Bottom Line

I've been doing video post-production long enough to be skeptical of anything that promises "one-click" results. Most of them look great in the demo reel and fall apart on real footage.

MatAnyone2 is different. It's not approximate segmentation dressed up as matting. It's genuine pixel-level alpha estimation, trained on 2.4 million frames of real-world video, with a built-in quality evaluator that ensures the model only learns from its best work.

If you do short-form content, film post-production, virtual streaming, or just want to swap the background on a home video — give this a try. It might change how you think about video extraction entirely.

GitHub: https://github.com/pq-yang/MatAnyone2

Live Demo: https://huggingface.co/spaces/PeiqingYang/MatAnyone2

One-Click Deploy Package: https://www.patreon.com/posts/154208684

Top comments (0)