SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2203.15662 · CVPR · 2022

MatteFormer: Transformer-Based Image Matting via Prior-Tokens

Jaeyoung Yoo, Nojun Kwak, Seho Kim, Gyutae Park, Sungjoon Son

arXiv · PDF · Open in the Atlas

Code that ran

5 of 8 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (3 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 3 have no contract verdict; 2 failures of our instrument; 3 no recorded run), measured 2026-11-22; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2203.15662.json · badge: /api/ran/2203.15662.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
webtoon/matteformer marked official in Papers with Code
Papers with Code archive
4 ran · 3 no recorded run
copy not recorded community
not in the paper's declared repositories
1 ran · 0 no recorded run
FunctionStatusWhere it lives
PAWSA Ran
ran on a synthesized input · constructed an object; no result was computed
webtoon/matteformer/networks/encoders/MatteFormer.py
code served (permissive licence) · get_code("be3f1570f7ddf136")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, PAWSA: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
import torch.nn.functional as F
from timm.models.layers import DropPath, to_2tuple, trunc_normal_

torch.manual_seed(0)

# Parameters for PAWSA.__init__
dim = 4
window_size = (2, 2)
num_heads = 2
qkv_bias = True
qk_scale = None
attn_drop = 0.0
proj_drop = 0.0
use_prior = True
num_priorset = 1

# Build x tensor: (B_, N, C) where B_=2, N=4, C=4
x = torch.randn(2, 4, 4)

# Build mask: shape (nW, N, N) where nW=1, N=4
# This is optional but we'll include it
mask = torch.zeros(1, 4, 4)

# Build _inp_shape: (B, H, W, C) where B=2, H=4, W=4, C=4
_inp_shape = (2, 4, 4, 4)

# Build prior_bins: list of dicts with 'unknown', 'fg', 'bg' keys
# Each prior tensor should have shape (B, 1, C) = (2, 1, 4)
prior_bins = [
    {
        'unknown': torch.randn(2, 1, 4),
        'fg': torch.randn(2, 1, 4),
        'bg': torch.randn(2, 1, 4),
    }
]

ARGS = {
    'dim': dim,
    'window_size': window_size,
    'num_heads': num_heads,
    'qkv_bias': qkv_bias,
    'qk_scale': qk_scale,
    'attn_drop': attn_drop,
    'proj_drop': proj_drop,
    'use_prior': use_prior,
    'num_priorset': num_priorset,
}

# For forward() call, we'd use:
# pawsa = PAWSA(**ARGS)
# output = pawsa(x, mask=mask, _inp_shape=_inp_shape, prior_bins=prior_bins)
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
timm, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type PAWSA — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a PAWSA output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
PatchEmbed Ran
ran on a synthesized input · constructed an object; no result was computed
webtoon/matteformer/networks/encoders/MatteFormer.py
code served (permissive licence) · get_code("129c03641741d697")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, PatchEmbed: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
from timm.models.layers import to_2tuple

torch.manual_seed(0)

# Create a simple normalization layer to use as norm_layer
norm_layer = nn.LayerNorm

