How to run MatAnyone video matting on a cloud GPU

Rent a GPU on Deploy, then open a terminal in JupyterLab or over SSH. Install MatAnyone from the official pq-yang/MatAnyone README, download the weight that README links, and run the documented inference command with a video and a first-frame mask. Copy the results folder off the instance before you destroy it. Destroying the instance deletes its disk.

The README says the first-frame segmentation mask could be obtained from an interactive segmentation model, and it links a SAM 2 demo. Promptable segmentation from the repository this site follows is How to run SAM 2 (Segment Anything 2) on a cloud GPU. Image background removal whose README prints 3.45GB, 3.5GB, 4.8GB, and 5.5G in separate sentences is How to remove image backgrounds with BiRefNet on a cloud GPU. Text-prompted detection whose README prints no GPU GB figure is How to run Grounding DINO on a cloud GPU. Video upscaling whose linked ComfyUI node prints 8GB, 12-16GB, and 24GB+ is How to upscale video with SeedVR2 on a cloud GPU. Image and video upscaling whose README prints no GPU GB figure is How to upscale images and video with Real-ESRGAN on a cloud GPU. If the process runs out of memory: How to fix CUDA out of memory on a cloud GPU. The tunnel is How to use SSH port forwarding on a cloud GPU.

The LICENSE file is titled “S-Lab License 1.0”. The copyright line is “Copyright 2023 S-Lab”. It permits redistribution and use for non-commercial purpose, and it says that if redistribution or use for a commercial purpose is required, you should contact the contributors. The GitHub license field on 2026-11-13 was NOASSERTION. The model API for PeiqingYang/MatAnyone that day did not set cardData.license. gated was false. lastModified was 2025-04-08T08:16:03.000Z. sha was d3395d72e3baa4508521ab8a6ae9a7d41f873dc4. That license text is not a CloudGPU price. Read the file before you redistribute the program or the weights.

The commands below are copied from the upstream files named in each step. They were not run on a CloudGPU instance for this page. Anything this page adds around them is marked.

What the README says about memory

The GitHub README prints no GPU GB figure. The sample comments say “short video; 720p”, “short video; 1080p”, and “long video; 1080p”. Those words describe the example files. They are not a GB figure. hugging_face/app.py has a note about the hosted demo: “Due to the online GPU memory constraints, any input with too big resolution will be resized to 1080p.” That note does not print a GB figure. This page did not remeasure memory.

The README’s first line after the overview says to check the new release on MatAnyone 2. This page does not copy that repository’s install.

GET /v1/public/compute-capabilities does not list GPUs. It returns feature flags. The memory column is vram_gb from gpu-prices.json, updated_at 2026-11-13T23:11:30.761Z. GET /v1/public/gpu-catalog the same day (generated_at 2026-11-13T23:11:29.742Z) listed the same names and the same vram_gb values, plus Ascend 910B at 64, which is not in gpu-prices.json and is not listed here. The catalog response also includes an availability field. This page does not copy it. Every prices row has gpu_count 1. Every catalog row has min_gpu_count 1. There is no upstream GPU GB cutoff to match these values against. This page does not mark a row as enough. Which listing you can start is on Deploy.

The catalog template list had no MatAnyone template.

Catalog name vram_gb
RTX 2080 8
RTX 3080 10
RTX 2080 Ti 11
RTX 3080 Ti 12
V100 16G 16
A30 24
RTX 3090 24
RTX 4090 24
RTX 4090D 24
RTX 4080 SUPER 32G 32
RTX 5090 32
RTX 5090D 32
V100 32G 32
A100 40G 40
A800 40G 40
A40 48
RTX 4090 48G 48
RTX 4090D 48G 48
RTX A6000 48
NVIDIA RTX PRO 5000 72G 72
RTX PRO 5000 72G 72
A100 80G 80
A800 80G 80
H800 80
RTX 6000D 83
H20 96G 96
RTX PRO 6000 96G 96
RTX PRO 6000 Max-Q 96
H20-3e 141G 141

