wikillm

Paper · 2024-02-23 · cs.CV

MambaIR: A Simple Baseline for Image Restoration with State-Space Model

Image restoration backbone that replaces window attention with a four-direction Mamba scan (VSSM), adding a conv bottleneck with channel attention and learnable skip scales in each block. Author-reported: beats SwinIR on classic SR (e.g. +0.41 dB Manga109 x2), lightweight SR and Gaussian color denoising (+0.48 dB Urban100, sigma 50); close to Restormer on real denoising.

State-space model (SSM)Image super-resolutionImage denoisingChannel attentionimage-restorationsuper-resolutiondenoisingmambastate-space-modellow-level-vision

arXivPDFCodeMarkdown15 min read

AI-compiled by claude-opus-5-5 on 2026-10-18, not yet reviewed by a human. Every claim cites its source; check it when a detail matters.

In plain words

Image restoration means taking a damaged picture (too small, noisy, blurry) and producing a clean one. A good restorer looks at many pixels when it rebuilds each output pixel. Convolutional networks only look at a small neighbourhood. Transformers could look at the whole image, but comparing every pixel with every other pixel gets too expensive, so restoration transformers such as SwinIR only attend inside small windows.

MambaIR swaps the attention for Mamba, a "state-space model". Think of it as a reader that walks along a sequence once and keeps a running memory, so the cost grows linearly with the number of pixels while information can still travel across the whole image. Because an image is 2D, the feature map is unrolled into four 1D sequences (row by row, column by column, and both backwards), each one is scanned, and the results are added.

Unrolling an image puts some neighbouring pixels far apart in the sequence, and Mamba's large memory leaves many channels unused. The authors patch both problems with plain tools: a small convolution after the scan to bring back local detail, and a channel-attention gate that reweights channels. On super-resolution and denoising benchmarks the result matches or beats SwinIR at similar compute, by the authors' own numbers.

TL;DR

MambaIR is a SwinIR-shaped restoration network (shallow 3×3 conv → stacked residual groups → reconstruction head) whose core block, the RSSB, is LN → VSSM (4-direction selective scan) + scaled skip followed by LN → conv bottleneck → channel attention + scaled skip. It targets classic, lightweight and real-world SR, Gaussian color denoising, real denoising and JPEG artifact removal. Author-reported gains over SwinIR are up to 0.45 dB on SR at similar cost. The paper leaves most architecture sizes unstated; they are only in the official code (Apache-2.0), which also differs from the paper in a few training details (see Paper vs code).

Problem

Restoration quality tends to improve with receptive field, but CNN backbones have a small effective receptive field, and Transformers either pay quadratic cost in the number of pixels or restrict attention to shifted windows, which loses the global receptive field §1 fig. 1. Mamba offers linear-cost long-range modelling, but it was built for causal 1D sequences: flattening an image separates spatially adjacent pixels ("local pixel forgetting"), and the large hidden state leads to many inactive channels ("channel redundancy") §1 §3.3 fig. 3.

Method

Three stages §3.2 fig. 2:

  1. Shallow features: a 3×3 conv maps I_LQ ∈ R^{H×W×3} to F_S ∈ R^{H×W×C} §3.2.
  2. Deep features: several Residual State-Space Groups (RSSGs), each a stack of RSSBs followed by a conv; then F_R = F_D^L + F_S §3.2. In code each RSSG also has its own residual connection, and a LayerNorm plus a 3×3 conv follow the last group mambair_arch.py mambair_arch.py.
  3. Reconstruction: produces I_HQ from F_R §3.2. In code: conv + LeakyReLU + pixel-shuffle upsampler + conv for classic SR; a single conv + pixel shuffle for lightweight SR; and for denoising a conv whose output is added to the input image mambair_arch.py mambair_arch.py.

SSM background §3.1. Continuous system eq. 1:

h'(t) = \mathbf{A}h(t) + \mathbf{B}x(t), \quad y(t) = \mathbf{C}h(t) + \mathbf{D}x(t)

with state size N, A ∈ R^{N×N}, B ∈ R^{N×1}, C ∈ R^{1×N}, D ∈ R. Zero-order-hold discretization as printed in the paper eq. 2:

