Skip to content

How-ToGPU

How to Remove a Video Background Locally with MatAnyone 2

MatAnyone 2 is an open AI video matting model that cuts people out of footage on your own PC without a green screen. We explain what hardware you need, how to install it with Conda or uv, how to make the first-frame mask it needs (or use its local demo), the key settings and how to composite the result.

By , Systems & Technical Editor

4 min read

How to Remove a Video Background Locally with MatAnyone 2

This guide is based on the official MatAnyone and MatAnyone 2 GitHub pages and NVIDIA's official specifications, all checked on 6 December 2026. Neither project publishes a minimum graphics card or VRAM figure, so the hardware advice below is our general guidance rather than measured results.

Video matting is the job of cutting a person (or another subject) out of every frame of a video, complete with a soft-edged alpha matte for hair and motion blur, so you can drop them onto a new background without a green screen. MatAnyone, from Nanyang Technological University's S-Lab and SenseTime Research, is an open video matting project. Its first version was presented at CVPR 2025, and MatAnyone 2, released with inference code in March 2026, is listed by its authors as a CVPR 2026 Highlight paper. Both run entirely on your own PC, so your footage never leaves it.

If you only need to cut out still images, our guide to running BEN3 background removal locally is a simpler place to start. If you want a faster tool that needs no mask at all, see our MatAnyone vs Robust Video Matting comparison.

What you need

  • A PC with an NVIDIA graphics card. MatAnyone 2's Python example loads the model on cuda:0, which means an NVIDIA GPU with CUDA. Neither project lists a minimum VRAM figure. In our view a modern card with 8GB is a sensible starting point for short clips, and 16GB gives more headroom for long or 1080p and higher videos. Our best GPUs for AI video matting guide goes into more detail.

  • Python and a package manager. The MatAnyone 2 instructions create a Conda environment with Python 3.10, or you can install it with uv.

  • FFmpeg, which the official instructions say is required for the optional Gradio demo.

  • Your video as an MP4, MOV or AVI file, or a folder of frames.

  • A first-frame mask: a black-and-white image marking the person you want to keep in the first frame. This is the key difference from many other tools.

Step 1: Install MatAnyone 2

Following the official README, clone the repository and set up an environment:

git clone https://github.com/pq-yang/MatAnyone2
cd MatAnyone2
conda create -n matanyone2 python=3.10 -y
conda activate matanyone2
pip install -e .
pip3 install -r hugging_face/requirements.txt

The last line is only needed for the point-and-click Gradio demo. The pretrained model, matanyone2.pth, can be downloaded from the project's GitHub release page into a pretrained_models folder, and the README says it will also be downloaded automatically the first time you run it.

Step 2: Make a first-frame mask (or use the demo)

MatAnyone takes a video plus a segmentation mask for the first frame, and then follows that subject through the rest of the clip. The authors suggest creating the mask with an interactive segmentation model such as SAM 2. Our guide to running SAM 3 locally covers a newer model from the same family.

The easier route is the project's Gradio demo, which you can launch locally:

cd hugging_face
python app.py

According to the README, you drop in your video, pick the target with a few clicks and get the matting results, with no need to prepare a mask file yourself.

Step 3: Run matting from the command line

If you have your own mask, run:

python inference_matanyone2.py -i myclip.mp4 -m myclip_mask.png

or use the matanyone2 command-line tool that was added in March 2026 (run matanyone2 --help to see every option). Results go to the results folder as two videos: the foreground and the alpha matte.

Two options are worth knowing:

  • --save-image saves per-frame images instead of only videos, which is handy for importing into an editor.

  • --max-size caps the input resolution. By default there is no limit, so if a 4K clip is too much for your graphics card, this is the setting to try first.

Step 4: Composite onto a new background

The alpha video is a greyscale matte: white is the subject, black is the background. Most video editors can use it as a luma matte or track matte to place your subject over new footage. Our guide to DaVinci Resolve's AI tools covers an editor that handles this well.

Original MatAnyone or MatAnyone 2?

The original MatAnyone repository now points visitors to MatAnyone 2 as its newer release. The first version used Python 3.8 in its instructions and remains available, with training code released in March 2026. For new projects, we'd start with MatAnyone 2.

A note on the licence

Both MatAnyone versions are released under the NTU S-Lab License 1.0, not a standard open-source licence, and the authors say redistribution and use should follow it. Read the licence on GitHub before using either in paid client work.

The bottom line

MatAnyone 2 lets you remove a video's background on your own PC without a green screen: install it with Conda or uv, mark the subject in the first frame (or click it in the local Gradio demo), and it produces a foreground video and an alpha matte you can composite in any editor. An NVIDIA card is the safe choice, and --max-size helps if high-resolution clips are too demanding.

Sources

  1. 01MatAnyone 2 (S-Lab, NTU), GitHub repository and README
  2. 02MatAnyone (S-Lab, NTU), GitHub repository and README
  3. 03MatAnyone 2 model files (Hugging Face)

About the author

Marcus Thorne

Systems & Technical Editor

Marcus writes Forge PC's step-by-step build, troubleshooting and system optimisation guides. His background spans Windows kernel and power-state diagnostics, UEFI/BIOS configuration, NVMe storage arrays, ATX 3.1 power delivery and running local AI and LLM workloads on consumer graphics cards.

More from Marcus Thorne

Read next

Best GPUs for Local AI Video Matting in 2026

Best Picks

Best GPUs for Local AI Video Matting in 2026

AI video matting tools such as MatAnyone 2 and Robust Video Matting run on your own graphics card. We pick the best NVIDIA GPUs for removing video backgrounds locally, from the 16GB RTX 5070 Ti and RTX 5060 Ti to the 32GB RTX 5090 and a budget 8GB RTX 5060, based on official specs and documentation.

Hannah Vance3 min

MatAnyone 2 vs Robust Video Matting: Which Local AI Video Matting Tool?

Versus

MatAnyone 2 vs Robust Video Matting: Which Local AI Video Matting Tool?

MatAnyone 2 and Robust Video Matting both remove video backgrounds locally without a green screen, but one follows a subject you mark in the first frame while the other is fully automatic. We compare how they work, ease of use, hardware demands, formats, development and licences.

Callum Reid3 min