Install

On Deploy, choose Raw GPU. The README’s install, copied.

git clone https://github.com/pq-yang/MatAnyone
cd MatAnyone
# create new conda env
conda create -n matanyone python=3.8 -y
conda activate matanyone

# install python dependencies
pip install -e .
# [optional] install python dependencies for gradio demo
pip3 install -r hugging_face/requirements.txt

The Hugging Face section prints a different install: pip install -q git+https://github.com/pq-yang/MatAnyone. This page did not run either install.

Download the weights

The README says to download the pretrained model from MatAnyone v1.0.0 to the pretrained_models folder, and that the pretrained model can also be automatically downloaded during the first inference. The directory it prints is pretrained_models/matanyone.pth. inference_matanyone.py defaults --ckpt_path to pretrained_models/matanyone.pth.

The same README says models can be loaded from PeiqingYang/MatAnyone. The model API file list on 2026-11-13 was .gitattributes, README.md, config.json, inference_matanyone_api.py, and model.safetensors. It did not list matanyone.pth. The block below is added on this page. It downloads that repository. It does not replace the release file the CLI default names. This page did not download either file. How to download a Hugging Face model prints pip install -U "huggingface_hub" and hf download.

# Added on this page. The README's CLI weight is the GitHub release file matanyone.pth.
# The Hugging Face repo file list did not include that name.
hf download PeiqingYang/MatAnyone --local-dir ./PeiqingYang-MatAnyone

Inference

The README says each run takes a video and its first-frame segmentation mask. The single-target examples, copied:

python inference_matanyone.py -i inputs/video/test-sample1.mp4 -m inputs/mask/test-sample1.png
python inference_matanyone.py -i inputs/video/test-sample2.mp4 -m inputs/mask/test-sample2.png
python inference_matanyone.py -i inputs/video/test-sample3.mp4 -m inputs/mask/test-sample3.png

The multiple-target examples add --suffix target1 and --suffix target2. The README says the results are saved in the results folder, including the foreground output video and the alpha output video. It says --save_image saves per-frame images, and --max_size downsamples the video if min(w, h) exceeds that value. It says that by default it does not set the limit. In inference_matanyone.py, --output_path defaults to results/, --max_size defaults to -1, and --save_image defaults to false. When suffix is not empty, the script appends it to video_name. It then writes {output_path}/{video_name}_fgr.mp4 and {output_path}/{video_name}_pha.mp4. With --save_image, it also writes png files under {output_path}/{video_name}/pha and {output_path}/{video_name}/fgr.

The Hugging Face example, copied:

from matanyone import InferenceCore
processor = InferenceCore("PeiqingYang/MatAnyone")

foreground_path, alpha_path = processor.process_video(
    input_path = "inputs/video/test-sample1.mp4",
    mask_path = "inputs/mask/test-sample1.png",
    output_path = "outputs"
)

The README says to refer to inference_hf.py for more arguments. This page did not run the script.

Gradio

The README says a Gradio demo can be launched locally. Copied:

cd hugging_face

# install python dependencies
pip3 install -r requirements.txt # FFmpeg required

# launch the demo
python app.py

app.py ends with demo.launch(debug=True). That call does not pass server_name or server_port. The README does not print a port. This page does not assign one. How to use SSH port forwarding on a cloud GPU is how a program on your computer reaches the port the process prints. This page did not start the demo.

When it fails

CUDA out of memory. The README prints no GPU GB figure. The hosted-demo note in app.py does not print one either. If the process raises that error, use how to fix CUDA out of memory on a cloud GPU.

“CUDA error: no kernel image is available for execution on the device” on an RTX 5090. The install is pip install -e . and conda create -n matanyone python=3.8. Those lines do not pin a PyTorch build and do not name compute capability 12.0. The RTX 5090 guide says that card is compute capability 12.0 (sm_120) and that PyTorch 2.7 and later, on a build for CUDA 12.8 or newer, is the line that announced support. This page did not install a torch wheel and did not re-test this package on an RTX 5090. Catalog RTX 5090 and RTX 5090D are 32. That is the catalog number only.