\overline{\mathbf{A}} = \exp(\Delta\mathbf{A}), \quad \overline{\mathbf{B}} = (\Delta\mathbf{A})^{-1}(\exp(\mathbf{A}) - \mathbf{I})\cdot\Delta\mathbf{B}

Recurrent form eq. 3:

h_k = \overline{\mathbf{A}}h_{k-1} + \overline{\mathbf{B}}x_k, \quad y_k = \mathbf{C}h_k + \mathbf{D}x_k

Equivalent convolutional form over a length-L sequence eq. 4:

\overline{\mathbf{K}} \triangleq (\mathbf{C}\overline{\mathbf{B}}, \mathbf{C}\overline{\mathbf{A}}\overline{\mathbf{B}}, \dots, \mathbf{C}\overline{\mathbf{A}}^{L-1}\overline{\mathbf{B}}), \quad \mathbf{y} = \mathbf{x} \circledast \overline{\mathbf{K}}

Mamba makes B̄, C and Δ input-dependent §3.1.

Residual State-Space Block (RSSB) §3.3 fig. 2a, with learnable per-channel scales s, s' ∈ R^C:

Z^l = \mathrm{VSSM}(\mathrm{LN}(F_D^l)) + s \cdot F_D^l eq. 5

F_D^{l+1} = \mathrm{CA}(\mathrm{Conv}(\mathrm{LN}(Z^l))) + s' \cdot Z^l eq. 6

Conv is a bottleneck that compresses channels by a factor γ to C/γ and expands back §3.3. CA is squeeze-and-excitation channel attention §3.3.

Vision State-Space Module (VSSM) §3.4 fig. 2b, following VMamba, with channel expansion factor λ eq. 7:

X_1 = \mathrm{LN}(\text{2D-SSM}(\mathrm{SiLU}(\mathrm{DWConv}(\mathrm{Linear}(X))))) X_2 = \mathrm{SiLU}(\mathrm{Linear}(X)), \quad X_{out} = \mathrm{Linear}(X_1 \odot X_2)

2D Selective Scan (2D-SSM) §3.5 fig. 2c: flatten the feature map into four sequences, run the selective scan on each, sum the four outputs and reshape back to 2D.

Pseudocode
# MambaIR forward pass (classic SR head), shapes for one image
# Input: low_quality (B, 3, H, W); output: (B, 3, s*H, s*W)

def mambair(low_quality):
    # subtract the fixed DIV2K RGB mean
    # [code: basicsr/archs/mambair_arch.py#L541-L545]
    x = low_quality - rgb_mean
    # shallow 3x3 conv to C channels  [§3.2]
    shallow = conv3x3(x, out=C)                      # (B, C, H, W)
    # tokens = pixels, LayerNorm after embedding
    # [code: basicsr/archs/mambair_arch.py#L560-L565]
    tokens = layer_norm(flatten_hw(shallow))         # (B, H*W, C)
    for group in groups:
        group_input = tokens
        for block in group.blocks:
            tokens = rssb(block, tokens, H, W)
        # per-group conv and residual
        # [§3.2] [code: basicsr/archs/mambair_arch.py#L765-L766]
        grid = unflatten(tokens)
        tokens = flatten_hw(group.conv3x3(grid)) + group_input
    # final norm and conv, then the long skip F_R = F_D + F_S  [§3.2]
    deep = conv3x3(unflatten(layer_norm(tokens)))
    features = deep + shallow
    # conv + LeakyReLU, pixel-shuffle upsampling, conv to RGB
    # [code: basicsr/archs/mambair_arch.py#L615-L620]
    out = conv_last(upsample(leaky_relu(conv3x3(features, out=64))))
    return out + rgb_mean

def rssb(block, tokens, H, W):
    x = reshape(tokens, (B, H, W, C))
    # global branch with scaled skip  [eq. 5]
    z = vssm(block, layer_norm(x)) + block.s * x
    # local branch: conv bottleneck then channel attention  [eq. 6]
    local = channel_attention(conv_bottleneck(layer_norm(z)))
    return flatten(local + block.s_prime * z)

