Matte Anything makes alpha mattes from a box and a few clicks

Matte Anything is an interactive image matting model: from a bounding box and a few clicks it predicts an alpha matte, the transparency of every pixel of an object, so hair and transparent parts keep their soft edges. In Supervisely it runs behind the Smart Tool of the image matting labeling interface and needs no training.

A woman with flying curly hair matted out of her background, every strand kept, on the Serve Matte Anything poster
Labels
  • Alpha masks from a bounding box and points
Apps
Serve

Apps in the Supervisely Ecosystem

Every model in Supervisely comes as a Supervisely App: a module from the Ecosystem that plugs into the platform and runs on your own GPU, with no code to install. A Serve App puts the model behind the labeling tools, and where the model can be trained, a Train App fits it to your labeled project. All Apps work on the same projects, so you add a model, update it or swap it for another without changing anything else.

Matting without drawing a trimap

A segmentation mask says whether a pixel belongs to an object. An alpha matte says how much: a value between fully transparent and fully opaque, which is what a strand of hair, a veil or a glass needs to be cut out cleanly. Matting models usually need a trimap as a hint, a map that marks sure foreground, sure background and an unknown band between them, and drawing trimaps by hand is slow.

"Matte Anything: Interactive Natural Image Matting with Segment Anything Models", by Jingfeng Yao, Xinggang Wang, Lang Ye and Wenyu Liu of Huazhong University of Science and Technology, builds the trimap automatically. Segment Anything predicts the contour of the object from simple user input, an open-vocabulary detector finds transparent objects, and a pretrained matting model turns the image and the pseudo trimap into an alpha matte. None of the parts is trained again. Against earlier matting methods with simple guidance, the authors report 58.3% lower MSE and 40.6% lower SAD.

Three models in one app

StageWhat it doesCheckpoints in the app
Segment AnythingSegments the object from your bounding box and clicksViT-B, ViT-L or ViT-H SAM (ViT-H by default)
TrimapErodes the mask for sure foreground and dilates it for the unknown bandErode and dilate kernel sizes from 1 to 30 (20 by default)
Grounding DINO, optionalFinds transparent objects from a text prompt and marks their area as unknown, so the matting model decides their transparencyGroundingDINO-T or GroundingDINO-B
MattingPredicts the alpha matte from the image and the trimapViTMatte-S or -B trained on Composition-1k or Distinctions-646, or DiffMatte ViT-S 1024 or ViT-B (ViTMatte-B, Distinctions-646, by default)

ViTMatte, earlier work of the same HUST lab, adapts a plain vision transformer to matting with a convolution neck and a light detail capture module. DiffMatte, which the Supervisely app adds to the original pipeline, refines the matte with a diffusion process. The default Grounding DINO prompt is "glass, lens, crystal, diamond, bubble, bulb, web, grid".

The app requires a GPU. To save GPU memory, switch on Resize input images: the longer side of each image is scaled to a resolution you choose, from 1000 to 1920 pixels (1300 by default), which helps most with the heavier DiffMatte models.

Drawing alpha masks in the labeling tool

  1. Run Serve Matte Anything, choose the Segment Anything and matting checkpoints, tick Grounding DINO if your images have transparent objects, and press Serve.
  2. In the settings of your images project, open Visuals and select image matting as the labeling interface.
  3. Open an image, select the Smart Tool and create a class of the Alpha mask shape.
  4. Draw a bounding box around the object. Add positive and negative points if the mask needs correcting.

The erode and dilate settings control the soft fringe around the object. They are not pixels or percent but the size of the square kernel used for erosion and dilation. Use small values for simple contours, such as an apple, and larger ones for complex outlines, such as a person with curly hair; the app README shows clean masks with both set to 1 on its example images.

When to use Matte Anything

Use it when the soft edge is the point: people and animals to cut out with their hair, transparent objects such as glass, bubbles or light bulbs, or training data for background removal. When a hard mask is enough, a click model is quicker: SAM 2.1 or RITM in the ordinary Smart Tool, or InSPyReNet and IS-Net to turn whole projects of bounding boxes into masks.

The app works on images only, not video, and has no training counterpart. Its masks are drafts like any model-assisted labeling output: check the fringe before you export.

Frequently asked questions.

What is alpha matting, and how is it different from segmentation?

Segmentation gives each pixel a yes or no: it belongs to the object or it does not. Matting gives each pixel an alpha value between transparent and opaque, so partly transparent edges such as hair or glass blend correctly when the object is cut out.

Does Matte Anything need a trimap?

No. It makes one from the Segment Anything mask by erosion and dilation, optionally corrects it with Grounding DINO for transparent objects, and passes it to ViTMatte or DiffMatte. You only draw a bounding box and, if needed, a few points.

Can I use Matte Anything on video or train it in Supervisely?

No. Serve Matte Anything works on images, needs a GPU and is serve-only. It runs in the Smart Tool of the image matting labeling interface.

Train and serve models on your own data.

Label a project in a free account, train a model on it from the browser and deploy it on your own GPU. Or book a demo to run Supervisely on your servers.