Save the videos, then destroy

Copy results/ before you destroy the instance. The CLI writes {video_name}_fgr.mp4 and {video_name}_pha.mp4 there unless you pass --output_path. The Hugging Face example passes output_path outputs. Save your work before you destroy a cloud GPU is the checklist. The terms say data on local instance storage is permanently deleted when the instance is destroyed.

The pricing page FAQ states the billing rule in these words:

Per-minute options have a 1-minute minimum; unused prepaid minutes are refunded when you destroy the instance. Some configurations use whole-hour billing with a 1-hour minimum; unused time within a charged hour is not refunded on voluntary stop. The billing period, minimum charge and initial prepayment are shown before confirmation. No subscription.

Prices are not copied here.

Frequently asked questions

How much VRAM does the README print?

The MatAnyone README prints no GPU GB figure. app.py’s note about the hosted demo says any input with too big resolution will be resized to 1080p and does not print a GPU GB figure. This page does not mark a catalog row as enough. Which listing you can start is on https://cloudgpu.app/deploy.

Which inference command does the README print?

The single-target example is python inference_matanyone.py -i inputs/video/test-sample1.mp4 -m inputs/mask/test-sample1.png. The Hugging Face example calls InferenceCore with PeiqingYang/MatAnyone and process_video with output_path outputs. The Gradio section says cd hugging_face and python app.py. This page did not run them.

Where are the videos saved?

inference_matanyone.py defaults --output_path to results/. It writes the output path, the video name, and _fgr.mp4, and the same prefix with _pha.mp4. When --suffix is set, the video name gains that suffix. --save_image writes png frames under pha and fgr. The Hugging Face example passes output_path outputs. This page did not run the script.

What license does the file print?

The LICENSE file is titled S-Lab License 1.0 and the copyright line is Copyright 2023 S-Lab. It permits redistribution and use for non-commercial purpose, and it says commercial purpose requires contacting the contributors. The GitHub license field on 2026-11-13 was NOASSERTION. The model API did not set cardData.license. That license text is not a CloudGPU price.

Sources (read 2026-11-13, Asia/Shanghai)

  • pq-yang/MatAnyone README.md (clone, conda install, release URL matanyone.pth, Hugging Face id, inference commands, results folder, Gradio python app.py, MatAnyone 2 link, S-Lab License 1.0 sentence): repository HEAD e5ddc534c1fff9bb9e54cf476095d29071b7cb4f, committed 2026-03-04T15:52:40Z. https://github.com/pq-yang/MatAnyone/blob/main/README.md
  • inference_matanyone.py (--output_path default results/, --ckpt_path default pretrained_models/matanyone.pth, _fgr.mp4 and _pha.mp4, --suffix, --save_image, --max_size default -1): read from that HEAD
  • hugging_face/app.py (demo.launch(debug=True) with no server_port, hosted-demo 1080p note): read from that HEAD
  • LICENSE (S-Lab License 1.0, Copyright 2023 S-Lab, non-commercial grant, commercial-use contact sentence): read from that HEAD. GitHub license field NOASSERTION
  • Hugging Face model API PeiqingYang/MatAnyone (gated false, no cardData.license, files .gitattributes, README.md, config.json, inference_matanyone_api.py, model.safetensors, lastModified 2025-04-08T08:16:03.000Z, sha d3395d72e3baa4508521ab8a6ae9a7d41f873dc4): read 2026-11-13
  • Public GPU memory: https://cloudgpu.app/gpu-prices.json (updated_at 2026-11-13T23:11:30.761Z) and https://cloudgpu.app/v1/public/gpu-catalog (generated_at 2026-11-13T23:11:29.742Z). GET /v1/public/compute-capabilities returned feature flags and no GPU list. The catalog had no MatAnyone template

Cards you can start are on the Deploy page. Prices are on https://cloudgpu.app/pricing and are not repeated here.

Last updated: 2026-11-13 (Asia/Shanghai).