def vssm(block, x):                                  # x (B, H, W, C)
    # one linear gives both branches, each lambda*C wide
    # [eq. 7] [code: basicsr/archs/mambair_arch.py#L374-L375]
    branch_ssm, gate = split(linear(x, out=2 * lam * C))
    # depthwise 3x3 conv + SiLU
    # [eq. 7] [code: basicsr/archs/mambair_arch.py#L377-L378]
    branch_ssm = silu(depthwise_conv3x3(branch_ssm))
    # four-direction selective scan, outputs summed  [§3.5]
    y = sum(selective_scan_2d(branch_ssm))
    # LayerNorm, gate with SiLU, project back to C  [eq. 7]
    return linear(layer_norm(y) * silu(gate), out=C)

def selective_scan_2d(feature):                      # (B, D, H, W)
    # row-major, column-major, and both reversed
    # [code: basicsr/archs/mambair_arch.py#L343-L344]
    rows = flatten_row_major(feature)
    cols = flatten_column_major(feature)
    sequences = [rows, cols, reverse(rows), reverse(cols)]
    # separate dt/B/C projections, A and D per direction
    # [code: basicsr/archs/mambair_arch.py#L346-L362]
    outputs = []
    for direction, sequence in enumerate(sequences):
        outputs.append(mamba_scan(sequence, params[direction]))
    # undo reversal and transpose so all four align row-major
    # [code: basicsr/archs/mambair_arch.py#L365-L369]
    return realign(outputs)

The bottleneck and channel attention in the classic and denoising models are conv3x3(C→C/3) → GELU → conv3x3(C/3→C) → CA, with CA = avgpool → 1×1 conv (C→C/30) → ReLU → 1×1 conv → sigmoid → multiply mambair_arch.py mambair_arch.py.

Loss §3.6: L1 for SR eq. 8; Charbonnier with ε = 1e-3 for denoising eq. 9:

\mathcal{L} = \|I_{HQ} - I_{LQ}\|_1 \qquad \mathcal{L} = \sqrt{\|I_{HQ} - I_{LQ}\|^2 + \epsilon^2}

(As printed; the target should be the ground truth, see Pitfalls.)

Hyperparameters

Paper-stated values:

NameValueWhereNotes
optimizerAdam, β1 = 0.9, β2 = 0.999§4.1code uses β2 = 0.99
initial learning rate2e-4, halved at milestones§4.1milestones not stated in paper
batch size32 (SR), 16 (denoising)§4.1
training patch64×64 (SR), 128×128 (denoising)§4.1for SR, LR size per code (see Paper vs code)
augmentationhorizontal flip, rotations 90/180/270°§4.1
×3, ×4 SR initfrom ×2 weights; LR and iterations halved§4.1
Charbonnier ε1e-3§3.6code applies it unsquared
hardware8× NVIDIA V100§4.1
C, number of RSSGs/RSSBs, N, λ, γnot statedonly in code
total iterations, schedulenot statedonly in code
real denoisingprogressive training following Restormer§4.4details not stated
real-world SRtraining protocol of HAT§4.3details not stated; no config in repo
test-timeMambaIR+ = self-ensemble§4.1

From the official code (not stated in the paper):

NameClassic SRLightweight SRColor denoisingWhere
embed dim C18060180train_MambaIR_SR_x2.yml train_MambaIR_lightSR_x2.yml train_MambaIR_ColorDN_level15.yml
RSSGs × RSSBs6 × 64 × 66 × 6same
state size N (d_state)161016same
expansion λ (mlp_ratio)21.21.2same
bottleneck γ323mambair_arch.py
CA squeeze factor303030mambair_arch.py
depthwise conv kernel333mambair_arch.py
Δ rankceil(C/16)ceil(C/16)ceil(C/16)mambair_arch.py
Δ init range[0.001, 0.1], floor 1e-4samesamemambair_arch.py
A initS4D-real: A = −[1..N] per channel (stored as log)samesamemambair_arch.py
D init, skip scales s, s' initonessamesamemambair_arch.py mambair_arch.py
stochastic depthlinear 0 → 0.1samesamemambair_arch.py mambair_arch.py
upsamplerpixelshufflepixelshuffledirectnoneconfigs above
GPUs × batch/GPU8 × 42 × 168 × 2configs above
HR crop (gt_size)128 (×2), 192 (×3, ×4)128 (×2), 192 (×3, ×4)128train_MambaIR_SR_x4.yml
LR, iterations (×2 / σ15)2e-4, 500k, halve at 250k/400k/450k/475k2e-4, 500k, same2e-4, 1.6M, halve at 800k/1.2M/1.4M/1.5Mtrain_MambaIR_SR_x2.yml train_MambaIR_ColorDN_level15.yml
LR, iterations (×3, ×4 / σ25, σ50)1e-4, 250k, halve at 125k/200k/225k/237.5k2e-4, 500k (not halved)1e-4, 800k, halve at 400k/600k/700k/750ktrain_MambaIR_SR_x4.yml train_MambaIR_lightSR_x4.yml train_MambaIR_ColorDN_level50.yml
init for ×3/×4 or σ25/σ50×2 model×2 modelσ15 modeltrain_MambaIR_SR_x4.yml train_MambaIR_ColorDN_level50.yml
weight decay, warmup0, none0, none0, noneconfigs above

