All models

MatteFormer

MatteFormer estimates alpha mattes from an image and trimap using Swin-based blocks with prior-tokens.

Segmentation · 3,175 operations Checked

100%

Showing the top corner; full diagram not loaded yetShowing a small copy; full diagram not loaded yetLarge diagram, not loaded yet

Open SVG

This diagram has 3,175 operations (10 KB) and is drawn when you ask.

Open in a new tab

Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.

At a glance

Parameters
44.8M
Operations
3,175
Framework
PyTorch
Recurrent
No
Published
CVPR 2022
Cited by
93 (as of 24 October 2026)
Authors
GyuTae Park, SungJoon Son, JaeYoung Yoo and others
License
Apache-2.0
Checked
Passed: the trace was replayed operation by operation and matched the model's own output for this input.

Files

The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.

Details
Stable ID
m18354
Graph hash
7692f7e89d5d1aa19ef86c799d750204b9c4f35fc4a5e6209eb3ed6b74dca8fc
Skeleton hash
7a9fdac5c514412d7c90d234daf7283b5ebf605b9f25f3061074cfbfc35615fb
Architecture hash
8c3fb2fd9eefda5f7fb41ab75275633fdb20c77ddcafb7efee8797ca62f903d2
Diagram SHA-256
414fb60853db350407404dfdb06a3948071eafafc6e3cd5038681cc085ba835a
TorchLens version
2.36.0
Renderer
graphviz 2.43.0+pyvips 3.2.0+libvips 8.18.7+render-opts@06c1f0d3
Check
Forward pass replayed in PyTorch

What it is

MatteFormer is a transformer-based image matting model designed to take full advantage of trimap information inside its transformer blocks. Image matting is mainly used to separate a foreground object precisely for image editing and compositing.

Its central element is the prior-token: for each of the three trimap regions (foreground, background and unknown), all tokens belonging to that region are averaged into one token. These prior-tokens act as global priors and take part in the self-attention of each block. The encoder blocks, named PAST (Prior-Attentive Swin Transformer), are based on the Swin Transformer block. Each also has a prior-memory that accumulates prior-tokens from previous blocks and passes them to the next block.

The network takes a trimap and an RGB image together, so it has 6 input channels. The encoder is initialized with the Tiny model of Swin Transformer pretrained on ImageNet. The decoder outputs three alpha mattes from different intermediate layers, at 1/8, 1/4 and 1/1 of the input resolution. The paper evaluates MatteFormer on two image matting datasets, Composition-1k and Distinctions-646.

Key idea. MatteFormer introduces prior-tokens, global representations of each trimap region that participate in the self-attention of every encoder block.

  • matteformer
  • image matting
  • trimap matting
  • alpha matte
  • prior-token
  • prior-tokens
  • transformer matting
  • past block
  • natural image matting

AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.

Cite the paper

@misc{park2022matteformertransformerbasedimagematting,
      title={MatteFormer: Transformer-Based Image Matting via Prior-Tokens}, 
      author={GyuTae Park and SungJoon Son and JaeYoung Yoo and SeHo Kim and Nojun Kwak},
      year={2022},
      eprint={2203.15662},
      archivePrefix={arXiv},
      primaryClass={cs.CV},
      url={https://arxiv.org/abs/2203.15662}, 
}