--- license: cc-by-nc-sa-4.0 pipeline_tag: image-segmentation --- # SAM2Matting: Generalized Image and Video Matting This repository contains the official checkpoints for **SAM2Matting**, a generalized matting framework that decouples high-level tracking from dedicated low-level matting to support robust image and video matting of any open-world targets. [📄 Paper](https://huggingface.co/papers/2606.27339) | [🏠 Project Page](https://henghuiding.com/SAM2Matting/) | [💻 GitHub](https://github.com/FudanCVL/SAM2Matting)

SAM2Matting qualitative results

## Highlights - **Decoupled design**: Combines a VOS tracker for temporal consistency with ROI Detection & Progressive Matting for fine details. - **Image-only training, video SOTA**: Strong zero-shot video matting performance without requiring expensive video matting datasets. - **Diverse prompts**: Supports masks, points, boxes, and text prompts. - **Open-world generalization**: Robust matting for humans, animals, anime, translucent objects, and rapid-motion scenes. ## Installation To run SAM2Matting locally, clone the repository and install the dependencies: ```bash # clone the repo and enter directory git clone https://github.com/FudanCVL/SAM2Matting.git cd SAM2Matting # create and activate conda environment conda create -n sam2matting python=3.10 -y conda activate sam2matting # install required packages pip install -r requirements.txt ``` ## Quick Start The codebase provides separate inference scripts for image and video matting. To run video matting on a sample with SAM2-based trackers, run: ```bash python inference_video_sam2.py --save_mp4 ``` To enable compilation for faster execution (though the first run may be slower): ```bash python inference_video_sam2.py --save_mp4 --compiled ``` ## Citation If you find SAM2Matting useful in your research, please consider citing the work: ```bibtex @inproceedings{SAM2Matting, title={{SAM2Matting}: Generalized Image and Video Matting}, author={Shen, Ruiqi and Jie, Guangquan and Liu, Chang and Ding, Henghui}, booktitle={European Conference on Computer Vision (ECCV)}, year={2026} } ```