Results

Author-reported. PSNR/SSIM on the Y channel of YCbCr §4.1. Classic SR trained on DIV2K + Flickr2K; lightweight SR on DIV2K only; Gaussian color denoising on DIV2K + Flickr2K + BSD500 + WED; real denoising on 320 SIDD images §4.1.

Ablations (setting not stated; the "baseline" row equals the ×2 classic SR model in tab. 3) tab. 1 tab. 2:

RSSB variant tab. 1Set5Set14Urban100
(1) remove Conv38.4834.5434.04
(2) remove Conv + CA38.5534.6434.06
(3) replace with MLP38.5534.6834.22
Scan mode tab. 2Set5Set14Urban100
one-direction (TL→BR)38.5334.6334.06
two-direction (TL→BR, BR→TL)38.5634.6033.96
baseline (four directions)38.5734.6734.15

Classic SR (PSNR / SSIM) tab. 3:

MethodScaleSet5Set14BSDS100Urban100Manga109
EDSR×238.11 / 0.960233.92 / 0.919532.32 / 0.901332.93 / 0.935139.10 / 0.9773
RCAN×238.27 / 0.961434.12 / 0.921632.41 / 0.902733.34 / 0.938439.44 / 0.9786
SAN×238.31 / 0.962034.07 / 0.921332.42 / 0.902833.10 / 0.937039.32 / 0.9792
HAN×238.27 / 0.961434.16 / 0.921732.41 / 0.902733.35 / 0.938539.46 / 0.9785
IGNN×238.24 / 0.961334.07 / 0.921732.41 / 0.902533.23 / 0.938339.35 / 0.9786
CSNLN×238.28 / 0.961634.12 / 0.922332.40 / 0.902433.25 / 0.938639.37 / 0.9785
NLSA×238.34 / 0.961834.08 / 0.923132.43 / 0.902733.42 / 0.939439.59 / 0.9789
ELAN×238.36 / 0.962034.20 / 0.922832.45 / 0.903033.44 / 0.939139.62 / 0.9793
IPT×238.37 / -34.43 / -32.48 / -33.76 / --
SwinIR×238.42 / 0.962334.46 / 0.925032.53 / 0.904133.81 / 0.942739.92 / 0.9797
SRFormer×238.51 / 0.962734.44 / 0.925332.57 / 0.904634.09 / 0.944940.07 / 0.9802
MambaIR×238.57 / 0.962734.67 / 0.926132.58 / 0.904834.15 / 0.944640.28 / 0.9806
MambaIR+×238.60 / 0.962834.69 / 0.926032.60 / 0.904834.17 / 0.944340.33 / 0.9806
EDSR×334.65 / 0.928030.52 / 0.846229.25 / 0.809328.80 / 0.865334.17 / 0.9476
RCAN×334.74 / 0.929930.65 / 0.848229.32 / 0.811129.09 / 0.870234.44 / 0.9499
SAN×334.75 / 0.930030.59 / 0.847629.33 / 0.811228.93 / 0.867134.30 / 0.9494
HAN×334.75 / 0.929930.67 / 0.848329.32 / 0.811029.10 / 0.870534.48 / 0.9500
IGNN×334.72 / 0.929830.66 / 0.848429.31 / 0.810529.03 / 0.869634.39 / 0.9496
CSNLN×334.74 / 0.930030.66 / 0.848229.33 / 0.810529.13 / 0.871234.45 / 0.9502
NLSA×334.85 / 0.930630.70 / 0.848529.34 / 0.811729.25 / 0.872634.57 / 0.9508
ELAN×334.90 / 0.931330.80 / 0.850429.38 / 0.812429.32 / 0.874534.73 / 0.9517
IPT×334.81 / -30.85 / -29.38 / -29.49 / --
SwinIR×334.97 / 0.931830.93 / 0.853429.46 / 0.814529.75 / 0.882635.12 / 0.9537
SRFormer×335.02 / 0.932330.94 / 0.854029.48 / 0.815630.04 / 0.886535.26 / 0.9543
MambaIR×335.08 / 0.932330.99 / 0.853629.51 / 0.815729.93 / 0.884135.43 / 0.9546
MambaIR+×335.13 / 0.932631.06 / 0.854129.53 / 0.816229.98 / 0.883835.55 / 0.9549
EDSR×432.46 / 0.896828.80 / 0.787627.71 / 0.742026.64 / 0.803331.02 / 0.9148
RCAN×432.63 / 0.900228.87 / 0.788927.77 / 0.743626.82 / 0.808731.22 / 0.9173
SAN×432.64 / 0.900328.92 / 0.788827.78 / 0.743626.79 / 0.806831.18 / 0.9169
HAN×432.64 / 0.900228.90 / 0.789027.80 / 0.744226.85 / 0.809431.42 / 0.9177
IGNN×432.57 / 0.899828.85 / 0.789127.77 / 0.743426.84 / 0.809031.28 / 0.9182
CSNLN×432.68 / 0.900428.95 / 0.788827.80 / 0.743927.22 / 0.816831.43 / 0.9201
NLSA×432.59 / 0.900028.87 / 0.789127.78 / 0.744426.96 / 0.810931.27 / 0.9184
ELAN×432.75 / 0.902228.96 / 0.791427.83 / 0.745927.13 / 0.816731.68 / 0.9226
IPT×432.64 / -29.01 / -27.82 / -27.26 / --
SwinIR×432.92 / 0.904429.09 / 0.795027.92 / 0.748927.45 / 0.825432.03 / 0.9260
SRFormer×432.93 / 0.904129.08 / 0.795327.94 / 0.750227.68 / 0.831132.21 / 0.9271
MambaIR×433.03 / 0.904629.20 / 0.796127.98 / 0.750327.68 / 0.828732.32 / 0.9272
MambaIR+×433.13 / 0.905429.25 / 0.797128.01 / 0.751027.80 / 0.830332.48 / 0.9281