ARGS = {
    "patch_size": 4,
    "in_chans": 3,
    "embed_dim": 96,
    "norm_layer": norm_layer,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
timm, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type PatchEmbed — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a PatchEmbed output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
SpectralNorm Ran
ran on a synthesized input · constructed an object; no result was computed
webtoon/matteformer/networks/encoders/MatteFormer.py
code served (permissive licence) · get_code("e489b0e620c2827e")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, SpectralNorm: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

# Create a simple module with a weight parameter
# SpectralNorm wraps modules and accesses their weight attribute
class SimpleLinear(nn.Module):
    def __init__(self, in_features, out_features):
        super(SimpleLinear, self).__init__()
        self.weight = nn.Parameter(torch.randn(out_features, in_features))
        self.bias = nn.Parameter(torch.randn(out_features))
    
    def forward(self, x):
        return torch.nn.functional.linear(x, self.weight, self.bias)

# Create module instance
module = SimpleLinear(in_features=3, out_features=4)

ARGS = {
    'module': module,
    'name': 'weight',
    'power_iterations': 1
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type SpectralNorm — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a SpectralNorm output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
l2normalize Ran
ran; our contract draft was wrong, not the code
this paper's copy was not recorded; identical code first harvested from xxxliu95/RA_FA_Cardiac
pointer only; the stored copy get_code serves, from xxxliu95/RA_FA_Cardiac, is pointer only (licence: NONE) · get_code("bedff51745d2cf84")
How it ran

The body of this sample is withheld: this paper's copy of the code was not recorded (its link names no repository or source path), so no licence was read for it. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

window_partition Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
webtoon/matteformer/networks/encoders/MatteFormer.py
code served (permissive licence) · get_code("93033d45b73cce18")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

# Construct x: (B, H, W, C)
# B=2, H=8, W=8, C=4
B, H, W, C = 2, 8, 8, 4
x = torch.randn(B, H, W, C)

# window_size must divide H and W evenly
window_size = 4

# priors: list of dicts, each containing 'unknown', 'fg', 'bg' tensors
# These need to be 2D tensors (num_windows*B, something)
num_windows = (H // window_size) * (W // window_size)
num_windows_total = num_windows * B

priors = [
    {
        'unknown': torch.randn(num_windows_total, 3),
        'fg': torch.randn(num_windows_total, 3),
        'bg': torch.randn(num_windows_total, 3),
    }
]

ARGS = {
    'x': x,
    'window_size': window_size,
    'priors': priors,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
BasicLayer Not yet run
unverified (harvested, no recorded run)
webtoon/matteformer/networks/encoders/MatteFormer.py
code served (permissive licence) · get_code("0ff17c6f3aabd80e")
How it ran

no invocation recorded.

MatteFormer Not yet run
unverified (harvested, no recorded run)
webtoon/matteformer/networks/encoders/MatteFormer.py
code served (permissive licence) · get_code("af540816b46af375")
How it ran

no invocation recorded.

PASTBlock Not yet run
unverified (harvested, no recorded run)
webtoon/matteformer/networks/encoders/MatteFormer.py
code served (permissive licence) · get_code("42d0760afaf8ab98")
How it ran

no invocation recorded.

Also present in other papers' code

Of 8 samples lifted from this paper's linked repositories, 8 carry a function identity and 0 do not. Of the 8 distinct functions with an identity, 1 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 0 the same month, 1 later) and 7 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
l2normalize
brick of this paper's assembly: helper
27 other papers
14 dated earlier, 11 later, 2 same year, order not determinable · 2 only as an assembly brick
1703.09452 (2017-03)
SEGAN: Speech Enhancement Generative Adversarial Network
1802.05957 (2018-02)
Spectral Normalization for Generative Adversarial Networks
1806.03589 (2018-06)
Free-Form Image Inpainting with Gated Convolution
and 24 more not named here

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-22.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

In this paper, we propose a transformer-based image matting model called MatteFormer, which takes full advantage of trimap information in the transformer block. Our method first introduces a prior-token which is a global representation of each trimap region (e.g. foreground, background and unknown). These prior-tokens are used as global priors and participate in the self-attention mechanism of each block. Each stage of the encoder is composed of PAST (Prior-Attentive Swin Transformer) block, which is based on the Swin Transformer block, but differs in a couple of aspects: 1) It has PA-WSA (Prior-Attentive Window Self-Attention) layer, performing self-attention not only with spatial-tokens but also with prior-tokens. 2) It has prior-memory which saves prior-tokens accumulatively from the previous blocks and transfers them to the next block. We evaluate our MatteFormer on the commonly used image matting datasets: Composition-1k and Distinctions-646. Experiment results show that our proposed method achieves state-of-the-art performance with a large margin. Our codes are available at https://github.com/ webtoon/matteformer.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2203.15662")
get_code_for_paper("2203.15662")
have("2203.15662")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2203.15662.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2203.15662.svg)](https://syntology.ai/paper/2203.15662)

Connect an agent — have() is free.