Lightweight SR (MACs for a 1280×720 output) tab. 4:

MethodScale#paramMACsSet5Set14BSDS100Urban100Manga109
CARN×21,592K222.8G37.76 / 0.959033.52 / 0.916632.09 / 0.897831.92 / 0.925638.36 / 0.9765
IMDN×2694K158.8G38.00 / 0.960533.63 / 0.917732.19 / 0.899632.17 / 0.928338.88 / 0.9774
LAPAR-A×2548K171.0G38.01 / 0.960533.62 / 0.918332.19 / 0.899932.10 / 0.928338.67 / 0.9772
LatticeNet×2756K169.5G38.13 / 0.961033.78 / 0.919332.25 / 0.900532.43 / 0.9302-
SwinIR-light×2910K122.2G38.14 / 0.961133.86 / 0.920632.31 / 0.901232.76 / 0.934039.12 / 0.9783
MambaIR-light×2905K167.1G38.13 / 0.961033.95 / 0.920832.31 / 0.901332.85 / 0.934939.20 / 0.9782
CARN×31,592K118.8G34.29 / 0.925530.29 / 0.840729.06 / 0.803428.06 / 0.849333.50 / 0.9440
IMDN×3703K71.5G34.36 / 0.927030.32 / 0.841729.09 / 0.804628.17 / 0.851933.61 / 0.9445
LAPAR-A×3544K114.0G34.36 / 0.926730.34 / 0.842129.11 / 0.805428.15 / 0.852333.51 / 0.9441
LatticeNet×3765K76.3G34.53 / 0.928130.39 / 0.842429.15 / 0.805928.33 / 0.8538-
SwinIR-light×3918K55.4G34.62 / 0.928930.54 / 0.846329.20 / 0.808228.66 / 0.862433.98 / 0.9478
MambaIR-light×3913K74.5G34.63 / 0.928830.54 / 0.845929.23 / 0.808428.70 / 0.863134.12 / 0.9479
CARN×41,592K90.9G32.13 / 0.893728.60 / 0.780627.58 / 0.734926.07 / 0.783730.47 / 0.9084
IMDN×4715K40.9G32.21 / 0.894828.58 / 0.781127.56 / 0.735326.04 / 0.783830.45 / 0.9075
LAPAR-A×4659K94.0G32.15 / 0.894428.61 / 0.781827.61 / 0.736626.14 / 0.787130.42 / 0.9074
LatticeNet×4777K43.6G32.30 / 0.896228.68 / 0.783027.62 / 0.736726.25 / 0.7873-
SwinIR-light×4930K31.8G32.44 / 0.897628.77 / 0.785827.69 / 0.740626.47 / 0.798030.92 / 0.9151
MambaIR-light×4924K42.3G32.42 / 0.897728.74 / 0.784727.68 / 0.740026.52 / 0.798330.94 / 0.9135

Gaussian color denoising (PSNR) tab. 5:

MethodBSD68 σ15/25/50Kodak24 σ15/25/50McMaster σ15/25/50Urban100 σ15/25/50
IRCNN33.86 / 31.16 / 27.8634.69 / 32.18 / 28.9334.58 / 32.18 / 28.9133.78 / 31.20 / 27.70
FFDNet33.87 / 31.21 / 27.9634.63 / 32.13 / 28.9834.66 / 32.35 / 29.1833.83 / 31.40 / 28.05
DnCNN33.90 / 31.24 / 27.9534.60 / 32.14 / 28.9533.45 / 31.52 / 28.6232.98 / 30.81 / 27.59
DRUNet34.30 / 31.69 / 28.5135.31 / 32.89 / 29.8635.40 / 33.14 / 30.0834.81 / 32.60 / 29.61
SwinIR34.42 / 31.78 / 28.5635.34 / 32.89 / 29.7935.61 / 33.20 / 30.2235.13 / 32.90 / 29.82
Restormer34.40 / 31.79 / 28.6035.47 / 33.04 / 30.0135.61 / 33.34 / 30.3035.13 / 32.96 / 30.02
MambaIR34.48 / 32.24 / 28.6635.42 / 32.99 / 29.9235.70 / 33.43 / 30.3535.37 / 33.21 / 30.30

Real denoising (PSNR / SSIM) tab. 6:

DatasetDeamNetMPRNetDAGLUformerRestormerMambaIR
SIDD39.47 / 0.95739.71 / 0.95838.94 / 0.95339.77 / 0.95940.02 / 0.96039.89 / 0.960
DND39.63 / 0.95339.80 / 0.95439.77 / 0.95639.96 / 0.95640.03 / 0.95640.04 / 0.956

Other results: real-world ×4 SR is shown only as visual comparisons, since there is no ground truth §4.3 fig. 6. GPU memory as the input grows from 48×48 to 84×84 scales roughly like SwinIR and far below full attention §4.3 fig. 5; no numbers are given in the text. JPEG artifact-reduction results and further ablations (e.g. the number of RSSBs) are in the supplementary material, which is not part of the arXiv source §4.1 §4.2.

Paper vs code

  • Adam β2: paper 0.999 §4.1; code 0.99 train_MambaIR_SR_x2.yml.
  • Charbonnier ε: paper sqrt(d² + ε²) with ε = 1e-3 eq. 9; code computes sqrt(d² + eps) per element with eps = 1e-3, i.e. an effective ε of about 0.032 losses.py train_MambaIR_ColorDN_level15.yml.
  • SR patch size: paper says 64×64 SR patches §4.1. Code crops HR at 128 for ×2 and 192 for ×3/×4, so LR patches are 64 (×2, ×3) but 48 for ×4 train_MambaIR_SR_x2.yml train_MambaIR_SR_x4.yml.
  • Scan order: the paper lists four corner-to-corner directions (TL→BR, BR→TL, TR→BL, BL→TR) §3.5. The code scans row-major, column-major, and the reverse of each mambair_arch.py.
  • ×3/×4 halving: paper says to halve LR and iterations when initialising from ×2 §4.1. The classic configs do this train_MambaIR_SR_x4.yml; the lightweight ×3/×4 configs load ×2 weights but keep 2e-4 and 500k iterations train_MambaIR_lightSR_x4.yml.
  • Lightweight block: not described in the paper. Code swaps the bottleneck to 1×1 (C→C/2) → depthwise 3×3 → GELU → 1×1 → depthwise 3×3 with dilation 2 → CA and uses a one-step pixel-shuffle head mambair_arch.py mambair_arch.py.
  • Real denoising: paper describes one architecture and Charbonnier loss for denoising §3.6. The real-denoising config uses a different U-Net model (MambaIRUNet, dim 48, blocks [4, 6, 6, 8], 4 refinement blocks, λ = 1.5), L1 loss, AdamW (3e-4, weight decay 1e-4, β2 0.999), gradient clipping, mixup, and progressive patches 128→384 over 300k iterations train_MambaIR_RealDN.yml train_MambaIR_RealDN.yml.
  • Color denoising metric: paper reports Y-channel PSNR for everything §4.1; the color-denoising test configs compute RGB PSNR with test_y_channel: false test_MambaIR_ColorDN_level15.yml.
  • σ25/σ50 denoising: initialised from the σ15 model with LR 1e-4 and 800k iterations; not in the paper train_MambaIR_ColorDN_level50.yml.
  • Extra pieces not in the paper: subtraction of the RGB mean, a LayerNorm after patch embedding, a residual around each RSSG, a final LayerNorm, and a global input skip for denoising mambair_arch.py mambair_arch.py.

Pitfalls

  • Most architecture sizes are only in code. The paper gives no values for C, the group/block counts, state size N, λ or γ; use the code tables above.
  • Eq. 2 as printed is inconsistent: B̄ uses exp(A) while Ā uses exp(ΔA). The code never implements eq. 2 itself; it calls mamba_ssm's selective_scan_fn with softplus on Δ plus a bias mambair_arch.py. Reuse that kernel rather than coding eq. 2 from the paper.
  • Loss equations compare output with input. Eqs. 8 and 9 are written as I_HQ − I_LQ; the code compares the prediction with the ground truth losses.py.
  • Four scans means four sets of SSM parameters. Each direction has its own Δ/B/C projection, Δ projection, A and D mambair_arch.py. The scan itself runs in float32 even under mixed precision mambair_arch.py.
  • Hard CUDA dependency. The model imports mamba_ssm's fused selective scan mambair_arch.py. A pure-PyTorch port must reproduce its Δ softplus, bias and D-skip behaviour.
  • Narrow channel attention. Squeeze factor 30 leaves 6 hidden channels at C = 180 and 2 at C = 60 mambair_arch.py.
  • Noise synthesis. Gaussian noise of σ/255 is added on the fly to float images in [0, 1] with no clipping; validation fixes seed 0 paired_image_dataset.py.
  • Ablation setup unstated. tab. 1 and tab. 2 give no training setting, and they leave out the parameter and MAC counts that the variants change.
  • Long training. Classic ×2 SR runs 500k iterations on 8 GPUs, and σ15 denoising 1.6M iterations train_MambaIR_SR_x2.yml train_MambaIR_ColorDN_level15.yml.
  • Repository also holds MambaIRv2. mambairv2_arch.py and the mambairv2 configs belong to a later model; the files for this paper are mambair_arch.py and options/*/mambair/.

Lineage

  • Builds on: Mamba (arXiv:2312.00752) for the selective scan; VMamba (arXiv:2401.10166) for the VSSM and the 2D four-direction scan; SwinIR's three-stage pipeline and experimental setup; squeeze-and-excitation channel attention §3.3 §3.4 §3.5 §4.1.
  • Compared against: SwinIR, SRFormer, IPT, ELAN, RCAN, EDSR, HAT (receptive-field plots), Restormer, DRUNet, Uformer and lightweight SR models tab. 3-6.

Source and license

Adapted from “MambaIR: A Simple Baseline for Image Restoration with State-Space Model” by Hang Guo, Jinmin Li, Tao Dai, Zhihao Ouyang, Xudong Ren, Shu-Tao Xia (arXiv:2402.15648), used under CC BY-SA 4.0. Changes: condensed and restructured for implementation, with tables, equations and algorithms taken from the paper and its code, each cited to its source. Not affiliated with or endorsed by the authors. This page is licensed under CC BY-SA 4.0. Code citations refer to https://github.com/csguoh/MambaIR at commit 33d7b3460c46 (Apache-2.0). Any quoted code is shown under that license.